skintemplate.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 1,125 行 · 第 1/3 页
PHP
1,125 行
'text' => $varname, 'href' => $this->mTitle->getLocalUrl( $actstr . 'variant=' . urlencode( $code ) ) ); $vcount ++; } } wfRunHooks( 'SkinTemplateContentActions', array( &$content_actions ) ); wfProfileOut( $fname ); return $content_actions; } /** * build array of common navigation links * @return array * @private */ function buildNavUrls () { global $wgUseTrackbacks, $wgTitle, $wgArticle; $fname = 'SkinTemplate::buildNavUrls'; wfProfileIn( $fname ); global $wgUser, $wgRequest; global $wgEnableUploads, $wgUploadNavigationUrl; $action = $wgRequest->getText( 'action' ); $oldid = $wgRequest->getVal( 'oldid' ); $diff = $wgRequest->getVal( 'diff' );// Modified for mediawiki for XOOPS - by D.J. $nav_urls = array(); //$nav_urls['mainpage'] = array('href' => $this->makeI18nUrl('mainpage')); $u = $wgTitle->escapeLocalURL( 'style=x' ); if ( '' != $wgTitle->getFragment() ) { if( $wgTitle->getPrefixedDbkey() == '' ) { $u = ''; } $anchor = urlencode( Sanitizer::decodeCharReferences( str_replace( ' ', '_', $wgTitle->getFragment() ) ) ); $replacearray = array( '%3A' => ':', '%' => '.' ); $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor); } $nav_urls['mainpage'] = array('href' => str_replace("&", "&", $u)); if( $wgEnableUploads ) { if ($wgUploadNavigationUrl) { $nav_urls['upload'] = array('href' => $wgUploadNavigationUrl ); } else { $nav_urls['upload'] = array('href' => $this->makeSpecialUrl('Upload')); } } else { if ($wgUploadNavigationUrl) $nav_urls['upload'] = array('href' => $wgUploadNavigationUrl ); else $nav_urls['upload'] = false; } $nav_urls['specialpages'] = array('href' => $this->makeSpecialUrl('Specialpages')); // A print stylesheet is attached to all pages, but nobody ever // figures that out. :) Add a link... if( $this->iscontent && ($action == '' || $action == 'view' || $action == 'purge' ) ) { $revid = $wgArticle->getLatest(); if ( !( $revid == 0 ) ) $nav_urls['print'] = array( 'text' => wfMsg( 'printableversion' ), 'href' => $wgRequest->appendQuery( 'printable=yes' ) ); // Also add a "permalink" while we're at it if ( (int)$oldid ) { $nav_urls['permalink'] = array( 'text' => wfMsg( 'permalink' ), 'href' => '' ); } else { if ( !( $revid == 0 ) ) $nav_urls['permalink'] = array( 'text' => wfMsg( 'permalink' ), 'href' => $wgTitle->getLocalURL( "oldid=$revid" ) ); } wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$oldid, &$revid ) ); } if( $this->mTitle->getNamespace() != NS_SPECIAL ) { $wlhTitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ); $nav_urls['whatlinkshere'] = array( 'href' => $wlhTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) ) ); if( $this->mTitle->getArticleId() ) { $rclTitle = Title::makeTitle( NS_SPECIAL, 'Recentchangeslinked' ); $nav_urls['recentchangeslinked'] = array( 'href' => $rclTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) ) ); } if ($wgUseTrackbacks) $nav_urls['trackbacklink'] = array( 'href' => $wgTitle->trackbackURL() ); } if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) { $id = User::idFromName($this->mTitle->getText()); $ip = User::isIP($this->mTitle->getText()); } else { $id = 0; $ip = false; } if($id || $ip) { # both anons and non-anons have contri list $nav_urls['contributions'] = array( 'href' => $this->makeSpecialUrl('Contributions/' . $this->mTitle->getText() ) ); if ( $wgUser->isAllowed( 'block' ) ) $nav_urls['blockip'] = array( 'href' => $this->makeSpecialUrl( 'Blockip/' . $this->mTitle->getText() ) ); } else { $nav_urls['contributions'] = false; } $nav_urls['emailuser'] = false; if( $this->showEmailUser( $id ) ) { $nav_urls['emailuser'] = array( 'href' => $this->makeSpecialUrl('Emailuser/' . $this->mTitle->getText() ) ); } wfProfileOut( $fname ); return $nav_urls; } /** * Generate strings used for xml 'id' names * @return string * @private */ function getNameSpaceKey () { return $this->mTitle->getNamespaceKey(); } /** * @private */ function setupUserCss() { $fname = 'SkinTemplate::setupUserCss'; wfProfileIn( $fname ); global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser; $sitecss = ''; $usercss = ''; $siteargs = '&maxage=' . $wgSquidMaxage; # Add user-specific code if this is a user and we allow that kind of thing if ( $wgAllowUserCss && $this->loggedin ) { $action = $wgRequest->getText('action'); # if we're previewing the CSS page, use it if( $this->mTitle->isCssSubpage() and $this->userCanPreview( $action ) ) { $siteargs = "&smaxage=0&maxage=0"; $usercss = $wgRequest->getText('wpTextbox1'); } else { $usercss = '@import "' . $this->makeUrl($this->userpage . '/'.$this->skinname.'.css', 'action=raw&ctype=text/css') . '";' ."\n"; } $siteargs .= '&ts=' . $wgUser->mTouched; } if ($wgContLang->isRTL()) $sitecss .= '@import "' . $wgStylePath . '/' . $this->stylename . '/rtl.css";' . "\n"; # If we use the site's dynamic CSS, throw that in, too if ( $wgUseSiteCss ) { $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; $sitecss .= '@import "' . $this->makeNSUrl('Common.css', $query, NS_MEDIAWIKI) . '";' . "\n"; $sitecss .= '@import "' . $this->makeNSUrl(ucfirst($this->skinname) . '.css', $query, NS_MEDIAWIKI) . '";' . "\n"; $sitecss .= '@import "' . $this->makeUrl('-','action=raw&gen=css' . $siteargs) . '";' . "\n"; } # If we use any dynamic CSS, make a little CDATA block out of it. if ( !empty($sitecss) || !empty($usercss) ) { $this->usercss = "/*<![CDATA[*/\n" . $sitecss . $usercss . '/*]]>*/'; } wfProfileOut( $fname ); } /** * @private */ function setupUserJs() { $fname = 'SkinTemplate::setupUserJs'; wfProfileIn( $fname ); global $wgRequest, $wgAllowUserJs, $wgJsMimeType; $action = $wgRequest->getText('action'); if( $wgAllowUserJs && $this->loggedin ) { if( $this->mTitle->isJsSubpage() and $this->userCanPreview( $action ) ) { # XXX: additional security check/prompt? $this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/'; } else { $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s'); } } wfProfileOut( $fname ); } /** * Code for extensions to hook into to provide per-page CSS, see * extensions/PageCSS/PageCSS.php for an implementation of this. * * @private */ function setupPageCss() { $fname = 'SkinTemplate::setupPageCss'; wfProfileIn( $fname ); $out = false; wfRunHooks( 'SkinTemplateSetupPageCss', array( &$out ) ); wfProfileOut( $fname ); return $out; } /** * returns css with user-specific options * @public */ function getUserStylesheet() { $fname = 'SkinTemplate::getUserStylesheet'; wfProfileIn( $fname ); $s = "/* generated user stylesheet */\n"; $s .= $this->reallyDoGetUserStyles(); wfProfileOut( $fname ); return $s; } /** * @public */ function getUserJs() { $fname = 'SkinTemplate::getUserJs'; wfProfileIn( $fname ); global $wgStylePath; $s = '/* generated javascript */'; $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';"; $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n"; // avoid inclusion of non defined user JavaScript (with custom skins only) // by checking for default message content $msgKey = ucfirst($this->skinname).'.js'; $userJS = wfMsg($msgKey); if ('<'.$msgKey.'>' != $userJS) { $s .= $userJS; } wfProfileOut( $fname ); return $s; }}/** * Generic wrapper for template functions, with interface * compatible with what we use of PHPTAL 0.7. * @package MediaWiki * @subpackage Skins */class QuickTemplate { /** * @public */ function QuickTemplate() { $this->data = array(); $this->translator = new MediaWiki_I18N(); } /** * @public */ function set( $name, $value ) { $this->data[$name] = $value; } /** * @public */ function setRef($name, &$value) { $this->data[$name] =& $value; } /** * @public */ function setTranslator( &$t ) { $this->translator = &$t; } /** * @public */ function execute() { echo "Override this function."; } /** * @private */ function text( $str ) { echo htmlspecialchars( $this->data[$str] ); } /** * @private */ function html( $str ) { echo $this->data[$str]; } /** * @private */ function msg( $str ) { echo htmlspecialchars( $this->translator->translate( $str ) ); } /** * @private */ function msgHtml( $str ) { echo $this->translator->translate( $str ); } /** * An ugly, ugly hack. * @private */ function msgWiki( $str ) { global $wgParser, $wgTitle, $wgOut; $text = $this->translator->translate( $str ); $parserOutput = $wgParser->parse( $text, $wgTitle, $wgOut->mParserOptions, true ); echo $parserOutput->getText(); } /** * @private */ function haveData( $str ) { return $this->data[$str]; } /** * @private */ function haveMsg( $str ) { $msg = $this->translator->translate( $str ); return ($msg != '-') && ($msg != ''); # ???? }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?