- <?PHP
- CLASS ModelsGlobal_Controller EXTENDS ILLI_Controller_Controller_Abstract
- {
- /**
- * usage:
- *
- *
- *
- required is the following route
- ROUTETABLEALIAS is the selector-ident in illi_rootmenu:routetable
- <page-ROUTETABLEALIAS
- uri.location = "pages"
- uri.regexp = "(ROUTETABLEALIAS/(([a-z]{2})/(([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-/!]+/)?)?)?)?"
- uri.params = "string routetable, string iso, string rootroutenode, string subroutenode"
- app.module = "page"
- />
- params:
- routetable:
- ident in illi_rootmenu:routetable => ROUTETABLEALIAS
- rootroutenode:
- ident in illi_rootmenu:routenode
- subroutenode:
- ident in illi_submenu:routenode
- iso:
- grab content by lang
- db-query:
- illi_rootmenu:routetable
- &&
- illi_rootmenu:iso
- => illi_rootmenu:routenode
- &&
- illi_submenu:iso
- => illi_submenu:routenode
- */
- // args
- const rt_table
- = 'routetable';
- const rt_section
- = 'rootroutenode';
- const rt_sub
- = 'subroutenode';
- const rt_lang
- = 'iso';
- // database-field-names
- const db_route
- = 'routenode';
- const db_rtable
- = 'routetable';
- const db_lang
- = 'iso';
- const db_ruri
- = 'uri';
- const db_id
- = 'id';
- const db_oid
- = 'oid';
- const db_pid
- = 'pid';
- const db_ciid
- = 'ciid';
- // db-tablenames
- const dbt_rootmenu
- = 'rootmenu';
- const dbt_submenu
- = 'submenu';
- // subs
- const lang
- = 'models/db/language';
- const tree
- = 'models/db/treemenu';
- const db
- = 'db/bridge';
- const nav
- = 'menu/Main-Nav-Deeplinked';
- private $rt = '';
- // st
- private $route_pages
- = NULL;
- private $current_sub_pages
- = NULL;
- private $alternate_subaction
- = NULL;
- private $alternate_sectionaction
- = NULL;
- private $page_entry
- = NULL;
- private $submenu
- = NULL;
- public function set_routeNode($route)
- {
- if(isset($this->get_RouteParams()->{'_'.ModelsGlobal_Controller::rt_table}))
- $this->rt = $route.':'.$this->get_RouteParams()->{'_'.ModelsGlobal_Controller::rt_table};
- else
- $this->rt = $route;
- return $this;
- }
- public function set_LangIso($iso)
- {
- return $this->get_SubController(self::lang)->set_Iso($iso);
- }
- public function get_LangError()
- {
- return $this->get_SubController(self::lang)->get_error();
- }
- public function get_LangIso()
- {
- return $this->get_SubController(self::lang)->get_Iso();
- }
- public function get_RoutePages($route)
- {
- if(NULL === $this->route_pages)
- $this->route_pages = $this->get_SubController(self::db)->simple_multi_search(self::dbt_submenu, array(self::db_route => $route, self::db_lang => $this->get_LangIso()), array('limit' => NULL));
- return $this->route_pages;
- }
- public function set_SubMenuItem(ILLI_Container $config)
- {
- $this->get_SubMenuInstance()->add_RouteLink
- (
- $config->_ident,
- array
- (
- ILLI_View_Navigation::active
- => $config->_active,
- 'a'
- => $config->_title
- ),
- $this->rt,
- array
- (
- self::rt_table
- => $this->get_RouteParams()->{'_'.self::rt_table},
- self::rt_lang
- => $this->get_LangIso(),
- self::rt_section
- => $config->_routenode,
- self::rt_sub
- => $config->_uri));
- return $this;
- }
- public function get_SubMenuInstance()
- {
- return $this->get_SubController(self::nav)->get_instance('sub');
- }
- public function get_SubMenu()
- {
- $SUBMENU = NULL;
- if(isset($this->get_RouteParams()->{'_'.self::rt_section}))
- $SUBMENU = $this->get_SubController(self::tree)->from_route($this->get_RoutePages($this->get_RouteParams()->{'_'.self::rt_section}));
- return ((NULL !== $SUBMENU) ? $SUBMENU->menu() : '');
- }
- private function get_SubEntry()
- {
- if(NULL === $this->current_sub_pages)
- $this->current_sub_pages = $this->get_SubController(self::tree)->get_current();
- return $this->current_sub_pages;
- }
- private function get_SubEntryByID($id)
- {
- $id = intval($id);
- $result = $this->get_SubController(self::db)->simple_multi_search(self::dbt_submenu,array(self::db_id => $id),array('limit' => 1));
- return $result[0];
- }
- private function get_RootEntryBySubRoute($route)
- {
- $result = $this->get_SubController(self::db)->simple_multi_search(self::dbt_rootmenu, array(self::db_route => $route, self::db_lang => $this->get_LangIso()), array('limit' => 1));
- return $result[0];
- }
- private function get_RootEntry()
- {
- if(NULL === $this->current_sub_pages)
- $page_entry = $this->get_SubController(self::db)->simple_multi_search(self::dbt_rootmenu, array(self::db_rtable => $this->get_RouteParams()->{'_'.self::rt_table}, self::db_route => $this->get_RouteParams()->{'_'.self::rt_section}, self::db_lang => $this->get_LangIso()), array('limit' => 1));
- return $page_entry[0];
- }
- public function get_CurrentEntry()
- {
- if(isset($this->get_RouteParams()->{'_'.self::rt_sub})&& isset($this->get_RouteParams()->{'_'.self::rt_section}))
- {
- $subaction = ILLI_Constructeur::get_Instance(self::c_FLTRRT_.'App_Action')->filter($this->get_RouteParams()->{'_'.self::rt_section}.'/'.$this->get_RouteParams()->{'_'.self::rt_sub});
- $this->alternate_subaction = $subaction['action'];
- $this->page_entry = $this->get_SubEntry();
- $root = $this->get_RootEntryBySubRoute($this->page_entry['routenode']);
- if(!$this->get_SubController('models/usergroup')->check_usergroup($root['gid']))
- $this->page_entry['permission'] = FALSE;
- }
- elseif(isset($this->get_RouteParams()->{'_'.self::rt_section}) && !isset($this->get_RouteParams()->{'_'.self::rt_sub}))
- {
- $sectionaction = ILLI_Constructeur::get_Instance(self::c_FLTRRT_.'App_Action')->filter($this->get_RouteParams()->{'_'.self::rt_section});
- $this->alternate_sectionaction = $sectionaction['action'];
- $this->page_entry = $this->get_RootEntry();
- }
- if(is_array($this->page_entry) && array_key_exists('gid', $this->page_entry) && !$this->get_SubController('models/usergroup')->check_usergroup($this->page_entry['gid']))
- $this->page_entry['permission'] = FALSE;
- if(array_key_exists('permission', $this->page_entry) && $this->page_entry['permission'] === FALSE)
- $this->get_SubController('error')->Locked_Action();
- return $this->page_entry;
- }
- public function get_SectionAction($prfx = 'Default')
- {
- if(NULL === $this->alternate_sectionaction)
- return NULL;
- return $prfx.'_'.$this->alternate_sectionaction;
- }
- public function get_SubAction($prfx = 'Default')
- {
- if(NULL === $this->alternate_subaction)
- return NULL;
- return $prfx.'_'.$this->alternate_subaction;
- }
- public function get_RootMenu($routingtable = 'pages', $route = 'page')
- {
- $routingtable = $routingtable.':'.$route;
- if(NULL !== $this->get_SubController(self::nav)->get_instance($routingtable.'_rootmenu')->menu())
- return $this->get_SubController(self::nav)->get_instance($routingtable.'_rootmenu');
- if(is_array($menu = $this->get_SubController(self::db)->simple_multi_search(self::dbt_rootmenu, array(self::db_rtable => $route, self::db_lang => $this->get_LangIso()), array('limit' => NULL))))
- foreach(array_sortkey($menu, self::db_oid) as $page)
- $this->get_SubController(self::nav)->get_instance($routingtable.'_rootmenu')->add_RouteLink($page[self::db_rtable].$page['title'], array(ILLI_View_Navigation::active => (isset($this->get_RouteParams()->{'_'.self::rt_section}) && $this->get_RouteParams()->{'_'.self::rt_section} === $page[self::db_route]), 'a' => $page['title']), $routingtable, array(self::rt_table => $route, self::rt_lang => $this->get_LangIso(), self::rt_section => $page[self::db_route]));
- return $this->get_SubController(self::nav)->get_instance($routingtable.'_rootmenu');
- }
- public function redirect_RootPage($db_rotenode = NULL)
- {
- if(is_array($page = $this->get_SubController(self::db)->simple_multi_search(self::dbt_rootmenu, array(self::db_route => ((NULL === $db_rotenode) ? $this->get_SubController('models/affiliates')->_start_page : $db_rotenode), self::db_lang => $this->get_SubController(self::lang)->get_Iso()), array('limit' => NULL))))
- {
- $page = $page[0];
- if(!ILLI_Constructeur::get_Instance(self::c_COREHDR)->redirect(ILLI_Constructeur::get_Instance(self::c_RT)->convert_RouteID2Base((((NULL === $db_rotenode) ? Application::rt_master_page : ((isset($this->get_RouteParams()->{'_'.ModelsGlobal_Controller::rt_table})) ? $this->rt : $this->rt.':'.$page[self::db_rtable]))), array(self::rt_table => $page[self::db_rtable], self::db_lang => $this->get_SubController(self::lang)->get_Iso(),self::rt_section => $page[self::db_route]))))
- $this->get_SubController('error')->Default_Action();
- }
- else
- {
- $this->get_SubController('error')->Internal_Action('Page not found in Database. Can not redirect.');
- return;
- }
- }
- public function redirect_SubPage($id)
- {
- $this->get_View()->get_Factory()->set_Title('Redirect');
- foreach(($pages = $this->get_SubController(self::tree)->get_all()) as $index => $page)
- {
- if($page[self::db_id] == $page[self::db_ciid])
- if(!$this->redirect_RootPage())
- return $this->get_SubController('error')->Internal_Action('Recursion detected, code(id:'.$page[self::db_id].'#ciid:'.$page[self::db_ciid].')');
- if($page[self::db_id] == $id && $page[self::db_route] == $this->page_entry[self::db_route])
- {
- if($page[self::db_ciid] == $this->page_entry[self::db_id])
- if(!$this->redirect_RootPage())
- return $this->get_SubController('error')->Internal_Action('Recursion detected, code(id:'.$page[self::db_id].'.ciid:'.$page[self::db_ciid].'#id:'.$this->page_entry[self::db_id].'.ciid:'.$this->page_entry[self::db_ciid].')');
- if(!ILLI_Constructeur::get_Instance(self::c_COREHDR)->redirect(ILLI_Constructeur::get_Instance(self::c_RT)->convert_RouteID2Base($this->rt, array(self::rt_table => $this->get_RouteParams()->{'_'.self::rt_table},self::rt_lang => $this->get_SubController(self::lang)->get_Iso(), self::rt_section => $page[self::db_route].'/'.$page[self::db_ruri]))))
- $this->get_SubController('error')->Default_Action();
- }
- }
- return $this->redirect_RootPage();
- }
- }
Undefined
By: Guest | Date: May 19 2010 17:46 | Format: None | Expires: never | Size: 11.36 KB | Hits: 910
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago