Пример #1
0
 /**
  * Render single menu item
  *
  * @param array $menuItem menu item metadata xml array
  * @return string html content of each menu item
  */
 protected function renderSingleMenuItem(&$menuItem)
 {
     $profile = Openbizx::$app->getUserProfile();
     $svcobj = Openbizx::getService(ACCESS_SERVICE);
     $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null;
     if (isset($menuItem["ATTRIBUTES"]['URL'])) {
         $url = $menuItem["ATTRIBUTES"]["URL"];
     } elseif (isset($menuItem["ATTRIBUTES"]['VIEW'])) {
         $view = $menuItem["ATTRIBUTES"]["VIEW"];
         // menuitem's containing VIEW attribute is renderd if access is granted in accessservice.xml
         // menuitem's are rendered if no definition is found in accessservice.xml (default)
         if ($svcobj->allowViewAccess($view, $role)) {
             $url = "javascript:GoToView('" . $view . "')";
         } else {
             return '';
         }
     }
     $caption = $this->translate($menuItem["ATTRIBUTES"]["CAPTION"]);
     $target = $menuItem["ATTRIBUTES"]["TARGET"];
     $icon = $menuItem["ATTRIBUTES"]["ICON"];
     $img = $icon ? "<img src='" . Openbizx::$app->getImageUrl() . "/{$icon}' class=menu_img> " : "";
     if ($view) {
         $url = "javascript:GoToView('" . $view . "')";
     }
     if ($target) {
         $sHTML .= "<li><a href=\"" . $url . "\" target='{$target}'>{$img}" . $caption . "</a>";
     } else {
         $sHTML .= "<li><a href=\"" . $url . "\">{$img}" . $caption . "</a>";
     }
     if ($menuItem["MENUITEM"]) {
         $sHTML .= "\n<ul>\n";
         $sHTML .= $this->renderMenuItems($menuItem["MENUITEM"]);
         $sHTML .= "</ul>";
     }
     $sHTML .= "</li>\n";
     return $sHTML;
 }
Пример #2
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->validateErrors = array();
     }
     $this->dataPanel->rewind();
     while ($this->dataPanel->valid()) {
         /* @var $element Element */
         $element = $this->dataPanel->current();
         if ($element->label) {
             $elementName = $element->label;
         } else {
             $elementName = $element->text;
         }
         if ($element->checkRequired() === true && ($element->value == null || $element->value == "")) {
             $errorMessage = $this->getMessage("FORM_ELEMENT_REQUIRED", array($elementName));
             $this->validateErrors[$element->objectName] = $errorMessage;
             //return false;
         } elseif ($element->value !== null && $element->Validate() == false) {
             $validateService = Openbizx::getService(VALIDATE_SERVICE);
             $errorMessage = $this->getMessage("FORM_ELEMENT_INVALID_INPUT", array($elementName, $value, $element->validator));
             if ($errorMessage == false) {
                 //Couldn't get a clear error message so let's try this
                 $errorMessage = $validateService->getErrorMessage($element->validator, $elementName);
             }
             $this->validateErrors[$element->objectName] = $errorMessage;
             //return false;
         }
         $this->dataPanel->next();
     }
     if (count($this->validateErrors) > 0) {
         throw new Openbizx\Validation\Exception($this->validateErrors);
         return false;
     }
     return true;
 }
Пример #3
0
 /**
  * Render step
  *
  * @param number $step
  * @return void
  */
 public function renderStep($step)
 {
     if ($this->currentStep) {
         $currentStep = $this->currentStep;
     } else {
         $currentStep = $this->getCurrentStep();
     }
     if ($currentStep == $step) {
         return;
     }
     switch (strtoupper($this->naviMethod)) {
         case "SWITCHFORM":
             $targetForm = $this->getStepName($step);
             $currentForm = $this->getStepName($currentStep);
             $this->currentStep = $step;
             $formObj = Openbizx::getObject($currentForm);
             $formObj->switchForm($targetForm);
             break;
         case "SWITCHPAGE":
         default:
             $currentURL = Openbizx::getService(OPENBIZ_UTIL_SERVICE)->getViewURL($this->objectName);
             $url = OPENBIZ_APP_INDEX_URL . '/' . $currentURL . '/step_' . $step;
             Openbizx::$app->getClientProxy()->ReDirectPage($url);
             break;
     }
 }
