private function onDelete($nid) { return GWF_Navigations::deleteNavigation($nid); }
public function onDelete($nid) { return GWF_Navigations::deleteNavigation($nid); }
/** * 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; }