public function _index($navigation) { # There will always be a root_holder so no items is actually =1 if ('1' == $navigation->navigation_items->count()) { return $this->wrap_tool('(no items)', 'navigation', $navigation); } $view = new View('public_navigation/lists/stock'); $view->navigation = $navigation; # public node_generation function is contained in the tree class... $view->tree = Tree::display_tree('navigation', $navigation->navigation_items); return $this->wrap_tool($view, 'navigation', $navigation); }
function manage() { valid::id_key($this->pid); $navigation_items = ORM::factory('navigation_item')->where(array('fk_site' => $this->site_id, 'navigation_id' => $this->pid))->find_all(); if (0 == $navigation_items->count()) { die('Error: this navigation has no root node.'); } $pages = ORM::factory('page')->where('fk_site', $this->site_id)->find_all(); $view = new View('edit_navigation/manage'); $view->tree = Tree::display_tree('navigation', $navigation_items, NULL, NULL, 'render_edit_navigation', TRUE); $view->tool_id = $this->pid; $view->pages = $pages; die($view); }
public function parse_tokens($body) { # NEWSLETTER TOKEN. str_replace('{{newsletter}}', '', $body, $count); if (0 < $count) { $pages_config = yaml::parse($this->site_name, 'pages_config'); if (empty($pages_config['newsletter'])) { return $body; } $parent_id = explode('-', $pages_config['newsletter']); $parent_id = $parent_id['1']; # get the newsletter HTML. $newsletter = new Newsletter_Controller(); $body = str_replace('{{newsletter}}', $newsletter->_index($parent_id), $body); } # ------------------------------------------------------ # SHOWROOM TOKEN. format: {showroom_cats:parent_id:parameters} $pattern = '/{showroom_cats:(\\d+)\\:(\\w+)\\}/'; if (0 < preg_match($pattern, $body, $match)) { # get the page name. $page_name = yaml::does_value_exist($this->site_name, 'pages_config', "showroom-{$match[1]}"); if (!$page_name) { return $body; } # get the showroom category html. $showroom = ORM::factory('showroom', $match[1]); if (!$showroom->loaded) { return $body; } # how should the list be displayed? if (!empty($match[2]) and 'flat' == $match[2]) { # showing only root categories. $root_cats = ORM::factory('showroom_cat')->where(array('fk_site' => $this->site_id, 'showroom_id' => $showroom->id, 'local_parent' => $showroom->root_id))->orderby(array('lft' => 'asc'))->find_all(); $categories = Tree::display_flat_tree('showroom', $root_cats, $page_name); } else { $categories = Tree::display_tree('showroom', $showroom->showroom_cats, $page_name); } $body = preg_replace($pattern, $categories, $body, 1); } /* -------------------------------------------- */ # google map! format: {google_map:parent_id:parameters} $pattern = '/{google_map:(\\d+)\\:(\\w+)\\}/'; if (0 < preg_match($pattern, $body, $match)) { } return $body; }
private function items_category($page_name, $showroom, $category_id) { # get the parent to determine the view. if (!is_object($showroom)) { $showroom = ORM::factory('showroom', $showroom); } # get the category $category = ORM::factory('showroom_cat')->where(array('fk_site' => $this->site_id, 'showroom_id' => $showroom->id))->find($category_id); if (!$category->loaded) { return '<div class="not_found">Invalid category</div>'; } # get any sub categories ... $sub_cats = ORM::factory('showroom_cat')->where(array('fk_site' => $this->site_id, 'showroom_id' => $showroom->id, 'lft >=' => "{$category->lft}", 'lft <=' => "{$category->rgt}"))->find_all(); # create array from the cat and sub_cats $cat_ids = array(); foreach ($sub_cats as $cat) { $cat_ids[] = $cat->id; } # get all the items. $items = ORM::factory('showroom_cat_item')->where(array('fk_site' => $this->site_id))->in('showroom_cat_id', $cat_ids)->find_all(); if (0 == $items->count()) { return '<div class="not_found">No items. Check back soon!</div>'; } $view = new View("public_showroom/display/{$showroom->view}"); # do view stuff if ('gallery' == $showroom->view) { # request javascript file $view->request_js_files('lightbox/lightbox.js'); # parse the params. $params = explode('|', $showroom->params); $view->columns = (isset($params[1]) and is_numeric($params[1])) ? $params[1] : 2; $view->thumb_size = (isset($params[2]) and is_numeric($params[2])) ? $params[2] : 75; } # get the path to this category $path = ORM::factory('showroom_cat')->where(array('fk_site' => $this->site_id, 'showroom_id' => $showroom->id, 'lft <' => $category->lft, 'rgt >' => $category->rgt, 'local_parent !=' => 0))->orderby(array('lft' => 'asc'))->find_all(); $view->path = $path; $view->category = $category; $view->sub_categories = Tree::display_tree('showroom', $sub_cats, $page_name); $view->page_name = $page_name; $view->img_path = $this->assets->assets_url(); $view->items = $items; return $view; }