Example #1
0
 /**
  * Inherit from parent object. Name, Package, Class cannot be inherited
  *
  * @return void
  */
 protected function inheritParentObj()
 {
     if (!$this->m_InheritFrom) {
         return;
     }
     $parentObj = BizSystem::getObject($this->m_InheritFrom);
     $this->m_Title = $this->m_Title ? $this->m_Title : $parentObj->m_Title;
     $this->m_Icon = $this->m_Icon ? $this->m_Icon : $parentObj->m_Icon;
     $this->m_Description = $this->m_Description ? $this->m_Description : $parentObj->m_Description;
     $this->m_jsClass = $this->m_jsClass ? $this->m_jsClass : $parentObj->m_jsClass;
     $this->m_Height = $this->m_Height ? $this->m_Height : $parentObj->m_Height;
     $this->m_Width = $this->m_Width ? $this->m_Width : $parentObj->m_Width;
     $this->m_DefaultForm = $this->m_DefaultForm ? $this->m_DefaultForm : $parentObj->m_DefaultForm;
     $this->m_TemplateEngine = $this->m_TemplateEngine ? $this->m_TemplateEngine : $parentObj->m_TemplateEngine;
     $this->m_TemplateFile = $this->m_TemplateFile ? $this->m_TemplateFile : $parentObj->m_TemplateFile;
     $this->m_FormType = $this->m_FormType ? $this->m_FormType : $parentObj->m_FormType;
     $this->m_Range = $this->m_Range ? $this->m_Range : $parentObj->m_Range;
     $this->m_FixSearchRule = $this->m_FixSearchRule ? $this->m_FixSearchRule : $parentObj->m_FixSearchRule;
     $this->m_DefaultFixSearchRule = $this->m_DefaultFixSearchRule ? $this->m_DefaultFixSearchRule : $parentObj->m_DefaultFixSearchRule;
     $this->m_DataObjName = $this->m_DataObjName ? $this->m_DataObjName : $parentObj->m_DataObjName;
     $this->m_DirectMethodList = $this->m_DirectMethodList ? $this->m_DirectMethodList : $parentObj->m_DirectMethodList;
     $this->m_EventName = $this->m_EventName ? $this->m_EventName : $parentObj->m_EventName;
     $this->m_MessageFile = $this->m_MessageFile ? $this->m_MessageFile : $parentObj->m_MessageFile;
     $this->m_Messages = Resource::loadMessage($this->m_MessageFile, $this->m_Package);
     $this->m_CacheLifeTime = $this->m_CacheLifeTime ? $this->m_CacheLifeTime : $parentObj->m_CacheLifeTime;
     $this->m_CurrentPage = $this->m_CurrentPage ? $this->m_CurrentPage : $parentObj->m_CurrentPage;
     $this->m_StartItem = $this->m_StartItem ? $this->m_StartItem : $parentObj->m_StartItem;
     $this->m_DataPanel->merge($parentObj->m_DataPanel);
     $this->m_ActionPanel->merge($parentObj->m_ActionPanel);
     $this->m_NavPanel->merge($parentObj->m_NavPanel);
     $this->m_SearchPanel->merge($parentObj->m_SearchPanel);
     if ($this->m_DataPanel->current()) {
         foreach ($this->m_DataPanel as $elem) {
             $elem->adjustFormName($this->m_Name);
         }
     }
     if ($this->m_ActionPanel->current()) {
         foreach ($this->m_ActionPanel as $elem) {
             $elem->adjustFormName($this->m_Name);
         }
     }
     if ($this->m_NavPanel->current()) {
         foreach ($this->m_NavPanel as $elem) {
             $elem->adjustFormName($this->m_Name);
         }
     }
     if ($this->m_SearchPanel->current()) {
         foreach ($this->m_SearchPanel as $elem) {
             $elem->adjustFormName($this->m_Name);
         }
     }
     $this->m_Panels = array($this->m_DataPanel, $this->m_ActionPanel, $this->m_NavPanel, $this->m_SearchPanel);
 }
 /**
  * Inherit from parent object. Name, Package, Class cannot be inherited
  *
  * @return void
  */
 protected function inheritParentObj()
 {
     if (!$this->inheritFrom) {
         return;
     }
     $parentObj = Openbiz::getObject($this->inheritFrom);
     $this->title = $this->title ? $this->title : $parentObj->title;
     $this->icon = $this->icon ? $this->icon : $parentObj->icon;
     $this->objectDescription = $this->objectDescription ? $this->objectDescription : $parentObj->objectDescription;
     $this->jsClass = $this->jsClass ? $this->jsClass : $parentObj->jsClass;
     $this->height = $this->height ? $this->height : $parentObj->height;
     $this->width = $this->width ? $this->width : $parentObj->width;
     $this->templateEngine = $this->templateEngine ? $this->templateEngine : $parentObj->templateEngine;
     $this->templateFile = $this->templateFile ? $this->templateFile : $parentObj->templateFile;
     $this->formType = $this->formType ? $this->formType : $parentObj->formType;
     $this->range = $this->range ? $this->range : $parentObj->range;
     $this->fixSearchRule = $this->fixSearchRule ? $this->fixSearchRule : $parentObj->fixSearchRule;
     $this->defaultFixSearchRule = $this->defaultFixSearchRule ? $this->defaultFixSearchRule : $parentObj->defaultFixSearchRule;
     $this->dataObjName = $this->dataObjName ? $this->dataObjName : $parentObj->dataObjName;
     $this->eventName = $this->eventName ? $this->eventName : $parentObj->eventName;
     $this->messageFile = $this->messageFile ? $this->messageFile : $parentObj->messageFile;
     $this->objectMessages = MessageHelper::loadMessage($this->messageFile, $this->package);
     $this->cacheLifeTime = $this->cacheLifeTime ? $this->cacheLifeTime : $parentObj->cacheLifeTime;
     $this->dataPanel->merge($parentObj->dataPanel);
     $this->actionPanel->merge($parentObj->actionPanel);
     $this->navPanel->merge($parentObj->navPanel);
     $this->searchPanel->merge($parentObj->searchPanel);
     if ($this->dataPanel->current()) {
         foreach ($this->dataPanel as $elem) {
             $elem->adjustFormName($this->objectName);
         }
     }
     if ($this->actionPanel->current()) {
         foreach ($this->actionPanel as $elem) {
             $elem->adjustFormName($this->objectName);
         }
     }
     if ($this->navPanel->current()) {
         foreach ($this->navPanel as $elem) {
             $elem->adjustFormName($this->objectName);
         }
     }
     if ($this->searchPanel->current()) {
         foreach ($this->searchPanel as $elem) {
             $elem->adjustFormName($this->objectName);
         }
     }
     $this->panels = array($this->dataPanel, $this->actionPanel, $this->navPanel, $this->searchPanel);
 }
