本文整理汇总了PHP中Fisharebest\Webtrees\Tree::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::getAll方法的具体用法?PHP Tree::getAll怎么用?PHP Tree::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Tree
的用法示例。
在下文中一共展示了Tree::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/** {@inheritDoc} */
public function upgrade()
{
// add key 'LINK' to FTV_SETTINGS
// change options to multidimensional array with array key = tree id.
$module_settings = 'FTV_SETTINGS';
$ftv_settings = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_settings))->fetchOne();
$settings = unserialize($ftv_settings);
if (!empty($settings)) {
foreach ($settings as $setting) {
if (!array_key_exists('LINK', $setting)) {
$setting['LINK'] = I18N::translate('Descendants of the %s family', $setting['SURNAME']);
$new_settings[] = $setting;
}
}
if (isset($new_settings)) {
Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_settings), $module_settings));
}
unset($new_settings);
}
$module_options = 'FTV_OPTIONS';
$ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
$options = unserialize($ftv_options);
if (!empty($options)) {
$show_places = array_key_exists('SHOW_PLACES', $options) ? $options['SHOW_PLACES'] : '1';
$country = array_key_exists('COUNTRY', $options) ? $options['COUNTRY'] : '';
$show_occu = array_key_exists('SHOW_OCCU', $options) ? $options['SHOW_OCCU'] : '1';
foreach (Tree::getAll() as $tree) {
$new_options[$tree->getTreeId()] = array('SHOW_PLACES' => $show_places, 'COUNTRY' => $country, 'SHOW_OCCU' => $show_occu);
}
if (isset($new_options)) {
Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
}
unset($new_options);
}
}
示例2: menuHomePage
/**
* A menu for the home (family tree) pages.
*
* @return Menu
*/
protected function menuHomePage()
{
if (count(Tree::getAll()) === 1 || Site::getPreference('ALLOW_CHANGE_GEDCOM') === '0') {
return new Menu(I18N::translate('Family tree'), 'index.php?ctype=gedcom&' . $this->tree_url, 'menu-tree');
} else {
$submenus = array();
foreach (Tree::getAll() as $tree) {
if ($tree == $this->tree) {
$active = 'active ';
} else {
$active = '';
}
$submenus[] = new Menu($tree->getTitleHtml(), 'index.php?ctype=gedcom&ged=' . $tree->getNameUrl(), $active . 'menu-tree-' . $tree->getTreeId());
}
return new Menu(I18N::translate('Family trees'), '#', 'menu-tree', array(), $submenus);
}
}
示例3: pageBody
private function pageBody(PageController $controller)
{
$FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
?>
<!-- ADMIN PAGE CONTENT -->
<ol class="breadcrumb small">
<li><a href="admin.php"><?php
echo I18N::translate('Control panel');
?>
</a></li>
<li><a href="admin_modules.php"><?php
echo I18N::translate('Module administration');
?>
</a></li>
<li class="active"><?php
echo $controller->getPageTitle();
?>
</li>
</ol>
<h2><?php
echo $controller->getPageTitle();
?>
</h2>
<!-- *** FORM 1 *** -->
<form class="form-horizontal" method="post" name="form1">
<?php
echo Filter::getCsrf();
?>
<!-- SELECT TREE -->
<div class="form-group">
<label class="control-label col-sm-2" for="tree">
<?php
echo I18N::translate('Family tree');
?>
</label>
<div class="col-sm-4">
<select id="tree" name="NEW_FIB_TREE" class="form-control">
<?php
foreach (Tree::getAll() as $tree) {
?>
<?php
if ($tree->getTreeId() == $this->tree_id) {
?>
<option value="<?php
echo $tree->getTreeId();
?>
" data-ged="<?php
echo $tree->getNameHtml();
?>
" selected="selected">
<?php
echo $tree->getTitleHtml();
?>
</option>
<?php
} else {
?>
<option value="<?php
echo $tree->getTreeId();
?>
" data-ged="<?php
echo $tree->getNameHtml();
?>
">
<?php
echo $tree->getTitleHtml();
?>
</option>
<?php
}
?>
<?php
}
?>
</select>
</div>
</div>
</form>
<!-- PANEL GROUP ACCORDION -->
<div class="panel-group" id="accordion">
<!-- PANEL 1 -->
<div class="panel panel-default" id="panel1">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-target="#collapseOne" href="#">
<?php
echo I18N::translate('Pages');
?>
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
<?php
if (empty($FTV_SETTINGS) || !empty($FTV_SETTINGS) && !$this->searchArray($FTV_SETTINGS, 'TREE', $this->tree_id)) {
?>
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="' . I18N::translate('close') . '">
//.........这里部分代码省略.........
示例4: getBlock
/**
* Generate the HTML content of this block.
*
* @param int $block_id
* @param bool $template
* @param string[] $cfg
*
* @return string
*/
public function getBlock($block_id, $template = true, $cfg = array())
{
global $ctype, $WT_TREE;
$sendmail = $this->getBlockSetting($block_id, 'sendmail', '1');
$days = $this->getBlockSetting($block_id, 'days', '1');
$block = $this->getBlockSetting($block_id, 'block', '1');
foreach (array('days', 'sendmail', 'block') as $name) {
if (array_key_exists($name, $cfg)) {
${$name} = $cfg[$name];
}
}
$changes = Database::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne();
if ($changes === '1' && $sendmail === '1') {
// There are pending changes - tell moderators/managers/administrators about them.
if (WT_TIMESTAMP - Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) {
// Which users have pending changes?
foreach (User::all() as $user) {
if ($user->getPreference('contactmethod') !== 'none') {
foreach (Tree::getAll() as $tree) {
if ($tree->hasPendingEdit() && Auth::isManager($tree, $user)) {
I18N::init($user->getPreference('language'));
Mail::systemMessage($tree, $user, I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>');
I18N::init(WT_LOCALE);
}
}
}
}
Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP);
}
}
if (Auth::isEditor($WT_TREE) && $WT_TREE->hasPendingEdit()) {
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
if ($ctype === 'user' || Auth::isManager($WT_TREE)) {
$title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>';
} else {
$title = '';
}
$title .= $this->getTitle();
$content = '';
if (Auth::isModerator($WT_TREE)) {
$content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . I18N::translate('There are pending changes for you to moderate.') . "</a><br>";
}
if ($sendmail === '1') {
$content .= I18N::translate('Last email reminder was sent ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>";
$content .= I18N::translate('Next email reminder will be sent after ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>";
}
$content .= '<ul>';
$changes = Database::prepare("SELECT xref" . " FROM `##change`" . " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref")->execute(array($WT_TREE->getTreeId()))->fetchAll();
foreach ($changes as $change) {
$record = GedcomRecord::getInstance($change->xref, $WT_TREE);
if ($record->canShow()) {
$content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>';
}
}
$content .= '</ul>';
if ($template) {
if ($block) {
$class .= ' small_inner_block';
}
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
}
示例5: configureBlock
/**
* An HTML form to edit block settings
*
* @param int $block_id
*/
public function configureBlock($block_id)
{
global $WT_TREE;
if (Filter::postBool('save') && Filter::checkCsrf()) {
$languages = Filter::postArray('lang');
$this->setBlockSetting($block_id, 'gedcom', Filter::post('gedcom'));
$this->setBlockSetting($block_id, 'title', Filter::post('title'));
$this->setBlockSetting($block_id, 'html', Filter::post('html'));
$this->setBlockSetting($block_id, 'show_timestamp', Filter::postBool('show_timestamp'));
$this->setBlockSetting($block_id, 'timestamp', Filter::post('timestamp'));
$this->setBlockSetting($block_id, 'languages', implode(',', $languages));
}
$templates = array(I18N::translate('Keyword examples') => '#getAllTagsTable#', I18N::translate('Narrative description') => I18N::translate('This family tree was last updated on #gedcomUpdated#. There are #totalSurnames# surnames in this family tree. The earliest recorded event is the #firstEventType# of #firstEventName# in #firstEventYear#. The most recent event is the #lastEventType# of #lastEventName# in #lastEventYear#.<br><br>If you have any comments or feedback please contact #contactWebmaster#.'), I18N::translate('Statistics') => '<div class="gedcom_stats">
<span style="font-weight: bold;"><a href="index.php?command=gedcom">#gedcomTitle#</a></span><br>
' . I18N::translate('This family tree was last updated on %s.', '#gedcomUpdated#') . '
<table id="keywords">
<tr>
<td valign="top" class="width20">
<table cellspacing="1" cellpadding="0">
<tr>
<td class="facts_label">' . I18N::translate('Individuals') . '</td>
<td class="facts_value" align="right"><a href="indilist.php?surname_sublist=no">#totalIndividuals#</a></td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Males') . '</td>
<td class="facts_value" align="right">#totalSexMales#<br>#totalSexMalesPercentage#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Females') . '</td>
<td class="facts_value" align="right">#totalSexFemales#<br>#totalSexFemalesPercentage#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Total surnames') . '</td>
<td class="facts_value" align="right"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">#totalSurnames#</a></td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Families') . '</td>
<td class="facts_value" align="right"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalFamilies#</a></td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Sources') . '</td>
<td class="facts_value" align="right"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalSources#</a></td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Media objects') . '</td>
<td class="facts_value" align="right"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalMedia#</a></td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Repositories') . '</td>
<td class="facts_value" align="right"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalRepositories#</a></td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Total events') . '</td>
<td class="facts_value" align="right">#totalEvents#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Total users') . '</td>
<td class="facts_value" align="right">#totalUsers#</td>
</tr>
</table>
</td>
<td><br></td>
<td valign="top">
<table cellspacing="1" cellpadding="0" border="0">
<tr>
<td class="facts_label">' . I18N::translate('Earliest birth year') . '</td>
<td class="facts_value" align="right">#firstBirthYear#</td>
<td class="facts_value">#firstBirth#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Latest birth year') . '</td>
<td class="facts_value" align="right">#lastBirthYear#</td>
<td class="facts_value">#lastBirth#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Earliest death year') . '</td>
<td class="facts_value" align="right">#firstDeathYear#</td>
<td class="facts_value">#firstDeath#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Latest death year') . '</td>
<td class="facts_value" align="right">#lastDeathYear#</td>
<td class="facts_value">#lastDeath#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Individual who lived the longest') . '</td>
<td class="facts_value" align="right">#longestLifeAge#</td>
<td class="facts_value">#longestLife#</td>
</tr>
<tr>
<td class="facts_label">' . I18N::translate('Average age at death') . '</td>
<td class="facts_value" align="right">#averageLifespan#</td>
<td class="facts_value"></td>
</tr>
<tr>
//.........这里部分代码省略.........
示例6: saveConfig
/**
* {@inheritDoc}
* @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface::saveConfig()
*/
public function saveConfig()
{
try {
foreach (Tree::getAll() as $tree) {
if (Auth::isManager($tree)) {
$tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), 0, 1);
$tree->setPreference('MAJ_AT_' . $this->getName() . '_ENABLED', $tree_enabled);
}
}
return true;
} catch (\Exception $ex) {
Log::addErrorLog(sprintf('Error while updating the Admin Task "%s". Exception: %s', $this->getName(), $ex->getMessage()));
return false;
}
}
示例7: saveConfig
/**
* Save updated configuration settings.
*/
private function saveConfig()
{
if (Auth::isAdmin()) {
foreach (Tree::getAll() as $tree) {
$tree->setPreference('RELATIONSHIP_RECURSION', Filter::post('relationship-recursion-' . $tree->getTreeId()));
$tree->setPreference('RELATIONSHIP_ANCESTORS', Filter::post('relationship-ancestors-' . $tree->getTreeId()));
}
FlashMessages::addMessage(I18N::translate('The preferences for the chart “%s” have been updated.', $this->getTitle()), 'success');
}
header('Location: ' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=admin');
}
示例8: grandson
<?php
echo I18N::translate('Where a user is associated to an individual record in a family tree and has a role of member, editor, or moderator, you can prevent them from accessing the details of distant, living relations. You specify the number of relationship steps that the user is allowed to see.');
?>
<?php
echo I18N::translate('For example, if you specify a path length of 2, the individual will be able to see their grandson (child, child), their aunt (parent, sibling), their step-daughter (spouse, child), but not their first cousin (parent, sibling, child).');
?>
<?php
echo I18N::translate('Note: longer path lengths require a lot of calculation, which can make your website run slowly for these users.');
?>
</p>
</td>
</tr>
</thead>
<tbody>
<?php
foreach (Tree::getAll() as $tree) {
?>
<tr>
<td>
<?php
echo $tree->getTitleHtml();
?>
</td>
<td>
<select name="canedit<?php
echo $tree->getTreeId();
?>
">
<?php
foreach ($ALL_EDIT_OPTIONS as $EDIT_OPTION => $desc) {
?>
示例9: admin
/**
* Edit the configuration
*/
private function admin()
{
$controller = new PageController();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader();
// Save the updated preferences
if (Filter::post('action') == 'save') {
foreach (Tree::getAll() as $tree) {
$tree->setPreference('include_in_sitemap', Filter::postBool('include' . $tree->getTreeId()));
}
// Clear cache and force files to be regenerated
Database::prepare("DELETE FROM `##module_setting` WHERE setting_name LIKE 'sitemap%'")->execute();
}
$include_any = false;
?>
<ol class="breadcrumb small">
<li><a href="admin.php"><?php
echo I18N::translate('Control panel');
?>
</a></li>
<li><a href="admin_modules.php"><?php
echo I18N::translate('Module administration');
?>
</a></li>
<li class="active"><?php
echo $controller->getPageTitle();
?>
</li>
</ol>
<h1><?php
echo $controller->getPageTitle();
?>
</h1>
<?php
echo '<p>', I18N::translate('Sitemaps are a way for webmasters to tell search engines about the pages on a website that are available for crawling. All major search engines support sitemaps. For more information, see <a href="http://www.sitemaps.org/">www.sitemaps.org</a>.') . '</p>', '<p>', I18N::translate('Which family trees should be included in the sitemaps'), '</p>', '<form method="post" action="module.php?mod=' . $this->getName() . '&mod_action=admin">', '<input type="hidden" name="action" value="save">';
foreach (Tree::getAll() as $tree) {
echo '<div class="checkbox"><label><input type="checkbox" name="include', $tree->getTreeId(), '" ';
if ($tree->getPreference('include_in_sitemap')) {
echo 'checked';
$include_any = true;
}
echo '>', $tree->getTitleHtml(), '</label></div>';
}
echo '<input type="submit" value="', I18N::translate('save'), '">', '</form>', '<hr>';
if ($include_any) {
$site_map_url1 = WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml';
$site_map_url2 = rawurlencode(WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml');
echo '<p>', I18N::translate('To tell search engines that sitemaps are available, you should add the following line to your robots.txt file.'), '</p>', '<pre>Sitemap: ', $site_map_url1, '</pre>', '<hr>', '<p>', I18N::translate('To tell search engines that sitemaps are available, you can use the following links.'), '</p>', '<ul>', '<li><a href="http://www.bing.com/webmaster/ping.aspx?siteMap=' . $site_map_url2 . '">Bing</a></li>', '<li><a href="http://www.google.com/webmasters/tools/ping?sitemap=' . $site_map_url2 . '">Google</a></li>', '</ul>';
}
}
示例10: list
Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
Session::put('locale', Auth::user()->getPreference('language'));
Session::put('theme_id', Auth::user()->getPreference('theme'));
// We're logging in as an administrator
if (Auth::isAdmin()) {
// Check for updates
$latest_version_txt = Functions::fetchLatestVersion();
if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
if (version_compare(WT_VERSION, $latest_version) < 0) {
FlashMessages::addMessage(I18N::translate('A new version of webtrees is available.') . ' <a href="admin_site_upgrade.php"><b>' . I18N::translate('Upgrade to webtrees %s.', '<span dir="ltr">' . $latest_version . '</span>') . '</b></a>');
}
}
} else {
// We're not an administrator, so we can only log in if there is a tree.
if (empty(Tree::getAll())) {
Auth::logout();
FlashMessages::addMessage(I18N::translate('This user account does not have access to any tree.'));
}
}
// If we were on a "home page", redirect to "my page"
if ($url === '' || strpos($url, 'index.php?ctype=gedcom') === 0) {
$url = 'index.php?ctype=user';
// Switch to a tree where we have a genealogy record (or keep to the current/default).
$tree = Database::prepare("SELECT gedcom_name FROM `##gedcom` JOIN `##user_gedcom_setting` USING (gedcom_id)" . " WHERE setting_name = 'gedcomid' AND user_id = :user_id")->execute(array('user_id' => Auth::user()->getUserId()))->fetchOne();
$url .= '&ged=' . Filter::escapeUrl($tree);
}
// Redirect to the target URL
header('Location: ' . WT_BASE_URL . $url);
return;
} catch (\Exception $ex) {
示例11: foreach
Session::regenerate(false);
Session::put('initiated', true);
} else {
// An existing session
}
// Set the tree for the page; (1) the request, (2) the session, (3) the site default, (4) any tree
foreach (array(Filter::post('ged'), Filter::get('ged'), Session::get('GEDCOM'), Site::getPreference('DEFAULT_GEDCOM')) as $tree_name) {
$WT_TREE = Tree::findByName($tree_name);
if ($WT_TREE) {
Session::put('GEDCOM', $tree_name);
break;
}
}
// No chosen tree? Use any one.
if (!$WT_TREE) {
foreach (Tree::getAll() as $WT_TREE) {
break;
}
}
// With no parameters, init() looks to the environment to choose a language
define('WT_LOCALE', I18N::init());
Session::put('locale', WT_LOCALE);
// Note that the database/webservers may not be synchronised, so use DB time throughout.
define('WT_TIMESTAMP', (int) Database::prepare("SELECT UNIX_TIMESTAMP()")->fetchOne());
// Users get their own time-zone. Visitors get the site time-zone.
if (Auth::check()) {
date_default_timezone_set(Auth::user()->getPreference('TIMEZONE', 'UTC'));
} else {
date_default_timezone_set(Site::getPreference('TIMEZONE') ?: 'UTC');
}
define('WT_TIMESTAMP_OFFSET', date_offset_get(new \DateTime('now')));
示例12:
<?php
echo I18N::translate('After creating the family tree, you will be able to import data from a GEDCOM file.');
?>
</p>
</div>
</div>
</form>
</div>
</div>
</div>
<?php
}
?>
<!-- display link to PhpGedView-WT transfer wizard on first visit to this page, before any GEDCOM is loaded -->
<?php
if (count(Tree::getAll()) === 0 && count(User::all()) === 1) {
?>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
<i class="fa fa-fw fa-magic"></i>
<a data-toggle="collapse" data-parent="#accordion" href="#pgv-import-wizard">
<?php
echo I18N::translate('PhpGedView to webtrees transfer wizard');
?>
</a>
</h2>
</div>
<div id="pgv-import-wizard" class="panel-collapse collapse">
<div class="panel-body">
<p>
示例13: modAction
/** {@inheritdoc} */
public function modAction($mod_action)
{
Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
switch ($mod_action) {
case 'admin_config':
$template = new AdminTemplate();
return $template->pageContent();
case 'admin_search':
// new settings
$surname = Filter::post('SURNAME');
$pid = Filter::post('PID');
if ($surname) {
$soundex_std = Filter::postBool('soundex_std');
$soundex_dm = Filter::postBool('soundex_dm');
$indis = $this->module()->indisArray($surname, $soundex_std, $soundex_dm);
usort($indis, 'Fisharebest\\Webtrees\\Individual::compareBirthDate');
if (isset($indis) && count($indis) > 0) {
$pid = $indis[0]->getXref();
} else {
$result['error'] = I18N::translate('Error: The surname you entered doesn’t exist in this tree.');
}
}
if (isset($pid)) {
$FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
if ($this->module()->searchArray($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree')), 'PID', $pid)) {
if ($surname) {
$result['error'] = I18N::translate('Error: The root person belonging to this surname already exists');
} else {
$result['error'] = I18N::translate('Error: A root person with ID %s already exists', $pid);
}
} else {
$record = Individual::getInstance($pid, $this->tree());
if ($record) {
$root = $record->getFullName() . ' (' . $record->getLifeSpan() . ')';
$title = $this->module()->getPageLink($pid);
$result = array('access_level' => '2', 'pid' => $pid, 'root' => $root, 'sort' => count($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree'))) + 1, 'surname' => $this->module()->getSurname($pid), 'title' => $title, 'tree' => Filter::getInteger('tree'));
} else {
if (empty($result['error'])) {
$result['error'] = I18N::translate('Error: A person with ID %s does not exist in this tree', $pid);
}
}
}
}
echo json_encode($result);
break;
case 'admin_add':
$FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
$NEW_FTV_SETTINGS = $FTV_SETTINGS;
$NEW_FTV_SETTINGS[] = array('TREE' => Filter::getInteger('tree'), 'SURNAME' => Filter::post('surname'), 'PID' => Filter::post('pid'), 'ACCESS_LEVEL' => Filter::postInteger('access_level'), 'SORT' => Filter::postInteger('sort'));
$this->setSetting('FTV_SETTINGS', serialize(array_values($NEW_FTV_SETTINGS)));
Log::addConfigurationLog($this->getTitle() . ' config updated');
break;
case 'admin_update':
$FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
$new_surname = Filter::postArray('surname');
$new_access_level = Filter::postArray('access_level');
$new_sort = Filter::postArray('sort');
foreach ($new_surname as $key => $new_surname) {
$FTV_SETTINGS[$key]['SURNAME'] = $new_surname;
}
foreach ($new_access_level as $key => $new_access_level) {
$FTV_SETTINGS[$key]['ACCESS_LEVEL'] = $new_access_level;
}
foreach ($new_sort as $key => $new_sort) {
$FTV_SETTINGS[$key]['SORT'] = $new_sort;
}
$NEW_FTV_SETTINGS = $this->module()->sortArray($FTV_SETTINGS, 'SORT');
$this->setSetting('FTV_SETTINGS', serialize($NEW_FTV_SETTINGS));
break;
case 'admin_save':
$FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS'));
$FTV_OPTIONS[Filter::getInteger('tree')] = Filter::postArray('NEW_FTV_OPTIONS');
$this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS));
Log::addConfigurationLog($this->getTitle() . ' config updated');
// the cache has to be recreated because the image options could have been changed
$this->module()->emptyCache();
break;
case 'admin_copy':
$FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS'));
foreach (Tree::getAll() as $tree) {
$FTV_OPTIONS[$tree->getTreeId()] = Filter::postArray('NEW_FTV_OPTIONS');
}
$this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS));
Log::addConfigurationLog($this->getTitle() . ' config saved and copied to all trees');
// the cache has to be recreated because the image options could have been changed
$this->module()->emptyCache();
break;
case 'admin_reset':
$FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS'));
unset($FTV_OPTIONS[Filter::getInteger('tree')]);
$this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS));
Log::addConfigurationLog($this->getTitle() . ' options set to default');
break;
case 'admin_delete':
$FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
unset($FTV_SETTINGS[Filter::getInteger('key')]);
$this->setSetting('FTV_SETTINGS', serialize($FTV_SETTINGS));
Log::addConfigurationLog($this->getTitle() . ' item deleted');
break;
//.........这里部分代码省略.........
示例14: index
/**
* AdminConfig@index
*/
public function index()
{
global $WT_TREE;
Theme::theme(new AdministrationTheme())->init($WT_TREE);
$controller = new PageController();
$controller->restrictAccess(Auth::isManager($WT_TREE))->setPageTitle($this->module->getTitle());
$data = new ViewBag();
$data->set('title', $controller->getPageTitle());
$data->set('tree', $WT_TREE);
$data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
$table_id = 'table-geoanalysis-' . Uuid::uuid4();
$data->set('table_id', $table_id);
$other_trees = array();
foreach (Tree::getAll() as $tree) {
if ($tree->getTreeId() != $WT_TREE->getTreeId()) {
$other_trees[] = $tree;
}
}
$data->set('other_trees', $other_trees);
$data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
$controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript('
//Datatable initialisation
jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);};
jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);};
var geoAnalysisTable = jQuery("#' . $table_id . '")
.on("draw.dt", function ( e, settings, json, xhr ) {
jQuery("[data-toggle=\'tooltip\']").tooltip();
}).DataTable({
' . I18N::datatablesI18N() . ',
sorting: [[3, "asc"], [4, "asc"]],
pageLength: 10,
processing: true,
serverSide : true,
ajax : {
url : "module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@jsonGeoAnalysisList&ged=' . $WT_TREE->getNameUrl() . '",
type : "POST"
},
columns: [
/* 0 Edit */ { sortable: false, className: "text-center"},
/* 1 ID */ { visible: false },
/* 2 Enabled */ { sortable: false, className: "text-center" },
/* 3 Description */ null,
/* 4 Analysis Level */ { dataSort: 5, className: "text-center" },
/* 5 ANAL_LEVEL_SORT*/ { visible: false },
/* 6 Map */ { sortable: false, className: "text-center" },
/* 7 Map Top Level */ { sortable: false, className: "text-center" },
/* 8 Use Flags */ { sortable: false, className: "text-center" },
/* 9 Place Details */ { sortable: false, className: "text-center" }
],
});
')->addInlineJavascript('
function set_geoanalysis_status(ga_id, status, gedcom) {
jQuery.ajax({
url: "module.php",
type: "GET",
data: {
mod: "' . $this->module->getName() . '",
mod_action: "GeoAnalysis@setStatus",
ga_id: ga_id,
ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom,
status: status
},
error: function(result, stat, error) {
var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err);
},
complete: function(result, stat) {
geoAnalysisTable.ajax.reload(null, false);
}
});
}
function delete_geoanalysis(ga_id, status, gedcom) {
jQuery.ajax({
url: "module.php",
type: "GET",
data: {
mod: "' . $this->module->getName() . '",
mod_action: "GeoAnalysis@delete",
ga_id: ga_id,
ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom
},
error: function(result, stat, error) {
var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err);
},
complete: function(result, stat) {
geoAnalysisTable.ajax.reload(null, false);
}
});
}
');
ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
//.........这里部分代码省略.........
示例15:
<?php
}
?>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary">
<i class="fa fa-check"></i>
<?php
echo I18N::translate('save');
?>
</button>
<!-- Coming soon
<div class="checkbox">
<?php
if (count(Tree::getAll()) > 1) {
?>
<label>
<input type="checkbox" name="all_trees">
<?php
echo I18N::translate('Apply these preferences to all family trees');
?>
</label>
<?php
}
?>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="new_trees">
<?php