PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/alfresco/Service/BaseObject.php

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