Ejemplo n.º 1
0
 public static function Instance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 2
0
 public function action_set()
 {
     $mTemplates = M_Templates::Instance();
     $this->messages = array();
     $this->currentTemplate = $mTemplates->getCurrentTemplate();
     if ($this->isPost()) {
         if (isset($_POST['templ'])) {
             if ($mTemplates->setTemplate($_POST)) {
                 $this->redirect(M_Link::ToAdminTemplates('set'));
             }
         } elseif (isset($_POST['region'])) {
             unset($_POST['region']);
             $mTemplates->updateRegionsBlocks($_POST, $this->currentTemplate);
         }
         $this->messages = $mTemplates->errors();
     }
     $this->listTemplates = $mTemplates->get_templates();
     $this->regions = M_Regions::Instance()->getByTemplate($this->currentTemplate);
     $this->blocks = $mTemplates->regionsBlocks($this->currentTemplate);
     //var_dump($this->regions, $this->blocks); die();
     // Получение пути к шаблону
     $templateName = $this->getTemplate('components/templates/v_set_template.php', $this);
     // Формирование контента страницы
     $this->content = $this->Template($templateName, $this);
 }
Ejemplo n.º 3
0
 public function render()
 {
     $mTemplates = M_Templates::Instance();
     // Загружаем данные блоков
     $this->loadBlocks();
     //Получаем блоки который есть регионах
     $blocks = $mTemplates->regionsBlocks($this->template_name);
     // Список всех регионов
     $_regions = M_Regions::Instance()->getByTemplate($this->template_name);
     $regions = array();
     // Подключаем хлебные крошки(навигацию)
     $this->blocks['_content_page'] = $this->getBreadCrumbs($this->menuLinkId) . "" . $this->blocks['_content_page'];
     // Наполняем регионы содержимым блоков
     foreach ($_regions as $region) {
         $rid = $region['region_id'];
         if ($rid == 0) {
             continue;
         }
         if (isset($blocks[$rid])) {
             foreach ($blocks[$rid] as $block) {
                 $regions[$region['region_name']][] = isset($this->blocks[$block['block_name']]) ? $this->blocks[$block['block_name']] : "";
             }
         } else {
             $regions[$region['region_name']] = array();
         }
     }
     $regions_s = array();
     // Делаем каждый регион строкой
     foreach ($regions as $key => $region) {
         $regions_s[$key] = implode("\n", $region);
     }
     $this->regions = $regions_s;
     $page = $this->Template($this->template, $this);
     //print_r($page);
     //echo $page;
     echo $this->replace_widgets($page);
 }