コード例 #1
0
 /**
  * setUp.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $view = new View();
     $view->theme(option('front_theme'));
     $this->helper = new MenuHelper($view);
 }
コード例 #2
0
 /**
  * setUp.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $View = new View();
     $View->theme(option('front_theme'));
     $options = ['fixMissing' => false];
     $this->regions = [new Region($View, 'left-sidebar', $options), new Region($View, 'right-sidebar', $options), new Region($View, 'footer', $options)];
     $this->regions[0]->blocks(collection([new Entity(['region' => new Entity(['region' => 'left-sidebar'])]), new Entity(['region' => new Entity(['region' => 'left-sidebar'])]), new Entity(['region' => new Entity(['region' => 'left-sidebar'])])]));
     $this->regions[1]->blocks(collection([new Entity(['region' => new Entity(['region' => 'right-sidebar'])]), new Entity(['region' => new Entity(['region' => 'right-sidebar'])])]));
     $this->regions[2]->blocks(collection([new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])])]));
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  *
  * This method will look for certain view elements when rendering each custom
  * block, if one of this elements is not present it'll look the next one, and so
  * on. These view elements should be defined by Themes by placing them in
  * `<MyTheme>/Template/Element`.
  *
  * ### Render block based on theme's region & view-mode
  *
  *     render_block_[region-name]_[view-mode].ctp
  *
  * Renders the given block based on theme's **region-name and view-mode**, for
  * example:
  *
  * - render_block_left-sidebar_full.ctp: Render for blocks in `left-sidebar`
  *   region when view-mode is `full`
  *
  * - render_block_left-sidebar_search-result.ctp: Render for blocks in
  *   `left-sidebar` region when view-mode is `search-result`.
  *
  * - render_block_footer_search-result.ctp: Render for blocks in `footer`
  *   region when view-mode is `search-result`.
  *
  *
  * ### Render block based on theme's region
  *
  *     render_block_[region-name].ctp
  *
  * Similar as before, but based on theme's **region-name** (and any view-mode),
  * for example:
  *
  * - render_block_right-sidebar.ctp: Render for blocks in `right-sidebar` region.
  *
  * - render_block_left-sidebar.ctp: Render for blocks in `left-sidebar` region.
  *
  *
  * ### Default
  *
  *     render_block.ctp
  *
  * This is the global render, if none of the above renders is found we try to
  * use this last. Themes can overwrite this view element by creating a new one
  * at `ExampleTheme/Template/Element/render_block.ctp`.
  *
  * ---
  *
  * NOTE: Please note the difference between "_" and "-"
  */
 public function render(Block $block, View $view)
 {
     $viewMode = $view->viewMode();
     $blockRegion = isset($block->region->region) ? 'none' : $block->region->region;
     $cacheKey = "render_{$block->id}_{$blockRegion}_{$viewMode}";
     $cache = static::cache($cacheKey);
     $element = 'Block.render_block';
     if ($cache !== null) {
         $element = $cache;
     } else {
         $try = ["Block.render_block_{$blockRegion}_{$viewMode}", "Block.render_block_{$blockRegion}", 'Block.render_block'];
         foreach ($try as $possible) {
             if ($view->elementExists($possible)) {
                 $element = static::cache($cacheKey, $possible);
                 break;
             }
         }
     }
     return $view->element($element, compact('block', 'options'));
 }
