예제 #1
0
 /**
  * Return HTML code for the place formatted as requested.
  * The format string should used %n with n to describe the level of division to be printed (in the order of the GEDCOM place).
  * For instance "%1 (%2)" will display "Subdivision (Town)".
  *
  * @param string $format Format for the place
  * @param bool $anchor Option to print a link to placelist
  * @return string HTML code for formatted place
  */
 public function htmlFormattedName($format, $anchor = false)
 {
     $html = '';
     $levels = array_map('trim', explode(',', $this->place->getGedcomName()));
     $nbLevels = count($levels);
     $displayPlace = $format;
     preg_match_all('/%[^%]/', $displayPlace, $matches);
     foreach ($matches[0] as $match2) {
         $index = str_replace('%', '', $match2);
         if (is_numeric($index) && $index > 0 && $index <= $nbLevels) {
             $displayPlace = str_replace($match2, $levels[$index - 1], $displayPlace);
         } else {
             $displayPlace = str_replace($match2, '', $displayPlace);
         }
     }
     if ($anchor && !Auth::isSearchEngine()) {
         $html .= '<a href="' . $this->place->getURL() . '">' . $displayPlace . '</a>';
     } else {
         $html .= $displayPlace;
     }
     return $html;
 }
예제 #2
0
 /**
  * Handle AJAX requests - to generate the tab content
  */
 public function ajaxRequest()
 {
     // Search engines should not make AJAX requests
     if (Auth::isSearchEngine()) {
         http_response_code(403);
         exit;
     }
     // Initialise tabs
     $tab = Filter::get('module');
     // A request for a non-existant tab?
     if (array_key_exists($tab, $this->tabs)) {
         $mod = $this->tabs[$tab];
     } else {
         http_response_code(404);
         exit;
     }
     header("Content-Type: text/html; charset=UTF-8");
     // AJAX calls do not have the meta tag headers and need this set
     header("X-Robots-Tag: noindex,follow");
     // AJAX pages should not show up in search results, any links can be followed though
     echo $mod->getTabContent();
     if (WT_DEBUG_SQL) {
         echo Database::getQueryLog();
     }
 }
예제 #3
0
 /** {@inheritdoc} */
 public function canLoadAjax()
 {
     return !Auth::isSearchEngine();
     // Search engines cannot use AJAX
 }
