Exemple #1
0
 /** @return array|false */
 private function getNavigation($id)
 {
     if (false === ($navis = GWF_Navigations::getById($id))) {
         return false;
         # TODO
     }
     $nsid = $navis->getID();
     $pb = $navis->isnotPB() ? 'navi_vars' : 'navi_pbvars';
     $cols = 't.*, page_url, page_title, page_lang, page_meta_desc/*, page_views,*/';
     $t = GDO::table('GWF_Navigation');
     # TODO: page_lang, permissions
     $where = "navi_nid={$nsid}";
     $navi = array();
     $navi['category_name'] = $navis->getName();
     $navi['subs'] = array();
     $navi['links'] = false !== ($links = $t->selectAll($cols, $where, 'navi_position', array($pb))) ? $links : array();
     if (false === ($subs = $navis->selectAll('navis_id', 'navis_pid=' . $nsid))) {
         $subs = array();
         # TODO: error
     }
     foreach ($subs as $sub) {
         if (false !== ($sn = $this->getNavigation($sub['navis_id']))) {
             $navi['subs'][] = $sn;
         } else {
             # TODO
         }
     }
     return $navi;
 }
Exemple #2
0
 public function onDelete($nid)
 {
     return GWF_Navigations::deleteNavigation($nid);
 }
Exemple #3
0
 private function templateAdmin()
 {
     $tVars = array('navigations' => GWF_Navigations::getNavigations());
     return $this->module->template($this->_tpl, $tVars);
 }
Exemple #4
0
 /**
  * Get all Navigationentries by it's nid name
  * @param string $name
  * @return GWF_Navigation
  */
 public static function getByName($name)
 {
     $nid = GWF_Navigations::getIdByName($name);
     return self::getNavigation($nid);
 }
Exemple #5
0
 /**
  * Install the PageMenu
  * @param array $pmarray = array of GWF_NaviPage Rows
  * @todo GWF_Exception
  * @todo navi_pbid bug
  * @todo encapsulate
  * 	remove old pagemenu: recursive in GWF_Navigations
  * 	possibility to merge old PageMenu?
  * @return true|string|GWF_Exception # TODO
  */
 public static function installPageMenu2(array $pmarray)
 {
     # Are there PageMenu entries?
     if (0 === count($pmarray)) {
         return true;
     }
     # Create Instances
     $navigation = GDO::table('GWF_Navigation');
     $pagevars = GDO::table('GWF_NaviPage');
     if (false === ($navigations = GWF_Navigations::getByName('PageMenu'))) {
         # There is no PageMenu yet
         $navigations = GDO::table('GWF_Navigations');
     } else {
         # recursive remove old PageMenu
         # TODO: merging possibility?
         if (false === GWF_Navigations::deleteNavigation('PageMenu')) {
             return GWF_HTML::error('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     # The PageMenu row for GWF_Navigations
     $pm = array('navis_name' => 'PageMenu', 'navis_pid' => '0', 'navis_options' => GWF_Navigations::ENABLED | GWF_Navigations::NONPBSITE);
     # Insert the new GWF_Navigations PageMenu row
     if (false === $navigations->insertAssoc($pm)) {
         return GWF_HTML::error('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $pmid = 1;
     # TODO: get the PageMenu ID
     $catid = createPageMenuCategory();
     $count = 0;
     foreach ($pmarray as $modulename => $pbmodule) {
         # The $modulename-Module row for GWF_Navigations
         $pm = array('navis_name' => $modulename, 'navis_pid' => $pmid, 'navis_options' => GWF_Navigations::ENABLED | GWF_Navigations::NONPBSITE);
         # Insert the GWF_Navigations $modulename row
         if (false === $navigations->insertAssoc($pm)) {
             return GWF_HTML::error('ERR_DATABASE', array(__FILE__, __LINE__));
             # continue ?
         }
         $count++;
         # increase count because module have been added
         $modulecount = 0;
         # The modulecount (how many methods the module has)
         $nid = '1';
         # TODO: get $modulename-Navigation ID
         $i = 0;
         # counter variable used for position
         # TODO: only check values here, dont insert
         if (is_array($pbmodule)) {
             foreach ($pbmodule as $methodname => $methodlinks) {
                 foreach ($methodlinks as $num => $pbvars) {
                     if (false === is_array($pbvars) || false === isset($pbvars['page_url']) || false === isset($pbvars['page_title'])) {
                         unset($pbmodule[$methodname][$num]);
                         continue;
                         # required entries does not exists
                     }
                     # page_id is AUTO INCREMENT
                     unset($pbvars['page_id']);
                     # entries that need to exist
                     $overwritable = array('page_cat' => $catid, 'page_views' => '0', 'page_meta_desc' => '', 'page_options' => GWF_Page::ENABLED);
                     $pbvars = array_merge($overwritable, $pbvars);
                     # Insert the GWF_NaviPage
                     if (false === $pagevars->insertAssoc($pbvars)) {
                         return GWF_HTML::error('ERR_DATABASE', array(__FILE__, __LINE__));
                     }
                     # Get the ID of the inserted GWF_NaviPage # TODO: a more comfortable way?
                     if (false === ($pb = $pagevars->selectFirst('page_id', "page_url='" . $pbvars['page_url'] . "'"))) {
                         return GWF_HTML::error('ERR_DATABASE', array(__FILE__, __LINE__));
                     }
                     $pbid = $pb['page_id'];
                     $navi = array('navi_nid' => $nid, 'navi_pbid' => $pbid, 'navi_position' => ++$i, 'navi_options' => GWF_Navigation::ENABLED);
                     if (false === $navigation->insertAssoc($navi)) {
                         return GWF_HTML::error('ERR_DATABASE', array(__FILE__, __LINE__));
                     }
                     # increase the modulecount, a methodlink has been added
                     $modulecount++;
                 }
             }
         }
         if ($modulecount === 0) {
             # TODO: remove the $modulename-Navigation
         } else {
             $navigations->set("navis_count = '{$modulecount}'", "navis_name='{$modulename}'");
         }
     }
     $navigations->set("navis_count = '{$count}'", 'navis_name=\'PageMenu\'');
     return true;
 }