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


PHP Preferences::defaultPreferences方法代码示例

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


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

示例1: getPreferences

 static function getPreferences($user)
 {
     if (self::$defaultPreferences) {
         return self::$defaultPreferences;
     }
     global $wgRCMaxAge;
     $defaultPreferences = array();
     self::profilePreferences($user, $defaultPreferences);
     self::skinPreferences($user, $defaultPreferences);
     self::filesPreferences($user, $defaultPreferences);
     self::mathPreferences($user, $defaultPreferences);
     self::datetimePreferences($user, $defaultPreferences);
     self::renderingPreferences($user, $defaultPreferences);
     self::editingPreferences($user, $defaultPreferences);
     self::rcPreferences($user, $defaultPreferences);
     self::watchlistPreferences($user, $defaultPreferences);
     self::searchPreferences($user, $defaultPreferences);
     self::miscPreferences($user, $defaultPreferences);
     wfRunHooks('GetPreferences', array($user, &$defaultPreferences));
     ## Remove preferences that wikis don't want to use
     global $wgHiddenPrefs;
     foreach ($wgHiddenPrefs as $pref) {
         if (isset($defaultPreferences[$pref])) {
             unset($defaultPreferences[$pref]);
         }
     }
     ## Prod in defaults from the user
     global $wgDefaultUserOptions;
     foreach ($defaultPreferences as $name => &$info) {
         $prefFromUser = self::getOptionFromUser($name, $info, $user);
         $field = HTMLForm::loadInputFromParameters($info);
         // For validation
         $defaultOptions = User::getDefaultOptions();
         $globalDefault = isset($defaultOptions[$name]) ? $defaultOptions[$name] : null;
         // If it validates, set it as the default
         if (isset($info['default'])) {
             // Already set, no problem
             continue;
         } elseif (!is_null($prefFromUser) && $field->validate($prefFromUser, $user->mOptions) === true) {
             $info['default'] = $prefFromUser;
         } elseif ($field->validate($globalDefault, $user->mOptions) === true) {
             $info['default'] = $globalDefault;
         } else {
             throw new MWException("Global default '{$globalDefault}' is invalid for field {$name}");
         }
     }
     self::$defaultPreferences = $defaultPreferences;
     return $defaultPreferences;
 }
开发者ID:rocLv,项目名称:conference,代码行数:49,代码来源:Preferences.php

示例2: getPreferences

	/**
	 * @throws MWException
	 * @param $user User
	 * @param $context IContextSource
	 * @return array|null
	 */
	static function getPreferences( $user, IContextSource $context ) {
		if ( self::$defaultPreferences ) {
			return self::$defaultPreferences;
		}

		$defaultPreferences = array();

		self::profilePreferences( $user, $context, $defaultPreferences );
		self::skinPreferences( $user, $context, $defaultPreferences );
		self::filesPreferences( $user, $context, $defaultPreferences );
		self::datetimePreferences( $user, $context, $defaultPreferences );
		self::renderingPreferences( $user, $context, $defaultPreferences );
		self::editingPreferences( $user, $context, $defaultPreferences );
		self::rcPreferences( $user, $context, $defaultPreferences );
		self::watchlistPreferences( $user, $context, $defaultPreferences );
		self::searchPreferences( $user, $context, $defaultPreferences );
		self::miscPreferences( $user, $context, $defaultPreferences );

		wfRunHooks( 'GetPreferences', array( $user, &$defaultPreferences ) );

		## Remove preferences that wikis don't want to use
		global $wgHiddenPrefs;
		foreach ( $wgHiddenPrefs as $pref ) {
			if ( isset( $defaultPreferences[$pref] ) ) {
				unset( $defaultPreferences[$pref] );
			}
		}

		## Make sure that form fields have their parent set. See bug 41337.
		$dummyForm = new HTMLForm( array(), $context );

		$disable = !$user->isAllowed( 'editmyoptions' );

		## Prod in defaults from the user
		foreach ( $defaultPreferences as $name => &$info ) {
			$prefFromUser = self::getOptionFromUser( $name, $info, $user );
			if ( $disable && !in_array( $name, self::$saveBlacklist ) ) {
				$info['disabled'] = 'disabled';
			}
			$field = HTMLForm::loadInputFromParameters( $name, $info ); // For validation
			$field->mParent = $dummyForm;
			$defaultOptions = User::getDefaultOptions();
			$globalDefault = isset( $defaultOptions[$name] )
				? $defaultOptions[$name]
				: null;

			// If it validates, set it as the default
			if ( isset( $info['default'] ) ) {
				// Already set, no problem
				continue;
			} elseif ( !is_null( $prefFromUser ) && // Make sure we're not just pulling nothing
					$field->validate( $prefFromUser, $user->getOptions() ) === true ) {
				$info['default'] = $prefFromUser;
			} elseif ( $field->validate( $globalDefault, $user->getOptions() ) === true ) {
				$info['default'] = $globalDefault;
			} else {
				throw new MWException( "Global default '$globalDefault' is invalid for field $name" );
			}
		}

		self::$defaultPreferences = $defaultPreferences;

		return $defaultPreferences;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:70,代码来源:Preferences.php

示例3: getPreferences

 /**
  * @throws MWException
  * @param User $user
  * @param IContextSource $context
  * @return array|null
  */
 static function getPreferences($user, IContextSource $context)
 {
     if (self::$defaultPreferences) {
         return self::$defaultPreferences;
     }
     $defaultPreferences = array();
     self::profilePreferences($user, $context, $defaultPreferences);
     self::skinPreferences($user, $context, $defaultPreferences);
     self::datetimePreferences($user, $context, $defaultPreferences);
     self::filesPreferences($user, $context, $defaultPreferences);
     self::renderingPreferences($user, $context, $defaultPreferences);
     self::editingPreferences($user, $context, $defaultPreferences);
     self::rcPreferences($user, $context, $defaultPreferences);
     self::watchlistPreferences($user, $context, $defaultPreferences);
     self::searchPreferences($user, $context, $defaultPreferences);
     self::miscPreferences($user, $context, $defaultPreferences);
     Hooks::run('GetPreferences', array($user, &$defaultPreferences));
     self::loadPreferenceValues($user, $context, $defaultPreferences);
     self::$defaultPreferences = $defaultPreferences;
     return $defaultPreferences;
 }
开发者ID:guochangjiang,项目名称:mediawiki,代码行数:27,代码来源:Preferences.php


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