예제 #4
0
 public function getMenu()
 {
     global $controller, $WT_TREE;
     $menu_titles = $this->getMenuList();
     $lang = '';
     $min_block = webtrees\Database::prepare("SELECT MIN(block_order) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne();
     foreach ($menu_titles as $items) {
         $languages = $this->getBlockSetting($items->block_id, 'languages');
         if (in_array(WT_LOCALE, explode(',', $languages))) {
             $lang = WT_LOCALE;
         } else {
             $lang = '';
         }
     }
     $default_block = webtrees\Database::prepare("SELECT ##block.block_id FROM `##block`, `##block_setting` WHERE block_order=? AND module_name=? AND ##block.block_id = ##block_setting.block_id AND ##block_setting.setting_value LIKE ?")->execute(array($min_block, $this->getName(), '%' . $lang . '%'))->fetchOne();
     $main_menu_address = webtrees\Database::prepare("SELECT setting_value FROM `##block_setting` WHERE block_id=? AND setting_name=?")->execute(array($default_block, 'menu_address'))->fetchOne();
     if (count($menu_titles) > 1) {
         $main_menu_title = $this->getMenuTitle();
     } else {
         $main_menu_title = webtrees\Database::prepare("SELECT setting_value FROM `##block_setting` WHERE block_id=? AND setting_name=?")->execute(array($default_block, 'menu_title'))->fetchOne();
     }
     if (webtrees\Auth::isSearchEngine()) {
         return null;
     }
     if (file_exists(WT_MODULES_DIR . $this->getName() . '/themes/' . webtrees\Theme::theme()->themeId() . '/')) {
         echo '<link rel="stylesheet" href="' . WT_MODULES_DIR . $this->getName() . '/themes/' . webtrees\Theme::theme()->themeId() . '/style.css" type="text/css">';
     } else {
         echo '<link rel="stylesheet" href="' . WT_MODULES_DIR . $this->getName() . '/themes/webtrees/style.css" type="text/css">';
     }
     //-- main menu item
     $menu = new webtrees\Menu($main_menu_title, $main_menu_address, $this->getName());
     $menu->addClass('menuitem', 'menuitem_hover', '');
     foreach ($menu_titles as $items) {
         if (count($menu_titles) > 1) {
             $languages = $this->getBlockSetting($items->block_id, 'languages');
             if ((!$languages || in_array(WT_LOCALE, explode(',', $languages))) && $items->menu_access >= webtrees\Auth::accessLevel($WT_TREE)) {
                 $submenu = new webtrees\Menu(webtrees\I18N::translate($items->menu_title), $items->menu_address, $this->getName() . '-' . str_replace(' ', '', $items->menu_title));
                 $menu->addSubmenu($submenu);
             }
         }
     }
     if (webtrees\Auth::isAdmin()) {
         $submenu = new webtrees\Menu(webtrees\I18N::translate('Edit menus'), $this->getConfigLink(), $this->getName() . '-edit');
         $menu->addSubmenu($submenu);
     }
     return $menu;
 }
 /** {@inheritdoc} */
 public function hasSidebarContent()
 {
     return !Auth::isSearchEngine();
 }
예제 #6
0
 /** {@inheritdoc} */
 public function hasTabContent()
 {
     return !Auth::isSearchEngine();
 }
예제 #7
0
 /**
  * Get the list of initial letters
  * 
  * @return string[]
  */
 private function getInitialLettersList()
 {
     $list = array();
     /** @var \Fisharebest\Webtrees\Tree $tree */
     $tree = $this->data->get('tree');
     $script_base_url = WT_SCRIPT_NAME . '?mod=' . \MyArtJaub\Webtrees\Constants::MODULE_MAJ_PATROLIN_NAME . '&mod_action=Lineage';
     foreach (QueryName::surnameAlpha($tree, false, false) as $letter => $count) {
         switch ($letter) {
             case '@':
                 $html = I18N::translateContext('Unknown surname', '…');
                 break;
             case ',':
                 $html = I18N::translate('None');
                 break;
             default:
                 $html = Filter::escapeHtml($letter);
                 break;
         }
         if ($count) {
             if ($letter == $this->data->get('alpha')) {
                 $list[] = '<a href="' . $script_base_url . '&alpha=' . rawurlencode($letter) . '&amp;ged=' . $tree->getNameUrl() . '" class="warning" title="' . I18N::number($count) . '">' . $html . '</a>';
             } else {
                 $list[] = '<a href="' . $script_base_url . '&alpha=' . rawurlencode($letter) . '&amp;ged=' . $tree->getNameUrl() . '" title="' . I18N::number($count) . '">' . $html . '</a>';
             }
         } else {
             $list[] = $html;
         }
     }
     // Search spiders don't get the "show all" option as the other links give them everything.
     if (!Auth::isSearchEngine()) {
         if ($this->data->get('show_all') === 'yes') {
             $list[] = '<span class="warning">' . I18N::translate('All') . '</span>';
         } else {
             $list[] = '<a href="' . $script_base_url . '&show_all=yes' . '&amp;ged=' . $tree->getNameUrl() . '">' . I18N::translate('All') . '</a>';
         }
     }
     return $list;
 }
예제 #8
0
                 default:
                     $html = Filter::escapeHtml($givn_initial);
                     break;
             }
             if ($count) {
                 if ($show === 'indi' && $givn_initial === $falpha && $show_all_firstnames === 'no') {
                     $list[] = '<a class="warning" href="' . $url . '&amp;falpha=' . rawurlencode($givn_initial) . '" title="' . I18N::number($count) . '">' . $html . '</a>';
                 } else {
                     $list[] = '<a href="' . $url . '&amp;falpha=' . rawurlencode($givn_initial) . '" title="' . I18N::number($count) . '">' . $html . '</a>';
                 }
             } else {
                 $list[] = $html;
             }
         }
         // Search spiders don't get the "show all" option as the other links give them everything.
         if (!Auth::isSearchEngine()) {
             if ($show_all_firstnames === 'yes') {
                 $list[] = '<span class="warning">' . I18N::translate('All') . '</span>';
             } else {
                 $list[] = '<a href="' . $url . '&amp;show_all_firstnames=yes">' . I18N::translate('All') . '</a>';
             }
         }
         if ($show_all === 'no') {
             echo '<h2 class="center">', I18N::translate('Individuals with surname %s', $legend), '</h2>';
         }
         echo '<p class="center alpha_index">', implode(' | ', $list), '</p>';
     }
 }
 if ($show === 'indi') {
     echo FunctionsPrintLists::individualTable(QueryName::individuals($WT_TREE, $surname, $alpha, $falpha, $show_marnm === 'yes', false));
 }
