Beispiel #1
0
 public static function getFavoritesMenu()
 {
     global $REQUIRE_AUTHENTICATION, $controller, $SEARCH_SPIDER;
     $show_user_favs = WT_USER_ID && array_key_exists('user_favorites', WT_Module::getActiveModules());
     $show_gedc_favs = !$REQUIRE_AUTHENTICATION && array_key_exists('gedcom_favorites', WT_Module::getActiveModules());
     if ($show_user_favs && !$SEARCH_SPIDER) {
         if ($show_gedc_favs && !$SEARCH_SPIDER) {
             $favorites = array_merge(gedcom_favorites_WT_Module::getFavorites(WT_GED_ID), user_favorites_WT_Module::getFavorites(WT_USER_ID));
         } else {
             $favorites = user_favorites_WT_Module::getFavorites(WT_USER_ID);
         }
     } else {
         if ($show_gedc_favs && !$SEARCH_SPIDER) {
             $favorites = gedcom_favorites_WT_Module::getFavorites(WT_GED_ID);
         } else {
             return null;
         }
     }
     // Sort $favorites alphabetically?
     $menu = new WT_Menu(WT_I18N::translate('Favorites'), '#', 'menu-favorites');
     foreach ($favorites as $favorite) {
         switch ($favorite['type']) {
             case 'URL':
                 $submenu = new WT_Menu($favorite['title'], $favorite['url']);
                 $menu->addSubMenu($submenu);
                 break;
             case 'INDI':
             case 'FAM':
             case 'SOUR':
             case 'OBJE':
             case 'NOTE':
                 $obj = WT_GedcomRecord::getInstance($favorite['gid']);
                 if ($obj && $obj->canShowName()) {
                     $submenu = new WT_Menu($obj->getFullName(), $obj->getHtmlUrl());
                     $menu->addSubMenu($submenu);
                 }
                 break;
         }
     }
     if ($show_user_favs) {
         if (isset($controller->record) && $controller->record instanceof WT_GedcomRecord) {
             $submenu = new WT_Menu(WT_I18N::translate('Add to favorites'), '#');
             $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'" . $controller->record->getXref() . "'},function(){location.reload();})");
             $menu->addSubMenu($submenu);
         }
     }
     return $menu;
 }
Beispiel #2
0
 static function totalGedcomFavorites()
 {
     return count(gedcom_favorites_WT_Module::getFavorites(WT_GED_ID));
 }