getView()->$name = $value; } function __get ($name) { return $this->getView()->$name; } function setView ($view) { $this->view = $view; } function getView () { return $this->view; } function setParams($params) { $this->params = $params; } function getParams ($name = null, $default = null) { if (isset ($name)) { if (is_array ($name)) { $result = array (); foreach ($name as $single_name) { $result[] = $this->getParams ($single_name); } return $result; } else { if ($this->hasParam ($name)) { return $this->params [$name]; } return $default; } } else { return $this->params; } } function hasParam ($name) { return isset ($this->params [$name]); } function passThrough () { $params = func_get_args(); foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator(array($params))) as $param) { $result = $this->getParams($param, 'THIS_PARAM_IS_NOT_SET'); if ($result !== 'THIS_PARAM_IS_NOT_SET') { $this->$param = $result; } } } protected function isHomePage () { return $this->getView()->getGlobalVars(View_Template::G_HOME); } protected function createVisibleTypeList ($force = false, array $from_the_list = array ()) { $result = array(); $pattern = Setting_Model::get (Setting_Model::S_ROUTE_TYPE_FIRST); $records = ORM::factory ('templatetype') ->where ('template_count>', 0) ->where ('enabled_template_count>', 0) ->where ('visibility !=', TemplateType_Model::STATE_DISABLED) ->orderby ('position'); if ($from_the_list) { $records->in ('id', $from_the_list); } $records = $records->find_all (); foreach ($records as $record) { $is_visible_home = $this->isHomePage() && $record->isVisibleOnHomePage(); $is_visible_list = !$this->isHomePage() && $record->isVisibleExceptHomePage(); if ($is_visible_home || $is_visible_list || $force) { $type = new Theme_Link_Catalog_Type(); $type->setMacrophage(new Theme_Macrophage()); $type->setRecord($record); $type->setUrlPattern($pattern); $result[] = $type; } } return $result; } protected function createVisibleCategoryList ($force = false, array $from_the_list = array ()) { $url_pattern = Setting_Model::get (Setting_Model::S_ROUTE_CATEGORY_FIRST); $categories = ORM::factory ('templatecategory') ->where ('template_count>', 0) ->where ('enabled_template_count>', 0) ->where ('visibility !=', TemplateCategory_Model::STATE_DISABLED) ->orderby ('position', 'asc') ; if ($from_the_list) { $categories->in ('id', $from_the_list); } if (!$force) { if ($this->getParams('home')) { $categories->where('visibility', DAL_Catalog::STATE_VISIBLE_EVERYWHERE); } else { $categories->where('visibility !=', DAL_Catalog::STATE_HIDDEN); } } $result = array(); foreach ($categories->find_all() as $record) { $category = new Theme_Link_Catalog_Category (); $category->setMacrophage (new Theme_Macrophage ()); $category->setRecord ($record); $category->setUrlPattern ($url_pattern); $result[] = $category; } return $result; } function createVisiblePackagesList($force = false, array $from_the_list = array ()) { $result = array (); $url_pattern = Setting_Model::get (Setting_Model::S_ROUTE_PACKAGE_FIRST); $packages = ORM::factory('templatepackage') ->where ('url_name !=', '') ->where ('template_count >', 0) ->where ('visibility !=', TemplateType_Model::STATE_DISABLED) ->orderby ('position'); if ($from_the_list) { $packages->in('id', $from_the_list); } if(!$force) { if($this->isHomePage()) { $packages = $packages->where('visibility', DAL_Catalog::STATE_VISIBLE_EVERYWHERE); } else { $packages = $packages->where('visibility !=', DAL_Catalog::STATE_HIDDEN); } } foreach ($packages->find_all() as $record) { $package = new Theme_Link_Catalog_Package (); $package->setMacrophage(new Theme_Macrophage); $package->setRecord($record); $package->setUrlPattern($url_pattern); $result[] = $package; } return $result; } }