本文整理汇总了PHP中Skin::makeUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Skin::makeUrl方法的具体用法?PHP Skin::makeUrl怎么用?PHP Skin::makeUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skin
的用法示例。
在下文中一共展示了Skin::makeUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addHelpLink
/**
* Adds help link with an icon via page indicators.
* Link target can be overridden by a local message containing a wikilink:
* the message key is: lowercase action name + '-helppage'.
* @param string $to Target MediaWiki.org page title or encoded URL.
* @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
* @since 1.25
*/
public function addHelpLink($to, $overrideBaseUrl = false)
{
global $wgContLang;
$msg = wfMessage($wgContLang->lc(Action::getActionName($this->getContext())) . '-helppage');
if (!$msg->isDisabled()) {
$helpUrl = Skin::makeUrl($msg->plain());
$this->getOutput()->addHelpLink($helpUrl, true);
} else {
$this->getOutput()->addHelpLink($to, $overrideBaseUrl);
}
}
示例2: addHelpLink
/**
* Adds help link with an icon via page indicators.
* Link target can be overridden by a local message containing a wikilink:
* the message key is: 'namespace-' + namespace number + '-helppage'.
* @param string $to Target MediaWiki.org page title or encoded URL.
* @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
* @since 1.25
*/
public function addHelpLink($to, $overrideBaseUrl = false)
{
$msg = wfMessage('namespace-' . $this->getTitle()->getNamespace() . '-helppage');
$out = $this->getContext()->getOutput();
if (!$msg->isDisabled()) {
$helpUrl = Skin::makeUrl($msg->plain());
$out->addHelpLink($helpUrl, true);
} else {
$out->addHelpLink($to, $overrideBaseUrl);
}
}
示例3: 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;
}
示例4: loadJs
private function loadJs() {
global $wgTitle, $wgOut, $wgJsMimeType, $wgUser;
wfProfileIn(__METHOD__);
// decide where JS should be placed (only add JS at the top for special and edit pages)
if ($wgTitle->getNamespace() == NS_SPECIAL || BodyController::isEditPage()) {
$this->jsAtBottom = false;
}
else {
$this->jsAtBottom = true;
}
//store AssetsManager output and reset jsFiles
$jsAssets = $this->jsFiles;
$this->jsFiles = '';
// load WikiaScriptLoader
$this->wikiaScriptLoader = '';
$wslFiles = AssetsManager::getInstance()->getGroupCommonURL( 'wsl' );
foreach($wslFiles as $wslFile) {
$this->wikiaScriptLoader .= "<script type=\"$wgJsMimeType\" src=\"$wslFile\"></script>";
}
// get JS files from <script> tags returned by AssetsManager
// TODO: get AssetsManager package (and other JS files to be loaded) here
preg_match_all("/src=\"([^\"]+)/", $jsAssets, $matches, PREG_SET_ORDER);
foreach($matches as $scriptSrc) {
$jsReferences[] = str_replace('&', '&', $scriptSrc[1]);;
}
// move JS files added to OutputPage to list of files to be loaded using WSL
$scripts = $wgUser->getSkin()->getScripts();
foreach ( $scripts as $s ) {
//add inline scripts to jsFiles and move non-inline to WSL queue
if ( !empty( $s['url'] ) ) {
$jsReferences[] = $s['url'];
} else {
$this->jsFiles .= $s['tag'];
}
}
// add user JS (if User:XXX/wikia.js page exists)
// copied from Skin::getHeadScripts
if($wgUser->isLoggedIn()){
wfProfileIn(__METHOD__ . '::checkForEmptyUserJS');
$userJS = $wgUser->getUserPage()->getPrefixedText() . '/wikia.js';
$userJStitle = Title::newFromText( $userJS );
if ( $userJStitle->exists() ) {
global $wgSquidMaxage;
$siteargs = array(
'action' => 'raw',
'maxage' => $wgSquidMaxage,
);
$userJS = Skin::makeUrl( $userJS, wfArrayToCGI( $siteargs ) );
$jsReferences[] = Skin::makeUrl( $userJS, wfArrayToCGI( $siteargs ) );;
}
wfProfileOut(__METHOD__ . '::checkForEmptyUserJS');
}
// generate code to load JS files
$jsReferences = json_encode($jsReferences);
$jsLoader = "<script type=\"text/javascript\">/*<![CDATA[*/ (function(){ wsl.loadScript({$jsReferences}); })(); /*]]>*/</script>";
// use loader script instead of separate JS files
$this->jsFiles = $jsLoader . $this->jsFiles;
wfProfileOut(__METHOD__);
}
示例5: onTitleGetSquidURLs
/**
* Get list of all URLs to be purged for a given Title
*
* @param Title $title page to be purged
* @param Array $urls list of URLs to be purged
* @return mixed true - it's a hook
*/
public static function onTitleGetSquidURLs(Title $title, array $urls)
{
// if this is a site css or js purge it as well
global $wgUseSiteCss, $wgAllowUserJs;
global $wgSquidMaxage, $wgJsMimeType;
wfProfileIn(__METHOD__);
if ($wgUseSiteCss && $title->getNamespace() == NS_MEDIAWIKI) {
global $wgServer;
$urls[] = $wgServer . '/__am/';
$urls[] = $wgServer . '/__wikia_combined/';
$query = array('usemsgcache' => 'yes', 'ctype' => 'text/css', 'smaxage' => $wgSquidMaxage, 'action' => 'raw', 'maxage' => $wgSquidMaxage);
if ($title->getText() == 'Common.css' || $title->getText() == 'Wikia.css') {
// BugId:20929 - tell (or trick) varnish to store the latest revisions of Wikia.css and Common.css.
$oTitleCommonCss = Title::newFromText('Common.css', NS_MEDIAWIKI);
$oTitleWikiaCss = Title::newFromText('Wikia.css', NS_MEDIAWIKI);
$query['maxrev'] = max((int) $oTitleWikiaCss->getLatestRevID(), (int) $oTitleCommonCss->getLatestRevID());
unset($oTitleWikiaCss, $oTitleCommonCss);
$urls[] = $title->getInternalURL($query);
} else {
foreach (Skin::getSkinNames() as $skinkey => $skinname) {
if ($title->getText() == ucfirst($skinkey) . '.css') {
$urls[] = str_replace('text%2Fcss', 'text/css', $title->getInternalURL($query));
// For Artur
$urls[] = $title->getInternalURL($query);
// For Artur
break;
} elseif ($title->getText() == 'Common.js') {
$urls[] = Skin::makeUrl('-', "action=raw&smaxage=86400&gen=js&useskin=" . urlencode($skinkey));
}
}
}
} elseif ($wgAllowUserJs && $title->isCssJsSubpage()) {
if ($title->isJsSubpage()) {
$urls[] = $title->getInternalURL('action=raw&ctype=' . $wgJsMimeType);
} elseif ($title->isCssSubpage()) {
$urls[] = $title->getInternalURL('action=raw&ctype=text/css');
}
}
// purge Special:RecentChanges too
$urls[] = SpecialPage::getTitleFor('RecentChanges')->getInternalURL();
wfProfileOut(__METHOD__);
return true;
}
示例6: smwfCreateLinks
/**
* Creates links for different groups by accessing group link pages.
* Name of page is: $name_$group
*
* @return HTML
*/
function smwfCreateLinks($name)
{
global $wgUser, $wgTitle;
$groups = $wgUser->getGroups();
$links = array();
foreach ($groups as $g) {
$nav = new Article(Title::newFromText($name . '_' . $g, NS_MEDIAWIKI));
$content = $nav->fetchContent(0, false, false);
$matches = array();
preg_match_all('/\\*\\s*([^|]+)\\|\\s*([^|\\n]*)(\\|.*)?/', $content, $matches);
for ($i = 0; $i < count($matches[0]); $i++) {
$links[$matches[2][$i]] = $matches[1][$i];
$extraAttributes[$matches[2][$i]] = isset($matches[3][$i]) ? substr(trim($matches[3][$i]), 1) : "";
}
}
$links = array_unique($links);
$result = "";
foreach ($links as $name => $page_title) {
$name = Sanitizer::stripAllTags($name);
$page_title = Sanitizer::stripAllTags($page_title);
$query = "";
if (stripos($page_title, "?") !== false) {
$query = substr($page_title, stripos($page_title, "?") + 1);
$page_title = substr($page_title, 0, stripos($page_title, "?"));
}
// Replace some variables:
// PAGE_TITLE : Page title WITH namespace
// PAGE_TITLE_WNS : Page title WITHOUT namespace
// PAGE_NS : Page namespace as text
$query = str_replace("{{{PAGE_TITLE}}}", $wgTitle->getPrefixedDBkey(), $query);
$query = str_replace("{{{PAGE_NS}}}", $wgTitle->getNsText(), $query);
$query = str_replace("{{{PAGE_TITLE_WNS}}}", $wgTitle->getDBkey(), $query);
$page_title = str_replace("{{{PAGE_TITLE}}}", $wgTitle->getPrefixedDBkey(), $page_title);
//Check if ontoskin is available else return code for new skins
global $wgUser;
if ($wgUser->getSkin() == 'ontoskin') {
$result .= '<li><a href="' . Skin::makeUrl($page_title, $query) . '" ' . $extraAttributes[$name] . '>' . $name . '</a></li>';
} else {
$result .= '<tr><td><div class="smwf_naviitem"><a href="' . Skin::makeUrl($page_title, $query) . '" ' . $extraAttributes[$name] . '>' . $name . '</a></div></td></tr>';
}
}
return $result;
}
示例7: loadJs
private function loadJs() {
global $wgJsMimeType, $wgUser, $wgSpeedBox, $wgDevelEnvironment, $wgEnableAbTesting, $wgAllInOne;
wfProfileIn(__METHOD__);
$this->jsAtBottom = self::JsAtBottom();
// load WikiaScriptLoader, AbTesting files, anything that's so mandatory that we're willing to make a blocking request to load it.
$this->wikiaScriptLoader = '';
$jsAssetGroups = array( 'oasis_blocking' );
wfRunHooks('OasisSkinAssetGroupsBlocking', array(&$jsAssetGroups));
$blockingScripts = $this->assetsManager->getURL($jsAssetGroups);
foreach($blockingScripts as $blockingFile) {
if( $wgSpeedBox && $wgDevelEnvironment ) {
$blockingFile = $this->rewriteJSlinks( $blockingFile );
}
$this->wikiaScriptLoader .= "<script type=\"$wgJsMimeType\" src=\"$blockingFile\"></script>";
}
// move JS files added to OutputPage to list of files to be loaded using WSL
$scripts = RequestContext::getMain()->getSkin()->getScripts();
foreach ( $scripts as $s ) {
//add inline scripts to jsFiles and move non-inline to WSL queue
if ( !empty( $s['url'] ) ) {
// FIXME: quick hack to load MW core JavaScript at the top of the page - really, please fix me!
// @author macbre
if (strpos($s['url'], 'load.php') !== false) {
$this->globalVariablesScript = $s['tag'] . $this->globalVariablesScript;
}
else {
$url = $s['url'];
if ( $wgAllInOne ) {
$url = $this->minifySingleAsset( $url );
}
if ( !empty( $wgSpeedBox ) && !empty( $wgDevelEnvironment ) ) {
$url = $this->rewriteJSlinks( $url );
}
$jsReferences[] = $url;
}
} else {
$this->jsFiles .= $s['tag'];
}
}
// add user JS (if User:XXX/wikia.js page exists)
// copied from Skin::getHeadScripts
if($wgUser->isLoggedIn()){
wfProfileIn(__METHOD__ . '::checkForEmptyUserJS');
$userJS = $wgUser->getUserPage()->getPrefixedText() . '/wikia.js';
$userJStitle = Title::newFromText( $userJS );
if ( $userJStitle->exists() ) {
global $wgSquidMaxage;
$siteargs = array(
'action' => 'raw',
'maxage' => $wgSquidMaxage,
);
$userJS = Skin::makeUrl( $userJS, wfArrayToCGI( $siteargs ) );
$jsReferences[] = ( !empty( $wgSpeedBox ) && !empty( $wgDevelEnvironment ) ) ? $this->rewriteJSlinks( $userJS ) : $userJS;
}
wfProfileOut(__METHOD__ . '::checkForEmptyUserJS');
}
// Load the combined JS
$jsAssetGroups = array(
'oasis_shared_core_js', 'oasis_shared_js',
);
if ($wgUser->isLoggedIn()) {
$jsAssetGroups[] = 'oasis_user_js';
} else {
$jsAssetGroups[] = 'oasis_anon_js';
}
wfRunHooks('OasisSkinAssetGroups', array(&$jsAssetGroups));
$assets = array();
$assets['oasis_shared_js'] = $this->assetsManager->getURL($jsAssetGroups);
// jQueryless version - appears only to be used by the ad-experiment at the moment.
$assets['oasis_nojquery_shared_js'] = $this->assetsManager->getURL( ( $wgUser->isLoggedIn() ) ? 'oasis_nojquery_shared_js_user' : 'oasis_nojquery_shared_js_anon' );
if ( !empty( $wgSpeedBox ) && !empty( $wgDevelEnvironment ) ) {
foreach ( $assets as $group => $urls ) {
foreach ( $urls as $index => $u ) {
$assets[$group][$index] = $this->rewriteJSlinks( $assets[$group][$index] );
}
}
}
$assets['references'] = $jsReferences;
// generate code to load JS files
$assets = json_encode($assets);
$jsLoader = <<<EOT
//.........这里部分代码省略.........