• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List

E:/E/GEAMP/www/openbiz/openbiz/bin/easy/ViewRenderer.php

00001 <?php
00002 
00026 class ViewRenderer
00027 {
00028 
00035     static public function render ($viewObj)
00036     {
00037         $tplEngine = $viewObj->m_TemplateEngine;
00038         $tplAttributes = ViewRenderer::buildTemplateAttributes($viewObj);
00039         
00040         if ($tplEngine == "Smarty" || $tplEngine == null)
00041             return ViewRenderer::renderSmarty($viewObj, $tplAttributes);
00042         else
00043             return ViewRenderer::renderPHP($viewObj, $tplAttributes);
00044     }
00045 
00052     static public function buildTemplateAttributes ($viewObj)
00053     {
00054         // Assocative Array to hold all Template Values
00055         // Fill with default viewobj attributes
00056         $tplAttributes = $viewObj->outputAttrs();
00057         
00058         //Not sure what this is doing...
00059         $newClntObjs = '';
00060         
00061         //Fill other direct view variables
00062         $tplAttributes["module"] = $viewObj->getModuleName($viewObj->m_Name);
00063         $tplAttributes["description"] = $viewObj->m_Description;
00064         $tplAttributes["keywords"] = $viewObj->m_Keywords;
00065         if ($viewObj->m_Tiles) {
00066             foreach ($viewObj->m_Tiles as $tname => $tile) {
00067                 foreach ($tile as $formRef) {
00068                     if ($formRef->m_Display == false)
00069                         continue;
00070                     $tiles[$tname][$formRef->m_Name] = BizSystem::getObject($formRef->m_Name)->render();
00071                     $tiletabs[$tname][$formRef->m_Name] = $formRef->m_Description;
00072                 }
00073             }
00074         } else {
00075             foreach ($viewObj->m_FormRefs as $formRef) {
00076                 if ($formRef->m_Display == false)
00077                     continue;
00078                 $forms[$formRef->m_Name] = BizSystem::getObject($formRef->m_Name)->render();
00079                 $formtabs[$formRef->m_Name] = $formRef->m_Description;
00080             }
00081         }
00082         //Fill Loop related data
00083         $tplAttributes["forms"] = $forms;
00084         $tplAttributes["formtabs"] = $formtabs;
00085         $tplAttributes["tiles"] = $tiles;
00086         $tplAttributes["tiletabs"] = $tiletabs;
00087         
00088         // add clientProxy scripts
00089         $includedScripts = BizSystem::clientProxy()->getAppendedScripts();
00090         $tplAttributes["style_sheets"] = BizSystem::clientProxy()->getAppendedStyles();
00091         if ($viewObj->m_IsPopup && $bReRender == false) {
00092             $moveToCenter = "moveToCenter(self, " . $viewObj->m_Width . ", " . $viewObj->m_Height . ");";
00093             $tplAttributes["scripts"] = $includedScripts . "\n<script>\n" . $newClntObjs . $moveToCenter . "</script>\n";
00094         } else
00095             $tplAttributes["scripts"] = $includedScripts . "\n<script>\n" . $newClntObjs . "</script>\n";
00096         
00097         if ($viewObj->m_Title)
00098             $tplAttributes["title"] = Expression::evaluateExpression($viewObj->m_Title, $viewObj);
00099         else
00100             $tplAttributes["title"] = $viewObj->m_Description;
00101             
00102        if(DEFAULT_SYSTEM_NAME){
00103               $tplAttributes["title"] = DEFAULT_SYSTEM_NAME.' - '.$tplAttributes["title"];
00104         }
00105         return $tplAttributes;
00106     }
00107 
00115     static protected function renderSmarty ($viewObj, $tplAttributes = Array())
00116     {
00117         $smarty = BizSystem::getSmartyTemplate();
00118               
00119               $viewOutput = $viewObj->outputAttrs();
00120         foreach ($viewOutput as $k=>$v) {
00121             $smarty->assign($k, $v);
00122         }
00123         // render the formobj attributes
00124         $smarty->assign("view", $viewOutput);
00125               
00126         //Translate Array of template variables to Zend template object
00127         foreach ($tplAttributes as $key => $value) {
00128             $smarty->assign($key, $value);
00129         }
00130         if ($viewObj->m_ConsoleOutput)
00131             $smarty->display(BizSystem::getTplFileWithPath($viewObj->m_TemplateFile, $viewObj->m_Package));
00132         else
00133             return $smarty->fetch(BizSystem::getTplFileWithPath($viewObj->m_TemplateFile, $viewObj->m_Package));
00134     }
00135 
00143     static protected function renderPHP ($viewObj, $tplAttributes = Array())
00144     {
00145         $view = BizSystem::getZendTemplate();
00146         $tplFile = BizSystem::getTplFileWithPath($viewObj->m_TemplateFile, $viewObj->m_Package);
00147         $view->addScriptPath(dirname($tplFile));
00148         
00149         //Translate Array of template variables to Zend template object
00150         foreach ($tplAttributes as $key => $value) {
00151             if ($value == NULL) {
00152                 $view->$key = '';
00153             } else {
00154                 $view->$key = $value;
00155             }
00156         }
00157         if ($viewObj->m_ConsoleOutput)
00158             echo $view->render($viewObj->m_TemplateFile);
00159         else
00160             return $view->render($viewObj->m_TemplateFile);
00161     }
00162 
00169     static protected function setHeaders ($viewObj)
00170     {
00171         // get the cache attribute
00172         // if cache = browser, set the cache control in headers
00173         header('Pragma:', true);
00174         header('Cache-Control: max-age=3600', true);
00175         $offset = 60 * 60 * 24 * - 1;
00176         $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
00177         header($ExpStr, true);
00178     }
00179 }
00180 ?>

Generated on Thu Apr 19 2012 17:09:13 for openbiz by  doxygen 1.7.2