|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 /* 00003 * Copyright (C) 2005 Alfresco, Inc. 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 00033 class Version extends BaseObject 00034 { 00035 private $_session; 00036 private $_store; 00037 private $_id; 00038 private $_description; 00039 private $_major; 00040 private $_properties; 00041 private $_type; 00042 private $_aspects; 00043 00053 public function __construct($session, $store, $id, $description=null, $major=false) 00054 { 00055 $this->_session = $session; 00056 $this->_store = $store; 00057 $this->_id = $id; 00058 $this->_description = $description; 00059 $this->_major = $major; 00060 $this->_properties = null; 00061 $this->_aspects = null; 00062 $this->_type = null; 00063 } 00064 00072 public function __get($name) 00073 { 00074 $fullName = $this->_session->namespaceMap->getFullName($name); 00075 if ($fullName != $name) 00076 { 00077 $this->populateProperties(); 00078 if (array_key_exists($fullName, $this->_properties) == true) 00079 { 00080 return $this->_properties[$fullName]; 00081 } 00082 else 00083 { 00084 return null; 00085 } 00086 } 00087 else 00088 { 00089 return parent::__get($name); 00090 } 00091 } 00092 00098 public function getSession() 00099 { 00100 return $this->_session; 00101 } 00102 00108 public function getStore() 00109 { 00110 return $this->_store; 00111 } 00112 00113 public function getId() 00114 { 00115 return $this->_id; 00116 } 00117 00118 public function getDescription() 00119 { 00120 return $this->_description; 00121 } 00122 00123 public function getMajor() 00124 { 00125 return $this->_major; 00126 } 00127 00128 public function getType() 00129 { 00130 return $this->_type; 00131 } 00132 00133 public function getProperties() 00134 { 00135 return $this->_properties; 00136 } 00137 00138 public function getAspects() 00139 { 00140 return $this->_aspects; 00141 } 00142 00143 private function populateProperties() 00144 { 00145 if ($this->_properties == null) 00146 { 00147 $result = $this->_session->repositoryService->get(array ( 00148 "where" => array ( 00149 "nodes" => array( 00150 "store" => $this->_store->__toArray(), 00151 "uuid" => $this->_id)))); 00152 00153 $this->populateFromWebServiceNode($result->getReturn); 00154 } 00155 } 00156 00157 private function populateFromWebServiceNode($webServiceNode) 00158 { 00159 $this->_type = $webServiceNode->type; 00160 00161 // Get the aspects 00162 $this->_aspects = array(); 00163 $aspects = $webServiceNode->aspects; 00164 if (is_array($aspects) == true) 00165 { 00166 foreach ($aspects as $aspect) 00167 { 00168 $this->_aspects[] = $aspect; 00169 } 00170 } 00171 else 00172 { 00173 $this->_aspects[] = $aspects; 00174 } 00175 00176 // Set the property values 00177 $this->_properties = array(); 00178 foreach ($webServiceNode->properties as $propertyDetails) 00179 { 00180 $name = $propertyDetails->name; 00181 $isMultiValue = $propertyDetails->isMultiValue; 00182 $value = null; 00183 if ($isMultiValue == false) 00184 { 00185 $value = $propertyDetails->value; 00186 if ($this->isContentData($value) == true) 00187 { 00188 $value = new ContentData($this, $name); 00189 } 00190 } 00191 else 00192 { 00193 $value = $propertyDetails->values; 00194 } 00195 00196 $this->_properties[$name] = $value; 00197 } 00198 } 00199 } 00200 ?>