예제 #9
0
파일: index.php 프로젝트: AlexSnet/webtrees
                echo $active_blocks[$module_name]->getBlock($block_id);
            } else {
                // Load the block asynchronously
                echo '<div id="block_', $block_id, '"><div class="loading-image">&nbsp;</div></div>';
                $controller->addInlineJavascript('jQuery("#block_' . $block_id . '").load("index.php?ctype=' . $ctype . '&action=ajax&block_id=' . $block_id . '");');
            }
        }
    }
    echo '</div>';
}
if ($blocks['side']) {
    if ($blocks['main']) {
        echo '<div id="index_small_blocks">';
    } else {
        echo '<div id="index_full_blocks">';
    }
    foreach ($blocks['side'] as $block_id => $module_name) {
        if (array_key_exists($module_name, $active_blocks)) {
            if (Auth::isSearchEngine() || !$active_blocks[$module_name]->loadAjax()) {
                // Load the block directly
                echo $active_blocks[$module_name]->getBlock($block_id);
            } else {
                // Load the block asynchronously
                echo '<div id="block_', $block_id, '"><div class="loading-image">&nbsp;</div></div>';
                $controller->addInlineJavascript('jQuery("#block_' . $block_id . '").load("index.php?ctype=' . $ctype . '&action=ajax&block_id=' . $block_id . '");');
            }
        }
    }
    echo '</div>';
}
echo '</div>';
예제 #10
0
 public function getMenu()
 {
     global $controller, $WT_TREE;
     $args = array();
     $args['block_order'] = 0;
     $args['module_name'] = $this->getName();
     $block_id = webtrees\Filter::get('block_id');
     $default_block = webtrees\Database::prepare("SELECT block_id FROM `##block` WHERE block_order=:block_order AND module_name=:module_name")->execute($args)->fetchOne();
     if (webtrees\Auth::isSearchEngine()) {
         return null;
     }
     if (file_exists(WT_MODULES_DIR . $this->getName() . '/themes/' . webtrees\Theme::theme()->themeId() . '/')) {
         echo '<link rel="stylesheet" href="' . WT_MODULES_DIR . $this->getName() . '/themes/' . webtrees\Theme::theme()->themeId() . '/style.css" type="text/css">';
     } else {
         echo '<link rel="stylesheet" href="' . WT_MODULES_DIR . $this->getName() . '/themes/webtrees/style.css" type="text/css">';
     }
     //-- main PAGES menu item
     $menu = new webtrees\Menu($this->getMenuTitle(), 'module.php?mod=' . $this->getName() . '&amp;mod_action=show&amp;pages_id=' . $default_block, $this->getName());
     $menu->addClass('menuitem', 'menuitem_hover', '');
     foreach ($this->getMenupagesList() as $items) {
         $languages = $this->getBlockSetting($items->block_id, 'languages');
         if ((!$languages || in_array(WT_LOCALE, explode(',', $languages))) && $items->pages_access >= webtrees\Auth::accessLevel($WT_TREE)) {
             $path = 'module.php?mod=' . $this->getName() . '&amp;mod_action=show&amp;pages_id=' . $items->block_id;
             $submenu = new webtrees\Menu(webtrees\I18N::translate($items->pages_title), $path, $this->getName() . '-' . $items->block_id);
             $menu->addSubmenu($submenu);
         }
     }
     if (webtrees\Auth::isAdmin()) {
         $submenu = new webtrees\Menu(webtrees\I18N::translate('Edit pages'), $this->getConfigLink(), $this->getName() . '-edit');
         $menu->addSubmenu($submenu);
     }
     return $menu;
 }
