**/ abstract class twIf_Generic_Object extends twIf_Generic_Basic { // Some default information for our parents const CAPTION = "Element bearbeiten"; const ALLOW_FEEDBACK = true; const CREATE_MODE = false; const CREATE_STRICT = true; const EDITOR_SUBMIT_CAPTION = "Speichern"; const CREATOR_SUBMIT_CAPTION = "Anlegen"; // Our pointer to the object we are editing private $Item = null; // {{{ setItem /** * Store the item for the editor * * @param object $Item * * @access public * @return void **/ public function setItem ($Item) { $this->Item = $Item; } // }}} // {{{ getItem /** * Retrive the item from the editor * * @access public * @return object **/ public function getItem () { return $this->Item; } // }}} // {{{ getFields /** * Get field-definition for the editor * * @access protected * @return array */ protected function getFields () { return array (); } // }}} // {{{ getCreateParams /** * Determine which params pass to constructor of our class * * @access protected * @return array */ protected function getCreateParams () { return array (); } // }}} // {{{ getCreateStrict /** * Check wheter to parse Create-parameters in strict mode * * @access protected * @return bool **/ protected function getCreateStrict () { return self::findConstant ("CREATE_STRICT", true); } // }}} // {{{ isCreator /** * Determine if we are creating objects (instead of editing them) * * @access protected * @return bool **/ protected function isCreator () { return self::findConstant ("CREATE_MODE", false); } // }}} // {{{ onCommit /** * Callback after an object was saved * * @param object $Handle * * @access protected * @return bool - null do nothing, true reload the definition, false fail directly **/ protected function onCommit ($Handle) { } // }}} // {{{ giveFeedback /** * Determine wheter the editor-widget should output a feedback or not * * @access protected * @return bool **/ protected function giveFeedback () { return self::findConstant ("ALLOW_FEEDBACK", true); } // }}} // {{{ getMessageSaved /** * Which message to output when an object was saved * * @access protected * @return string **/ protected function getMessageSaved () { return self::findConstant ("MSG_SAVED", self::MSG_SAVED); } // }}} // {{{ getMessageSaveFailed /** * Which message to output whenver save failed * * @access protected * @return string **/ protected function getMessageSaveFailed () { return self::findConstant ("MSG_SAVE_FAILED", self::MSG_SAVE_FAILED); } // }}} // {{{ getMessageNoChanges /** * Which message to output whenever no changes where made * * @access protected * @return string **/ protected function getMessageNoChanges () { return self::findConstant ("MSG_NO_CHANGES", self::MSG_NO_CHANGES); } // }}} // {{{ getSubmitCaption /** * Retrive the caption of our submit-button * * @access protected * @return string **/ protected function getSubmitCaption () { if ($this->isCreator ()) return self::findConstant ("CREATOR_SUBMIT_CAPTION", "Anlegen"); return self::findConstant ("EDITOR_SUBMIT_CAPTION", "Speichern"); } // }}} // {{{ getDefintion /** * Retrive Page-Definition from this object * * @access public * @return array */ public function getDefinition () { // Determine our mode $isCreator = $this->isCreator (); // Output an error-state if there is no item assigned if (!$isCreator && !is_object ($this->Item)) return array ( array ("Type" => "Feedback", "Success" => false, "Message" => "No item was specified"), ); // Generate definition for the editor return array ( // Caption of this section array ("Type" => "Caption", "Text" => $this->getCaption ()), // The Editor self::getEditorDefinition (), ); } // }}} // {{{ getEditorDefinition /** * Retrive the default definition for our editor * * @access protected * @return array **/ protected function getEditorDefinition () { // Determine our mode $isCreator = $this->isCreator (); // Return the definition return array ( "Type" => "Editor", "Mode" => ($isCreator ? "new" : ""), "Source" => ($isCreator ? $this->getClass () : array ($this, "getItem")), "Fields" => array ($this, "getFields"), "SuccessURL" => $this->getBase (), "onSuccess" => array ($this, "onCommit"), "Feedback" => $this->giveFeedback (), "Constructor" => array ($this, "getCreateParams"), "Strict" => $this->getCreateStrict (), "msgSaved" => $this->getMessageSaved (), "msgSaveFailed" => $this->getMessageSaveFailed (), "msgNoChanges" => $this->getMessageNoChanges (), "msgSubmit" => $this->getSubmitCaption (), ); } // }}} } ?>