本文整理汇总了PHP中Fisharebest\Webtrees\Functions\Functions类的典型用法代码示例。如果您正苦于以下问题:PHP Functions类的具体用法?PHP Functions怎么用?PHP Functions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Functions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate the likely value of this census column, based on available information.
*
* @param Individual $individual
* @param Individual|null $head
*
* @return string
*/
public function generate(Individual $individual, Individual $head = null)
{
if ($head === null) {
return '';
} elseif ($individual == $head) {
return 'head';
} else {
return Functions::getCloseRelationshipName($head, $individual);
}
}
示例2: getFacts
/**
* Return a list of facts
*
* @return Fact[]
*/
public function getFacts()
{
$facts = $this->record->getFacts();
// Add some dummy facts to show additional information
if ($this->record->fileExists()) {
// get height and width of image, when available
$imgsize = $this->record->getImageAttributes();
if (!empty($imgsize['WxH'])) {
$facts[] = new Fact('1 __IMAGE_SIZE__ ' . $imgsize['WxH'], $this->record, 0);
}
//Prints the file size
$facts[] = new Fact('1 __FILE_SIZE__ ' . $this->record->getFilesize(), $this->record, 0);
}
Functions::sortFacts($facts);
return $facts;
}
示例3: menuLogin
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>';
}
}
示例4: formatFactPlace
/**
* print fact PLACe TEMPle STATus
*
* @param Fact $event gedcom fact record
* @param bool $anchor to print a link to placelist
* @param bool $sub_records to print place subrecords
* @param bool $lds to print LDS TEMPle and STATus
*
* @return string HTML
*/
public static function formatFactPlace(Fact $event, $anchor = false, $sub_records = false, $lds = false)
{
if ($anchor) {
// Show the full place name, for facts/events tab
$html = '<a href="' . $event->getPlace()->getURL() . '">' . $event->getPlace()->getFullName() . '</a>';
} else {
// Abbreviate the place name, for chart boxes
return ' - ' . $event->getPlace()->getShortName();
}
if ($sub_records) {
$placerec = Functions::getSubRecord(2, '2 PLAC', $event->getGedcom());
if (!empty($placerec)) {
if (preg_match_all('/\\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) {
foreach ($matches[1] as $match) {
$wt_place = new Place($match, $event->getParent()->getTree());
$html .= ' - ' . $wt_place->getFullName();
}
}
$map_lati = "";
$cts = preg_match('/\\d LATI (.*)/', $placerec, $match);
if ($cts > 0) {
$map_lati = $match[1];
$html .= '<br><span class="label">' . GedcomTag::getLabel('LATI') . ': </span>' . $map_lati;
}
$map_long = '';
$cts = preg_match('/\\d LONG (.*)/', $placerec, $match);
if ($cts > 0) {
$map_long = $match[1];
$html .= ' <span class="label">' . GedcomTag::getLabel('LONG') . ': </span>' . $map_long;
}
if ($map_lati && $map_long) {
$map_lati = trim(strtr($map_lati, "NSEW,�", " - -. "));
// S5,6789 ==> -5.6789
$map_long = trim(strtr($map_long, "NSEW,�", " - -. "));
// E3.456� ==> 3.456
$html .= ' <a rel="nofollow" href="https://maps.google.com/maps?q=' . $map_lati . ',' . $map_long . '" class="icon-googlemaps" title="' . I18N::translate('Google Maps™') . '"></a>';
$html .= ' <a rel="nofollow" href="https://www.bing.com/maps/?lvl=15&cp=' . $map_lati . '~' . $map_long . '" class="icon-bing" title="' . I18N::translate('Bing Maps™') . '"></a>';
$html .= ' <a rel="nofollow" href="https://www.openstreetmap.org/#map=15/' . $map_lati . '/' . $map_long . '" class="icon-osm" title="' . I18N::translate('OpenStreetMap™') . '"></a>';
}
if (preg_match('/\\d NOTE (.*)/', $placerec, $match)) {
$html .= '<br>' . self::printFactNotes($placerec, 3);
}
}
}
if ($lds) {
if (preg_match('/2 TEMP (.*)/', $event->getGedcom(), $match)) {
$html .= '<br>' . I18N::translate('LDS temple') . ': ' . GedcomCodeTemp::templeName($match[1]);
}
if (preg_match('/2 STAT (.*)/', $event->getGedcom(), $match)) {
$html .= '<br>' . I18N::translate('Status') . ': ' . GedcomCodeStat::statusName($match[1]);
if (preg_match('/3 DATE (.*)/', $event->getGedcom(), $match)) {
$date = new Date($match[1]);
$html .= ', ' . GedcomTag::getLabel('STAT:DATE') . ': ' . $date->display();
}
}
}
return $html;
}
示例5: adminPlaces
//.........这里部分代码省略.........
<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;
}
$i = $i + 1;
$placerec = Functions::getSubRecord(2, '2 PLAC', $gedrec, $i);
示例6: checkRelationship
/**
* check (blood) relationship between partners
*
* @param type $person
* @param type $spouse
* @return string (relationship name)
*/
private function checkRelationship($person, $spouse)
{
$controller = new RelationshipController();
$paths = $controller->calculateRelationships($person, $spouse, 1);
foreach ($paths as $path) {
$relationships = $controller->oldStyleRelationshipPath($path);
if (empty($relationships)) {
// Cannot see one of the families/individuals, due to privacy;
continue;
}
foreach (array_keys($path) as $n) {
if ($n % 2 === 1) {
switch ($relationships[$n]) {
case 'sis':
case 'bro':
case 'sib':
return Functions::getRelationshipNameFromPath(implode('', $relationships), $person, $spouse);
}
}
}
}
}
示例7: htmlAncestorDispersionG3
/**
* Returns HTML code for a graph showing the dispersion of ancestors across grand-parents
* @return string HTML code
*/
private function htmlAncestorDispersionG3()
{
$ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3);
$size = '700x300';
$color_motmot = 'ffd1dc';
$color_motfat = 'b998a0';
$color_fatfat = '577292';
$color_fatmot = '84beff';
$color_shared = '777777';
$total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
$total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
$total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0;
$total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0;
$total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
$total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha;
$chd = $this->arrayToExtendedEncoding(array(4095 * Functions::safeDivision($total_fatfat, $total), 4095 * Functions::safeDivision($total_fatmot, $total), 4095 * Functions::safeDivision($total_sha, $total), 4095 * Functions::safeDivision($total_motfat, $total), 4095 * Functions::safeDivision($total_motmot, $total)));
$chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3');
$chl = \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
}
示例8: foreach
$sourceDATE = '';
$sourceQUAY = '';
if (!empty($gedrec)) {
preg_match_all('/\\n(1 (?!FILE|FORM|TYPE|TITL|_PRIM|_THUM|CHAN|DATA).*(\\n[2-9] .*)*)/', $gedrec, $matches);
foreach ($matches[1] as $subrec) {
$pieces = explode("\n", $subrec);
foreach ($pieces as $piece) {
$ft = preg_match("/(\\d) (\\w+)(.*)/", $piece, $match);
if ($ft == 0) {
continue;
}
$subLevel = $match[1];
$fact = trim($match[2]);
$event = trim($match[3]);
if ($fact === 'NOTE' || $fact === 'TEXT') {
$event .= Functions::getCont($subLevel + 1, $subrec);
}
if ($sourceSOUR !== '' && $subLevel <= $sourceLevel) {
// Get rid of all saved Source data
FunctionsEdit::addSimpleTag($sourceLevel . ' SOUR ' . $sourceSOUR);
FunctionsEdit::addSimpleTag($sourceLevel + 1 . ' PAGE ' . $sourcePAGE);
FunctionsEdit::addSimpleTag($sourceLevel + 2 . ' TEXT ' . $sourceTEXT);
FunctionsEdit::addSimpleTag($sourceLevel + 2 . ' DATE ' . $sourceDATE, '', GedcomTag::getLabel('DATA:DATE'));
FunctionsEdit::addSimpleTag($sourceLevel + 1 . ' QUAY ' . $sourceQUAY);
$sourceSOUR = '';
}
if ($fact === 'SOUR') {
$sourceLevel = $subLevel;
$sourceSOUR = $event;
$sourcePAGE = '';
$sourceTEXT = '';
示例9: restrictAccess
/**
* Restrict access
*
* @param bool $condition
*
* @return $this
*/
public function restrictAccess($condition)
{
if ($condition !== true) {
header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(Functions::getQueryUrl()));
exit;
}
return $this;
}
示例10: printFamily
/**
* Print a family group.
*
* @param Family $family
* @param string $type
* @param string $label
*/
private function printFamily(Family $family, $type, $label)
{
global $controller;
if ($family->getTree()->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) {
$access_level = Auth::PRIV_HIDE;
} else {
$access_level = Auth::accessLevel($family->getTree());
}
?>
<table>
<tr>
<td>
<i class="icon-cfamily"></i>
</td>
<td>
<span class="subheaders"> <?php
echo $label;
?>
</span>
<a class="noprint" href="<?php
echo $family->getHtmlUrl();
?>
"> - <?php
echo I18N::translate('View this family');
?>
</a>
</td>
</tr>
</table>
<table class="facts_table">
<?php
///// HUSB /////
$found = false;
foreach ($family->getFacts('HUSB', false, $access_level) as $fact) {
$found |= !$fact->isPendingDeletion();
$person = $fact->getTarget();
if ($person instanceof Individual) {
if ($fact->isPendingAddition()) {
$class = 'facts_label new';
} elseif ($fact->isPendingDeletion()) {
$class = 'facts_label old';
} else {
$class = 'facts_label';
}
?>
<tr>
<td class="<?php
echo $class;
?>
">
<?php
echo Functions::getCloseRelationshipName($controller->record, $person);
?>
</td>
<td class="<?php
echo $controller->getPersonStyle($person);
?>
">
<?php
echo Theme::theme()->individualBoxLarge($person);
?>
</td>
</tr>
<?php
}
}
if (!$found && $family->canEdit()) {
?>
<tr>
<td class="facts_label"></td>
<td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php
echo $family->getXref();
?>
', 'HUSB');"><?php
echo I18N::translate('Add a husband to this family');
?>
</a></td>
</tr>
<?php
}
///// WIFE /////
$found = false;
foreach ($family->getFacts('WIFE', false, $access_level) as $fact) {
$person = $fact->getTarget();
if ($person instanceof Individual) {
$found |= !$fact->isPendingDeletion();
if ($fact->isPendingAddition()) {
$class = 'facts_label new';
} elseif ($fact->isPendingDeletion()) {
$class = 'facts_label old';
} else {
$class = 'facts_label';
}
//.........这里部分代码省略.........
示例11: AjaxController
$action = Filter::get('action');
// The default view depends on whether we are logged in
if (Auth::check()) {
$ctype = Filter::get('ctype', 'gedcom|user', 'user');
} else {
$ctype = 'gedcom';
}
// Get the blocks list
if ($ctype === 'user') {
$blocks = FunctionsDb::getUserBlocks(Auth::id());
} else {
$blocks = FunctionsDb::getTreeBlocks($WT_TREE->getTreeId());
}
$active_blocks = Module::getActiveBlocks($WT_TREE);
// The latest version is shown on the administration page. This updates it every day.
Functions::fetchLatestVersion();
// We generate individual blocks using AJAX
if ($action === 'ajax') {
$controller = new AjaxController();
$controller->pageHeader();
// Check we’re displaying an allowable block.
$block_id = Filter::getInteger('block_id');
if (array_key_exists($block_id, $blocks['main'])) {
$module_name = $blocks['main'][$block_id];
} elseif (array_key_exists($block_id, $blocks['side'])) {
$module_name = $blocks['side'][$block_id];
} else {
return;
}
if (array_key_exists($module_name, $active_blocks)) {
echo $active_blocks[$module_name]->getBlock($block_id);
示例12: getGedcomValue
/**
* get gedcom tag value
*
* @param string $tag The tag to find, use : to delineate subtags
* @param int $level The gedcom line level of the first tag to find, setting level to 0 will cause it to use 1+ the level of the incoming record
* @param string $gedrec The gedcom record to get the value from
*
* @return string the value of a gedcom tag from the given gedcom record
*/
private function getGedcomValue($tag, $level, $gedrec)
{
global $WT_TREE;
if (empty($gedrec)) {
return '';
}
$tags = explode(':', $tag);
$origlevel = $level;
if ($level == 0) {
$level = $gedrec[0] + 1;
}
$subrec = $gedrec;
foreach ($tags as $t) {
$lastsubrec = $subrec;
$subrec = Functions::getSubRecord($level, "{$level} {$t}", $subrec);
if (empty($subrec) && $origlevel == 0) {
$level--;
$subrec = Functions::getSubRecord($level, "{$level} {$t}", $lastsubrec);
}
if (empty($subrec)) {
if ($t == "TITL") {
$subrec = Functions::getSubRecord($level, "{$level} ABBR", $lastsubrec);
if (!empty($subrec)) {
$t = "ABBR";
}
}
if (empty($subrec)) {
if ($level > 0) {
$level--;
}
$subrec = Functions::getSubRecord($level, "@ {$t}", $gedrec);
if (empty($subrec)) {
return '';
}
}
}
$level++;
}
$level--;
$ct = preg_match("/{$level} {$t}(.*)/", $subrec, $match);
if ($ct == 0) {
$ct = preg_match("/{$level} @.+@ (.+)/", $subrec, $match);
}
if ($ct == 0) {
$ct = preg_match("/@ {$t} (.+)/", $subrec, $match);
}
if ($ct > 0) {
$value = trim($match[1]);
if ($t == 'NOTE' && preg_match('/^@(.+)@$/', $value, $match)) {
$note = Note::getInstance($match[1], $WT_TREE);
if ($note) {
$value = $note->getNote();
} else {
//-- set the value to the id without the @
$value = $match[1];
}
}
if ($level != 0 || $t != "NOTE") {
$value .= Functions::getCont($level + 1, $subrec);
}
return $value;
}
return "";
}
示例13: foreach
// at a scale of 25 or higher, show every year
$mod = 25 / $controller->scale;
if ($mod < 1) {
$mod = 1;
}
for ($i = $controller->baseyear + 1; $i < $controller->topyear; $i++) {
if ($i % $mod === 0) {
echo '<div id="scale' . $i . '" style="position:absolute; ' . (I18N::direction() === 'ltr' ? 'left: ' . $basexoffset : 'right: ' . $basexoffset) . 'px; top:' . ($baseyoffset + ($i - $controller->baseyear) * $controller->scale - $controller->scale / 2) . 'px; font-size: 7pt; text-align:' . (I18N::direction() === 'ltr' ? 'left' : 'right') . ';">';
echo $i . '—';
echo '</div>';
}
}
echo '<div id="scale' . $controller->topyear . '" style="position:absolute; ' . (I18N::direction() === 'ltr' ? 'left: ' . $basexoffset : 'right: ' . $basexoffset) . 'px; top:' . ($baseyoffset + ($controller->topyear - $controller->baseyear) * $controller->scale) . 'px; font-size: 7pt; text-align:' . (I18N::direction() === 'ltr' ? 'left' : 'right') . ';">';
echo $controller->topyear . '—';
echo '</div>';
Functions::sortFacts($controller->indifacts);
$factcount = 0;
foreach ($controller->indifacts as $fact) {
$controller->printTimeFact($fact);
$factcount++;
}
// print the age boxes
foreach ($controller->people as $p => $indi) {
$pid = $indi->getXref();
$ageyoffset = $baseyoffset + $controller->bheight * $p;
$col = $p % 6;
?>
<div id="agebox<?php
echo $p;
?>
" style="cursor:move; position:absolute; <?php
示例14: foreach
global $WT_TREE;
use Fisharebest\Webtrees\Functions\Functions;
define('WT_SCRIPT_NAME', 'expand_view.php');
require './includes/session.php';
header('Content-Type: text/html; charset=UTF-8');
$individual = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE);
if (!$individual || !$individual->canShow()) {
return I18N::translate('Private');
}
$facts = $individual->getFacts();
foreach ($individual->getSpouseFamilies() as $family) {
foreach ($family->getFacts() as $fact) {
$facts[] = $fact;
}
}
Functions::sortFacts($facts);
foreach ($facts as $fact) {
switch ($fact->getTag()) {
case 'ADDR':
case 'ALIA':
case 'ASSO':
case 'CHAN':
case 'CHIL':
case 'EMAIL':
case 'FAMC':
case 'FAMS':
case 'HUSB':
case 'NAME':
case 'NOTE':
case 'OBJE':
case 'PHON':
示例15: foreach
$chdod = $chchild->getDeathDate()->julianDay();
// Child’s Date of Death (Julian)
$chBLD = $chfulln . ', ' . $chdob . ', ' . $chdod;
array_push($chBLDarray, $chBLD);
}
}
// Get Spouse child’s details
$nam = $child->getAllNames();
$fulln = strip_tags($nam[0]['full']);
$fulmn = $fulln;
foreach ($nam as $n) {
if ($n['type'] === '_MARNM') {
$fulmn = strip_tags($n['full']);
}
}
$label = Functions::getCloseRelationshipName($person, $child);
$menu = new Menu($label);
print_pedigree_person_nav_cens($child->getXref(), $label, $censyear);
$submenu = new Menu($spouselinks);
$menu->addSubmenu($submenu);
?>
<tr>
<td align="left" class="linkcell optionbox">
<?php
echo $menu->getMenu();
?>
</td>
<td align="left" class="facts_value">
<?php
echo "<a href=\"edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=" . $child->getXref() . "&gedcom=" . $child->getTree()->getNameUrl() . "\">";
echo $headImg2;