예제 #11
0
    if (!array_key_exists($theme_id, Theme::themeNames()) && $WT_TREE) {
        $theme_id = $WT_TREE->getPreference('THEME_DIR');
    }
    // Default for site
    if (!array_key_exists($theme_id, Theme::themeNames())) {
        $theme_id = Site::getPreference('THEME_DIR');
    }
    // Default
    if (!array_key_exists($theme_id, Theme::themeNames())) {
        $theme_id = 'webtrees';
    }
    foreach (Theme::installedThemes() as $theme) {
        if ($theme->themeId() === $theme_id) {
            Theme::theme($theme)->init($WT_TREE);
            // Remember this setting
            if (Site::getPreference('ALLOW_USER_THEMES')) {
                Session::put('theme_id', $theme_id);
            }
            break;
        }
    }
}
// Search engines are only allowed to see certain pages.
if (Auth::isSearchEngine() && !in_array(WT_SCRIPT_NAME, array('index.php', 'indilist.php', 'module.php', 'mediafirewall.php', 'individual.php', 'family.php', 'mediaviewer.php', 'note.php', 'repo.php', 'source.php'))) {
    http_response_code(403);
    $controller = new PageController();
    $controller->setPageTitle(I18N::translate('Search engine'));
    $controller->pageHeader();
    echo '<p class="ui-state-error">', I18N::translate('You do not have permission to view this page.'), '</p>';
    exit;
}
예제 #12
0
파일: module.php 프로젝트: bxbroze/webtrees
 /** {@inheritdoc} */
 public function getMenu()
 {
     global $controller;
     if (!Auth::isSearchEngine()) {
         Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
         static $menu;
         // Function has already run
         if ($menu !== null && count($menu->getSubmenus()) > 0) {
             return $menu;
         }
         $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
         if (!empty($FTV_SETTINGS)) {
             foreach ($FTV_SETTINGS as $FTV_ITEM) {
                 if ($FTV_ITEM['TREE'] == $this->tree_id && !empty($FTV_ITEM['PID']) && $FTV_ITEM['ACCESS_LEVEL'] >= Auth::accessLevel($this->tree)) {
                     $FTV_GED_SETTINGS[] = $FTV_ITEM;
                 }
             }
             if (!empty($FTV_GED_SETTINGS)) {
                 if (Theme::theme()->themeId() !== '_administration') {
                     // load the module stylesheets
                     echo $this->module()->getStylesheet();
                     // add javascript files and scripts
                     $this->module()->includeJs($controller, 'menu');
                     if (WT_SCRIPT_NAME === 'individual.php') {
                         $this->module()->includeJs($controller, 'tab');
                     }
                 }
                 $tree_name = Filter::escapeUrl($this->tree->getName());
                 $menu = new Menu(I18N::translate('Family tree overview'), 'module.php?mod=' . $this->getName() . '&amp;mod_action=page&amp;rootid=' . $FTV_GED_SETTINGS[0]['PID'] . '&amp;ged=' . $tree_name, 'menu-fancy_treeview');
                 foreach ($FTV_GED_SETTINGS as $FTV_ITEM) {
                     $record = Individual::getInstance($FTV_ITEM['PID'], $this->tree);
                     if ($record && $record->canShowName()) {
                         if ($this->module()->options('use_fullname') == true) {
                             $submenu = new Menu(I18N::translate('Descendants of %s', $record->getFullName()), 'module.php?mod=' . $this->getName() . '&amp;mod_action=page&amp;rootid=' . $FTV_ITEM['PID'] . '&amp;ged=' . $tree_name, 'menu-fancy_treeview-' . $FTV_ITEM['PID']);
                         } else {
                             $submenu = new Menu(I18N::translate('Descendants of the %s family', $FTV_ITEM['SURNAME']), 'module.php?mod=' . $this->getName() . '&amp;mod_action=page&amp;rootid=' . $FTV_ITEM['PID'] . '&amp;ged=' . $tree_name, 'menu-fancy_treeview-' . $FTV_ITEM['PID']);
                         }
                         $menu->addSubmenu($submenu);
                     }
                 }
                 if (count($menu->getSubmenus()) > 0) {
                     return $menu;
                 }
             }
         }
     }
 }
예제 #13
0
파일: theme.php 프로젝트: bxbroze/justlight
 public function menuLogin()
 {
     if (Auth::check() || Auth::isSearchEngine()) {
         return null;
     } else {
         return '<div class="menu-login btn-group">' . '<a href="' . WT_LOGIN_URL . '?url=' . rawurlencode(Functions::getQueryUrl()) . '" class="btn btn-default">' . I18N::translate('Sign in') . '</a></div>';
     }
 }