本文整理汇总了PHP中Fisharebest\Webtrees\Tree::getPreference方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::getPreference方法的具体用法?PHP Tree::getPreference怎么用?PHP Tree::getPreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Tree
的用法示例。
在下文中一共展示了Tree::getPreference方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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: searchAndReplace
/**
* Performs a search and replace
*
* @param Tree $tree
*/
private function searchAndReplace(Tree $tree)
{
$this->generalSearch();
//-- don't try to make any changes if nothing was found
if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) {
return;
}
Log::addEditLog("Search And Replace old:" . $this->query . " new:" . $this->replace);
$adv_name_tags = preg_split("/[\\s,;: ]+/", $tree->getPreference('ADVANCED_NAME_FACTS'));
$name_tags = array_unique(array_merge(Config::standardNameFacts(), $adv_name_tags));
$name_tags[] = '_MARNM';
$records_updated = 0;
foreach ($this->myindilist as $id => $record) {
$old_record = $record->getGedcom();
$new_record = $old_record;
if ($this->replaceAll) {
$new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record);
} else {
if ($this->replaceNames) {
foreach ($name_tags as $tag) {
$new_record = preg_replace("~(\\d) " . $tag . " (.*)" . $this->query . "(.*)~i", "\$1 " . $tag . " \$2" . $this->replace . "\$3", $new_record);
}
}
if ($this->replacePlaces) {
if ($this->replacePlacesWord) {
$new_record = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $this->query . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $new_record);
} else {
$new_record = preg_replace("~(\\d) PLAC (.*)" . $this->query . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $new_record);
}
}
}
//-- if the record changed replace the record otherwise remove it from the search results
if ($new_record !== $old_record) {
$record->updateRecord($new_record, true);
$records_updated++;
} else {
unset($this->myindilist[$id]);
}
}
if ($records_updated) {
FlashMessages::addMessage(I18N::plural('%s individual has been updated.', '%s individuals have been updated.', $records_updated, I18N::number($records_updated)));
}
$records_updated = 0;
foreach ($this->myfamlist as $id => $record) {
$old_record = $record->getGedcom();
$new_record = $old_record;
if ($this->replaceAll) {
$new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record);
} else {
if ($this->replacePlaces) {
if ($this->replacePlacesWord) {
$new_record = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $this->query . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $new_record);
} else {
$new_record = preg_replace("~(\\d) PLAC (.*)" . $this->query . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $new_record);
}
}
}
//-- if the record changed replace the record otherwise remove it from the search results
if ($new_record !== $old_record) {
$record->updateRecord($new_record, true);
$records_updated++;
} else {
unset($this->myfamlist[$id]);
}
}
if ($records_updated) {
FlashMessages::addMessage(I18N::plural('%s family has been updated.', '%s families have been updated.', $records_updated, I18N::number($records_updated)));
}
$records_updated = 0;
foreach ($this->mysourcelist as $id => $record) {
$old_record = $record->getGedcom();
$new_record = $old_record;
if ($this->replaceAll) {
$new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record);
} else {
if ($this->replaceNames) {
$new_record = preg_replace("~(\\d) TITL (.*)" . $this->query . "(.*)~i", "\$1 TITL \$2" . $this->replace . "\$3", $new_record);
$new_record = preg_replace("~(\\d) ABBR (.*)" . $this->query . "(.*)~i", "\$1 ABBR \$2" . $this->replace . "\$3", $new_record);
}
if ($this->replacePlaces) {
if ($this->replacePlacesWord) {
$new_record = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $this->query . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $new_record);
} else {
$new_record = preg_replace("~(\\d) PLAC (.*)" . $this->query . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $new_record);
}
}
}
//-- if the record changed replace the record otherwise remove it from the search results
if ($new_record !== $old_record) {
$record->updateRecord($new_record, true);
$records_updated++;
} else {
unset($this->mysourcelist[$id]);
}
}
//.........这里部分代码省略.........
示例4: reformatRecord
//.........这里部分代码省略.........
break;
case 'STATE':
$tag = 'STAE';
break;
case 'STATUS':
$tag = 'STAT';
case 'STAT':
if ($data == 'CANCELLED') {
// PhpGedView mis-spells this tag - correct it.
$data = 'CANCELED';
}
break;
case 'SUBMISSION':
$tag = 'SUBN';
break;
case 'SUBMITTER':
$tag = 'SUBM';
break;
case 'SURNAME':
$tag = 'SURN';
break;
case 'SURN_PREFIX':
$tag = 'SPFX';
break;
case 'TEMPLE':
$tag = 'TEMP';
case 'TEMP':
// Temple codes are upper case
$data = strtoupper($data);
break;
case 'TITLE':
$tag = 'TITL';
break;
case 'TRAILER':
$tag = 'TRLR';
case 'TRLR':
// TRLR records don't have an XREF or DATA
if ($level == '0') {
$xref = '';
$data = '';
}
break;
case 'VERSION':
$tag = 'VERS';
break;
case 'WEB':
$tag = 'WWW';
break;
}
// Suppress "Y", for facts/events with a DATE or PLAC
if ($data == 'y') {
$data = 'Y';
}
if ($level == '1' && $data == 'Y') {
for ($i = $n + 1; $i < $num_matches - 1 && $matches[$i][1] != '1'; ++$i) {
if ($matches[$i][3] == 'DATE' || $matches[$i][3] == 'PLAC') {
$data = '';
break;
}
}
}
// Reassemble components back into a single line
switch ($tag) {
default:
// Remove tabs and multiple/leading/trailing spaces
if (strpos($data, "\t") !== false) {
$data = str_replace("\t", ' ', $data);
}
if (substr($data, 0, 1) == ' ' || substr($data, -1, 1) == ' ') {
$data = trim($data);
}
while (strpos($data, ' ')) {
$data = str_replace(' ', ' ', $data);
}
$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
break;
case 'NOTE':
case 'TEXT':
case 'DATA':
case 'CONT':
$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
break;
case 'FILE':
// Strip off the user-defined path prefix
$GEDCOM_MEDIA_PATH = $tree->getPreference('GEDCOM_MEDIA_PATH');
if ($GEDCOM_MEDIA_PATH && strpos($data, $GEDCOM_MEDIA_PATH) === 0) {
$data = substr($data, strlen($GEDCOM_MEDIA_PATH));
}
// convert backslashes in filenames to forward slashes
$data = preg_replace("/\\\\/", "/", $data);
$newrec .= ($newrec ? "\n" : '') . $level . ' ' . ($level == '0' && $xref ? $xref . ' ' : '') . $tag . ($data === '' && $tag != "NOTE" ? '' : ' ' . $data);
break;
case 'CONC':
// Merge CONC lines, to simplify access later on.
$newrec .= ($tree->getPreference('WORD_WRAPPED_NOTES') ? ' ' : '') . $data;
break;
}
}
return $newrec;
}
示例5: formatText
/**
* Format block-level text such as notes or transcripts, etc.
*
* @param string $text
* @param Tree $WT_TREE
*
* @return string
*/
public static function formatText($text, Tree $WT_TREE)
{
switch ($WT_TREE->getPreference('FORMAT_TEXT')) {
case 'markdown':
return '<div class="markdown" dir="auto">' . self::markdown($text) . '</div>';
default:
return '<div style="white-space: pre-wrap;" dir="auto">' . self::expandUrls($text) . '</div>';
}
}
示例6: getCommonSurnames
/**
* Get array of common surnames
*
* This function returns a simple array of the most common surnames
* found in the individuals list.
*
* @param int $min The number of times a surname must occur before it is added to the array
* @param Tree $tree
*
* @return mixed[][]
*/
public static function getCommonSurnames($min, Tree $tree)
{
$COMMON_NAMES_ADD = $tree->getPreference('COMMON_NAMES_ADD');
$COMMON_NAMES_REMOVE = $tree->getPreference('COMMON_NAMES_REMOVE');
$topsurns = self::getTopSurnames($tree->getTreeId(), $min, 0);
foreach (explode(',', $COMMON_NAMES_ADD) as $surname) {
if ($surname && !array_key_exists($surname, $topsurns)) {
$topsurns[$surname] = $min;
}
}
foreach (explode(',', $COMMON_NAMES_REMOVE) as $surname) {
unset($topsurns[I18N::strtoupper($surname)]);
}
//-- check if we found some, else recurse
if (empty($topsurns) && $min > 2) {
return self::getCommonSurnames($min / 2, $tree);
} else {
uksort($topsurns, '\\Fisharebest\\Webtrees\\I18N::strcasecmp');
foreach ($topsurns as $key => $value) {
$topsurns[$key] = array('name' => $key, 'match' => $value);
}
return $topsurns;
}
}