예제 #1
0
 /**
  * Render widget object
  *
  * @param MenuWidget $widgetObj
  * @return string result of rendering process
  */
 public static function render($widgetObj)
 {
     $tplEngine = $widgetObj->templateEngine;
     $tplFile = TemplateHelper::getTplFileWithPath($widgetObj->templateFile, $widgetObj->package);
     if ($tplEngine == "Smarty" || $tplEngine == null) {
         return MenuRenderer::renderSmarty($widgetObj, $tplFile);
     } else {
         return MenuRenderer::renderPHP($widgetObj, $tplFile);
     }
 }
예제 #2
0
 /**
  * Render the html tabs
  *
  * @global BizSystem $g_BizSystem
  * @return string html content of the tabs
  */
 public function render()
 {
     $curView = Openbiz::$app->getCurrentViewName();
     $curViewobj = $curView ? Openbiz::getObject($curView) : null;
     $profile = Openbiz::$app->getUserProfile();
     $svcobj = Openbiz::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));
 }
예제 #3
0
 private function saveToXML($data)
 {
     $smarty = TemplateHelper::getSmartyTemplate();
     $smarty->assign("data", $data);
     $xmldata = $smarty->fetch(TemplateHelper::getTplFileWithPath("serviceTemplate.xml.tpl", $this->package));
     $service_dir = Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR . "service";
     $service_file = $service_dir . DIRECTORY_SEPARATOR . $this->configFile;
     file_put_contents($service_file, $xmldata);
     return true;
 }
예제 #4
0
 public function UpdateLangPack($lang, $recArr)
 {
     $this->recordID = $lang;
     $locale = explode('_', $lang);
     $lang_code = strtolower($locale[0]);
     //clean up array
     foreach ($recArr as $key => $value) {
         $recArr[$key] = addslashes($recArr[$key]);
         $recArr[$key] = str_replace("\n", '\\n', $recArr[$key]);
     }
     //create lang.xml metainfo
     $smarty = TemplateHelper::getSmartyTemplate();
     $smarty->assign("language", $this->Code2Language($lang_code));
     $smarty->assign("lang_code", $lang);
     $smarty->assign("version", $recArr['version']);
     $smarty->assign("create_date", $recArr['creationDate']);
     $smarty->assign("author", $recArr['author']);
     $smarty->assign("author_email", $recArr['authorEmail']);
     $smarty->assign("author_url", $recArr['authorUrl']);
     $smarty->assign("description", $recArr['description']);
     $data = $smarty->fetch(TemplateHelper::getTplFileWithPath("lang.xml.tpl", $this->package));
     $lang_dir = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "languages" . DIRECTORY_SEPARATOR . $lang;
     $lang_file = $lang_dir . DIRECTORY_SEPARATOR . $lang . ".xml";
     @unlink($lang_file);
     file_put_contents($lang_file, $data);
     //generate lang string files.
     return true;
 }
예제 #5
0
 public function UpdateThemePack($theme, $recArr)
 {
     $this->recordID = $theme;
     $locale = explode('_', $theme);
     $theme_code = strtolower($locale[0]);
     //clean up array
     foreach ($recArr as $key => $value) {
         $recArr[$key] = addslashes($recArr[$key]);
         $recArr[$key] = str_replace("\n", '\\n', $recArr[$key]);
     }
     //create theme.xml metainfo
     $smarty = TemplateHelper::getSmartyTemplate();
     $smarty->assign("theme_name", $recArr['name']);
     $smarty->assign("preview", $recArr['preview']);
     $smarty->assign("icon", $recArr['icon']);
     $smarty->assign("version", $recArr['version']);
     $smarty->assign("create_date", $recArr['creationDate']);
     $smarty->assign("author", $recArr['author']);
     $smarty->assign("author_email", $recArr['authorEmail']);
     $smarty->assign("author_url", $recArr['authorUrl']);
     $smarty->assign("description", $recArr['description']);
     $data = $smarty->fetch(TemplateHelper::getTplFileWithPath("theme.xml.tpl", $this->package));
     $theme_dir = OPENBIZ_THEME_PATH . DIRECTORY_SEPARATOR . $theme;
     $theme_file = $theme_dir . DIRECTORY_SEPARATOR . "theme.xml";
     @unlink($theme_file);
     file_put_contents($theme_file, $data);
     //generate theme string files.
     return true;
 }
예제 #6
0
 /**
  * Render PHP template for view object
  *
  * @param EasyForm $formObj
  * @param string $tplFile
  * @return string result of rendering process
  */
 protected static function renderPHP($viewObj, $tplAttributes = array())
 {
     $view = TemplateHelper::getZendTemplate();
     $tplFile = TemplateHelper::getTplFileWithPath($viewObj->templateFile, $viewObj->package);
     $view->addScriptPath(dirname($tplFile));
     //Translate Array of template variables to \Zend template object
     foreach ($tplAttributes as $key => $value) {
         if ($value == NULL) {
             $view->{$key} = '';
         } else {
             $view->{$key} = $value;
         }
     }
     if ($viewObj->consoleOutput) {
         echo $view->render($viewObj->templateFile);
     } else {
         return $view->render($viewObj->templateFile);
     }
 }
예제 #7
0
 /**
  * Render PHP template for form object
  *
  * @param EasyForm $formObj
  * @param string $tplFile
  * @return string result of rendering process
  */
 protected static function renderPHP($formObj, $tplAttributes = array())
 {
     $form = TemplateHelper::getZendTemplate();
     $tplFile = TemplateHelper::getTplFileWithPath($formObj->templateFile, $formObj->package);
     $form->addScriptPath(dirname($tplFile));
     /* $formOutput = $formObj->outputAttrs();
        foreach ($formOutput as $k=>$v) {
        $form->$k = $v;
        } */
     foreach ($tplAttributes as $key => $value) {
         if ($value == NULL) {
             $form->{$key} = '';
         } else {
             $form->{$key} = $value;
         }
     }
     // render the formobj attributes
     //$form->form = $formOutput;
     return $form->render($formObj->templateFile);
 }
예제 #8
0
 private function saveToXML($data)
 {
     $smarty = TemplateHelper::getSmartyTemplate();
     $smarty->assign("data", $data);
     $xmldata = $smarty->fetch(TemplateHelper::getTplFileWithPath("applicationTemplate.xml.tpl", $this->package));
     $service_dir = OPENBIZ_APP_PATH;
     $service_file = $service_dir . DIRECTORY_SEPARATOR . $this->configFile;
     file_put_contents($service_file, $xmldata);
     return true;
 }
예제 #9
0
 public function CronJobEmail($recipientEmail, $job_name, $output)
 {
     //init email info
     $template = $this->tempaltes["CronjobEmail"]["TEMPLATE"];
     $subject = $this->tempaltes["CronjobEmail"]["TITLE"];
     $sender = $this->tempaltes["CronjobEmail"]["EMAILACCOUNT"];
     //prepare data
     $data["job_name"] = $job_name;
     $data["job_output"] = $output;
     //render the email tempalte
     $tplFile = TemplateHelper::getTplFileWithPath($template, "email");
     $content = $this->renderEmail($data, $tplFile);
     //prepare recipient info
     $recipient['email'] = $recipientEmail;
     $recipient['name'] = $recipientEmail;
     //send it to the queue
     $result = $this->sendEmail($sender, $recipient, $subject, $content);
     return $result;
 }