本文整理汇总了PHP中Skin::newFromKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Skin::newFromKey方法的具体用法?PHP Skin::newFromKey怎么用?PHP Skin::newFromKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skin
的用法示例。
在下文中一共展示了Skin::newFromKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputHook
static function outputHook( $out, $parserOutput ) {
global $wgUser;
if ( isset( $parserOutput->spp_skin ) ) {
$wgUser->mSkin =& Skin::newFromKey( $parserOutput->spp_skin );
}
return true;
}
示例2: __construct
function __construct()
{
//Some internal methods called from this controller need the skin to be wikiamobile
//It makes sense to set it explicitly here as other skins shouldn't use it anyway
RequestContext::getMain()->setSkin(Skin::newFromKey('wikiamobile'));
parent::__construct();
}
示例3: efSkinPerPageBeforePageDisplayHook
/**
* Hook function for BeforePageDisplay
*/
function efSkinPerPageBeforePageDisplayHook( &$out, &$skin ){
global $wgSkinPerNamespace, $wgSkinPerSpecialPage,
$wgSkinPerNamespaceOverrideLoggedIn, $wgUser;
if( !$wgSkinPerNamespaceOverrideLoggedIn && $wgUser->isLoggedIn() )
return true;
$title = $out->getTitle();
$ns = $title->getNamespace();
$skinName = null;
if( $ns == NS_SPECIAL ) {
list( $canonical, /* $subpage */ ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
if( isset( $wgSkinPerSpecialPage[$canonical] ) ) {
$skinName = $wgSkinPerSpecialPage[$canonical];
}
}
if( $skinName === null && isset( $wgSkinPerNamespace[$ns] ) ) {
$skinName = $wgSkinPerNamespace[$ns];
}
if( $skinName !== null ) {
$skin = Skin::newFromKey( $skinName );
$skin->setTitle( $out->getTitle() );
}
return true;
}
示例4: testWikiaMobileUserProfilePageTemplate
public function testWikiaMobileUserProfilePageTemplate()
{
$mobileSkin = Skin::newFromKey('wikiamobile');
$this->setUpMobileSkin($mobileSkin);
$response = $this->app->sendRequest('UserProfilePage', 'index', array('format' => 'html'));
$response->toString();
$this->assertEquals(dirname($this->app->wg->AutoloadClasses['UserProfilePageController']) . '/templates/UserProfilePage_WikiaMobileIndex.php', $response->getView()->getTemplatePath());
$this->tearDownMobileSkin();
}
示例5: testWikiaMobileChangePasswordTemplate
/**
* @group Slow
* @slowExecutionTime 0.50775 ms
*/
public function testWikiaMobileChangePasswordTemplate()
{
$mobileSkin = Skin::newFromKey('wikiamobile');
$this->setUpMockObject('User', array('getSkin' => $mobileSkin), true, 'wgUser');
$this->setUpMockObject('WebRequest', array('wasPosted' => true), false, 'wgRequest');
$this->setUpMock();
$this->setUpMobileSkin($mobileSkin);
$response = $this->app->sendRequest('UserLoginSpecial', 'index', array('format' => 'html', 'action' => wfMessage('resetpass_submit')->escaped()));
$response->toString();
// triggers set up of template path
$this->assertEquals(dirname($this->app->wg->AutoloadClasses['UserLoginSpecialController']) . '/templates/UserLoginSpecial_WikiaMobileChangePassword.php', $response->getView()->getTemplatePath());
$this->tearDownMobileSkin();
}
示例6: renderPage
/**
* @brief this is a function that return rendered article
*
* @requestParam String title of a page
*/
public function renderPage()
{
wfProfileIn(__METHOD__);
$titleName = $this->request->getVal('page');
$html = ApiService::call(array('action' => 'parse', 'page' => $titleName, 'prop' => 'text', 'redirects' => 1, 'useskin' => 'wikiamobile'));
$this->response->setVal('globals', Skin::newFromKey('wikiamobile')->getTopScripts());
$this->response->setVal('messages', JSMessages::getPackages(array('GameGuides')));
$this->response->setVal('title', Title::newFromText($titleName)->getText());
$this->response->setVal('html', $html['parse']['text']['*']);
wfProfileOut(__METHOD__);
}
示例7: wfProfileIn
/**
* Load a skin if it doesn't exist or return it
* @todo FIXME : need to check the old failback system [AV]
*/
function &getSkin()
{
global $IP, $wgRequest;
if (!isset($this->mSkin)) {
$fname = 'User::getSkin';
wfProfileIn($fname);
# get the user skin
$userSkin = $this->getOption('skin');
$userSkin = $wgRequest->getVal('useskin', $userSkin);
$this->mSkin =& Skin::newFromKey($userSkin);
wfProfileOut($fname);
}
return $this->mSkin;
}
示例8: wfProfileIn
/**
* Load a skin if it doesn't exist or return it
* @todo FIXME : need to check the old failback system [AV]
*/
function &getSkin()
{
global $wgRequest;
if (!isset($this->mSkin)) {
wfProfileIn(__METHOD__);
# get the user skin
$userSkin = $this->getOption('skin');
$userSkin = $wgRequest->getVal('useskin', $userSkin);
$this->mSkin =& Skin::newFromKey($userSkin);
wfProfileOut(__METHOD__);
}
return $this->mSkin;
}
示例9: getAsJson
public function getAsJson()
{
$articleId = $this->getRequest()->getInt(self::SIMPLE_JSON_ARTICLE_ID_PARAMETER_NAME, NULL);
$articleTitle = $this->getRequest()->getVal(self::SIMPLE_JSON_ARTICLE_TITLE_PARAMETER_NAME, NULL);
$redirect = $this->request->getVal('redirect');
if (!empty($articleId) && !empty($articleTitle)) {
throw new BadRequestApiException('Can\'t use id and title in the same request');
}
if (empty($articleId) && empty($articleTitle)) {
throw new BadRequestApiException('You need to pass title or id of an article');
}
if (!empty($articleId)) {
$article = Article::newFromID($articleId);
} else {
$title = Title::newFromText($articleTitle, NS_MAIN);
if ($title instanceof Title && $title->exists()) {
$article = Article::newFromTitle($title, RequestContext::getMain());
}
}
if (empty($article)) {
throw new NotFoundApiException("Unable to find any article");
}
if ($redirect !== 'no' && $article->getPage()->isRedirect()) {
// false, Title object of local target or string with URL
$followRedirect = $article->getPage()->followRedirect();
if ($followRedirect && !is_string($followRedirect)) {
$article = Article::newFromTitle($followRedirect, RequestContext::getMain());
}
}
//Response is based on wikiamobile skin as this already removes inline style
//and make response smaller
RequestContext::getMain()->setSkin(Skin::newFromKey('wikiamobile'));
global $wgArticleAsJson;
$wgArticleAsJson = true;
$parsedArticle = $article->getParserOutput();
if ($parsedArticle instanceof ParserOutput) {
$articleContent = json_decode($parsedArticle->getText());
} else {
throw new ArticleAsJsonParserException('Parser is currently not available');
}
$wgArticleAsJson = false;
$categories = [];
foreach (array_keys($parsedArticle->getCategories()) as $category) {
$categoryTitle = Title::newFromText($category, NS_CATEGORY);
if ($categoryTitle) {
$categories[] = ['title' => $categoryTitle->getText(), 'url' => $categoryTitle->getLocalURL()];
}
}
$result = ['content' => $articleContent->content, 'media' => $articleContent->media, 'users' => $articleContent->users, 'categories' => $categories];
$this->setResponseData($result, '', self::SIMPLE_JSON_VARNISH_CACHE_EXPIRATION);
}
示例10: getSkin
/**
* Get the Skin object
*
* @return Skin
*/
public function getSkin()
{
if ($this->skin === null) {
wfProfileIn(__METHOD__ . '-createskin');
$skin = null;
wfRunHooks('RequestContextCreateSkin', array($this, &$skin));
// If the hook worked try to set a skin from it
if ($skin instanceof Skin) {
$this->skin = $skin;
} elseif (is_string($skin)) {
$this->skin = Skin::newFromKey($skin);
}
// If this is still null (the hook didn't run or didn't work)
// then go through the normal processing to load a skin
if ($this->skin === null) {
global $wgHiddenPrefs;
if (!in_array('skin', $wgHiddenPrefs)) {
# get the user skin
$userSkin = $this->getUser()->getOption('skin');
$userSkin = $this->getRequest()->getVal('useskin', $userSkin);
} else {
# if we're not allowing users to override, then use the default
global $wgDefaultSkin;
$userSkin = $wgDefaultSkin;
}
$this->skin = Skin::newFromKey($userSkin);
}
// After all that set a context on whatever skin got created
$this->skin->setContext($this);
wfProfileOut(__METHOD__ . '-createskin');
}
return $this->skin;
}
示例11: onGetSkin
/**
* Select proper skin and theme based on user preferences / default settings
*/
public static function onGetSkin(RequestContext $context, &$skin)
{
global $wgDefaultSkin, $wgDefaultTheme, $wgSkinTheme, $wgForceSkin, $wgAdminSkin, $wgSkipSkins, $wgEnableAnswers;
wfProfileIn(__METHOD__);
$isOasisPublicBeta = $wgDefaultSkin == 'oasis';
$request = $context->getRequest();
$title = $context->getTitle();
$user = $context->getUser();
$useskin = $request->getVal('useskin', null);
/**
* check headers sent by varnish, if X-Skin is send force skin unless there is useskin param in url
* @author eloy, requested by artur
*/
if (is_null($useskin) && function_exists('apache_request_headers')) {
$headers = apache_request_headers();
if (isset($headers['X-Skin'])) {
if (in_array($headers['X-Skin'], array('monobook', 'oasis', 'venus', 'wikia', 'wikiamobile', 'uncyclopedia'))) {
$skin = Skin::newFromKey($headers['X-Skin']);
// X-Skin header fallback for Mercury which is actually not a MediaWiki skin but a separate application
} elseif ($headers['X-Skin'] === 'mercury') {
$skin = Skin::newFromKey('wikiamobile');
}
wfProfileOut(__METHOD__);
return false;
}
}
// useskin query param fallback for Mercury which is actually not a MediaWiki skin but a separate application
if ($useskin === 'mercury') {
$useskin = 'wikiamobile';
}
if (!$title instanceof Title || in_array(self::getUserOption('skin'), $wgSkipSkins)) {
$skin = Skin::newFromKey(isset($wgDefaultSkin) ? $wgDefaultSkin : 'monobook');
wfProfileOut(__METHOD__);
return false;
}
// only allow useskin=wikia for beta & staff.
if ($request->getVal('useskin') == 'wikia') {
$request->setVal('useskin', 'oasis');
}
if (!empty($wgForceSkin)) {
$wgForceSkin = $request->getVal('useskin', $wgForceSkin);
$elems = explode('-', $wgForceSkin);
$userSkin = array_key_exists(0, $elems) ? $elems[0] : null;
$userTheme = array_key_exists(1, $elems) ? $elems[1] : null;
$skin = Skin::newFromKey($userSkin);
$skin->themename = $userTheme;
self::log(__METHOD__, "forced skin to be {$wgForceSkin}");
wfProfileOut(__METHOD__);
return false;
}
# Get skin logic
wfProfileIn(__METHOD__ . '::GetSkinLogic');
if (!$user->isLoggedIn()) {
# If user is not logged in
if ($wgDefaultSkin == 'oasis') {
$userSkin = $wgDefaultSkin;
$userTheme = null;
} else {
if (!empty($wgAdminSkin) && !$isOasisPublicBeta) {
$adminSkinArray = explode('-', $wgAdminSkin);
$userSkin = isset($adminSkinArray[0]) ? $adminSkinArray[0] : null;
$userTheme = isset($adminSkinArray[1]) ? $adminSkinArray[1] : null;
} else {
$userSkin = $wgDefaultSkin;
$userTheme = $wgDefaultTheme;
}
}
} else {
$userSkin = self::getUserOption('skin');
$userTheme = self::getUserOption('theme');
// RT:81173 Answers force hack. It's in here because wgForceSkin is overwritten in CommonExtensions to '', most likely due to allowing admin skins and themes. This will force answers and falls through to admin skin and theme logic if there is one.
if (!empty($wgDefaultSkin) && $wgDefaultSkin == 'answers') {
$userSkin = 'answers';
}
if (empty($userSkin)) {
if (!empty($wgAdminSkin)) {
$adminSkinArray = explode('-', $wgAdminSkin);
$userSkin = isset($adminSkinArray[0]) ? $adminSkinArray[0] : null;
$userTheme = isset($adminSkinArray[1]) ? $adminSkinArray[1] : null;
} else {
$userSkin = 'oasis';
}
} else {
if (!empty($wgAdminSkin) && $userSkin != 'venus' && $userSkin != 'oasis' && $userSkin != 'monobook' && $userSkin != 'wowwiki' && $userSkin != 'lostbook') {
$adminSkinArray = explode('-', $wgAdminSkin);
$userSkin = isset($adminSkinArray[0]) ? $adminSkinArray[0] : null;
$userTheme = isset($adminSkinArray[1]) ? $adminSkinArray[1] : null;
}
}
}
wfProfileOut(__METHOD__ . '::GetSkinLogic');
$chosenSkin = !is_null($useskin) ? $useskin : $userSkin;
$elems = explode('-', $chosenSkin);
$userSkin = array_key_exists(0, $elems) ? empty($wgEnableAnswers) && $elems[0] == 'answers' ? 'oasis' : $elems[0] : null;
$userTheme = array_key_exists(1, $elems) ? $elems[1] : $userTheme;
$userTheme = $request->getVal('usetheme', $userTheme);
wfRunHooks('BeforeSkinLoad', [&$userSkin, $useskin, $title]);
//.........这里部分代码省略.........
示例12: executeWikiaMobileCommentsPage
/**
* Renders the contents of a page of comments including post button/form and prev/next page
* used in the WikiaMobile skin to deliver the first page of comments via AJAX and any page of comments for non-JS browsers
*
* @author Federico "Lox" Lucignano <federico(at)wikia-inc.com>
**/
public function executeWikiaMobileCommentsPage()
{
wfProfileIn(__METHOD__);
$articleID = $this->request->getInt('articleID');
$title = null;
//set mobile skin as this is based on it
RequestContext::getMain()->setSkin(Skin::newFromKey('wikiamobile'));
if (!empty($articleID)) {
$title = Title::newFromId($articleID);
}
if (!$title instanceof Title) {
$title = $this->wg->title;
}
$this->getCommentsData($title, $this->wg->request->getInt('page', 1));
if ($this->page > 1) {
$this->response->setVal('prevPage', $this->page - 1);
}
if ($this->page < $this->pagesCount) {
$this->response->setVal('nextPage', $this->page + 1);
}
wfProfileOut(__METHOD__);
}
示例13: preview
/**
* Parse provided wikitext to HTML using MW parser
*/
public static function preview()
{
global $wgRequest;
wfProfileIn(__METHOD__);
$skin = $wgRequest->getVal('skin');
if (!empty($skin)) {
RequestContext::getMain()->setSkin(Skin::newFromKey($skin));
}
$res = self::resolveWikitextFromRequest('preview');
// parse summary
// DAR-2382 -- render edit summary the same way it's rendered on Special:WikiActivity and Special:RecentChanges
$summary = $wgRequest->getText('summary');
$summary = RequestContext::getMain()->getSkin()->formatComment($summary, false);
if ($summary != '') {
$res['summary'] = wfMessage('wikia-editor-preview-editSummary')->rawParams($summary)->parse();
}
wfProfileOut(__METHOD__);
return $res;
}
示例14: wfProfileIn
/**
* Get the current skin, loading it if required
* @return \type{Skin} Current skin
* @todo FIXME : need to check the old failback system [AV]
*/
function &getSkin()
{
global $wgRequest, $wgAllowUserSkin, $wgDefaultSkin;
if (!isset($this->mSkin)) {
wfProfileIn(__METHOD__);
if ($wgAllowUserSkin) {
# get the user skin
$userSkin = $this->getOption('skin');
$userSkin = $wgRequest->getVal('useskin', $userSkin);
} else {
# if we're not allowing users to override, then use the default
$userSkin = $wgDefaultSkin;
}
$this->mSkin =& Skin::newFromKey($userSkin);
wfProfileOut(__METHOD__);
}
return $this->mSkin;
}
示例15: getGlobals
/**
* function returns globals needed for an Article
*/
public function getGlobals()
{
$wg = F::app()->wg;
$skin = Skin::newFromKey('wikiamobile');
//global variables
//from Output class
//and from ResourceLoaderStartUpModule
$res = new ResourceVariablesGetter();
$vars = array_intersect_key($wg->Out->getJSVars() + $res->get(), array_flip($wg->GameGuidesGlobalsWhiteList));
$this->setVal('globals', WikiaSkin::makeInlineVariablesScript($vars) . $skin->getTopScripts());
}