public function get_page_name($page_name, $toolname, $parent_id) { if (!empty($page_name)) { if ('get' == $page_name) { return yaml::does_value_exist($this->site_name, 'pages_config', "{$toolname}-{$parent_id}"); } else { return $page_name; } } return $this->homepage; }
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; }