本文整理汇总了PHP中Skin::getSkinName方法的典型用法代码示例。如果您正苦于以下问题:PHP Skin::getSkinName方法的具体用法?PHP Skin::getSkinName怎么用?PHP Skin::getSkinName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skin
的用法示例。
在下文中一共展示了Skin::getSkinName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSkinAfterBottomScripts
/**
* @brief Adds Wall Notifications script to Monobook pages
*
* @return boolean
*
* @author Liz Lee
*/
public static function onSkinAfterBottomScripts(Skin $skin, &$text)
{
global $wgUser, $wgJsMimeType, $wgResourceBasePath, $wgExtensionsPath;
if ($wgUser instanceof User && $wgUser->isLoggedIn() && $skin->getSkinName() == 'monobook') {
$text .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgResourceBasePath}/resources/wikia/libraries/jquery/timeago/jquery.timeago.js\"></script>\n" . "<script type=\"{$wgJsMimeType}\" src=\"{$wgExtensionsPath}/wikia/WallNotifications/scripts/WallNotifications.js\"></script>\n";
}
return true;
}
示例2: onSkinAfterBottomScripts
/**
* @brief Adds Wall Notifications script to Monobook pages
*
* @return boolean
*
* @author Liz Lee
*/
public function onSkinAfterBottomScripts(Skin $skin, &$text)
{
$app = F::App();
$user = $app->wg->User;
if ($user instanceof User && $user->isLoggedIn() && $skin->getSkinName() == 'monobook') {
$text .= "<script type=\"{$app->wg->JsMimeType}\" src=\"{$app->wg->ResourceBasePath}/resources/wikia/libraries/jquery/timeago/jquery.timeago.js\"></script>\n" . "<script type=\"{$app->wg->JsMimeType}\" src=\"{$app->wg->ExtensionsPath}/wikia/Wall/js/WallNotifications.js\"></script>\n";
}
return true;
}
示例3: onBeforePageDisplay
/**
* Adds VisualEditor JS to the output.
*
* This is attached to the MediaWiki 'BeforePageDisplay' hook.
*
* @param OutputPage $output
* @param Skin $skin
* @return boolean
*/
public static function onBeforePageDisplay(OutputPage &$output, Skin &$skin)
{
$output->addModules(array('ext.visualEditor.desktopArticleTarget.init', 'ext.visualEditor.targetLoader'));
$output->addModuleStyles(array('ext.visualEditor.desktopArticleTarget.noscript'));
// add scroll offset js variable to output
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig('visualeditor');
$skinsToolbarScrollOffset = $veConfig->get('VisualEditorSkinToolbarScrollOffset');
$toolbarScrollOffset = 0;
$skinName = $skin->getSkinName();
if (isset($skinsToolbarScrollOffset[$skinName])) {
$toolbarScrollOffset = $skinsToolbarScrollOffset[$skinName];
}
$output->addJsConfigVars('wgVisualEditorToolbarScrollOffset', $toolbarScrollOffset);
return true;
}
示例4: headElement
/**
* @param Skin $sk The given Skin
* @param bool $includeStyle Unused
* @return string The doctype, opening "<html>", and head element.
*/
public function headElement(Skin $sk, $includeStyle = true)
{
global $wgContLang;
$userdir = $this->getLanguage()->getDir();
$sitedir = $wgContLang->getDir();
$ret = Html::htmlHeader($sk->getHtmlElementAttributes());
if ($this->getHTMLTitle() == '') {
$this->setHTMLTitle($this->msg('pagetitle', $this->getPageTitle())->inContentLanguage());
}
$openHead = Html::openElement('head');
if ($openHead) {
# Don't bother with the newline if $head == ''
$ret .= "{$openHead}\n";
}
if (!Html::isXmlMimeType($this->getConfig()->get('MimeType'))) {
// Add <meta charset="UTF-8">
// This should be before <title> since it defines the charset used by
// text including the text inside <title>.
// The spec recommends defining XHTML5's charset using the XML declaration
// instead of meta.
// Our XML declaration is output by Html::htmlHeader.
// http://www.whatwg.org/html/semantics.html#attr-meta-http-equiv-content-type
// http://www.whatwg.org/html/semantics.html#charset
$ret .= Html::element('meta', array('charset' => 'UTF-8')) . "\n";
}
$ret .= Html::element('title', null, $this->getHTMLTitle()) . "\n";
foreach ($this->getHeadLinksArray() as $item) {
$ret .= $item . "\n";
}
// No newline after buildCssLinks since makeResourceLoaderLink did that already
$ret .= $this->buildCssLinks();
$ret .= $this->getHeadScripts() . "\n";
foreach ($this->mHeadItems as $item) {
$ret .= $item . "\n";
}
$closeHead = Html::closeElement('head');
if ($closeHead) {
$ret .= "{$closeHead}\n";
}
$bodyClasses = array();
$bodyClasses[] = 'mediawiki';
# Classes for LTR/RTL directionality support
$bodyClasses[] = $userdir;
$bodyClasses[] = "sitedir-{$sitedir}";
if ($this->getLanguage()->capitalizeAllNouns()) {
# A <body> class is probably not the best way to do this . . .
$bodyClasses[] = 'capitalize-all-nouns';
}
$bodyClasses[] = $sk->getPageClasses($this->getTitle());
$bodyClasses[] = 'skin-' . Sanitizer::escapeClass($sk->getSkinName());
$bodyClasses[] = 'action-' . Sanitizer::escapeClass(Action::getActionName($this->getContext()));
$bodyAttrs = array();
// While the implode() is not strictly needed, it's used for backwards compatibility
// (this used to be built as a string and hooks likely still expect that).
$bodyAttrs['class'] = implode(' ', $bodyClasses);
// Allow skins and extensions to add body attributes they need
$sk->addToBodyAttributes($this, $bodyAttrs);
Hooks::run('OutputPageBodyAttributes', array($this, $sk, &$bodyAttrs));
$ret .= Html::openElement('body', $bodyAttrs) . "\n";
return $ret;
}
示例5: makeResourceLoaderLink
/**
* TODO: Document
* @param $skin Skin
* @param $modules Array/string with the module name
* @param $only String ResourceLoaderModule TYPE_ class constant
* @param $useESI boolean
* @return string html <script> and <style> tags
*/
protected function makeResourceLoaderLink(Skin $skin, $modules, $only, $useESI = false)
{
global $wgLoadScript, $wgResourceLoaderUseESI;
// Lazy-load ResourceLoader
// TODO: Should this be a static function of ResourceLoader instead?
$baseQuery = array('lang' => $this->getContext()->getLang()->getCode(), 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false', 'skin' => $skin->getSkinName(), 'only' => $only);
// Propagate printable and handheld parameters if present
if ($this->isPrintable()) {
$baseQuery['printable'] = 1;
}
if ($this->getRequest()->getBool('handheld')) {
$baseQuery['handheld'] = 1;
}
if (!count($modules)) {
return '';
}
if (count($modules) > 1) {
// Remove duplicate module requests
$modules = array_unique((array) $modules);
// Sort module names so requests are more uniform
sort($modules);
if (ResourceLoader::inDebugMode()) {
// Recursively call us for every item
$links = '';
foreach ($modules as $name) {
$links .= $this->makeResourceLoaderLink($skin, $name, $only, $useESI);
}
return $links;
}
}
// Create keyed-by-group list of module objects from modules list
$groups = array();
$resourceLoader = $this->getResourceLoader();
foreach ((array) $modules as $name) {
$module = $resourceLoader->getModule($name);
# Check that we're allowed to include this module on this page
if (!$module || $module->getOrigin() > $this->getAllowedModules(ResourceLoaderModule::TYPE_SCRIPTS) && $only == ResourceLoaderModule::TYPE_SCRIPTS || $module->getOrigin() > $this->getAllowedModules(ResourceLoaderModule::TYPE_STYLES) && $only == ResourceLoaderModule::TYPE_STYLES) {
continue;
}
$group = $module->getGroup();
if (!isset($groups[$group])) {
$groups[$group] = array();
}
$groups[$group][$name] = $module;
}
$links = '';
foreach ($groups as $group => $modules) {
$query = $baseQuery;
// Special handling for user-specific groups
if (($group === 'user' || $group === 'private') && $this->getUser()->isLoggedIn()) {
$query['user'] = $this->getUser()->getName();
}
// Create a fake request based on the one we are about to make so modules return
// correct timestamp and emptiness data
$context = new ResourceLoaderContext($resourceLoader, new FauxRequest($query));
// Drop modules that know they're empty
foreach ($modules as $key => $module) {
if ($module->isKnownEmpty($context)) {
unset($modules[$key]);
}
}
// If there are no modules left, skip this group
if ($modules === array()) {
continue;
}
$query['modules'] = ResourceLoader::makePackedModulesString(array_keys($modules));
// Inline private modules. These can't be loaded through load.php for security
// reasons, see bug 34907. Note that these modules should be loaded from
// getHeadScripts() before the first loader call. Otherwise other modules can't
// properly use them as dependencies (bug 30914)
if ($group === 'private') {
if ($only == ResourceLoaderModule::TYPE_STYLES) {
$links .= Html::inlineStyle($resourceLoader->makeModuleResponse($context, $modules));
} else {
$links .= Html::inlineScript(ResourceLoader::makeLoaderConditionalScript($resourceLoader->makeModuleResponse($context, $modules)));
}
continue;
}
// Special handling for the user group; because users might change their stuff
// on-wiki like user pages, or user preferences; we need to find the highest
// timestamp of these user-changable modules so we can ensure cache misses on change
// This should NOT be done for the site group (bug 27564) because anons get that too
// and we shouldn't be putting timestamps in Squid-cached HTML
if ($group === 'user') {
// Get the maximum timestamp
$timestamp = 1;
foreach ($modules as $module) {
$timestamp = max($timestamp, $module->getModifiedTime($context));
}
// Add a version parameter so cache will break when things change
$query['version'] = wfTimestamp(TS_ISO_8601_BASIC, $timestamp);
}
//.........这里部分代码省略.........
示例6: getHeadScripts
/**
* Gets the global variables and mScripts; also adds userjs to the end if
* enabled
*
* @param $sk Skin object to use
* @return String: HTML fragment
*/
function getHeadScripts(Skin $sk)
{
global $wgUser, $wgRequest, $wgJsMimeType, $wgUseSiteJs;
global $wgStylePath, $wgStyleVersion;
$scripts = Skin::makeGlobalVariablesScript($sk->getSkinName());
$scripts .= Html::linkedScript("{$wgStylePath}/common/wikibits.js?{$wgStyleVersion}");
//add site JS if enabled:
if ($wgUseSiteJs) {
$jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
$this->addScriptFile(Skin::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($sk->getSkinName())));
}
//add user js if enabled:
if ($this->isUserJsAllowed() && $wgUser->isLoggedIn()) {
$action = $wgRequest->getVal('action', 'view');
if ($this->mTitle && $this->mTitle->isJsSubpage() and $sk->userCanPreview($action)) {
# XXX: additional security check/prompt?
$this->addInlineScript($wgRequest->getText('wpTextbox1'));
} else {
$userpage = $wgUser->getUserPage();
$scriptpage = Title::makeTitleSafe(NS_USER, $userpage->getDBkey() . '/' . $sk->getSkinName() . '.js');
if ($scriptpage && $scriptpage->exists()) {
$userjs = Skin::makeUrl($scriptpage->getPrefixedText(), 'action=raw&ctype=' . $wgJsMimeType);
$this->addScriptFile($userjs);
}
}
}
$scripts .= "\n" . $this->mScripts;
return $scripts;
}
示例7: headElement
/**
* @param Skin $sk The given Skin
* @param bool $includeStyle Unused
* @return string The doctype, opening "<html>", and head element.
*/
public function headElement(Skin $sk, $includeStyle = true)
{
global $wgContLang;
$userdir = $this->getLanguage()->getDir();
$sitedir = $wgContLang->getDir();
$pieces = [];
$pieces[] = Html::htmlHeader(Sanitizer::mergeAttributes($this->getRlClient()->getDocumentAttributes(), $sk->getHtmlElementAttributes()));
$pieces[] = Html::openElement('head');
if ($this->getHTMLTitle() == '') {
$this->setHTMLTitle($this->msg('pagetitle', $this->getPageTitle())->inContentLanguage());
}
if (!Html::isXmlMimeType($this->getConfig()->get('MimeType'))) {
// Add <meta charset="UTF-8">
// This should be before <title> since it defines the charset used by
// text including the text inside <title>.
// The spec recommends defining XHTML5's charset using the XML declaration
// instead of meta.
// Our XML declaration is output by Html::htmlHeader.
// http://www.whatwg.org/html/semantics.html#attr-meta-http-equiv-content-type
// http://www.whatwg.org/html/semantics.html#charset
$pieces[] = Html::element('meta', ['charset' => 'UTF-8']);
}
$pieces[] = Html::element('title', null, $this->getHTMLTitle());
$pieces[] = $this->getRlClient()->getHeadHtml();
$pieces[] = $this->buildExemptModules();
$pieces = array_merge($pieces, array_values($this->getHeadLinksArray()));
$pieces = array_merge($pieces, array_values($this->mHeadItems));
$pieces[] = Html::closeElement('head');
$bodyClasses = [];
$bodyClasses[] = 'mediawiki';
# Classes for LTR/RTL directionality support
$bodyClasses[] = $userdir;
$bodyClasses[] = "sitedir-{$sitedir}";
if ($this->getLanguage()->capitalizeAllNouns()) {
# A <body> class is probably not the best way to do this . . .
$bodyClasses[] = 'capitalize-all-nouns';
}
// Parser feature migration class
// The idea is that this will eventually be removed, after the wikitext
// which requires it is cleaned up.
$bodyClasses[] = 'mw-hide-empty-elt';
$bodyClasses[] = $sk->getPageClasses($this->getTitle());
$bodyClasses[] = 'skin-' . Sanitizer::escapeClass($sk->getSkinName());
$bodyClasses[] = 'action-' . Sanitizer::escapeClass(Action::getActionName($this->getContext()));
$bodyAttrs = [];
// While the implode() is not strictly needed, it's used for backwards compatibility
// (this used to be built as a string and hooks likely still expect that).
$bodyAttrs['class'] = implode(' ', $bodyClasses);
// Allow skins and extensions to add body attributes they need
$sk->addToBodyAttributes($this, $bodyAttrs);
Hooks::run('OutputPageBodyAttributes', [$this, $sk, &$bodyAttrs]);
$pieces[] = Html::openElement('body', $bodyAttrs);
return self::combineWrappedStrings($pieces);
}
示例8: headElement
/**
* @param $sk Skin The given Skin
* @param $includeStyle Boolean: unused
* @return String: The doctype, opening <html>, and head element.
*/
public function headElement(Skin $sk, $includeStyle = true)
{
global $wgContLang;
# start wikia change
global $wgDevelEnvironment;
if ($wgDevelEnvironment) {
$this->addMeta('robots', 'noindex, nofollow');
}
# end wikia change
$userdir = $this->getLanguage()->getDir();
$sitedir = $wgContLang->getDir();
if ($sk->commonPrintStylesheet()) {
$this->addModuleStyles('mediawiki.legacy.wikiprintable');
}
$ret = Html::htmlHeader(array('lang' => $this->getLanguage()->getHtmlCode(), 'dir' => $userdir, 'class' => 'client-nojs'));
if ($this->getHTMLTitle() == '') {
# start wikia change
wfProfileIn("parsePageTitle");
$this->setHTMLTitle($this->getWikiaPageTitle($this->getPageTitle()));
wfProfileOut("parsePageTitle");
# end wikia change
# $this->setHTMLTitle( $this->msg( 'pagetitle', $this->getPageTitle() ) );
}
$openHead = Html::openElement('head');
if ($openHead) {
# Don't bother with the newline if $head == ''
$ret .= "{$openHead}\n";
}
$ret .= Html::element('title', null, $this->getHTMLTitle()) . "\n";
$ret .= implode("\n", array($this->getHeadLinks(null, true), $this->buildCssLinks(), $this->getHeadScripts(), $this->getHeadItems()));
$closeHead = Html::closeElement('head');
if ($closeHead) {
$ret .= "{$closeHead}\n";
}
$bodyAttrs = array();
# Classes for LTR/RTL directionality support
$bodyAttrs['class'] = "mediawiki {$userdir} sitedir-{$sitedir}";
if ($this->getLanguage()->capitalizeAllNouns()) {
# A <body> class is probably not the best way to do this . . .
$bodyAttrs['class'] .= ' capitalize-all-nouns';
}
$bodyAttrs['class'] .= ' ' . $sk->getPageClasses($this->getTitle());
$bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass($sk->getSkinName());
$bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass(Action::getActionName($this->getContext()));
$sk->addToBodyAttributes($this, $bodyAttrs);
// Allow skins to add body attributes they need
wfRunHooks('OutputPageBodyAttributes', array($this, $sk, &$bodyAttrs));
$ret .= Html::openElement('body', $bodyAttrs) . "\n";
return $ret;
}
示例9: onSkinAfterBottomScripts
public static function onSkinAfterBottomScripts(Skin $skin, &$text)
{
// TODO: Check whether this works also on Oasis!
if ($skin->getSkinName() === 'venus') {
$text .= AdEngine2Controller::getLiftiumOptionsScript();
$text .= Html::inlineScript('Liftium.init();') . "\n";
}
return true;
}
示例10: checkIfGroupForSkin
/**
* Checks if given asset's group should be loaded for provided skin
* @param string $group - Asset Manager group name
* @param Skin $skin - skin instance
* @return bool whether group should be loaded for given skin
*/
public function checkIfGroupForSkin($group, Skin $skin)
{
$this->loadConfig();
$skinName = $skin->getSkinName();
$registeredSkin = $this->mAssetsConfig->getGroupSkin($group);
$check = is_array($registeredSkin) ? in_array($skinName, $registeredSkin) : $skinName === $registeredSkin;
//if not strict packages with no skin registered are positive
if ($skin instanceof WikiaSkin && $skin->isStrict() === false) {
$check = $check || empty($registeredSkin);
}
return $check;
}