本文整理汇总了PHP中Fisharebest\Webtrees\Tree::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::findById方法的具体用法?PHP Tree::findById怎么用?PHP Tree::findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Tree
的用法示例。
在下文中一共展示了Tree::findById方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/**
* Upgrade to to the next version
*/
public function upgrade()
{
// - changes to the values for the gedcom setting SHOW_RELATIVES_EVENTS
$settings = Database::prepare("SELECT gedcom_id, setting_value FROM `##gedcom_setting` WHERE setting_name='SHOW_RELATIVES_EVENTS'")->fetchAssoc();
foreach ($settings as $gedcom_id => $setting) {
// Delete old settings
$setting = preg_replace('/_(BIRT|MARR|DEAT)_(COUS|MSIB|FSIB|GGCH|NEPH|GGPA)/', '', $setting);
$setting = preg_replace('/_FAMC_(RESI_EMIG)/', '', $setting);
// Rename settings
$setting = preg_replace('/_MARR_(MOTH|FATH|FAMC)/', '_MARR_PARE', $setting);
$setting = preg_replace('/_DEAT_(MOTH|FATH)/', '_DEAT_PARE', $setting);
// Remove duplicates
preg_match_all('/[_A-Z]+/', $setting, $match);
// And save
Tree::findById($gedcom_id)->setPreference('SHOW_RELATIVES_EVENTS', implode(',', array_unique($match[0])));
}
}
示例2: config
//.........这里部分代码省略.........
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th class="col-sm-2"><?php
echo webtrees\I18N::translate('Position');
?>
</th>
<th class="col-sm-4"><?php
echo webtrees\I18N::translate('Menu title');
?>
</th>
<th class="col-sm-4"><?php
echo webtrees\I18N::translate('Menu address');
?>
</th>
<th class="col-sm-2" colspan=4><?php
echo webtrees\I18N::translate('Controls');
?>
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($items as $item) {
?>
<tr>
<td>
<?php
echo $item->block_order, ', ';
if ($item->gedcom_id == null) {
echo webtrees\I18N::translate('All');
} else {
echo webtrees\Tree::findById($item->gedcom_id)->getTitleHtml();
}
?>
</td>
<td>
<?php
echo webtrees\Filter::escapeHtml(webtrees\I18N::translate($item->menu_title));
?>
</td>
<td>
<?php
echo webtrees\Filter::escapeHtml(substr(webtrees\I18N::translate($item->menu_address), 0, 1) == '<' ? webtrees\I18N::translate($item->menu_address) : nl2br(webtrees\I18N::translate($item->menu_address)));
?>
</td>
<td class="text-center">
<a href="module.php?mod=<?php
echo $this->getName();
?>
&mod_action=admin_edit&block_id=<?php
echo $item->block_id;
?>
">
<div class="icon-edit"> </div>
</a>
</td>
<td class="text-center">
<a href="module.php?mod=<?php
echo $this->getName();
?>
&mod_action=admin_moveup&block_id=<?php
echo $item->block_id;
?>
">
示例3: AjaxController
http_response_code(403);
return;
}
$controller = new AjaxController();
$controller->pageHeader();
// Don't allow the user to cancel the request. We do not want to be left
// with an incomplete transaction.
ignore_user_abort(true);
// Run in a transaction
Database::beginTransaction();
// Only allow one process to import each gedcom at a time
Database::prepare("SELECT * FROM `##gedcom_chunk` WHERE gedcom_id=? FOR UPDATE")->execute(array($gedcom_id));
// What is the current import status?
$row = Database::prepare("SELECT" . " SUM(IF(imported, LENGTH(chunk_data), 0)) AS import_offset," . " SUM(LENGTH(chunk_data)) AS import_total" . " FROM `##gedcom_chunk` WHERE gedcom_id=?")->execute(array($gedcom_id))->fetchOneRow();
if ($row->import_offset == $row->import_total) {
Tree::findById($gedcom_id)->setPreference('imported', '1');
// Finished? Show the maintenance links, similar to admin_trees_manage.php
Database::commit();
$controller->addInlineJavascript('jQuery("#import' . $gedcom_id . '").addClass("hidden");' . 'jQuery("#actions' . $gedcom_id . '").removeClass("hidden");');
return;
}
// Calculate progress so far
$progress = $row->import_offset / $row->import_total;
?>
<div class="progress" id="progress<?php
echo $gedcom_id;
?>
">
<div
class="progress-bar"
role="progressbar"
示例4: header
/**
* Defined in session.php
*
* @global Tree $WT_TREE
*/
global $WT_TREE;
use Fisharebest\Webtrees\Controller\PageController;
use Fisharebest\Webtrees\Module\CkeditorModule;
define('WT_SCRIPT_NAME', 'block_edit.php');
require './includes/session.php';
$block_id = Filter::getInteger('block_id');
$block = Database::prepare("SELECT SQL_CACHE * FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOneRow();
// Check access. (1) the block must exist and be enabled, (2) gedcom blocks require
// managers, (3) user blocks require the user or an admin
$blocks = Module::getActiveBlocks($WT_TREE);
if (!$block || !array_key_exists($block->module_name, $blocks) || $block->gedcom_id && !Auth::isManager(Tree::findById($block->gedcom_id)) || $block->user_id && $block->user_id != Auth::id() && !Auth::isAdmin()) {
header('Location: ' . WT_BASE_URL);
return;
}
$block = $blocks[$block->module_name];
if (Filter::post('save')) {
$ctype = Filter::post('ctype', 'user', 'gedcom');
header('Location: ' . WT_BASE_URL . 'index.php?ctype=' . $ctype . '&ged=' . $WT_TREE->getNameUrl());
$block->configureBlock($block_id);
return;
}
$ctype = FIlter::get('ctype', 'user', 'gedcom');
$controller = new PageController();
$controller->setPageTitle(I18N::translate('Configure') . ' — ' . $block->getTitle())->pageHeader();
if (Module::getModuleByName('ckeditor')) {
CkeditorModule::enableEditor($controller);
示例5: FROM
</ol>
<h1><?php
echo $controller->getPageTitle();
?>
</h1>
<?php
$tree1_id = Filter::post('tree1_id');
$tree2_id = Filter::post('tree2_id');
if ($tree1_id && $tree2_id != $tree1_id) {
// Every XREF used by both trees
$xrefs = Database::prepare("SELECT xref, type FROM (" . " SELECT i_id AS xref, 'INDI' AS type FROM `##individuals` WHERE i_file = ?" . " UNION " . " SELECT f_id AS xref, 'FAM' AS type FROM `##families` WHERE f_file = ?" . " UNION " . " SELECT s_id AS xref, 'SOUR' AS type FROM `##sources` WHERE s_file = ?" . " UNION " . " SELECT m_id AS xref, 'OBJE' AS type FROM `##media` WHERE m_file = ?" . " UNION " . " SELECT o_id AS xref, o_type AS type FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" . ") AS this_tree JOIN (" . " SELECT xref FROM `##change` WHERE gedcom_id = ?" . " UNION " . " SELECT i_id AS xref FROM `##individuals` WHERE i_file = ?" . " UNION " . " SELECT f_id AS xref FROM `##families` WHERE f_file = ?" . " UNION " . " SELECT s_id AS xref FROM `##sources` WHERE s_file = ?" . " UNION " . " SELECT m_id AS xref FROM `##media` WHERE m_file = ?" . " UNION " . " SELECT o_id AS xref FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" . ") AS other_trees USING (xref)")->execute(array($tree1_id, $tree1_id, $tree1_id, $tree1_id, $tree1_id, $tree2_id, $tree2_id, $tree2_id, $tree2_id, $tree2_id, $tree2_id))->fetchAssoc();
if ($xrefs) {
$tree1 = Tree::findById($tree1_id);
$tree2 = Tree::findById($tree2_id);
echo '<p>', I18N::translate('In a family tree, each record has an internal reference number (called an “XREF”) such as “F123” or “R14”.'), '</p>', '<p>', I18N::plural('The two family trees have %1$s record which uses the same “XREF”.', 'The two family trees have %1$s records which use the same “XREF”.', count($xrefs), count($xrefs)), '</p>', '<p>', I18N::translate('You must renumber the records in one of the trees before you can merge them.'), '</p>', '<p>', '<a class="current" href="admin_trees_renumber.php?ged=', $tree1->getNameUrl(), '">', I18N::translate('Renumber family tree'), ' — ', $tree1->getTitleHtml(), '</a>', '</p>', '<p>', '<a class="current" href="admin_trees_renumber.php?ged=', $tree2->getNameUrl(), '">', I18N::translate('Renumber family tree'), ' — ', $tree2->getTitleHtml(), '</a>', '</p>';
} else {
Database::beginTransaction();
Database::exec("LOCK TABLE" . " `##individuals` WRITE," . " `##individuals` AS individuals2 READ," . " `##families` WRITE," . " `##families` AS families2 READ," . " `##sources` WRITE," . " `##sources` AS sources2 READ," . " `##media` WRITE," . " `##media` AS media2 READ," . " `##other` WRITE," . " `##other` AS other2 READ," . " `##name` WRITE," . " `##name` AS name2 READ," . " `##placelinks` WRITE," . " `##placelinks` AS placelinks2 READ," . " `##change` WRITE," . " `##change` AS change2 READ," . " `##dates` WRITE," . " `##dates` AS dates2 READ," . " `##default_resn` WRITE," . " `##default_resn` AS default_resn2 READ," . " `##hit_counter` WRITE," . " `##hit_counter` AS hit_counter2 READ," . " `##link` WRITE," . " `##link` AS link2 READ");
Database::prepare("INSERT INTO `##individuals` (i_id, i_file, i_rin, i_sex, i_gedcom)" . " SELECT i_id, ?, i_rin, i_sex, i_gedcom FROM `##individuals` AS individuals2 WHERE i_file = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil)" . " SELECT f_id, ?, f_husb, f_wife, f_gedcom, f_numchil FROM `##families` AS families2 WHERE f_file = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom)" . " SELECT s_id, ?, s_name, s_gedcom FROM `##sources` AS sources2 WHERE s_file = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##media` (m_id, m_ext, m_type, m_titl, m_filename, m_file, m_gedcom)" . " SELECT m_id, m_ext, m_type, m_titl, m_filename, ?, m_gedcom FROM `##media` AS media2 WHERE m_file = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom)" . " SELECT o_id, ?, o_type, o_gedcom FROM `##other` AS other2 WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##name` (n_file, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm)" . " SELECT ?, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm FROM `##name` AS name2 WHERE n_file = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##placelinks` (pl_p_id, pl_gid, pl_file)" . " SELECT pl_p_id, pl_gid, ? FROM `##placelinks` AS placelinks2 WHERE pl_file = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##dates` (d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, d_file, d_type)" . " SELECT d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, ?, d_type FROM `##dates` AS dates2 WHERE d_file = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##default_resn` (gedcom_id, xref, tag_type, resn)" . " SELECT ?, xref, tag_type, resn FROM `##default_resn` AS default_resn2 WHERE gedcom_id = ?")->execute(array($tree2_id, $tree1_id));
Database::prepare("INSERT INTO `##link` (l_file, l_from, l_type, l_to)" . " SELECT ?, l_from, l_type, l_to FROM `##link` AS link2 WHERE l_file = ?")->execute(array($tree2_id, $tree1_id));
// This table may contain old (deleted) references, which could clash. IGNORE these.
示例6: checkGedcomImportForm
<li><a href="admin_trees_manage.php"><?php
echo I18N::translate('Manage family trees');
?>
</a></li>
<li class="active"><?php
echo $controller->getPageTitle();
?>
</li>
</ol>
<h1><?php
echo $controller->getPageTitle();
?>
</h1>
<?php
$tree = Tree::findById(Filter::getInteger('gedcom_id'));
// Check it exists
if (!$tree) {
break;
}
$gedcom_filename = $tree->getPreference('gedcom_filename');
?>
<p>
<?php
echo I18N::translate('This will delete all the genealogy data from “%s” and replace it with data from a GEDCOM file.', $tree->getTitleHtml());
?>
</p>
<form class="form form-horizontal" name="gedcomimportform" method="post" enctype="multipart/form-data" onsubmit="return checkGedcomImportForm('<?php
echo Filter::escapeHtml(I18N::translate('You have selected a GEDCOM file with a different name. Is this correct?'));
?>
');">
示例7: printReadMoreLink
/**
* Print read-more link
*
* @param type $root
* @return string
*/
private function printReadMoreLink($root)
{
return '<div id="read-more-link">' . '<a href="module.php?mod=' . $this->getName() . '&mod_action=page&rootid=' . $root . '&ged=' . Filter::escapeUrl(Tree::findById($this->tree_id)->getName()) . '">' . I18N::translate('Read more') . '</a>' . '</div>';
}
示例8: USING
// add/update
FunctionsImport::updateRecord($change->new_gedcom, $change->gedcom_id, false);
}
Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id));
Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database");
}
break;
}
$changed_gedcoms = Database::prepare("SELECT g.gedcom_name" . " FROM `##change` c" . " JOIN `##gedcom` g USING (gedcom_id)" . " WHERE c.status='pending'" . " GROUP BY g.gedcom_name")->fetchOneColumn();
if ($changed_gedcoms) {
$changes = Database::prepare("SELECT c.*, u.user_name, u.real_name, g.gedcom_name, new_gedcom, old_gedcom" . " FROM `##change` c" . " JOIN `##user` u USING (user_id)" . " JOIN `##gedcom` g USING (gedcom_id)" . " WHERE c.status='pending'" . " ORDER BY gedcom_id, c.xref, c.change_id")->fetchAll();
$output = '<br><br><table class="list_table">';
$prev_xref = null;
$prev_gedcom_id = null;
foreach ($changes as $change) {
$tree = Tree::findById($change->gedcom_id);
preg_match('/^0 @' . WT_REGEX_XREF . '@ (' . WT_REGEX_TAG . ')/', $change->old_gedcom . $change->new_gedcom, $match);
switch ($match[1]) {
case 'INDI':
$record = new Individual($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'FAM':
$record = new Family($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'SOUR':
$record = new Source($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'REPO':
$record = new Repository($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
break;
case 'OBJE':
示例9: header
$controller->setPageTitle(I18N::translate('Change the “My page” blocks'));
$can_reset = true;
}
} else {
if ($gedcom_id < 0) {
$controller->setPageTitle(I18N::translate('Set the default blocks for new family trees'));
$can_reset = false;
} else {
$controller->setPageTitle(I18N::translate('Change the “Home page” blocks'));
$can_reset = true;
}
}
// Only an admin can edit the "default" page
// Only managers can edit the "home page"
// Only a user or an admin can edit a user’s "my page"
if ($gedcom_id < 0 && !Auth::isAdmin() || $gedcom_id > 0 && !Auth::isManager(Tree::findById($gedcom_id)) || $user_id && Auth::id() != $user_id && !Auth::isAdmin()) {
header('Location: ' . WT_BASE_URL);
return;
}
$action = Filter::get('action');
if ($can_reset && Filter::post('default') === '1') {
if ($user_id) {
$defaults = FunctionsDb::getUserBlocks(-1);
} else {
$defaults = FunctionsDb::getTreeBlocks(-1);
}
$main = $defaults['main'];
$right = $defaults['side'];
} else {
if (isset($_REQUEST['main'])) {
$main = $_REQUEST['main'];
示例10: updateRecord
/**
* update a record in the database
*
* @param string $gedrec
* @param int $ged_id
* @param bool $delete
*/
public static function updateRecord($gedrec, $ged_id, $delete)
{
if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedrec, $match)) {
list(, $gid, $type) = $match;
} elseif (preg_match('/^0 (HEAD)(?:\\n|$)/', $gedrec, $match)) {
// The HEAD record has no XREF. Any others?
$gid = $match[1];
$type = $match[1];
} else {
echo "ERROR: Invalid gedcom record.";
return;
}
// TODO deleting unlinked places can be done more efficiently in a single query
$placeids = Database::prepare("SELECT pl_p_id FROM `##placelinks` WHERE pl_gid=? AND pl_file=?")->execute(array($gid, $ged_id))->fetchOneColumn();
Database::prepare("DELETE FROM `##placelinks` WHERE pl_gid=? AND pl_file=?")->execute(array($gid, $ged_id));
Database::prepare("DELETE FROM `##dates` WHERE d_gid =? AND d_file =?")->execute(array($gid, $ged_id));
//-- delete any unlinked places
foreach ($placeids as $p_id) {
$num = Database::prepare("SELECT count(pl_p_id) FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?")->execute(array($p_id, $ged_id))->fetchOne();
if ($num == 0) {
Database::prepare("DELETE FROM `##places` WHERE p_id=? AND p_file=?")->execute(array($p_id, $ged_id));
}
}
Database::prepare("DELETE FROM `##name` WHERE n_id=? AND n_file=?")->execute(array($gid, $ged_id));
Database::prepare("DELETE FROM `##link` WHERE l_from=? AND l_file=?")->execute(array($gid, $ged_id));
switch ($type) {
case 'INDI':
Database::prepare("DELETE FROM `##individuals` WHERE i_id=? AND i_file=?")->execute(array($gid, $ged_id));
break;
case 'FAM':
Database::prepare("DELETE FROM `##families` WHERE f_id=? AND f_file=?")->execute(array($gid, $ged_id));
break;
case 'SOUR':
Database::prepare("DELETE FROM `##sources` WHERE s_id=? AND s_file=?")->execute(array($gid, $ged_id));
break;
case 'OBJE':
Database::prepare("DELETE FROM `##media` WHERE m_id=? AND m_file=?")->execute(array($gid, $ged_id));
break;
default:
Database::prepare("DELETE FROM `##other` WHERE o_id=? AND o_file=?")->execute(array($gid, $ged_id));
break;
}
if (!$delete) {
self::importRecord($gedrec, Tree::findById($ged_id), true);
}
}
示例11: array
}
} else {
$SELECT1 = " 1 ASC";
}
if ($length > 0) {
$SELECT1 .= " LIMIT :length OFFSET :start";
$ARGS1['length'] = $length;
$ARGS1['start'] = $start;
}
$rows = Database::prepare($SELECT1)->execute($ARGS1)->fetchAll();
// Total filtered/unfiltered rows
$recordsFiltered = Database::prepare("SELECT FOUND_ROWS()")->fetchOne();
$recordsTotal = Database::prepare($SELECT2)->execute($ARGS2)->fetchOne();
$data = array();
foreach ($rows as $row) {
$media = Media::getInstance($row->xref, Tree::findById($row->gedcom_id), $row->gedcom);
$data[] = array(GedcomTag::getLabelValue('URL', $row->m_filename), $media->displayImage(), mediaObjectInfo($media));
}
break;
case 'unused':
// Which trees use this media folder?
$media_trees = Database::prepare("SELECT gedcom_name, gedcom_name" . " FROM `##gedcom`" . " JOIN `##gedcom_setting` USING (gedcom_id)" . " WHERE setting_name='MEDIA_DIRECTORY' AND setting_value = :media_folder AND gedcom_id > 0")->execute(array('media_folder' => $media_folder))->fetchAssoc();
$disk_files = all_disk_files($media_folder, $media_path, $subfolders, $search);
$db_files = all_media_files($media_folder, $media_path, $subfolders, $search);
// All unused files
$unused_files = array_diff($disk_files, $db_files);
$recordsTotal = count($unused_files);
// Filter unused files
if ($search) {
$unused_files = array_filter($unused_files, function ($x) use($search) {
return strpos($x, $search) !== false;
示例12: generateFile
/**
* A separate file for each family tree and each record type.
* These files depend on access levels, so only cache for visitors.
*
* @param int $ged_id
* @param string $rec_type
* @param string $volume
*/
private function generateFile($ged_id, $rec_type, $volume)
{
$tree = Tree::findById($ged_id);
// Check the cache
$timestamp = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp');
if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE && !Auth::check()) {
$data = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.xml');
} else {
$data = '<url><loc>' . WT_BASE_URL . 'index.php?ctype=gedcom&ged=' . $tree->getNameUrl() . '</loc></url>' . PHP_EOL;
$records = array();
switch ($rec_type) {
case 'i':
$rows = Database::prepare("SELECT i_id AS xref, i_gedcom AS gedcom" . " FROM `##individuals`" . " WHERE i_file = :tree_id" . " ORDER BY i_id" . " LIMIT :limit OFFSET :offset")->execute(array('tree_id' => $ged_id, 'limit' => self::RECORDS_PER_VOLUME, 'offset' => self::RECORDS_PER_VOLUME * $volume))->fetchAll();
foreach ($rows as $row) {
$records[] = Individual::getInstance($row->xref, $tree, $row->gedcom);
}
break;
case 's':
$rows = Database::prepare("SELECT s_id AS xref, s_gedcom AS gedcom" . " FROM `##sources`" . " WHERE s_file = :tree_id" . " ORDER BY s_id" . " LIMIT :limit OFFSET :offset")->execute(array('tree_id' => $ged_id, 'limit' => self::RECORDS_PER_VOLUME, 'offset' => self::RECORDS_PER_VOLUME * $volume))->fetchAll();
foreach ($rows as $row) {
$records[] = Source::getInstance($row->xref, $tree, $row->gedcom);
}
break;
case 'r':
$rows = Database::prepare("SELECT o_id AS xref, o_gedcom AS gedcom" . " FROM `##other`" . " WHERE o_file = :tree_id AND o_type = 'REPO'" . " ORDER BY o_id" . " LIMIT :limit OFFSET :offset")->execute(array('tree_id' => $ged_id, 'limit' => self::RECORDS_PER_VOLUME, 'offset' => self::RECORDS_PER_VOLUME * $volume))->fetchAll();
foreach ($rows as $row) {
$records[] = Repository::getInstance($row->xref, $tree, $row->gedcom);
}
break;
case 'n':
$rows = Database::prepare("SELECT o_id AS xref, o_gedcom AS gedcom" . " FROM `##other`" . " WHERE o_file = :tree_id AND o_type = 'NOTE'" . " ORDER BY o_id" . " LIMIT :limit OFFSET :offset")->execute(array('tree_id' => $ged_id, 'limit' => self::RECORDS_PER_VOLUME, 'offset' => self::RECORDS_PER_VOLUME * $volume))->fetchAll();
foreach ($rows as $row) {
$records[] = Note::getInstance($row->xref, $tree, $row->gedcom);
}
break;
case 'm':
$rows = Database::prepare("SELECT m_id AS xref, m_gedcom AS gedcom" . " FROM `##media`" . " WHERE m_file = :tree_id" . " ORDER BY m_id" . " LIMIT :limit OFFSET :offset")->execute(array('tree_id' => $ged_id, 'limit' => self::RECORDS_PER_VOLUME, 'offset' => self::RECORDS_PER_VOLUME * $volume))->fetchAll();
foreach ($rows as $row) {
$records[] = Media::getInstance($row->xref, $tree, $row->gedcom);
}
break;
}
foreach ($records as $record) {
if ($record->canShowName()) {
$data .= '<url>';
$data .= '<loc>' . WT_BASE_URL . $record->getHtmlUrl() . '</loc>';
$chan = $record->getFirstFact('CHAN');
if ($chan) {
$date = $chan->getDate();
if ($date->isOK()) {
$data .= '<lastmod>' . $date->minimumDate()->Format('%Y-%m-%d') . '</lastmod>';
}
}
$data .= '</url>' . PHP_EOL;
}
}
$data = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . PHP_EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL . $data . '</urlset>' . PHP_EOL;
// Cache this data - but only for visitors, as we don’t want
// visitors to see data created by signed-in users.
if (!Auth::check()) {
$this->setSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.xml', $data);
$this->setSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp', WT_TIMESTAMP);
}
}
header('Content-Type: application/xml');
header('Content-Length: ' . strlen($data));
echo $data;
}
示例13: getTreeBlocks
/**
* Get the blocks for the specified tree
*
* @param int $gedcom_id
*
* @return string[][]
*/
public static function getTreeBlocks($gedcom_id)
{
if ($gedcom_id < 0) {
$access_level = Auth::PRIV_NONE;
} else {
$access_level = Auth::accessLevel(Tree::findById($gedcom_id));
}
$blocks = array('main' => array(), 'side' => array());
$rows = Database::prepare("SELECT SQL_CACHE location, block_id, module_name" . " FROM `##block`" . " JOIN `##module` USING (module_name)" . " JOIN `##module_privacy` USING (module_name, gedcom_id)" . " WHERE gedcom_id = :tree_id" . " AND status='enabled'" . " AND access_level >= :access_level" . " ORDER BY location, block_order")->execute(array('tree_id' => $gedcom_id, 'access_level' => $access_level))->fetchAll();
foreach ($rows as $row) {
$blocks[$row->location][$row->block_id] = $row->module_name;
}
return $blocks;
}