|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 /* 00003 * Copyright (C) 2005-2007 Alfresco Software Limited. 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 00019 * As a special exception to the terms and conditions of version 2.0 of 00020 * the GPL, you may redistribute this Program in connection with Free/Libre 00021 * and Open Source Software ("FLOSS") applications as described in Alfresco's 00022 * FLOSS exception. You should have recieved a copy of the text describing 00023 * the FLOSS exception, and it is also available here: 00024 * http://www.alfresco.com/legal/licensing" 00025 */ 00026 00027 class BaseObject 00028 { 00029 public function __get($name) 00030 { 00031 $methodName = $name; 00032 $methodName[0] = strtoupper($methodName[0]); 00033 $methodName = 'get' . $methodName; 00034 00035 if (method_exists($this, $methodName) == true) 00036 { 00037 return $this->$methodName(); 00038 } 00039 } 00040 00041 public function __set($name, $value) 00042 { 00043 $methodName = $name; 00044 $methodName[0] = strtoupper($methodName[0]); 00045 $methodName = 'set' . $methodName; 00046 00047 if (method_exists($this, $methodName) == true) 00048 { 00049 return $this->$methodName($value); 00050 } 00051 } 00052 00053 protected function resultSetToNodes($session, $store, $resultSet) 00054 { 00055 $return = array(); 00056 if (isset($resultSet->rows) == true) 00057 { 00058 if (is_array($resultSet->rows) == true) 00059 { 00060 foreach($resultSet->rows as $row) 00061 { 00062 $id = $row->node->id; 00063 $return[] = $session->getNode($store, $id); 00064 } 00065 } 00066 else 00067 { 00068 $id = $resultSet->rows->node->id; 00069 $return[] = $session->getNode($store, $id); 00070 } 00071 } 00072 00073 return $return; 00074 } 00075 00076 protected function resultSetToMap($resultSet) 00077 { 00078 $return = array(); 00079 if (isset($resultSet->rows) == true) 00080 { 00081 if (is_array($resultSet->rows) == true) 00082 { 00083 foreach($resultSet->rows as $row) 00084 { 00085 $return[] = $this->columnsToMap($row->columns); 00086 } 00087 } 00088 else 00089 { 00090 $return[] = $this->columnsToMap($resultSet->rows->columns); 00091 } 00092 00093 } 00094 00095 return $return; 00096 } 00097 00098 private function columnsToMap($columns) 00099 { 00100 $return = array(); 00101 00102 foreach ($columns as $column) 00103 { 00104 $return[$column->name] = $column->value; 00105 } 00106 00107 return $return; 00108 } 00109 00110 protected function remove_array_value($value, &$array) 00111 { 00112 if ($array != null) 00113 { 00114 if (in_array($value, $array) == true) 00115 { 00116 foreach ($array as $index=>$value2) 00117 { 00118 if ($value == $value2) 00119 { 00120 unset($array[$index]); 00121 } 00122 } 00123 } 00124 } 00125 } 00126 00127 protected function isContentData($value) 00128 { 00129 $index = strpos($value, "contentUrl="); 00130 if ($index === false) 00131 { 00132 return false; 00133 } 00134 else 00135 { 00136 if ($index == 0) 00137 { 00138 return true; 00139 } 00140 else 00141 { 00142 return false; 00143 } 00144 } 00145 } 00146 } 00147 ?>