Пример #4
0
 /**
  * Render the html tabs
  *
  * @global BizSystem $g_BizSystem
  * @return string html content of the tabs
  */
 public function render()
 {
     $curView = Openbizx::$app->getCurrentViewName();
     $curViewobj = $curView ? Openbizx::getObject($curView) : null;
     $profile = Openbizx::$app->getUserProfile();
     $svcobj = Openbizx::getService(ACCESS_SERVICE);
     $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null;
     // list all views and highlight the current view
     // pass $tabs(caption, url, target, icon, current) to template
     $smarty = TemplateHelper::getSmartyTemplate();
     $tabs = array();
     $i = 0;
     $hasForms = false;
     foreach ($this->tabViews as $tview) {
         // tab is renderd if  no definition  is found in accessservice.xml (default)
         if ($svcobj->allowViewAccess($tview->view, $role)) {
             $tabs[$i]['name'] = $tview->objectName;
             //Name of each tab--jmmz
             $tabs[$i]['forms'] = $this->_renderJSCodeForForms($tview->forms);
             //Configuration of the forms to hide or show--jmmz
             $tabs[$i]['caption'] = $tview->caption;
             $tabs[$i]['url'] = $this->_renderURL($tview);
             //Call the method to render the url--jmmz
             //If I have forms to hide or show I add the event because I don't need an URL, I need an event
             if ((bool) $tview->hasForms()) {
                 $tabs[$i]['event'] = $tabs[$i]['url'];
                 //Assign The url rendered to the event on click
                 $tabs[$i]['url'] = 'javascript:void(0)';
                 //If I put url in '' then the href want send me to another direction
                 $this->setCurrentTabInSession($tview, $curViewobj, $curView);
                 //I set the current tab wrote in session
                 $hasForms = TRUE;
             }
             $tabs[$i]['target'] = $tview->target;
             $tabs[$i]['icon'] = $tview->icon;
             $tabs[$i]['current'] = $this->isCurrentTab($tview, $curViewobj, $curView);
             //I get the current tab.
             $i++;
         }
     }
     $this->setClientScripts($tabs, $hasForms);
     $smarty->assign("tabs", $tabs);
     $smarty->assign("tabs_Name", $this->objectName);
     return $smarty->fetch(TemplateHelper::getTplFileWithPath($this->templateFile, $this->package));
 }
Пример #5
0
 /**
  * Render this form (return html content),
  * called by WebPage's render method (called when form is loaded).
  * Query is issued before returning the html content.
  *
  * @return string - HTML text of this form's read mode
  * @example ../../../example/FormObject.php
  */
 public function render()
 {
     if (!$this->allowAccess()) {
         return "";
     }
     //$this->setClientScripts();
     if ($this->cacheLifeTime > 0 && $this->subForms == null) {
         $cache_id = md5($this->objectName);
         //try to process cache service.
         $cacheSvc = Openbizx::getService(CACHE_SERVICE, 1);
         $cacheSvc->init($this->objectName, $this->cacheLifeTime);
         if ($cacheSvc->test($cache_id)) {
             Openbizx::$app->getLog()->log(LOG_DEBUG, "FORM", "Cache Hit. form name = " . $this->objectName);
             $output = $cacheSvc->load($cache_id);
         } else {
             Openbizx::$app->getLog()->log(LOG_DEBUG, "FORM", "Set cache. form name = " . $this->objectName);
             $output = FormRenderer::render($this);
             $cacheSvc->save($output, $cache_id);
         }
         return $output;
     }
     //Moved the renderHTML function infront of declaring subforms
     $output = FormRenderer::render($this);
     // lazy subform loading - prepare the subforms' dataobjs, since the subform relates to parent form by dataobj association
     $this->prepareSubFormsDataObj();
     return $output;
 }