public function post_rebuild() { $layouts = Model_File_Layout::find_all(); $blocks = array(); foreach ($layouts as $layout) { $blocks[$layout->name] = $layout->rebuild_blocks(); } $this->response($blocks); $this->message('Layout blocks successfully update!'); }
/** * * @param string $layout_name * * array( * '[layout name]' => array( * [block name] => [block name], * ... * ) * ) * * @return array */ public static function get_blocks_by_layout($layout_name = NULL) { $blocks_by_layout = array(); $database_blocks = ORM::factory('layout_block'); if ($layout_name !== NULL) { $database_blocks->where('layout_name', '=', $layout_name); } foreach ($database_blocks->find_all() as $block) { if (empty($blocks_by_layout[$block->layout_name])) { $blocks_by_layout[$block->layout_name] = self::get_system_blocks(); } $blocks_by_layout[$block->layout_name][$block->block] = $block->block; } // Move POST key to end foreach ($blocks_by_layout as $layout_name => $blocks) { $post = $blocks['POST']; unset($blocks_by_layout[$layout_name]['POST']); $blocks_by_layout[$layout_name]['POST'] = $post; } $layout_files = Model_File_Layout::find_all(); foreach ($layout_files as $file) { if (!isset($blocks_by_layout[$file->name])) { $blocks_by_layout[$file->name] = self::get_system_blocks(); } } return $blocks_by_layout; }
/** * Получение списка шаблонов * * @return array */ public function get_layouts_list() { $options = array(); if ($this->id != 1) { $layout = NULL; if ($this->parent->loaded()) { $layout = $this->parent->layout(); } if (empty($layout)) { $layout = __('--- Not set ---'); } $options[0] = __('--- inherit (:layout) ---', array(':layout' => $layout)); } else { $options[0] = __('--- Not set ---'); } $layouts = Model_File_Layout::find_all(); foreach ($layouts as $layout) { $options[$layout->name] = $layout->name; } return $options; }
public function action_delete() { $this->auto_render = FALSE; $layout_name = $this->request->param('id'); $layout = new Model_File_Layout($layout_name); // find the user to delete if (!$layout->is_used()) { if ($layout->delete()) { Kohana::$log->add(Log::INFO, 'Layout :name has been deleted by :user', array(':name' => $layout_name))->write(); Messages::success(__('Layout has been deleted!')); Observer::notify('layout_after_delete', $layout_name); } else { Messages::errors(__('Something went wrong!')); } } else { Messages::errors(__('Layout is used! It CAN NOT be deleted!')); } $this->go(); }
/** * * @return Model_File_Layout * @throws Kohana_Exception */ public function get_layout_object() { if ($this->_layout_object === NULL) { $layout_name = $this->layout(); $this->_layout_object = new Model_File_Layout($layout_name); } if (!$this->_layout_object->is_exists()) { if (($found_file = $this->_layout_object->find_file()) !== FALSE) { $this->_layout_object = new Model_File_Layout($found_file); } else { throw new HTTP_Exception_500('Layout file :file not found!', array(':file' => $layout_name)); } } return $this->_layout_object; }
<?php defined('SYSPATH') or die('No direct access allowed.'); /** * Build layout blocks */ $layouts = Model_File_Layout::find_all(); foreach ($layouts as $layout) { $layout->rebuild_blocks(); } /** * Install widgets */ if (class_exists('Widget_Manager')) { $widgets = array(array('type' => 'page_menu', 'data' => array('name' => 'Header menu', 'template' => 'header', 'cache_tags' => 'pages', 'page_id' => 1, 'exclude' => array(6, 4)), 'blocks' => array(1 => 'header', 3 => 'header', 8 => 'header', 6 => 'header', 5 => 'header', 7 => 'header', 9 => 'header', 10 => 'header', 11 => 'header')), array('type' => 'page_breadcrumbs', 'data' => array('name' => 'Breadcrumbs', 'template' => 'bradcrumbs', 'cache_tags' => 'pages'), 'blocks' => array(1 => 'bradcrumbs', 3 => 'bradcrumbs', 8 => 'bradcrumbs', 6 => 'bradcrumbs', 5 => 'bradcrumbs', 7 => 'bradcrumbs', 9 => 'bradcrumbs', 10 => 'bradcrumbs', 11 => 'bradcrumbs')), array('type' => 'html', 'data' => array('name' => 'Footer', 'template' => 'footer'), 'blocks' => array(1 => 'footer', 3 => 'footer', 8 => 'footer', 6 => 'footer', 5 => 'footer', 7 => 'footer', 9 => 'footer', 10 => 'footer', 11 => 'footer')), array('type' => 'html', 'data' => array('name' => 'Sidebar', 'template' => 'sidebar'), 'blocks' => array(1 => 'sidebar', 3 => 'sidebar', 8 => 'sidebar', 6 => 'sidebar', 5 => 'sidebar', 7 => 'sidebar', 9 => 'sidebar', 10 => 'sidebar', 11 => 'sidebar')), array('type' => 'html', 'data' => array('name' => 'Top banner', 'template' => 'top_banner'), 'blocks' => array(1 => 'top_banner')), 'articles_headline' => array('type' => 'page_pages', 'data' => array('name' => 'Articles headline', 'template' => 'archive-headline', 'cache_tags' => 'pages,page_parts,page_tags'), 'blocks' => array(8 => 'body')), array('type' => 'page_pages', 'data' => array('name' => 'Recent entries', 'template' => 'recent-entries', 'caching' => 1, 'cache_lifetime' => 3600, 'cache_tags' => 'pages,page_parts,page_tags', 'header' => 'Recent entries', 'page_id' => 8), 'blocks' => array(3 => 'recent', 8 => 'recent', 6 => 'recent', 5 => 'recent', 7 => 'recent', 9 => 'recent', 10 => 'recent')), array('type' => 'page_pages', 'data' => array('name' => 'Recent entries index page', 'template' => 'recent-entries', 'caching' => 1, 'cache_lifetime' => 3600, 'cache_tags' => 'pages,page_parts,page_tags', 'page_id' => 8), 'blocks' => array(1 => 'extended')), array('type' => 'page_pages', 'data' => array('name' => 'last entry index page', 'template' => 'last-entry', 'caching' => 1, 'cache_lifetime' => 3600, 'cache_tags' => 'pages,page_parts,page_tags', 'page_id' => 8, 'list_size' => 1), 'blocks' => array(1 => 'body')), array('type' => 'page_pages', 'data' => array('name' => 'Recent entries RSS', 'template' => 'recent-entries-rss', 'caching' => 1, 'cache_lifetime' => 3600, 'cache_tags' => 'pages,page_parts,page_tags', 'page_id' => 8), 'blocks' => array(4 => 'body')), array('type' => 'sendmail', 'data' => array('name' => ' Send mail (sender)', 'template' => 'send-mail-template', 'allowed_tags' => '<b><i><u><p>', 'field' => array('source' => array(0 => '0', 1 => '2', 2 => '2', 3 => '2'), 'id' => array(0 => '', 1 => 'subject', 2 => 'email', 3 => 'text'), 'type' => array(0 => '10', 1 => '10', 2 => '10', 3 => '20'), 'validator' => array(0 => '', 1 => 'not_empty', 2 => 'email', 3 => ''), 'error' => array(0 => '', 1 => '', 2 => '', 3 => ''))), 'blocks' => array(12 => 'body')), array('type' => 'html', 'data' => array('name' => 'Send mail (form)', 'template' => 'send-mail-form'), 'blocks' => array(11 => 'body')), array('type' => 'pagination', 'data' => array('name' => 'Постраничная навигация', 'template' => 'paginator', 'related_widget_id' => 8, 'query_key' => 'page', 'related_widget_id' => NULL), 'blocks' => array(8 => 'pagination'))); $installed_widgets = array(); foreach ($widgets as $key => $widget) { if (isset($widget['data']['related_widget_id']) and isset($installed_widgets[$widget['data']['related_widget_id']])) { $widget['data']['related_widget_id'] = $installed_widgets[$widget['data']['related_widget_id']]; } $installed_widgets[$key] = Widget_Manager::install($widget); } }