当前位置: 首页>>代码示例>>PHP>>正文


PHP Site::setPreference方法代码示例

本文整理汇总了PHP中Fisharebest\Webtrees\Site::setPreference方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::setPreference方法的具体用法?PHP Site::setPreference怎么用?PHP Site::setPreference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fisharebest\Webtrees\Site的用法示例。


在下文中一共展示了Site::setPreference方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hookAfterInit

 /**
  * Create resources for the colors theme.
  */
 public function hookAfterInit()
 {
     $this->palettes = array('aquamarine' => I18N::translate('Aqua Marine'), 'ash' => I18N::translate('Ash'), 'belgianchocolate' => I18N::translate('Belgian Chocolate'), 'bluelagoon' => I18N::translate('Blue Lagoon'), 'bluemarine' => I18N::translate('Blue Marine'), 'coffeeandcream' => I18N::translate('Coffee and Cream'), 'coldday' => I18N::translate('Cold Day'), 'greenbeam' => I18N::translate('Green Beam'), 'mediterranio' => I18N::translate('Mediterranio'), 'mercury' => I18N::translate('Mercury'), 'nocturnal' => I18N::translate('Nocturnal'), 'olivia' => I18N::translate('Olivia'), 'pinkplastic' => I18N::translate('Pink Plastic'), 'sage' => I18N::translate('Sage'), 'shinytomato' => I18N::translate('Shiny Tomato'), 'tealtop' => I18N::translate('Teal Top'));
     uasort($this->palettes, '\\Fisharebest\\Webtrees\\I18N::strcasecmp');
     // If we've selected a new palette, and we are logged in, set this value as a default.
     if (isset($_GET['themecolor']) && array_key_exists($_GET['themecolor'], $this->palettes)) {
         // Request to change color
         $this->palette = $_GET['themecolor'];
         Auth::user()->setPreference('themecolor', $this->palette);
         if (Auth::isAdmin()) {
             Site::setPreference('DEFAULT_COLOR_PALETTE', $this->palette);
         }
         unset($_GET['themecolor']);
         // Rember that we have selected a value
         Session::put('subColor', $this->palette);
     }
     // If we are logged in, use our preference
     $this->palette = Auth::user()->getPreference('themecolor');
     // If not logged in or no preference, use one we selected earlier in the session?
     if (!$this->palette) {
         $this->palette = Session::get('subColor');
     }
     // We haven't selected one this session? Use the site default
     if (!$this->palette) {
         $this->palette = Site::getPreference('DEFAULT_COLOR_PALETTE');
     }
     // Make sure our selected palette actually exists
     if (!array_key_exists($this->palette, $this->palettes)) {
         $this->palette = 'ash';
     }
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:34,代码来源:ColorsTheme.php

示例2: 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');
     }
 }
开发者ID:jflash,项目名称:webtrees,代码行数:28,代码来源:Functions.php

