本文整理汇总了PHP中Fisharebest\Webtrees\Tree类的典型用法代码示例。如果您正苦于以下问题:PHP Tree类的具体用法?PHP Tree怎么用?PHP Tree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyWatermark
/**
* The media firewall passes in an image
* this function can manipulate the image however it wants
* before returning it back to the media firewall
*
* @param resource $im
* @param Tree $tree
*
* @return resource
*/
function applyWatermark($im, Tree $tree)
{
// text to watermark with
$word1_text = $tree->getTitle();
// maximum font size for “word1” ; will be automaticaly reduced to fit in the image
$word1_maxsize = 100;
// rgb color codes for text
$word1_color = '0,0,0';
// ttf font file to use
$word1_font = WT_ROOT . Config::FONT_DEJAVU_SANS_TTF;
// vertical position for the text to past; possible values are: top, middle or bottom, across
$word1_vpos = 'across';
// horizontal position for the text to past in media file; possible values are: left, right, top2bottom, bottom2top
// this value is used only if $word1_vpos=across
$word1_hpos = 'left';
$word2_text = $_SERVER['HTTP_HOST'];
$word2_maxsize = 20;
$word2_color = '0,0,0';
$word2_font = WT_ROOT . Config::FONT_DEJAVU_SANS_TTF;
$word2_vpos = 'top';
$word2_hpos = 'top2bottom';
embedText($im, $word1_text, $word1_maxsize, $word1_color, $word1_font, $word1_vpos, $word1_hpos);
embedText($im, $word2_text, $word2_maxsize, $word2_color, $word2_font, $word2_vpos, $word2_hpos);
return $im;
}
示例2: send
/**
* Send an external email message
* Caution! gmail may rewrite the "From" header unless you have added the address to your account.
*
* @param Tree $tree
* @param string $to_email
* @param string $to_name
* @param string $replyto_email
* @param string $replyto_name
* @param string $subject
* @param string $message
*
* @return bool
*/
public static function send(Tree $tree, $to_email, $to_name, $replyto_email, $replyto_name, $subject, $message)
{
try {
$mail = Swift_Message::newInstance()->setSubject($subject)->setFrom(Site::getPreference('SMTP_FROM_NAME'), $tree->getPreference('title'))->setTo($to_email, $to_name)->setReplyTo($replyto_email, $replyto_name)->setBody($message, 'text/html')->addPart(Filter::unescapeHtml($message), 'text/plain');
Swift_Mailer::newInstance(self::transport())->send($mail);
} catch (Exception $ex) {
Log::addErrorLog('Mail: ' . $ex->getMessage());
return false;
}
return true;
}
示例3: send
/**
* Send an external email message
* Caution! gmail may rewrite the "From" header unless you have added the address to your account.
*
* @param Tree $tree
* @param string $to_email
* @param string $to_name
* @param string $replyto_email
* @param string $replyto_name
* @param string $subject
* @param string $message
*
* @return bool
*/
public static function send(Tree $tree, $to_email, $to_name, $replyto_email, $replyto_name, $subject, $message)
{
try {
$mail = new Zend_Mail('UTF-8');
$mail->setSubject($subject)->setBodyHtml($message)->setBodyText(Filter::unescapeHtml($message))->setFrom(Site::getPreference('SMTP_FROM_NAME'), $tree->getPreference('title'))->addTo($to_email, $to_name)->setReplyTo($replyto_email, $replyto_name)->send(self::transport());
} catch (\Exception $ex) {
Log::addErrorLog('Mail: ' . $ex->getMessage());
return false;
}
return true;
}
示例4: 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);
}
}
示例5: getPlacesHierarchyFromData
/**
* Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
* It will look for the longest hierarchy in the tree.
* The places are reversed compared to normal GEDCOM structure.
*
* @return array
*/
protected function getPlacesHierarchyFromData()
{
$nb_levels = 0;
//Select all '2 PLAC ' tags in the file and create array
$places_list = array();
$ged_data = Database::prepare('SELECT i_gedcom AS gedcom' . ' FROM `##individuals`' . ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id' . ' UNION ALL' . 'SELECT f_gedcom AS gedcom' . ' FROM `##families`' . ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id')->execute(array('gedcom' => '%\\n2 PLAC %', 'gedcom_id' => $this->tree->getTreeId()))->fetchOneColumn();
foreach ($ged_data as $ged_datum) {
$matches = null;
preg_match_all('/\\n2 PLAC (.+)/', $ged_datum, $matches);
foreach ($matches[1] as $match) {
$places_list[$match] = true;
}
}
// Unique list of places
$places_list = array_keys($places_list);
//sort the array, limit to unique values, and count them
usort($places_list, array('I18N', 'strcasecmp'));
//calculate maximum no. of levels to display
$has_found_good_example = false;
foreach ($places_list as $place) {
$levels = explode(",", $place);
$parts = count($levels);
if ($parts >= $nb_levels) {
$nb_levels = $parts;
if (!$has_found_good_example) {
$random_place = $place;
if (min(array_map('strlen', $levels)) > 0) {
$has_found_good_example = true;
}
}
}
}
return array_reverse(array_map('trim', explode(',', $random_place)));
}
示例6: load
/**
* Sometimes, we'll know in advance that we need to load a set of records.
* Typically when we load families and their members.
*
* @param Tree $tree
* @param string[] $xrefs
*/
public static function load(Tree $tree, array $xrefs)
{
$args = array('tree_id' => $tree->getTreeId());
$placeholders = array();
foreach (array_unique($xrefs) as $n => $xref) {
if (!isset(self::$gedcom_record_cache[$tree->getTreeId()][$xref])) {
$placeholders[] = ':x' . $n;
$args['x' . $n] = $xref;
}
}
if (!empty($placeholders)) {
$rows = Database::prepare("SELECT i_id AS xref, i_gedcom AS gedcom" . " FROM `##individuals`" . " WHERE i_file = :tree_id AND i_id IN (" . implode(',', $placeholders) . ")")->execute($args)->fetchAll();
foreach ($rows as $row) {
self::getInstance($row->xref, $tree, $row->gedcom);
}
}
}
示例7: load
/**
* Sometimes, we'll know in advance that we need to load a set of records.
* Typically when we load families and their members.
*
* @param Tree $tree
* @param string[] $xrefs
*/
public static function load(Tree $tree, array $xrefs)
{
$sql = '';
$args = array('tree_id' => $tree->getTreeId());
foreach (array_unique($xrefs) as $n => $xref) {
if (!isset(self::$gedcom_record_cache[$tree->getTreeId()][$xref])) {
$sql .= ($n ? ',:x' : ':x') . $n;
$args['x' . $n] = $xref;
}
}
if (count($args) > 1) {
$rows = Database::prepare("SELECT i_id AS xref, i_gedcom AS gedcom" . " FROM `##individuals`" . " WHERE i_file = :tree_id AND i_id IN (" . $sql . ")")->execute($args)->fetchAll();
foreach ($rows as $row) {
self::getInstance($row->xref, $tree, $row->gedcom);
}
}
}
示例8: getAncestorDispersionForGen
/**
* Return a computed array of statistics about the dispersion of ancestors across the ancestors
* at a specified generation.
* This statistics cannot be used for generations above 11, as it would cause a out of range in MySQL
*
* Format:
* - key : a base-2 representation of the ancestor at generation G for which exclusive ancestors have been found,
* -1 is used for shared ancestors
* For instance base2(0100) = base10(4) represent the maternal grand father
* - values: number of ancestors exclusively in the ancestors of the ancestor in key
*
* For instance a result at generation 3 could be :
* array ( -1 => 12 -> 12 ancestors are shared by the grand-parents
* base10(1) => 32 -> 32 ancestors are exclusive to the paternal grand-father
* base10(2) => 25 -> 25 ancestors are exclusive to the paternal grand-mother
* base10(4) => 12 -> 12 ancestors are exclusive to the maternal grand-father
* base10(8) => 30 -> 30 ancestors are exclusive to the maternal grand-mother
* )
*
* @param int $gen Reference generation
* @return array
*/
public function getAncestorDispersionForGen($gen)
{
if (!$this->is_setup || $gen > 11) {
return array();
}
// Going further than 11 gen will be out of range in the query
return Database::prepare('SELECT branches, count(i_id)' . ' FROM (' . ' SELECT i_id,' . ' CASE' . ' WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)' . ' ELSE -1' . ' END branches' . ' FROM (' . ' SELECT DISTINCT majs_i_id i_id,' . ' POW(2, FLOOR(majs_sosa / POW(2, (majs_gen - :gen))) - POW(2, :gen -1)) branch' . ' FROM `##maj_sosa`' . ' WHERE majs_gedcom_id = :tree_id AND majs_user_id = :user_id' . ' AND majs_gen >= :gen' . ' ) indistat' . ' GROUP BY i_id' . ') grouped' . ' GROUP BY branches')->execute(array('tree_id' => $this->tree->getTreeId(), 'user_id' => $this->user->getUserId(), 'gen' => $gen))->fetchAssoc() ?: array();
}
示例9: getActiveModulesByComponent
/**
* Get a list of modules which (a) provide a specific function and (b) we have permission to see.
*
* We cannot currently use auto-loading for modules, as there may be user-defined
* modules about which the auto-loader knows nothing.
*
* @param Tree $tree
* @param string $component The type of module, such as "tab", "report" or "menu"
*
* @return AbstractModule[]
*/
private static function getActiveModulesByComponent(Tree $tree, $component)
{
$module_names = Database::prepare("SELECT SQL_CACHE module_name" . " FROM `##module`" . " JOIN `##module_privacy` USING (module_name)" . " WHERE gedcom_id = :tree_id AND component = :component AND status = 'enabled' AND access_level >= :access_level" . " ORDER BY CASE component WHEN 'menu' THEN menu_order WHEN 'sidebar' THEN sidebar_order WHEN 'tab' THEN tab_order ELSE 0 END, module_name")->execute(array('tree_id' => $tree->getTreeId(), 'component' => $component, 'access_level' => Auth::accessLevel($tree)))->fetchOneColumn();
$array = array();
foreach ($module_names as $module_name) {
$interface = '\\Fisharebest\\Webtrees\\Module\\Module' . ucfirst($component) . 'Interface';
$module = self::getModuleByName($module_name);
if ($module instanceof $interface) {
$array[$module_name] = $module;
}
}
// The order of menus/sidebars/tabs is defined in the database. Others are sorted by name.
if ($component !== 'menu' && $component !== 'sidebar' && $component !== 'tab') {
uasort($array, function (AbstractModule $x, AbstractModule $y) {
return I18N::strcasecmp($x->getTitle(), $y->getTitle());
});
}
return $array;
}
示例10: 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])));
}
}
示例11: gedcomHeader
/**
* Create a header for a (newly-created or already-imported) gedcom file.
*
* @param Tree $tree
*
* @return string
*/
public static function gedcomHeader(Tree $tree)
{
// Default values for a new header
$HEAD = "0 HEAD";
$SOUR = "\n1 SOUR " . WT_WEBTREES . "\n2 NAME " . WT_WEBTREES . "\n2 VERS " . WT_VERSION;
$DEST = "\n1 DEST DISKETTE";
$DATE = "\n1 DATE " . strtoupper(date("d M Y")) . "\n2 TIME " . date("H:i:s");
$GEDC = "\n1 GEDC\n2 VERS 5.5.1\n2 FORM Lineage-Linked";
$CHAR = "\n1 CHAR UTF-8";
$FILE = "\n1 FILE " . $tree->getName();
$LANG = "";
$PLAC = "\n1 PLAC\n2 FORM City, County, State/Province, Country";
$COPR = "";
$SUBN = "";
$SUBM = "\n1 SUBM @SUBM@\n0 @SUBM@ SUBM\n1 NAME " . Auth::user()->getUserName();
// The SUBM record is mandatory
// Preserve some values from the original header
$record = GedcomRecord::getInstance('HEAD', $tree);
if ($fact = $record->getFirstFact('PLAC')) {
$PLAC = "\n1 PLAC\n2 FORM " . $fact->getAttribute('FORM');
}
if ($fact = $record->getFirstFact('LANG')) {
$LANG = $fact->getValue();
}
if ($fact = $record->getFirstFact('SUBN')) {
$SUBN = $fact->getValue();
}
if ($fact = $record->getFirstFact('COPR')) {
$COPR = $fact->getValue();
}
// Link to actual SUBM/SUBN records, if they exist
$subn = Database::prepare("SELECT o_id FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBN', $tree->getTreeId()))->fetchOne();
if ($subn) {
$SUBN = "\n1 SUBN @{$subn}@";
}
$subm = Database::prepare("SELECT o_id FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBM', $tree->getTreeId()))->fetchOne();
if ($subm) {
$SUBM = "\n1 SUBM @{$subm}@";
}
return $HEAD . $SOUR . $DEST . $DATE . $GEDC . $CHAR . $FILE . $COPR . $LANG . $PLAC . $SUBN . $SUBM . "\n";
}
示例12: 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"
示例13: 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);
示例14: adminPlaces
//.........这里部分代码省略.........
<ul class="nav nav-tabs nav-justified" role="tablist">
<li role="presentation">
<a href="?mod=googlemap&mod_action=admin_config" role="tab">
<?php
echo I18N::translate('Google Maps™ preferences');
?>
</a>
</li>
<li role="presentation" class="active">
<a href="#">
<?php
echo I18N::translate('Geographic data');
?>
</a>
</li>
<li role="presentation">
<a href="?mod=googlemap&mod_action=admin_placecheck">
<?php
echo I18N::translate('Place check');
?>
</a>
</li>
</ul>
<h2><?php
echo I18N::translate('Geographic data');
?>
</h2>
<?php
if ($action == 'ImportGedcom') {
$placelist = array();
$j = 0;
$gedcom_records = Database::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_file=? UNION ALL SELECT f_gedcom FROM `##families` WHERE f_file=?")->execute(array($WT_TREE->getTreeId(), $WT_TREE->getTreeId()))->fetchOneColumn();
foreach ($gedcom_records as $gedrec) {
$i = 1;
$placerec = Functions::getSubRecord(2, '2 PLAC', $gedrec, $i);
while (!empty($placerec)) {
if (preg_match("/2 PLAC (.+)/", $placerec, $match)) {
$placelist[$j] = array();
$placelist[$j]['place'] = trim($match[1]);
if (preg_match("/4 LATI (.*)/", $placerec, $match)) {
$placelist[$j]['lati'] = trim($match[1]);
if ($placelist[$j]['lati'][0] != 'N' && $placelist[$j]['lati'][0] != 'S') {
if ($placelist[$j]['lati'] < 0) {
$placelist[$j]['lati'][0] = 'S';
} else {
$placelist[$j]['lati'] = 'N' . $placelist[$j]['lati'];
}
}
} else {
$placelist[$j]['lati'] = null;
}
if (preg_match("/4 LONG (.*)/", $placerec, $match)) {
$placelist[$j]['long'] = trim($match[1]);
if ($placelist[$j]['long'][0] != 'E' && $placelist[$j]['long'][0] != 'W') {
if ($placelist[$j]['long'] < 0) {
$placelist[$j]['long'][0] = 'W';
} else {
$placelist[$j]['long'] = 'E' . $placelist[$j]['long'];
}
}
} else {
$placelist[$j]['long'] = null;
}
$j = $j + 1;
示例15:
echo I18N::translate('User');
?>
</label>
<?php
echo FunctionsEdit::selectEditControl('user', $users_array, '', $user, 'class="form-control"');
?>
</div>
<div class="form-group col-xs-6 col-md-3">
<label for="gedc">
<?php
echo I18N::translate('Family tree');
?>
</label>
<?php
echo FunctionsEdit::selectEditControl('gedc', Tree::getNameList(), '', $gedc, Auth::isAdmin() ? 'class="form-control"' : 'disabled class="form-control"');
?>
</div>
</div>
<div class="row text-center">
<button type="submit" class="btn btn-primary">
<?php
echo I18N::translate('Filter');
?>
</button>
<button type="submit" class="btn btn-primary" onclick="document.logs.action.value='export';return true;" <?php
echo $action === 'show' ? '' : 'disabled';
?>
>