Exemplo n.º 1
0
 /**
  * Render PHP template for widget object
  *
  * @param MenuWidget $widgetObj
  * @param string $tplFile
  * @return string result of rendering process
  */
 protected static function renderPHP($widgetObj, $tplFile)
 {
     $view = TemplateHelper::getZendTemplate();
     $view->addScriptPath(dirname($tplFile));
     $view->widget = $widgetObj->OutputAttrs();
     /*
             $smarty->assign("formname", $widgetObj->objectName);
             $smarty->assign("module", $view->getModuleName($view->objectName));
             $smarty->assign("title", $view->title);
             $smarty->assign("errors", ( isset($view->errors) ? $view->errors : null ) );
             $smarty->assign("notices", $view->notices);
     * 
     */
     return $view->render($view->templateFile);
 }
Exemplo n.º 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));
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 5
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);
     }
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 9
0
 function modifyMod($table_name)
 {
     if (CLI) {
         echo "Start modify mod.xml." . PHP_EOL;
     }
     $module_name = getModuleName($this->module);
     $targetFile = $moduleDir = Openbiz::$app->getModulePath() . "/" . getModuleName($this->module) . "/mod.xml";
     $content = file_get_contents($targetFile);
     $smarty = TemplateHelper::getSmartyTemplate();
     $listview_uri = strtolower(str_replace(" ", "_", $this->opts[2])) . "_list";
     //$listview_uri = strtolower(getSubModuleName($this->module)) . "_list";
     //$listview_uri = strtolower($this->opts[1]) . "_list";
     $module = $this->module;
     //.".".$this->opts[1];
     $comp = $this->opts[2];
     $smarty->assign_by_ref("module_name", $module_name);
     $smarty->assign_by_ref("module", $module);
     $smarty->assign_by_ref("comp", $comp);
     $smarty->assign_by_ref("listview_uri", $listview_uri);
     $smarty->assign_by_ref("acl", $this->opts['acl']);
     $smarty->assign_by_ref("dashboard_enable", $this->dashboard_enable);
     //generate ACL sections
     $tpl_file = dirname(__FILE__) . '/' . META_TPL . self::MOD_RESOURCE;
     $str = $smarty->fetch($tpl_file);
     //test if New ACL sections is exists
     $pattern = "/\\<Resource Name=\"" . $this->opts['acl'][resource] . "\"\\>/si";
     if (!preg_match($pattern, $content)) {
         //do append new sections
         $content = preg_replace("/(<\\/ACL\\>)/si", $str . "\n</ACL>", $content);
     }
     //generate MenuItems sections
     $tpl_file = dirname(__FILE__) . '/' . META_TPL . self::MOD_ITEMMENU;
     $str = $smarty->fetch($tpl_file);
     //test if New MenuItems is exists
     $pattern = "/\\<MenuItem Name=\"" . ucwords($module) . "\"\\>/si";
     if (!preg_match($pattern, $content)) {
         //do append new sections
         $content = preg_replace("/\\<\\/MenuItem\\>\\s*?\\<\\/Menu\\>/si", $str . "\n</MenuItem>\n\t</Menu>", $content);
     }
     //save files
     file_put_contents($targetFile, $content);
     if (CLI) {
         echo "\t" . str_replace(Openbiz::$app->getModulePath(), "", $targetFile) . " is modified." . PHP_EOL;
     }
     return $targetFile;
 }
Exemplo n.º 10
0
 protected function renderEmail($content, $tplFile)
 {
     $smarty = TemplateHelper::getSmartyTemplate();
     foreach ($content as $key => $value) {
         $smarty->assign($key, $value);
     }
     return $smarty->fetch($tplFile);
 }
Exemplo n.º 11
0
 /**
  * render the report output
  *
  * @param string $objName object name which is the bizform name
  * @return void
  */
 public function render($objName)
 {
     // get the current UI bizobj
     $bizform = Openbiz::getObject($objName);
     // get the existing bizform object
     $bizobj = $bizform->getDataObj();
     $h = opendir($this->targetReportPath);
     if (!$h) {
         echo "cannot read dir " . $this->targetReportPath;
         exit;
     }
     // create a tmp csv file for hold the data, then feed csv file to report engine
     $uid = $this->getUniqueString();
     $tmpfname = $this->targetReportPath . $uid . ".csv";
     //echo "csv file is at $tmpfname.<br>";
     $fp = fopen($tmpfname, 'w');
     $keyList = $bizform->recordRow->GetSortControlKeys();
     $fieldNames = array();
     foreach ($keyList as $key) {
         $fieldNames[] = $bizform->GetControl($key)->bizFieldName;
     }
     fputcsv($fp, $fieldNames);
     $recList = $bizobj->directFetch();
     foreach ($recList as $recArray) {
         unset($fieldValues);
         $fieldValues = array();
         $line = "";
         foreach ($keyList as $key) {
             $fieldValues[] = $recArray[$bizform->GetControl($key)->bizFieldName];
         }
         fputcsv($fp, $fieldValues);
     }
     fclose($fp);
     $i = 0;
     foreach ($keyList as $key) {
         $rpt_fields[$i]["name"] = $bizform->GetControl($key)->bizFieldName;
         $rpt_fields[$i]["type"] = $bizobj->getField($rpt_fields[$i]["name"])->type;
         $i++;
     }
     // dataobj.rptdesign.tpl
     // $rpt_data_dir, $rpt_title, $rpt_csv_file, $rpt_fields[](name,type)
     $smarty = TemplateHelper::getSmartyTemplate();
     $smarty->assign("rpt_data_dir", $this->targetReportPath);
     $smarty->assign("rpt_title", $bizform->title);
     $smarty->assign("rpt_csv_file", basename($tmpfname));
     $smarty->assign("rpt_fields", $rpt_fields);
     $reportContent = $smarty->fetch($this->rptTemplate);
     $tmpRptDsgn = $this->targetReportPath . $uid . ".rptdesign";
     //echo "temp rpt design file is at $tmpRptDsgn.<br>";
     $fp = fopen($tmpRptDsgn, 'w');
     fwrite($fp, $reportContent);
     fclose($fp);
     ob_clean();
     $designFileName = $uid . ".rptdesign";
     $content = "<div style='font-family:Arial; font-size:12px; background-color:#FCFCFC;'>";
     $content .= "Reports can be viewed as ";
     $content .= "<li><a href='" . $this->birtViewer . "/run?__report=report\\{$designFileName}' target='__blank'>HTML report</a></li>";
     $content .= "<li><a href='" . $this->birtViewer . "/run?__report=report\\{$designFileName}&__format=pdf' target='__blank'>PDF report</a></li>";
     $content .= "<li><a href='" . $this->birtViewer . "/frameset?__report=report\\{$designFileName}' target='__blank'>Interactive report</a></li>";
     $content .= "</div>";
     echo $content;
     exit;
 }