示例3: header

    case 'tracking':
        if (Filter::checkCsrf()) {
            Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
            Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
            Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
            Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
            Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
            Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
            Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
            FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        }
        header('Location: ' . WT_BASE_URL . 'admin.php');
        return;
    case 'languages':
        if (Filter::checkCsrf()) {
            Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
            FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        }
        header('Location: ' . WT_BASE_URL . 'admin.php');
        return;
}
// Lists of options for <select> controls.
$SMTP_SSL_OPTIONS = array('none' => I18N::translate('none'), 'ssl' => I18N::translate('ssl'), 'tls' => I18N::translate('tls'));
$SMTP_ACTIVE_OPTIONS = array('internal' => I18N::translate('Use PHP mail to send messages'), 'external' => I18N::translate('Use SMTP to send messages'));
$WELCOME_TEXT_AUTH_MODE_OPTIONS = array(0 => I18N::translate('No predefined text'), 1 => I18N::translate('Predefined text that states all users can request a user account'), 2 => I18N::translate('Predefined text that states admin will decide on each request for a user account'), 3 => I18N::translate('Predefined text that states only family members can request a user account'), 4 => I18N::translate('Choose user defined welcome text typed below'));
$language_tags = array();
foreach (I18N::activeLocales() as $active_locale) {
    $language_tags[] = $active_locale->languageTag();
}
switch (Filter::get('action')) {
    case 'site':
开发者ID:AlexSnet,项目名称:webtrees,代码行数:31,代码来源:admin_site_config.php

示例4: array

    $gedcom_files = array_merge(glob(WT_DATA_DIR . '*.ged', GLOB_NOSORT) ?: array(), glob(WT_DATA_DIR . '*.Ged', GLOB_NOSORT) ?: array(), glob(WT_DATA_DIR . '*.GED', GLOB_NOSORT) ?: array());
}
// Process POST actions
switch (Filter::post('action')) {
    case 'delete':
        $gedcom_id = Filter::postInteger('gedcom_id');
        if (Filter::checkCsrf() && $gedcom_id) {
            $tree = Tree::findById($gedcom_id);
            FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success');
            $tree->delete();
        }
        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
        return;
    case 'setdefault':
        if (Filter::checkCsrf()) {
            Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged'));
            FlashMessages::addMessage(I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success');
        }
        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
        return;
    case 'new_tree':
        $basename = basename(Filter::post('tree_name'));
        $tree_title = Filter::post('tree_title');
        if (Filter::checkCsrf() && $basename && $tree_title) {
            if (Tree::findByName($basename)) {
                FlashMessages::addMessage(I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger');
            } else {
                Tree::create($basename, $tree_title);
                FlashMessages::addMessage(I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success');
            }
        }
开发者ID:AlexSnet,项目名称:webtrees,代码行数:31,代码来源:admin_trees_manage.php

示例5: 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;
 }
开发者ID:AlexSnet,项目名称:webtrees,代码行数:24,代码来源:Tree.php

示例6: 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;
     $sendmail = $this->getBlockSetting($block_id, 'sendmail', '1');
     $days = $this->getBlockSetting($block_id, 'days', '1');
     $block = $this->getBlockSetting($block_id, 'block', '1');
     foreach (array('days', 'sendmail', 'block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $changes = Database::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne();
     if ($changes === '1' && $sendmail === '1') {
         // There are pending changes - tell moderators/managers/administrators about them.
         if (WT_TIMESTAMP - Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) {
             // Which users have pending changes?
             foreach (User::all() as $user) {
                 if ($user->getPreference('contactmethod') !== 'none') {
                     foreach (Tree::getAll() as $tree) {
                         if ($tree->hasPendingEdit() && Auth::isManager($tree, $user)) {
                             I18N::init($user->getPreference('language'));
                             Mail::systemMessage($tree, $user, I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>');
                             I18N::init(WT_LOCALE);
                         }
                     }
                 }
             }
             Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP);
         }
     }
     if (Auth::isEditor($WT_TREE) && $WT_TREE->hasPendingEdit()) {
         $id = $this->getName() . $block_id;
         $class = $this->getName() . '_block';
         if ($ctype === 'user' || Auth::isManager($WT_TREE)) {
             $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
         } else {
             $title = '';
         }
         $title .= $this->getTitle();
         $content = '';
         if (Auth::isModerator($WT_TREE)) {
             $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . I18N::translate('There are pending changes for you to moderate.') . "</a><br>";
         }
         if ($sendmail === '1') {
             $content .= I18N::translate('Last email reminder was sent ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>";
             $content .= I18N::translate('Next email reminder will be sent after ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>";
         }
         $content .= '<ul>';
         $changes = Database::prepare("SELECT xref" . " FROM  `##change`" . " WHERE status='pending'" . " AND   gedcom_id=?" . " GROUP BY xref")->execute(array($WT_TREE->getTreeId()))->fetchAll();
         foreach ($changes as $change) {
             $record = GedcomRecord::getInstance($change->xref, $WT_TREE);
             if ($record->canShow()) {
                 $content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>';
             }
         }
         $content .= '</ul>';
         if ($template) {
             if ($block) {
                 $class .= ' small_inner_block';
             }
             return Theme::theme()->formatBlock($id, $title, $class, $content);
         } else {
             return $content;
         }
     }
 }
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:75,代码来源:ReviewChangesModule.php

示例7: 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;
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:38,代码来源:Database.php

示例8: IN

Database::exec("DELETE FROM `##user` WHERE user_id>0");
////////////////////////////////////////////////////////////////////////////////
echo '<p>', $INDEX_DIRECTORY, 'config.php => wt_site_setting…</p>';
Site::setPreference('USE_REGISTRATION_MODULE', $USE_REGISTRATION_MODULE);
Site::setPreference('ALLOW_USER_THEMES', $ALLOW_USER_THEMES);
Site::setPreference('ALLOW_CHANGE_GEDCOM', $ALLOW_CHANGE_GEDCOM);
Site::setPreference('SESSION_TIME', $PGV_SESSION_TIME);
Site::setPreference('SMTP_ACTIVE', $PGV_SMTP_ACTIVE ? 'external' : 'internal');
Site::setPreference('SMTP_HOST', $PGV_SMTP_HOST);
Site::setPreference('SMTP_HELO', $PGV_SMTP_HELO);
Site::setPreference('SMTP_PORT', $PGV_SMTP_PORT);
Site::setPreference('SMTP_AUTH', $PGV_SMTP_AUTH);
Site::setPreference('SMTP_AUTH_USER', $PGV_SMTP_AUTH_USER);
Site::setPreference('SMTP_AUTH_PASS', $PGV_SMTP_AUTH_PASS);
Site::setPreference('SMTP_SSL', $PGV_SMTP_SSL);
Site::setPreference('SMTP_FROM_NAME', $PGV_SMTP_FROM_NAME);
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_site_setting => wt_site_setting…</p>';
Database::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value)" . " SELECT site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" . " WHERE site_setting_name IN ('DEFAULT_GEDCOM', 'LAST_CHANGE_EMAIL')")->execute();
////////////////////////////////////////////////////////////////////////////////
if ($PGV_SCHEMA_VERSION >= 12) {
    echo '<p>pgv_gedcom => wt_gedcom…</p>';
    Database::prepare("INSERT INTO `##gedcom` (gedcom_id, gedcom_name)" . " SELECT gedcom_id, gedcom_name FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom`")->execute();
    echo '<p>pgv_gedcom_setting => wt_gedcom_setting…</p>';
    Database::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . " SELECT gedcom_id, setting_name," . "  CASE setting_name" . "  WHEN 'THEME_DIR' THEN" . "   CASE setting_value" . "   WHEN ''                    THEN ''" . "   WHEN 'themes/cloudy/'      THEN 'clouds'" . "   WHEN 'themes/minimal/'     THEN 'minimal'" . "   WHEN 'themes/simplyblue/'  THEN 'colors'" . "   WHEN 'themes/simplygreen/' THEN 'colors'" . "   WHEN 'themes/simplyred/'   THEN 'colors'" . "   WHEN 'themes/xenea/'       THEN 'xenea'" . "   ELSE 'themes/webtrees/'" . "  END" . "  WHEN 'LANGUAGE' THEN" . "   CASE setting_value" . "   WHEN 'arabic'     THEN 'ar'" . "   WHEN 'catalan'    THEN 'ca'" . "   WHEN 'chinese'    THEN 'zh_CN'" . "   WHEN 'croatian'   THEN 'hr'" . "   WHEN 'danish'     THEN 'da'" . "   WHEN 'dutch'      THEN 'nl'" . "   WHEN 'english'    THEN 'en_US'" . "   WHEN 'english-uk' THEN 'en_GB'" . "   WHEN 'estonian'   THEN 'et'" . "   WHEN 'finnish'    THEN 'fi'" . "   WHEN 'french'     THEN 'fr'" . "   WHEN 'german'     THEN 'de'" . "   WHEN 'greek'      THEN 'el'" . "   WHEN 'hebrew'     THEN 'he'" . "   WHEN 'hungarian'  THEN 'hu'" . "   WHEN 'indonesian' THEN 'id'" . "   WHEN 'italian'    THEN 'it'" . "   WHEN 'lithuanian' THEN 'lt'" . "   WHEN 'norwegian'  THEN 'nn'" . "   WHEN 'polish'     THEN 'pl'" . "   WHEN 'portuguese' THEN 'pt'" . "   WHEN 'romainian'  THEN 'ro'" . "   WHEN 'russian'    THEN 'ru'" . "   WHEN 'serbian-la' THEN 'sr@Latn'" . "   WHEN 'slovak'     THEN 'sk'" . "   WHEN 'slovenian'  THEN 'sl'" . "   WHEN 'spanish'    THEN 'es'" . "   WHEN 'spanish-ar' THEN 'es'" . "   WHEN 'swedish'    THEN 'sv'" . "   WHEN 'turkish'    THEN 'tr'" . "   WHEN 'vietnamese' THEN 'vi'" . "   ELSE 'en_US'" . "  END" . "  ELSE setting_value" . "  END" . " FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom_setting`" . " WHERE setting_name NOT IN ('HOME_SITE_TEXT', 'HOME_SITE_URL')")->execute();
    echo '<p>pgv_user => wt_user…</p>';
    try {
        // "INSERT IGNORE" is needed to allow for PhpGedView users with duplicate emails. Only the first will be imported.
        Database::prepare("INSERT IGNORE INTO `##user` (user_id, user_name, real_name, email, password)" . " SELECT user_id, user_name, CONCAT_WS(' ', us1.setting_value, us2.setting_value), us3.setting_value, password FROM `{$DBNAME}`.`{$TBLPREFIX}user`" . " LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us1 USING (user_id)" . " LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us2 USING (user_id)" . " JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us3 USING (user_id)" . " WHERE us1.setting_name='firstname'" . " AND us2.setting_name='lastname'" . " AND us3.setting_name='email'")->execute();
    } catch (PDOException $ex) {
        // Ignore duplicates
开发者ID:tronsmit,项目名称:webtrees,代码行数:31,代码来源:admin_pgv_to_wt.php


注:本文中的Fisharebest\Webtrees\Site::setPreference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。