/** * A list of common countries. * * @return string */ public function commonCountriesList() { $countries = $this->statsPlaces(); if (empty($countries)) { return ''; } $top10 = array(); $i = 1; // Get the country names for each language $country_names = array(); foreach (I18N::activeLocales() as $locale) { I18N::init($locale->languageTag()); $all_countries = $this->getAllCountries(); foreach ($all_countries as $country_code => $country_name) { $country_names[$country_name] = $country_code; } } I18N::init(WT_LOCALE); $all_db_countries = array(); foreach ($countries as $place) { $country = trim($place['country']); if (array_key_exists($country, $country_names)) { if (!isset($all_db_countries[$country_names[$country]][$country])) { $all_db_countries[$country_names[$country]][$country] = (int) $place['tot']; } else { $all_db_countries[$country_names[$country]][$country] += (int) $place['tot']; } } } // get all the user’s countries names $all_countries = $this->getAllCountries(); foreach ($all_db_countries as $country_code => $country) { $top10[] = '<li>'; foreach ($country as $country_name => $tot) { $tmp = new Place($country_name, $this->tree); $place = '<a href="' . $tmp->getURL() . '" class="list_item">' . $all_countries[$country_code] . '</a>'; $top10[] .= $place . ' - ' . I18N::number($tot); } $top10[] .= '</li>'; if ($i++ == 10) { break; } } $top10 = implode('', $top10); return '<ul>' . $top10 . '</ul>'; }
header('Location: ' . WT_BASE_URL . 'admin.php'); return; case 'languages': if (Filter::checkCsrf()) { Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES'))); FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success'); } header('Location: ' . WT_BASE_URL . 'admin.php'); return; } // Lists of options for <select> controls. $SMTP_SSL_OPTIONS = array('none' => I18N::translate('none'), 'ssl' => I18N::translate('ssl'), 'tls' => I18N::translate('tls')); $SMTP_ACTIVE_OPTIONS = array('internal' => I18N::translate('Use PHP mail to send messages'), 'external' => I18N::translate('Use SMTP to send messages')); $WELCOME_TEXT_AUTH_MODE_OPTIONS = array(0 => I18N::translate('No predefined text'), 1 => I18N::translate('Predefined text that states all users can request a user account'), 2 => I18N::translate('Predefined text that states admin will decide on each request for a user account'), 3 => I18N::translate('Predefined text that states only family members can request a user account'), 4 => I18N::translate('Choose user defined welcome text typed below')); $language_tags = array(); foreach (I18N::activeLocales() as $active_locale) { $language_tags[] = $active_locale->languageTag(); } switch (Filter::get('action')) { case 'site': $controller->setPageTitle(I18N::translate('Website preferences')); break; case 'email': $controller->setPageTitle(I18N::translate('Sending email')); break; case 'login': $controller->setPageTitle(I18N::translate('Login and registration')); break; case 'tracking': $controller->setPageTitle(I18N::translate('Tracking and analytics')); break;
private function edit() { global $WT_TREE; $args = array(); if (webtrees\Filter::postBool('save') && webtrees\Filter::checkCsrf()) { $block_id = webtrees\Filter::post('block_id'); if ($block_id) { $args['tree_id'] = webtrees\Filter::post('gedcom_id'); $args['block_order'] = (int) webtrees\Filter::post('block_order'); $args['block_id'] = $block_id; webtrees\Database::prepare("UPDATE `##block` SET gedcom_id=NULLIF(:tree_id, ''), block_order=:block_order WHERE block_id=:block_id")->execute($args); } else { $args['tree_id'] = webtrees\Filter::post('gedcom_id'); $args['module_name'] = $this->getName(); $args['block_order'] = (int) webtrees\Filter::post('block_order'); webtrees\Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, ''), :module_name, :block_order)")->execute($args); $block_id = webtrees\Database::getInstance()->lastInsertId(); } $this->setBlockSetting($block_id, 'pages_title', webtrees\Filter::post('pages_title')); $this->setBlockSetting($block_id, 'pages_content', webtrees\Filter::post('pages_content')); // allow html $this->setBlockSetting($block_id, 'pages_access', webtrees\Filter::post('pages_access')); $languages = array(); foreach (webtrees\I18N::installedLocales() as $locale) { if (webtrees\Filter::postBool('lang_' . $locale->languageTag())) { $languages[] = $locale->languageTag(); } } $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); $this->config(); } else { $block_id = webtrees\Filter::get('block_id'); $controller = new webtrees\Controller\PageController(); $controller->restrictAccess(webtrees\Auth::isEditor($WT_TREE)); if ($block_id) { $controller->setPageTitle(webtrees\I18N::translate('Edit page')); $items_title = $this->getBlockSetting($block_id, 'pages_title'); $items_content = $this->getBlockSetting($block_id, 'pages_content'); $items_access = $this->getBlockSetting($block_id, 'pages_access'); $args['block_id'] = $block_id; $block_order = webtrees\Database::prepare("SELECT block_order FROM `##block` WHERE block_id=:block_id")->execute($args)->fetchOne(); $gedcom_id = webtrees\Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=:block_id")->execute($args)->fetchOne(); } else { $controller->setPageTitle(webtrees\I18N::translate('Add page')); $items_title = ''; $items_content = ''; $items_access = 1; $args['module_name'] = $this->getName(); $block_order = webtrees\Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name=:module_name")->execute($args)->fetchOne(); $gedcom_id = $WT_TREE->getTreeId(); } $controller->pageHeader(); if (webtrees\Module::getModuleByName('ckeditor')) { webtrees\Module\CkeditorModule::enableEditor($controller); } ?> <ol class="breadcrumb small"> <li><a href="admin.php"><?php echo webtrees\I18N::translate('Control panel'); ?> </a></li> <li><a href="admin_modules.php"><?php echo webtrees\I18N::translate('Module administration'); ?> </a></li> <li><a href="module.php?mod=<?php echo $this->getName(); ?> &mod_action=admin_config"><?php echo webtrees\I18N::translate($this->getTitle()); ?> </a></li> <li class="active"><?php echo $controller->getPageTitle(); ?> </li> </ol> <form class="form-horizontal" method="POST" action="#" name="pages" id="pagesForm"> <?php echo webtrees\Filter::getCsrf(); ?> <input type="hidden" name="save" value="1"> <input type="hidden" name="block_id" value="<?php echo $block_id; ?> "> <h3><?php echo webtrees\I18N::translate('General'); ?> </h3> <div class="form-group"> <label class="control-label col-sm-3" for="pages_title"> <?php echo webtrees\I18N::translate('Title'); ?> </label> <div class="col-sm-9"> <input class="form-control" id="pages_title" size="90" name="pages_title" required type="text" value="<?php echo webtrees\Filter::escapeHtml($items_title); ?> " > </div> </div> <div class="form-group"> <label class="control-label col-sm-3" for="pages_content"> <?php echo webtrees\I18N::translate('Content'); ?> </label> <div class="col-sm-9"> <textarea class="form-control html-edit" id="pages_content" rows="10" cols="90" name="pages_content" required type="text"> <?php echo webtrees\Filter::escapeHtml($items_content); ?> </textarea> </div> </div> <h3><?php echo webtrees\I18N::translate('Languages'); ?> </h3> <div class="form-group"> <label class="control-label col-sm-3" for="lang_*"> <?php echo webtrees\I18N::translate('Show this page for which languages?'); ?> </label> <div class="col-sm-9"> <?php $accepted_languages = explode(',', $this->getBlockSetting($block_id, 'languages')); foreach (webtrees\I18N::activeLocales() as $locale) { ?> <div class="checkbox"> <label title="<?php echo $locale->languageTag(); ?> "> <input type="checkbox" name="lang_<?php echo $locale->languageTag(); ?> " <?php echo in_array($locale->languageTag(), $accepted_languages) ? 'checked' : ''; ?> ><?php echo $locale->endonym(); ?> </label> </div> <?php } ?> </div> </div> <h3><?php echo webtrees\I18N::translate('Visibility and Access'); ?> </h3> <div class="form-group"> <label class="control-label col-sm-3" for="block_order"> <?php echo webtrees\I18N::translate('Page position'); ?> </label> <div class="col-sm-9"> <input class="form-control" id="position" name="block_order" size="3" required type="number" value="<?php echo webtrees\Filter::escapeHtml($block_order); ?> " > </div> <span class="help-block col-sm-9 col-sm-offset-3 small text-muted"> <?php echo webtrees\I18N::translate('This field controls the order in which the pages are displayed.<br><br>You do not have to enter the numbers sequentially. If you leave holes in the numbering scheme, you can insert other pages later. For example, if you use the numbers 1, 6, 11, 16, you can later insert pages with the missing sequence numbers. Negative numbers and zero are allowed, and can be used to insert menu items in front of the first one.<br><br>When more than one page has the same position number, only one of these pages will be visible.'); ?> </span> </div> <div class="form-group"> <label class="control-label col-sm-3" for="block_order"> <?php echo webtrees\I18N::translate('Page visibility'); ?> </label> <div class="col-sm-9"> <?php echo webtrees\Functions\FunctionsEdit::selectEditControl('gedcom_id', webtrees\Tree::getIdList(), webtrees\I18N::translate('All'), $gedcom_id, 'class="form-control"'); ?> </div> <span class="help-block col-sm-9 col-sm-offset-3 small text-muted"> <?php echo webtrees\I18N::translate('You can determine whether this page will be visible regardless of family tree, or whether it will be visible only to the current family tree.'); ?> </span> </div> <div class="form-group"> <label class="control-label col-sm-3" for="pages_access"> <?php echo webtrees\I18N::translate('Access level'); ?> </label> <div class="col-sm-9"> <?php echo webtrees\Functions\FunctionsEdit::editFieldAccessLevel('pages_access', $items_access, 'class="form-control"'); ?> </div> </div> <div class="row col-sm-9 col-sm-offset-3"> <button class="btn btn-primary" type="submit"> <i class="fa fa-check"></i> <?php echo webtrees\I18N::translate('save'); ?> </button> <button class="btn" type="button" onclick="window.location='<?php echo $this->getConfigLink(); ?> ';"> <i class="fa fa-close"></i> <?php echo webtrees\I18N::translate('cancel'); ?> </button> </div> </form> <?php } }
/** * A menu to show a list of available languages. * * @return Menu|null */ protected function menuLanguages() { $menu = new Menu(I18N::translate('Language'), '#', 'menu-language'); foreach (I18N::activeLocales() as $locale) { $language_tag = $locale->languageTag(); $class = 'menu-language-' . $language_tag . (WT_LOCALE === $language_tag ? ' active' : ''); $menu->addSubmenu(new Menu($locale->endonym(), '#', $class, array('onclick' => 'return false;', 'data-language' => $language_tag))); } if (count($menu->getSubmenus()) > 1) { return $menu; } else { return null; } }
/** * Print an edit control for a language field. * * @param string $name * @param string $selected * @param string $extra * * @return string */ public static function editFieldLanguage($name, $selected = '', $extra = '') { $languages = array(); foreach (I18N::activeLocales() as $locale) { $languages[$locale->languageTag()] = $locale->endonym(); } return self::selectEditControl($name, $languages, null, $selected, $extra); }