public function backend_data() { $pages = Model_Page_Sitemap::get(TRUE); $select = array('-'); foreach ($pages->flatten() as $page) { $uri = !empty($page['uri']) ? $page['uri'] : '/'; $select[$page['id']] = $page['title'] . ' (' . $uri . ')'; } return array('select' => $select); }
/** * * @return array [$pages, $sitemap] */ public function fetch_data() { $pages = Model_Page_Sitemap::get((bool) $this->include_hidden); if (($page_id = $this->get_page_id()) !== NULL) { $pages->find($page_id); } $pages->exclude($this->exclude); $pages->fetch_widgets($this->fetched_widgets); $pages->children(); return array('sitemap' => $pages, 'pages' => $pages->as_array($this->match_all_paths == 1)); }
public function action_location() { $id = $this->request->param('id'); $widget = ORM::factory('widget', $id); if (!$widget->loaded()) { Messages::errors(__('Widget not found!')); $this->go_back(); } // check if trying to save if (Request::current()->method() == Request::POST) { return $this->_add_location($widget); } $this->template->title = __('Widget :name location', array(':name' => $widget->name)); $this->breadcrumbs->add(__('Widget :name', array(':name' => $widget->name)), Route::get('backend')->uri(array('controller' => 'widgets', 'action' => 'edit', 'id' => $widget->id)))->add(__('Widget location')); list($page_widgets, $pages_widgets) = $widget->locations(); $pages = Model_Page_Sitemap::get(TRUE)->as_array(); $this->template->content = View::factory('widgets/location', array('widget' => $widget, 'pages' => $pages, 'page_widgets' => $page_widgets, 'pages_widgets' => $pages_widgets, 'layouts_blocks' => Widget_Manager::get_blocks_by_layout())); }
}); Observer::observe('frontpage_after_render', function () { /** * Запуск метода в виджетах текущей страницы * Model_Widget_Decorator::after_page_load */ Observer::notify('after_page_load'); /** * Блок служит для помещения в него виджета с произволным PHP кодом, * который выполняется после загрузки HTML */ Block::run('POST'); }); Observer::observe('view_page_edit_plugins', function ($page) { $blocks = Widget_Manager::get_blocks_by_layout($page->layout()); echo View::factory('widgets/page/edit', array('page' => $page, 'pages' => Model_Page_Sitemap::get(TRUE)->exclude(array($page->id))->flatten(), 'widgets' => Widget_Manager::get_widgets_by_page($page->id), 'blocks' => Arr::get($blocks, $page->layout()))); }); Observer::observe('page_add_after_save', function ($page) { $post_data = Request::current()->post('widgets'); if (!empty($post_data['from_page_id'])) { Widget_Manager::copy($post_data['from_page_id'], $page->id); } }); Observer::observe('page_edit_after_save', function ($page) { $post_data = Request::current()->post('widget'); if (!is_array($post_data)) { return; } foreach ($post_data as $widget_id => $block) { Widget_Manager::update_location_by_page($page->id, $widget_id, $block); }
<?php defined('SYSPATH') or die('No direct access allowed.'); Observer::observe('view_page_edit_plugins', function ($page) { echo View::factory('page/fields/edit', array('page' => $page, 'fields' => ORM::factory('page_field')->get_by_page_id($page->id), 'pages' => Model_Page_Sitemap::get(TRUE)->exclude(array($page->id))->flatten())); }); Observer::observe('page_add_after_save', function ($page) { $post_data = Request::current()->post('fields'); if (!empty($post_data['from_page_id'])) { ORM::factory('page_field')->copy($post_data['from_page_id'], $page->id); } }); Observer::observe(array('controller_before_page_edit', 'controller_before_page_add'), function () { Assets::js('controller.page_fields', ADMIN_RESOURCES . 'js/controller/page_fields.js', 'global'); });
/** * Получение списка страниц за исключением текущей * * @return array */ public function get_sitemap() { $sitemap = Model_Page_Sitemap::get(TRUE); if ($this->loaded()) { $sitemap->exclude(array($this->id)); } return $sitemap->select_choices(); }
public function backend_data() { return array('pages' => Model_Page_Sitemap::get(TRUE)->flatten()); }
public function get_sort() { $pages = Model_Page_Sitemap::get(TRUE)->as_array(); $this->response((string) View::factory('page/sort', array('pages' => $pages))); }
<br /> <label><?php echo __('Document page'); ?> </label> <?php $pages = Model_Page_Sitemap::get(TRUE)->find($page->id)->children(); $select = array(__('--- none ---')); foreach ($pages->flatten() as $page) { $uri = !empty($page['uri']) ? $page['uri'] : '/'; $select[$page['id']] = $page['title'] . ' (' . $uri . ')'; } echo Form::select('behavior[item_page_id]', $select, Arr::get($settings, 'item_page_id')); ?> <script> cms.ui.init('select2') </script>