Public paste
Undefined
By: broadcast-model | Date: May 18 2010 16:28 | Format: None | Expires: never | Size: 6.45 KB | Hits: 884

  1. <?PHP
  2.  
  3.         CLASS ModelsGlobal_Controller EXTENDS ILLI_Controller_Controller_Abstract
  4.         {
  5.                 // route in routing xml
  6.                 const rt
  7.                         = 'page:sections';
  8.                        
  9.                 // args
  10.                 const rt_table
  11.                         = 'routetable';
  12.                        
  13.                        
  14.                 const rt_section
  15.                         = 'rootroutenode';
  16.                        
  17.                        
  18.                 const rt_sub
  19.                         = 'subroutenode';
  20.                        
  21.                
  22.                 const rt_lang
  23.                         = 'iso';
  24.                        
  25.                
  26.                 // database-field-names
  27.                 const db_route
  28.                         = 'routenode';
  29.                        
  30.                        
  31.                 const db_rtable
  32.                         = 'routetable';
  33.                        
  34.                        
  35.                 const db_lang
  36.                         = 'iso';
  37.                        
  38.                        
  39.                 const db_ruri
  40.                         = 'uri';
  41.                        
  42.                        
  43.                 const db_id
  44.                         = 'id';
  45.                        
  46.                        
  47.                 const db_oid
  48.                         = 'oid';
  49.                        
  50.                        
  51.                 const db_pid
  52.                         = 'pid';
  53.                        
  54.                        
  55.                        
  56.                 // db-tablenames
  57.                 const dbt_rootmenu
  58.                         = 'rootmenu';
  59.                        
  60.                        
  61.                 const dbt_submenu
  62.                         = 'submenu';
  63.                        
  64.                        
  65.                
  66.                 // subs        
  67.                 const lang
  68.                         = 'models/db/language';
  69.                        
  70.                 const tree
  71.                         = 'models/db/treemenu';
  72.                
  73.                 const db
  74.                         = 'db/bridge';
  75.                
  76.                 const nav
  77.                         = 'menu/Main-Nav-Deeplinked';
  78.                        
  79.                
  80.                 // st
  81.                 private $route_pages
  82.                         = NULL;
  83.                
  84.                
  85.                 private $current_sub_pages
  86.                         = NULL;
  87.                
  88.                 private $alternate_subaction
  89.                         = NULL;
  90.                        
  91.                
  92.                 private $alternate_sectionaction
  93.                         = NULL;
  94.                        
  95.                        
  96.                 private $page_entry
  97.                         = NULL;
  98.                
  99.                
  100.                 public function set_LangIso($iso)
  101.                 {
  102.                         return $this->get_SubController(self::lang)
  103.                                 ->set_Iso($iso);
  104.                 }
  105.                
  106.                 public function get_LangIso()
  107.                 {
  108.                         return $this->get_SubController(self::lang)
  109.                                 ->get_Iso();
  110.                 }
  111.                
  112.                
  113.                 public function get_RoutePages($route)
  114.                 {
  115.                         if(NULL === $this->route_pages)
  116.                                 $this->route_pages =
  117.                                         $this->get_SubController(self::db)
  118.                                                 ->simple_multi_search
  119.                                                 (
  120.                                                         self::dbt_submenu,
  121.                                                         array
  122.                                                         (
  123.                                                                 self::db_route
  124.                                                                         => $route,
  125.                                                                        
  126.                                                                        
  127.                                                                 self::db_lang
  128.                                                                         => $this->get_LangIso()
  129.                                                         ),
  130.                                                         array
  131.                                                         (
  132.                                                                 'limit'
  133.                                                                         => NULL
  134.                                                         )
  135.                                                 );
  136.                        
  137.                         return $this->route_pages;
  138.                 }
  139.                
  140.                
  141.                 public function set_SubMenuItem(ILLI_Container $config)
  142.                 {
  143.                         $this->get_SubMenu()
  144.                                 ->add_RouteLink
  145.                                 (
  146.                                         $config->_ident,
  147.                                         array
  148.                                         (
  149.                                                 ILLI_View_Navigation::active
  150.                                                         => $config->_active,
  151.                                                        
  152.                                                 'a'
  153.                                                         => $config->_title
  154.                                         ),
  155.                                         self::rt,
  156.                                         array
  157.                                         (
  158.                                                 self::rt_table
  159.                                                         => $this->get_RouteParams()->{'_'.self::rt_table},
  160.                                                        
  161.                                                 self::rt_lang
  162.                                                         => $this->get_LangIso(),
  163.                                                
  164.                                                 self::rt_section
  165.                                                         => $config->_routenode,
  166.                                                
  167.                                                 self::rt_sub
  168.                                                         => $config->_uri
  169.                                         )
  170.                                 );
  171.                                        
  172.                         return $this;
  173.                 }
  174.                
  175.                 public function get_SubMenu()
  176.                 {
  177.                         return $this->get_SubController(self::nav)
  178.                                 ->get_instance('sub');
  179.                 }
  180.                
  181.                 public function render_SubMenu()
  182.                 {
  183.                         $SUBMENU = NULL;
  184.                        
  185.                        
  186.                         if(isset($this->get_RouteParams()->{'_'.self::rt_section}))
  187.                                 $SUBMENU = $this->get_SubController(self::tree)
  188.                                                 ->from_route
  189.                                                 (
  190.                                                         $this->get_RoutePages
  191.                                                         (
  192.                                                                 $this->get_RouteParams()->{'_'.self::rt_section}
  193.                                                         )
  194.                                                 );
  195.                        
  196.                         return
  197.                         (
  198.                                 (NULL !== $SUBMENU)
  199.                                         ? $SUBMENU->menu()
  200.                                         : ''
  201.                         );
  202.                 }
  203.                
  204.                 public function get_SubEntry()
  205.                 {
  206.                         if(NULL === $this->current_sub_pages)
  207.                                 $this->current_sub_pages =
  208.                                          $this->get_SubController(self::tree)
  209.                                                 ->get_current();
  210.                        
  211.                         return $this->current_sub_pages;
  212.                        
  213.                 }
  214.                
  215.                 public function get_RootEntry()
  216.                 {
  217.                         if(NULL === $this->current_sub_pages)
  218.                                 $this->current_sub_pages =
  219.                                         $this->get_SubController(self::db)
  220.                                                 ->simple_multi_search
  221.                                                 (
  222.                                                         self::dbt_rootmenu,
  223.                                                         array
  224.                                                         (
  225.                                                                 self::db_rtable
  226.                                                                         => $this->get_RouteParams()
  227.                                                                                 ->{'_'.self::rt_table},
  228.                                                                                
  229.                                                                                
  230.                                                                 self::db_route
  231.                                                                         => $this->get_RouteParams()
  232.                                                                                 ->{'_'.self::rt_section},
  233.                                                                
  234.                                                                 self::db_lang
  235.                                                                         => $this->get_LangIso(),
  236.                                                         ),
  237.                                                         array
  238.                                                         (
  239.                                                                 'limit' => 1
  240.                                                         )
  241.                                                 );  
  242.                        
  243.                        
  244.                         return $this->current_sub_pages;
  245.                 }
  246.                
  247.                 public function get_CurrentEntry()
  248.                 {                              
  249.                         if(isset($this->get_RouteParams()->{'_'.self::rt_sub})
  250.                                 && isset($this->get_RouteParams()->{'_'.self::rt_section}))
  251.                                 {
  252.                                         $subaction =
  253.                                                 ILLI_Constructeur::get_Instance(self::c_FLTRRT_.'App_Action')
  254.                                                         ->filter
  255.                                                         (
  256.                                                                 $this->get_RouteParams()
  257.                                                                         ->{'_'.self::rt_section}
  258.                                                                 .'/'
  259.                                                                 .$this->get_RouteParams()
  260.                                                                         ->{'_'.self::rt_sub}
  261.                                                         );
  262.                                                
  263.                                                        
  264.                                         $this->alternate_subaction =
  265.                                                 $subaction['action'];
  266.                                                
  267.                                                
  268.                                         $this->page_entry =
  269.                                                 $this->get_SubEntry();
  270.                                 }
  271.                         else
  272.                         if(isset($this->get_RouteParams()->{'_'.self::rt_section})
  273.                                 && !isset($this->get_RouteParams()->{'_'.self::rt_sub}))
  274.                                 {
  275.                                         $sectionaction =
  276.                                                 ILLI_Constructeur::get_Instance(self::c_FLTRRT_.'App_Action')
  277.                                                         ->filter
  278.                                                         (
  279.                                                                 $this->get_RouteParams()->{'_'.self::rt_section}
  280.                                                         );
  281.                                                
  282.                                                
  283.                                         $this->alternate_sectionaction =
  284.                                                 $sectionaction['action'];
  285.        
  286.        
  287.                                         $this->page_entry =
  288.                                                 $this->get_RootEntry();                        
  289.                                 }
  290.                        
  291.                         return $this->page_entry;
  292.                 }
  293.                
  294.                 public function get_SectionAction($prfx = 'Default')
  295.                 {
  296.                         if(NULL === $this->alternate_sectionaction)
  297.                                 return NULL;
  298.                                
  299.                                
  300.                         return $prfx.'_'.$this->alternate_sectionaction;
  301.                 }
  302.                
  303.                 public function get_SubAction($prfx = 'Default')
  304.                 {
  305.                         if(NULL === $this->alternate_subaction)
  306.                                 return NULL;
  307.                                
  308.                                
  309.                         return $prfx.'_'.$this->alternate_subaction;
  310.                 }
  311.         }