PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/alfresco/Service/BaseObject.php

https://bitbucket.org/moodle/moodle
PHP | 141 lines | 109 code | 14 blank | 18 comment | 21 complexity | c94434ede8da1a5275f58e93acc30a90 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, BSD-3-Clause, MIT, GPL-3.0
  1. <?php
  2. /*
  3. * Copyright (C) 2005-2010 Alfresco Software Limited.
  4. *
  5. * This file is part of Alfresco
  6. *
  7. * Alfresco is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Alfresco is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. class BaseObject
  21. {
  22. public function __get($name)
  23. {
  24. $methodName = $name;
  25. $methodName[0] = strtoupper($methodName[0]);
  26. $methodName = 'get' . $methodName;
  27. if (method_exists($this, $methodName) == true)
  28. {
  29. return $this->$methodName();
  30. }
  31. }
  32. public function __set($name, $value)
  33. {
  34. $methodName = $name;
  35. $methodName[0] = strtoupper($methodName[0]);
  36. $methodName = 'set' . $methodName;
  37. if (method_exists($this, $methodName) == true)
  38. {
  39. return $this->$methodName($value);
  40. }
  41. }
  42. protected function resultSetToNodes($session, $store, $resultSet)
  43. {
  44. $return = array();
  45. if (isset($resultSet->rows) == true)
  46. {
  47. if (is_array($resultSet->rows) == true)
  48. {
  49. foreach($resultSet->rows as $row)
  50. {
  51. $id = $row->node->id;
  52. $return[] = $session->getNode($store, $id);
  53. }
  54. }
  55. else
  56. {
  57. $id = $resultSet->rows->node->id;
  58. $return[] = $session->getNode($store, $id);
  59. }
  60. }
  61. return $return;
  62. }
  63. protected function resultSetToMap($resultSet)
  64. {
  65. $return = array();
  66. if (isset($resultSet->rows) == true)
  67. {
  68. if (is_array($resultSet->rows) == true)
  69. {
  70. foreach($resultSet->rows as $row)
  71. {
  72. $return[] = $this->columnsToMap($row->columns);
  73. }
  74. }
  75. else
  76. {
  77. $return[] = $this->columnsToMap($resultSet->rows->columns);
  78. }
  79. }
  80. return $return;
  81. }
  82. private function columnsToMap($columns)
  83. {
  84. $return = array();
  85. foreach ($columns as $column)
  86. {
  87. $return[$column->name] = $column->value;
  88. }
  89. return $return;
  90. }
  91. protected function remove_array_value($value, &$array)
  92. {
  93. if ($array != null)
  94. {
  95. if (in_array($value, $array) == true)
  96. {
  97. foreach ($array as $index=>$value2)
  98. {
  99. if ($value == $value2)
  100. {
  101. unset($array[$index]);
  102. }
  103. }
  104. }
  105. }
  106. }
  107. protected function isContentData($value)
  108. {
  109. $index = strpos($value, "contentUrl=");
  110. if ($index === false)
  111. {
  112. return false;
  113. }
  114. else
  115. {
  116. if ($index == 0)
  117. {
  118. return true;
  119. }
  120. else
  121. {
  122. return false;
  123. }
  124. }
  125. }
  126. }
  127. ?>