/** * Sets clean subobjects * * @return boolean true on success, false on failure * @access private */ protected function _populateSubObjects() { //get all subObjects for fields foreach (array_keys($this->_objectFieldsDefinition) as $fieldID) { $this->_objectValues[$fieldID] = $this->_objectFieldsDefinition[$fieldID]->getTypeObject(false, $this->_public); if (is_a($this->_objectValues[$fieldID], 'CMS_poly_object')) { //load CMS_subobject_integer to store value $this->_polyObjectValues[$fieldID] = new CMS_subobject_integer('', array(), array(), $this->_public); } } //if this object is a primary resource, load CMS_subobject_integer to store resource value if ($this->_objectResourceStatus == 1) { parent::__construct(); $this->_resource = new CMS_subobject_integer('', array(), array(), $this->_public); } return true; }
/** * Constructor. * initializes the page if the id is given. * * @param integer $id DB id * @return void * @access public */ function __construct($id = 0) { $this->_remindedEditors = new CMS_stack(); $this->_lastReminder = new CMS_date(); $this->_lastFileCreation = new CMS_date(); if ($id) { if (!SensitiveIO::isPositiveInteger($id)) { $this->raiseError("Id is not a positive integer"); return; } $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tresources,\n\t\t\t\t\tresourceStatuses\n\t\t\t\twhere\n\t\t\t\t\tid_pag='{$id}' and\n\t\t\t\t\tresource_pag = id_res and\n\t\t\t\t\tstatus_res = id_rs\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $data = $q->getArray(); $this->_pageID = $id; $this->_remindedEditors->setTextDefinition($data["remindedEditorsStack_pag"]); $this->_lastReminder->setFromDBValue($data["lastReminder_pag"]); $this->_templateID = $data["template_pag"]; $this->_lastFileCreation->setFromDBValue($data["lastFileCreation_pag"]); $this->_pageURL = $data["url_pag"]; $this->_protected = $data["protected_pag"] ? true : false; $this->_https = $data["https_pag"] ? true : false; //initialize super-class parent::__construct($data); } else { //display this error only if we are in HTTP mode (not cli) because it is only relevant in this mode if (!defined('APPLICATION_EXEC_TYPE') || APPLICATION_EXEC_TYPE == 'http') { $this->raiseError("Unknown ID :" . $id . ' from ' . io::getCallInfos(3)); } else { $this->raiseError(); } } } else { //initialize super-class parent::__construct(); } }
/** * initialise all objects for this resource * * @return boolean true, false otherwise * @access private */ protected function _initObjects() { foreach ($this->_tableData as $label => $aData) { $method = ''; switch ($aData[0]) { case 'string': case 'html': case 'email': case 'integer': case 'positiveInteger': case 'boolean': case 'image': case 'file': case 'order': case 'internalLink': case 'externalLink': case 'linkType': //not objects, do nothing break; case 'resource': //initialize resource-class parent::__construct($aData[1]); break; case 'date': if ($aData[1]) { $method = $aData[1]; } //create CMS_date object $this->_tableData[$label][1] = new CMS_date(); //if object have a default method to lauch and if this method exists then launch it if ($method != "" && method_exists($this->_tableData[$label][1], $method)) { $this->_tableData[$label][1]->{$method}(); } break; default: //create object if class exists if (class_exists($aData[0])) { if ($aData[1]) { $method = $aData[1]; } $this->_tableData[$label][1] = new $aData[0](); //if object have a default method to lauch and if this method exists then launch it if ($method != "" && method_exists($this->_tableData[$label][1], $method)) { $this->_tableData[$label][1]->{$method}(); } } break; } } return true; }