Example #3
0
 /**
  * Validate input on EasyForm level
  * default form validation do nothing.
  * developers need to override this method to implement their logic
  *
  * @return boolean
  */
 protected function validateForm($cleanError = true)
 {
     if ($cleanError == true) {
         $this->m_ValidateErrors = array();
     }
     $this->m_DataPanel->rewind();
     while ($this->m_DataPanel->valid()) {
         /* @var $element Element */
         $element = $this->m_DataPanel->current();
         if ($element->m_Label) {
             $elementName = $element->m_Label;
         } else {
             $elementName = $element->m_Text;
         }
         if ($element->checkRequired() === true && ($element->m_Value == null || $element->m_Value == "")) {
             $errorMessage = $this->getMessage("FORM_ELEMENT_REQUIRED", array($elementName));
             $this->m_ValidateErrors[$element->m_Name] = $errorMessage;
             //return false;
         } elseif ($element->m_Value !== null && $element->Validate() == false) {
             $validateService = BizSystem::getService(VALIDATE_SERVICE);
             $errorMessage = $this->getMessage("FORM_ELEMENT_INVALID_INPUT", array($elementName, $value, $element->m_Validator));
             if ($errorMessage == false) {
                 //Couldn't get a clear error message so let's try this
                 $errorMessage = $validateService->getErrorMessage($element->m_Validator, $elementName);
             }
             $this->m_ValidateErrors[$element->m_Name] = $errorMessage;
             //return false;
         }
         $this->m_DataPanel->next();
     }
     if (count($this->m_ValidateErrors) > 0) {
         throw new ValidationException($this->m_ValidateErrors);
         return false;
     }
     return true;
 }