Location: PHPKode > projects > phpAWE > phpAWE.0.4.beta.demo-page/awe/classes/TawePageView.php
<?php



class TawePageView extends TaweQueryBase {

private $moduleName;

private $awePageViewDefaultStyleFile = "style.css";

      public function view($pageId) {
          global $layoutCssDir;
          global $layoutHtmlDir;
          global $templateAreola;
          global $templateDefaultFile;
          global $templateDefaultExtension;
          
          
          $pageData = $this->getData($pageId);
          $pageConf = $this->getConf();
          
          if (strlen($pageData[0][template])) $template = $pageData[0][template]; else $template = $templateDefaultFile;
          
          $pageTemplate = file_get_contents($layoutHtmlDir.$this->moduleName."/".$template.$templateDefaultExtension);
          $pageTemplate = str_replace("%style_file%", $layoutCssDir.$this->awePageViewDefaultStyleFile, $pageTemplate);
          
    
          if (isset($pageData[0])) $result = massReplace($pageData[0], $pageTemplate, $templateAreola); else $result = $pageTemplate;
          
          $result = str_replace("%content%", "", $result);
          $result = massReplace($pageConf[0], $result, $templateAreola);
          
          return $result;
      }
      
      protected function getData($pageId) {
        global $aweDataTable;
        global $aweSqlPrimaryKey;
        
        return $this->aweQuery->select("",$this->moduleName.$aweDataTable, sqlText(equals,$aweSqlPrimaryKey, $pageId) ,"", 1);
      }
      
      protected function getConf() {
        global $aweConfigTable;
        global $aweSqlPrimaryKey;
        
        return $this->aweQuery->select("",$this->moduleName.$aweConfigTable, $limit = 1);

      } 
      
      private function replaceContent($pageData, $pageTemplate) {
       
        global $templateAreola;
        global $aweSqlContentField;

        $result = str_replace($templateAreola.$aweSqlContentField.$templateAreola, $pageData[$aweSqlcontentField], $pageTemplate);
      
        return $result;
      }
      
      

      function __construct($moduleName) {
        parent::__construct();
        $this->moduleName = $moduleName;
      }
}

Return current item: phpAWE