phpDocumentor PHPShopCore
[ class tree: PHPShopCore ] [ all elements ]

Source for file page.core.php

Documentation is available at page.core.php

  1. <?
  2. /**
  3.  * Обработчик страниц
  4.  * @author PHPShop Software
  5.  * @version 1.0
  6.  * @package PHPShopCore
  7.  */
  8. class PHPShopPage extends PHPShopCore {
  9.  
  10.     /**
  11.      * Конструктор
  12.      */
  13.     function PHPShopPage({
  14.  
  15.         // Имя Бд
  16.         $this->objBase=$GLOBALS['SysValue']['base']['table_name11'];
  17.  
  18.         // Отладка
  19.         $this->debug=false;
  20.  
  21.         // Список экшенов
  22.         $this->action=array("nav"=>"CID");
  23.         parent::PHPShopCore();
  24.     }
  25.  
  26.     /**
  27.      * Экшен по умолчанию, вывод данных по странице
  28.      * @return string
  29.      */
  30.     function index({
  31.         // Безопасность
  32.         $link=PHPShopSecurity::TotalClean($this->PHPShopNav->getName(),2);
  33.  
  34.         // Выборка данных
  35.         $row=parent::getFullInfoItem(array('*'),array('link'=>"='$link'",'enabled'=>"='1'"));
  36.  
  37.         // Прикрываем страницу от дубля
  38.         if($row['category'== 2000)  return $this->setError404();
  39.         elseif(empty($row['id'])) return $this->setError404();
  40.  
  41.         // Определяем переменые
  42.         $this->set('pageContent',Parser($row['content']));
  43.         $this->set('pageTitle',$row['name']);
  44.  
  45.         // Мета
  46.         if(empty($row['title'])) $title=$row['name'];
  47.         else $title=$row['title'];
  48.         $this->title=$title." - ".$this->PHPShopSystem->getValue("name");
  49.         $this->description=$row['description'];
  50.         $this->keywords=$row['keywords'];
  51.         $this->lastmodified=$row['date'];
  52.  
  53.         // Навигация хлебные крошки
  54.         $this->navigation($row['category'],$row['name']);
  55.  
  56.         // Подключаем шаблон
  57.         $this->parseTemplate($this->getValue('templates.page_page_list'));
  58.     }
  59.  
  60.     /**
  61.      * Экшен выборки подробной информации при наличии переменной навигации CID
  62.      */
  63.     function CID({
  64.  
  65.         // ID категории
  66.         $this->category=PHPShopSecurity::TotalClean($this->PHPShopNav->getId(),1);
  67.         $this->PHPShopCategory &new PHPShopCategory($this->category);
  68.         $this->category_name=$this->PHPShopCategory->getName();
  69.  
  70.         $PHPShopOrm &new PHPShopOrm($this->getValue('base.table_name'));
  71.         $PHPShopOrm->debug=$this->debug;
  72.         $row=$PHPShopOrm->select(array('id,name'),array('parent_to'=>"=".$this->category),false,array('limit'=>1));
  73.  
  74.         // Если страницы
  75.         if(empty($row['id'])) {
  76.  
  77.             $this->ListPage();
  78.         }
  79.         // Если каталоги
  80.         else {
  81.  
  82.             $this->ListCategory();
  83.         }
  84.     }
  85.  
  86.     /**
  87.      * Вывод списка страниц
  88.      * @return string
  89.      */
  90.     function ListPage({
  91.         $dis='';
  92.  
  93.         // 404
  94.         if(!isset($this->category_name)) return $this->setError404();
  95.  
  96.         // Выборка данных
  97.         $this->dataArray=$this->PHPShopOrm->select(array('name,link,category'),array('category'=>'='.$this->category,'enabled'=>"='1'"),
  98.                 array('order'=>'num'),array('limit'=>100));
  99.         if(is_array($this->dataArray))
  100.             foreach($this->dataArray as $row{
  101.                 $dis.="<li><a href=\"/page/".$row['link'].".html\" title=\"".$row['name']."\">".$row['name']."</a></li>";
  102.             }
  103.  
  104.         $disp="<h1>".$this->category_name."</h1>";
  105.  
  106.         // Если есть описание каталога
  107.         if(!empty($this->LoadItems['CatalogPage'][$this->category]['content_enabled']))
  108.             $disp.=$this->PHPShopCategory->getContent();
  109.  
  110.         $disp.="<ul>$dis</ul>";
  111.  
  112.         // Назначаем переменные
  113.         $this->set('pageContent',$disp);
  114.         $this->set('pageTitle',$this->category_name);
  115.  
  116.         // Мета
  117.         $this->title=$this->category_name." - ".$this->PHPShopSystem->getValue("name");
  118.  
  119.         // Навигация хлебные крошки
  120.         if(!empty($this->LoadItems['CatalogPage'][$this->category]['parent_to']))
  121.             $this->navigation($this->LoadItems['CatalogPage'][$this->category]['parent_to'],$this->category_name);
  122.         else $this->navigation($row['category'],$this->category_name);
  123.  
  124.         // Подключаем шаблон
  125.         $this->parseTemplate($this->getValue('templates.page_page_list'));
  126.     }
  127.  
  128.     /**
  129.      * Вывод списка категорий
  130.      */
  131.     function ListCategory({
  132.  
  133.         // Выборка данных
  134.         $PHPShopOrm &new PHPShopOrm($this->getValue('base.table_name'));
  135.         $PHPShopOrm->debug=$this->debug;
  136.         $dataArray=$PHPShopOrm->select(array('name','id'),array('parent_to'=>'='.$this->category),array('order'=>'num'),array('limit'=>100));
  137.         if(is_array($dataArray))
  138.             foreach($dataArray as $row{
  139.                 $dis.="<li><a href=\"/page/CID_".$row['id'].".html\" title=\"".$row['name']."\">".$row['name']."</a></li>";
  140.             }
  141.  
  142.         $disp="<h1>".$this->category_name."</h1>";
  143.  
  144.         // Если есть описание каталога
  145.         if(!empty($this->LoadItems['CatalogPage'][$this->category]['content_enabled']))
  146.             $disp.=$this->PHPShopCategory->getContent();
  147.  
  148.         $disp.="<ul>$dis</ul>";
  149.  
  150.         $this->set('pageContent',$disp);
  151.         $this->set('pageTitle',$this->category_name);
  152.  
  153.         // Мета
  154.         $this->title=$this->category_name." - ".$this->PHPShopSystem->getValue("name");
  155.  
  156.         // Навигация хлебные крошки
  157.         if(!empty($this->LoadItems['CatalogPage'][$this->category]['parent_to']))
  158.             $this->navigation($this->LoadItems['CatalogPage'][$this->category]['parent_to'],$this->category_name);
  159.         else $this->navigation($this->category,$this->category_name);
  160.  
  161.         // Подключаем шаблон
  162.         $this->parseTemplate($this->getValue('templates.page_page_list'));
  163.     }
  164. }
  165. ?>

Documentation generated on Thu, 17 Feb 2011 15:58:45 +0300 by phpDocumentor 1.4.3