本文整理汇总了PHP中Fisharebest\Webtrees\Site::getPreference方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::getPreference方法的具体用法?PHP Site::getPreference怎么用?PHP Site::getPreference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Site
的用法示例。
在下文中一共展示了Site::getPreference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/**
* Upgrade to to the next version
*/
public function upgrade()
{
$index_dir = Site::getPreference('INDEX_DIRECTORY');
// Due to the language code changes in 1.7.0, we need to update some other settings
foreach ($this->languages as $old => $new) {
try {
Database::prepare("UPDATE `##site_setting` SET setting_name = REPLACE(setting_name, :old, :new) " . "WHERE setting_name LIKE 'WELCOME_TEXT_AUTH_MODE_%'")->execute(array('old' => $old, 'new' => $new));
} catch (PDOException $ex) {
// Duplicate key? Already done?
}
Database::prepare("UPDATE `##block_setting` SET setting_value = REPLACE(setting_value, :old, :new) " . "WHERE setting_name = 'languages'")->execute(array('old' => $old, 'new' => $new));
// Historical fact files
if (file_exists($index_dir . 'histo.' . $old . '.php') && !file_exists($index_dir . 'histo.' . $new . '.php')) {
rename($index_dir . 'histo.' . $old . '.php', $index_dir . 'histo.' . $new . '.php');
}
// Language files
if (file_exists($index_dir . 'language/' . $old . '.php') && !file_exists($index_dir . 'language/' . $new . '.php')) {
rename($index_dir . 'language/' . $old . '.php', $index_dir . 'language/' . $new . '.php');
}
if (file_exists($index_dir . 'language/' . $old . '.csv') && !file_exists($index_dir . 'language/' . $new . '.csv')) {
rename($index_dir . 'language/' . $old . '.csv', $index_dir . 'language/' . $new . '.csv');
}
if (file_exists($index_dir . 'language/' . $old . '.mo') && !file_exists($index_dir . 'language/' . $new . '.mo')) {
rename($index_dir . 'language/' . $old . '.mo', $index_dir . 'language/' . $new . '.mo');
}
}
}
示例2: cookieWarning
/** {@inheritdoc} */
public function cookieWarning()
{
if (empty($_SERVER['HTTP_DNT']) && empty($_COOKIE['cookie']) && (Site::getPreference('GOOGLE_ANALYTICS_ID') || Site::getPreference('PIWIK_SITE_ID') || Site::getPreference('STATCOUNTER_PROJECT_ID'))) {
$cookie_warning = '<div class="cookie-warning">' . I18N::translate('Cookies') . ' - ' . I18N::translate('This website uses cookies to learn about visitor behaviour.') . '</div>';
return $this->htmlAlert($cookie_warning, 'info', true);
} else {
return '';
}
}
示例3: fetchLatestVersion
/**
* Check with the webtrees.net server for the latest version of webtrees.
* Fetching the remote file can be slow, so check infrequently, and cache the result.
* Pass the current versions of webtrees, PHP and MySQL, as the response
* may be different for each. The server logs are used to generate
* installation statistics which can be found at http://svn.webtrees.net/statistics.html
*
* @return null|string
*/
public static function fetchLatestVersion()
{
$last_update_timestamp = Site::getPreference('LATEST_WT_VERSION_TIMESTAMP');
if ($last_update_timestamp < WT_TIMESTAMP - 24 * 60 * 60) {
$row = Database::prepare("SHOW VARIABLES LIKE 'version'")->fetchOneRow();
$params = '?w=' . WT_VERSION . '&p=' . PHP_VERSION . '&m=' . $row->value . '&o=' . (DIRECTORY_SEPARATOR === '/' ? 'u' : 'w');
$latest_version_txt = File::fetchUrl('http://dev.webtrees.net/build/latest-version.txt' . $params);
if ($latest_version_txt) {
Site::setPreference('LATEST_WT_VERSION', $latest_version_txt);
Site::setPreference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP);
return $latest_version_txt;
} else {
// Cannot connect to server - use cached version (if we have one)
return Site::getPreference('LATEST_WT_VERSION');
}
} else {
return Site::getPreference('LATEST_WT_VERSION');
}
}
示例4: activeLocales
/**
* The prefered locales for this site, or a default list if no preference.
*
* @return LocaleInterface[]
*/
public static function activeLocales()
{
$code_list = Site::getPreference('LANGUAGES');
if ($code_list) {
$codes = explode(',', $code_list);
} else {
$codes = array('ar', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', 'en-US', 'es', 'et', 'fi', 'fr', 'he', 'hr', 'hu', 'is', 'it', 'ka', 'lt', 'mr', 'nb', 'nl', 'nn', 'pl', 'pt', 'ru', 'sk', 'sv', 'tr', 'uk', 'vi', 'zh-Hans');
}
$locales = array();
foreach ($codes as $code) {
if (file_exists(WT_ROOT . 'language/' . $code . '.mo')) {
try {
$locales[] = Locale::create($code);
} catch (\Exception $ex) {
// No such locale exists?
}
}
}
usort($locales, '\\Fisharebest\\Localization\\Locale::compare');
return $locales;
}
示例5: 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 $controller, $WT_TREE;
$indi_xref = $controller->getSignificantIndividual()->getXref();
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
$title = $WT_TREE->getTitleHtml();
$content = '<table><tr>';
$content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '</a></td>';
$content .= '<td><a href="individual.php?pid=' . $indi_xref . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '</a></td>';
if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) {
$content .= '<td><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . I18N::translate('Request new user account') . '</a></td>';
}
$content .= "</tr>";
$content .= "</table>";
if ($template) {
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
示例6: delete
/**
* Delete everything relating to a tree
*/
public function delete()
{
// If this is the default tree, then unset it
if (Site::getPreference('DEFAULT_GEDCOM') === $this->name) {
Site::setPreference('DEFAULT_GEDCOM', '');
}
$this->deleteGenealogyData(false);
Database::prepare("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE gedcom_id=?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##block` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##user_gedcom_setting` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##gedcom_setting` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##module_privacy` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##next_id` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##hit_counter` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##default_resn` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##log` WHERE gedcom_id = ?")->execute(array($this->tree_id));
Database::prepare("DELETE FROM `##gedcom` WHERE gedcom_id = ?")->execute(array($this->tree_id));
// After updating the database, we need to fetch a new (sorted) copy
self::$trees = null;
}
示例7: array
echo I18N::translate('members');
?>
</span>
</div>
</div>
<div class="col-sm-8">
<?php
echo FunctionsEdit::selectEditControl('REQUIRE_AUTHENTICATION', array('0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')), null, $WT_TREE->getPreference('REQUIRE_AUTHENTICATION'), 'class="form-control"');
?>
<p class="small text-muted">
<?php
echo I18N::translate('Enabling this option will force all visitors to sign in before they can view any data on the website.');
?>
</p>
<?php
if (Site::getPreference('USE_REGISTRATION_MODULE')) {
?>
<p class="small text-muted">
<?php
echo I18N::translate('If visitors can not see the family tree, they will not be able to sign up for an account. You will need to add their account manually.');
?>
</p>
<?php
}
?>
</div>
</div>
<!-- SHOW_DEAD_PEOPLE -->
<div class="form-group">
<div class="control-label col-sm-4">
示例8: historicalFacts
/**
* Get any historical events.
*
* @param Individual $person
*
* @return Fact[]
*/
private static function historicalFacts(Individual $person)
{
$SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
$facts = array();
if ($SHOW_RELATIVES_EVENTS) {
// Only include events between birth and death
$birt_date = $person->getEstimatedBirthDate();
$deat_date = $person->getEstimatedDeathDate();
if (file_exists(Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
$histo = array();
require Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php';
foreach ($histo as $hist) {
// Earlier versions of the WIKI encouraged people to use HTML entities,
// rather than UTF8 encoding.
$hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8');
$fact = new Fact($hist, $person, 'histo');
$sdate = $fact->getDate();
if ($sdate->isOK() && Date::compare($birt_date, $sdate) <= 0 && Date::compare($sdate, $deat_date) <= 0) {
$facts[] = $fact;
}
}
}
}
return $facts;
}
示例9: menuThemes
/**
* Themes menu.
*
* @return Menu|null
*/
public function menuThemes()
{
if ($this->tree && Site::getPreference('ALLOW_USER_THEMES') && $this->tree->getPreference('ALLOW_THEME_DROPDOWN')) {
$submenus = array();
foreach (Theme::installedThemes() as $theme) {
$class = 'menu-theme-' . $theme->themeId() . ($theme === $this ? ' active' : '');
$submenus[] = new Menu($theme->themeName(), '#', $class, array('onclick' => 'return false;', 'data-theme' => $theme->themeId()));
}
usort($submenus, function (Menu $x, Menu $y) {
return I18N::strcasecmp($x->getLabel(), $y->getLabel());
});
$menu = new Menu(I18N::translate('Theme'), '#', 'menu-theme', array(), $submenus);
return $menu;
} else {
return null;
}
}
示例10: renderContent
/**
* {@inhericDoc}
* @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
*/
protected function renderContent()
{
/** @var \Fisharebest\Webtrees\Individual $indi */
$indi = $this->data->get('indi');
/** @var \Fisharebest\Webtrees\Tree $tree */
$tree = $this->data->get('tree');
//Welcome section - gedcom title, date, statistics - based on gedcom_block
$content = '<table>
<tr>
<td>
<a href="pedigree.php?rootid=' . $indi->getXref() . '&ged=' . $tree->getNameUrl() . '">
<i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '
</a>
</td>
<td>
<a href="individual.php?pid=' . $indi->getXref() . '&ged=' . $tree->getNameUrl() . '">
<i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '
</a>
</td>';
if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) {
$content .= '
<td>
<a href="' . WT_LOGIN_URL . '?action=register">
<i class="icon-user_add"></i><br>' . I18N::translate('Request new user account') . '
</a>
</td>';
}
$content .= '
</tr>
</table>';
// Piwik Statistics
if ($this->data->get('piwik_enabled', false)) {
$content .= '
<div class="center">
<div id="piwik_stats">
<i class="icon-loading-small"></i> ' . I18N::translate('Retrieving Piwik statistics...') . '
</div>
</div>';
}
$content .= '<hr />';
// Login section - based on login_block
if (Auth::check()) {
$content .= '
<div class="center">
<form method="post" action="logout.php" name="logoutform" onsubmit="return true;">
<br>
<a href="edituser.php" class="name2">' . I18N::translate('Logged in as ') . ' ' . Auth::user()->getRealNameHtml() . '</a>
<br><br>
<input type="submit" value="' . I18N::translate('Logout') . '">
<br><br>
</form>
</div>';
} else {
$content .= '
<div id="maj-login-box">
<form id="maj-login-form" name="maj-login-form" method="post" action="' . WT_LOGIN_URL . '">
<input type="hidden" name="action" value="login">
<div>
<label for="maj-username">' . I18N::translate('Username') . '<input type="text" id="maj-username" name="username" class="formField">
</label>
</div>
<div>
<label for="maj-password">' . I18N::translate('Password') . '<input type="password" id="maj-password" name="password" class="formField">
</label>
</div>
<div>
<input type="submit" value="' . I18N::translate('Login') . '">
</div>
<div>
<a href="#" id="maj-passwd_click">' . I18N::translate('Request new password') . '</a>
</div>';
if (Site::getPreference('USE_REGISTRATION_MODULE')) {
$content .= '
<div>
<a href="' . WT_LOGIN_URL . '?action=register">' . I18N::translate('Request new user account') . '</a>
</div>';
}
$content .= '
</form>';
// close "login-form"
// hidden New Password block
$content .= '
<div id="maj-new_passwd">
<form id="maj-new_passwd_form" name="new_passwd_form" action="' . WT_LOGIN_URL . '" method="post">
<input type="hidden" name="time" value="">
<input type="hidden" name="action" value="requestpw">
<h4>' . I18N::translate('Lost password request') . '</h4>
<div>
<label for="maj-new_passwd_username">' . I18N::translate('Username or email address') . '
<input type="text" id="maj-new_passwd_username" name="new_passwd_username" value="">
</label>
</div>
<div>
<input type="submit" value="' . I18N::translate('Continue') . '">
</div>
</form>
//.........这里部分代码省略.........
示例11: transport
/**
* Create a transport mechanism for sending mail
*
* @return Swift_Transport
*/
public static function transport()
{
switch (Site::getPreference('SMTP_ACTIVE')) {
case 'internal':
return Swift_MailTransport::newInstance();
case 'external':
$transport = Swift_SmtpTransport::newInstance()->setHost(Site::getPreference('SMTP_HOST'))->setPort(Site::getPreference('SMTP_PORT'))->setLocalDomain(Site::getPreference('SMTP_HELO'));
if (Site::getPreference('SMTP_AUTH')) {
$transport->setUsername(Site::getPreference('SMTP_AUTH_USER'))->setPassword(Site::getPreference('SMTP_AUTH_PASS'));
}
if (Site::getPreference('SMTP_SSL') !== 'none') {
$transport->setEncryption(Site::getPreference('SMTP_SSL'));
}
return $transport;
default:
// For testing
return Swift_NullTransport::newInstance();
}
}
示例12: elseif
echo Filter::escapeHtml(Site::getPreference('STATCOUNTER_PROJECT_ID'));
?>
" maxlength="255" pattern="[0-9]+">
</div>
</div>
<!-- STATCOUNTER_SECURITY_ID -->
<div class="form-group">
<label for="STATCOUNTER_SECURITY_ID" class="col-sm-3 control-label">
<?php
echo I18N::translate('Security code');
?>
</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="STATCOUNTER_SECURITY_ID" name="STATCOUNTER_SECURITY_ID" value="<?php
echo Filter::escapeHtml(Site::getPreference('STATCOUNTER_SECURITY_ID'));
?>
" maxlength="255" pattern="[0-9a-zA-Z]+">
<p class="small text-muted">
<?php
echo I18N::translate('Tracking and analytics are not added to the control panel.');
?>
</p>
</div>
</div>
<?php
} elseif (Filter::get('action') === 'languages') {
?>
<input type="hidden" name="action" value="languages">
示例13: 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;
$title = $this->getBlockSetting($block_id, 'title');
$html = $this->getBlockSetting($block_id, 'html');
$gedcom = $this->getBlockSetting($block_id, 'gedcom');
$show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0');
$languages = $this->getBlockSetting($block_id, 'languages');
// Only show this block for certain languages
if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) {
return '';
}
/*
* Select GEDCOM
*/
switch ($gedcom) {
case '__current__':
$stats = new Stats($WT_TREE);
break;
case '__default__':
$tree = Tree::findByName(Site::getPreference('DEFAULT_GEDCOM'));
if ($tree) {
$stats = new Stats($tree);
} else {
$stats = new Stats($WT_TREE);
}
break;
default:
$tree = Tree::findByName($gedcom);
if ($tree) {
$stats = new Stats($tree);
} else {
$stats = new Stats($WT_TREE);
}
break;
}
/*
* Retrieve text, process embedded variables
*/
if (strpos($title, '#') !== false || strpos($html, '#') !== false) {
$title = $stats->embedTags($title);
$html = $stats->embedTags($html);
}
/*
* Start Of Output
*/
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
$title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>' . $title;
}
$content = $html;
if ($show_timestamp) {
$content .= '<br>' . FunctionsDate::formatTimestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET);
}
if ($template) {
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}
示例14: updateSchema
/**
* Run a series of scripts to bring the database schema up to date.
*
* @param string $namespace Where to find our MigrationXXX classes
* @param string $schema_name Where to find our MigrationXXX classes
* @param int $target_version updade/downgrade to this version
*
* @throws PDOException
*
* @return bool Were any updates applied
*/
public static function updateSchema($namespace, $schema_name, $target_version)
{
try {
$current_version = (int) Site::getPreference($schema_name);
} catch (PDOException $e) {
// During initial installation, the site_preference table won’t exist.
$current_version = 0;
}
$updates_applied = false;
try {
// Update the schema, one version at a time.
while ($current_version < $target_version) {
$class = $namespace . '\\Migration' . $current_version;
/** @var MigrationInterface $migration */
$migration = new $class();
$migration->upgrade();
Site::setPreference($schema_name, ++$current_version);
$updates_applied = true;
}
} catch (PDOException $ex) {
// The schema update scripts should never fail. If they do, there is no clean recovery.
FlashMessages::addMessage($ex->getMessage(), 'danger');
header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
throw $ex;
}
return $updates_applied;
}
示例15: transport
/**
* Create a transport mechanism for sending mail
*
* @return Zend_Mail_Transport_File|Zend_Mail_Transport_Smtp
*/
public static function transport()
{
switch (Site::getPreference('SMTP_ACTIVE')) {
case 'internal':
return new Zend_Mail_Transport_Sendmail();
case 'external':
$config = array('name' => Site::getPreference('SMTP_HELO'), 'port' => Site::getPreference('SMTP_PORT'));
if (Site::getPreference('SMTP_AUTH')) {
$config['auth'] = 'login';
$config['username'] = Site::getPreference('SMTP_AUTH_USER');
$config['password'] = Site::getPreference('SMTP_AUTH_PASS');
}
if (Site::getPreference('SMTP_SSL') !== 'none') {
$config['ssl'] = Site::getPreference('SMTP_SSL');
}
return new Zend_Mail_Transport_Smtp(Site::getPreference('SMTP_HOST'), $config);
default:
// For testing
return new Zend_Mail_Transport_File();
}
}