/** * - Calls user defined constructor. * - Adds default Element's actions. * - Validates DataStorages. * - Fills its Datas' values if possible (requires a valid ID or array of values). * - Fills some of its Datas' meta-datas (parent, names). * @param mixed $id_or_array ID of the Element or array of Element's Datas values. * @param DataStorage $specialDataStorage DataStorage to use in uncommon cases. */ public function __construct($id_or_array = null, $storage = null, $specialDataStorage = null) { $this->sonMessage = new \SimplOn\Datas\Message(); //On heirs put here the asignation of SimplOndata and attributes if ($storage) { $this->storage($storage); } else { $this->storage(strtr($this->getClass(), '\\', '_')); } //Assings the storage element for the SimplOnelement. (a global one : or a particular one) if (!$specialDataStorage) { $this->dataStorage = Main::dataStorage(); } else { $this->dataStorage =& $specialDataStorage; } //Called to "construct" function $this->construct($id_or_array, $storage, $specialDataStorage); if (!$this->quickDelete) { $this->quickDelete = Main::$QUICK_DELETE; } if (!isset($this->viewAction)) { $this->viewAction = new Datas\ViewAction('', array('View')); } if (!isset($this->createAction)) { $this->createAction = new Datas\CreateAction('', array('Create')); } if (!isset($this->updateAction)) { $this->updateAction = new Datas\UpdateAction('', array('Update')); } if (!isset($this->deleteAction)) { $this->deleteAction = new Datas\DeleteAction('', array('Delete')); } //if( !isset($this->selectAction) )$this->selectAction = new Datas\SelectAction('', array('Select')); //$this->multiSelectAction = new Datas\DeleteAction('', array('Select')); //Load the attributes on the fly $this->addOnTheFlyAttributes(); $this->assignDatasName(); //user_error($this->{$this->field_id()}()); // Tells the SimplOndata whose thier "container" in case any of it has context dependent info or functions. $this->assignAsDatasParent(); //checking if there is already a dataStorage and storage for this element $this->dataStorage->ensureElementStorage($this); if (is_array($id_or_array)) { $this->fillFromArray($id_or_array); } else { if ($id_or_array) { //if there is a storage and an ID it fills the element with the proper info. $this->fillFromDSById($id_or_array); } } }