Beispiel #1
0
 /**
  * Update the gp_index, gp_titles and menus so that special pages can be renamed
  *
  */
 function Upgrade_234()
 {
     global $gp_index, $gp_titles, $gp_menu, $config, $dataDir;
     $special_indexes = array();
     $new_index = array();
     $new_titles = array();
     foreach ($gp_index as $title => $index) {
         $info = $gp_titles[$index];
         $type = \gp\tool::SpecialOrAdmin($title);
         if ($type === 'special') {
             $special_indexes[$index] = strtolower($title);
             $index = strtolower($title);
             $info['type'] = 'special';
             //some older versions didn't maintain this value well
         }
         $new_index[$title] = $index;
         $new_titles[$index] = $info;
     }
     $gp_titles = $new_titles;
     $gp_index = $new_index;
     //update gp_menu
     $gp_menu = $this->FixMenu($gp_menu, $special_indexes);
     //save pages
     if (!\gp\admin\Tools::SavePagesPHP()) {
         return;
     }
     $config['gpversion'] = '2.3.4';
     \gp\admin\Tools::SaveConfig();
     //update alt menus
     if (isset($config['menus']) && is_array($config['menus'])) {
         foreach ($config['menus'] as $key => $value) {
             $menu_file = $dataDir . '/data/_menus/' . $key . '.php';
             if (\gp\tool\Files::Exists($menu_file)) {
                 $menu = \gp\tool\Output::GetMenuArray($key);
                 $menu = $this->FixMenu($menu, $special_indexes);
                 \gp\tool\Files::SaveData($menu_file, 'menu', $menu);
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Get an array of titles that is not represented in any of the menus
  *
  */
 public function GetNoMenus()
 {
     global $gp_index;
     //first get all titles in a menu
     $menus = $this->GetAvailMenus('menu');
     $all_keys = array();
     foreach ($menus as $menu_id => $label) {
         $menu_array = \gp\tool\Output::GetMenuArray($menu_id);
         $keys = array_keys($menu_array);
         $all_keys = array_merge($all_keys, $keys);
     }
     $all_keys = array_unique($all_keys);
     //then check $gp_index agains $all_keys
     $avail = array();
     foreach ($gp_index as $title => $index) {
         if (in_array($index, $all_keys)) {
             continue;
         }
         $avail[] = $title;
     }
     return $avail;
 }