コード例 #4
0
ファイル: MenuWidget.php プロジェクト: quickapps-plugins/menu
 /**
  * {@inheritDoc}
  *
  * Renders menu's associated block.
  *
  * This method will look for certain view elements when rendering each menu, if
  * one of this elements is not present it'll look the next one, and so on. These
  * view elements should be defined by Themes by placing them in
  * `<MyTheme>/Template/Element`.
  *
  * ### Render menu based on theme's region & view-mode
  *
  *     render_menu_[region-name]_[view-mode].ctp
  *
  * Renders the given block based on theme's `region-name` and `view-mode`, for
  * example:
  *
  * - `render_menu_left-sidebar_full.ctp`: Render for menus in `left-sidebar`
  *    region when view-mode is `full`.
  *
  * - `render_menu_left-sidebar_search-result.ctp`: Render for menus in
  *   `left-sidebar` region when view-mode is `search-result`
  *
  * - `render_menu_footer_search-result.ctp`: Render for menus in `footer` region
  *   when view-mode is `search-result`.
  *
  * ### Render menu based on theme's region
  *
  *     render_menu_[region-name].ctp
  *
  * Similar as before, but based only on theme's `region` (and any view-mode), for
  * example:
  *
  * - `render_menu_right-sidebar.ctp`: Render for menus in `right-sidebar`
  *   region.
  *
  * - `render_menu_left-sidebar.ctp`: Render for menus in `left-sidebar`
  *   region.
  *
  * ### Default
  *
  *     render_block.ctp
  *
  * This is the default render, if none of the above is found we try to use this
  * last. Themes can overwrite this view element by creating a new one
  * at `ExampleTheme/Template/Element/render_block.ctp`.
  *
  * ---
  *
  * NOTE: Please note the difference between "_" and "-"
  */
 public function render(Block $block, View $view)
 {
     $menuId = intval($block->settings['menu_id']);
     $menu = TableRegistry::get('Menu.Menus')->find()->cache("info_{$menuId}", 'menus')->where(['Menus.id' => $menuId])->first();
     $links = TableRegistry::get('Menu.MenuLinks')->find('threaded')->cache("links_{$menuId}", 'menus')->where(['menu_id' => $menuId])->order(['lft' => 'ASC']);
     $menu->set('links', $links);
     $viewMode = $view->viewMode();
     $blockRegion = isset($block->region->region) ? $block->region->region : 'none';
     $cacheKey = "render_{$blockRegion}_{$viewMode}";
     $cache = static::cache($cacheKey);
     $element = 'Menu.render_menu';
     if ($cache !== null) {
         $element = $cache;
     } else {
         $try = ["Menu.render_menu_{$blockRegion}_{$viewMode}", "Menu.render_menu_{$blockRegion}", 'Menu.render_menu'];
         foreach ($try as $possible) {
             if ($view->elementExists($possible)) {
                 $element = static::cache($cacheKey, $possible);
                 break;
             }
         }
     }
     return $view->element($element, compact('menu'));
 }
コード例 #5
0
ファイル: Region.php プロジェクト: quickapps-plugins/block
 /**
  * Fetches all block entities that could be rendered within this region.
  *
  * @return void
  */
 protected function _prepareBlocks()
 {
     $cacheKey = "{$this->_View->theme}_{$this->_machineName}";
     $blocks = TableRegistry::get('Block.Blocks')->find('all')->cache($cacheKey, 'blocks')->contain(['Roles', 'BlockRegions'])->matching('BlockRegions', function ($q) {
         return $q->where(['BlockRegions.theme' => $this->_View->theme(), 'BlockRegions.region' => $this->_machineName]);
     })->where(['Blocks.status' => 1])->order(['BlockRegions.ordering' => 'ASC']);
     $blocks->sortBy(function ($block) {
         return $block->region->ordering;
     }, SORT_ASC);
     // remove blocks that cannot be rendered based on current request.
     $blocks = $blocks->filter(function ($block) {
         return $this->_filterBlock($block) && $block->renderable();
     });
     $this->blocks($blocks);
 }
コード例 #6
0
 /**
  * {@inheritDoc}
  */
 public function render(Block $block, View $view)
 {
     return $view->element('Content.Widget/dashboard_search_render', compact('block'));
 }
コード例 #7
0
ファイル: DateField.php プロジェクト: quickapps-plugins/field
 /**
  * {@inheritDoc}
  */
 public function viewModeSettings(FieldInstance $instance, View $view, $viewMode)
 {
     return $view->element('Field.DateField/view_mode_form', compact('instance', 'viewMode'));
 }
コード例 #8
0
 /**
  * {@inheritDoc}
  */
 public function viewModeSettings(FieldInstance $instance, View $view, $viewMode)
 {
     return $view->element('Taxonomy.taxonomy_field_view_mode_form', compact('instance'));
 }
コード例 #9
0
 /**
  * {@inheritDoc}
  */
 public function render(Block $block, View $view)
 {
     $contents = TableRegistry::get('Content.Contents')->find('all', ['fieldable' => false])->order(['created' => 'DESC'])->limit(10)->all();
     return $view->element('Content.Widget/dashboard_latest_content_render', compact('block', 'contents'));
 }
コード例 #10
0
 /**
  * {@inheritDoc}
  */
 public function render(Block $block, View $view)
 {
     return $view->element('User.user_menu_widget_render', compact('block'));
 }
コード例 #11
0
 /**
  * {@inheritDoc}
  */
 public function settings(Block $block, View $view)
 {
     return $view->element('Taxonomy.categories_widget_settings', compact('block'));
 }
コード例 #12
0
 /**
  * {@inheritDoc}
  */
 public function settings(Block $block, View $view)
 {
     $languagesList = LocaleToolbox::languagesList(false, false);
     return $view->element('Locale.language_switcher_widget_settings', compact('block', 'languagesList'));
 }
コード例 #13
0
 /**
  * {@inheritDoc}
  */
 public function settings(Block $block, View $view)
 {
     return $view->element('Content.Widget/recent_content_settings', compact('block'));
 }