monobookcbt.php

来自「php 开发的内容管理系统」· PHP 代码 · 共 1,391 行 · 第 1/3 页

PHP
1,391
字号
			$revid = $wgArticle->getLatest();			if ( $revid != 0 ) {				$url = $wgRequest->appendQuery( 'printable=yes' );			}		}		return cbt_value( $url, array( 'nonview dynamic', 'title' ) );	}		function nav_permalink() {		$url = (string)$this->getPermalink();		return cbt_value( $url, 'dynamic' );	}	function nav_trackbacklink() {		global $wgUseTrackbacks;		if ( !$wgUseTrackbacks ) return '';		return cbt_value( $this->mTitle->trackbackURL(), 'title' );	}		function is_permalink() {		return cbt_value( (string)($this->getPermalink() === false), 'nonview dynamic' );	}		function toolboxend() {		// This is where the MonoBookTemplateToolboxEnd hook went in the old skin		return '';	}		function language_urls( $outer, $inner ) {		global $wgHideInterlanguageLinks, $wgOut, $wgContLang;		if ( $wgHideInterlanguageLinks ) return '';		$links = $wgOut->getLanguageLinks();		$s = '';		if ( count( $links ) ) {			foreach( $links as $l ) {				$tmp = explode( ':', $l, 2 );				$nt = Title::newFromText( $l );				$s .= strtr( $inner,					array(						'$class' => htmlspecialchars( 'interwiki-' . $tmp[0] ),						'$href' => htmlspecialchars( $nt->getFullURL() ),						'$text' => ($wgContLang->getLanguageName( $nt->getInterwiki() ) != ''?							$wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),					)				);			}			$s = str_replace( '$body', $s, $outer );		}		return cbt_value( $s, 'dynamic' );	}		function poweredbyico() { return $this->getPoweredBy(); }	function copyrightico() { return $this->getCopyrightIcon(); }	function lastmod() { 		global $wgMaxCredits;		if ( $wgMaxCredits ) return '';		if ( !isset( $this->mLastmod ) ) {			if ( $this->isCurrentArticleView() ) {				$this->mLastmod = $this->lastModified(); 			} else {				$this->mLastmod = '';			}		}		return cbt_value( $this->mLastmod, 'dynamic' );	}		function viewcount() {		global $wgDisableCounters;		if ( $wgDisableCounters ) return '';				global $wgLang, $wgArticle;		if ( is_object( $wgArticle ) ) {			$viewcount = $wgLang->formatNum( $wgArticle->getCount() );			if ( $viewcount ) {				$viewcount = wfMsg( "viewcount", $viewcount );			} else {				$viewcount = '';			}		} else {			$viewcount = '';		}		return cbt_value( $viewcount, 'dynamic' );   	}		function numberofwatchingusers() {		global $wgPageShowWatchingUsers;		if ( !$wgPageShowWatchingUsers ) return '';		$dbr =& wfGetDB( DB_SLAVE );		extract( $dbr->tableNames( 'watchlist' ) );		$sql = "SELECT COUNT(*) AS n FROM $watchlist			WHERE wl_title='" . $dbr->strencode($this->mTitle->getDBKey()) .			"' AND  wl_namespace=" . $this->mTitle->getNamespace() ;		$res = $dbr->query( $sql, 'SkinTemplate::outputPage');		$row = $dbr->fetchObject( $res );		$num = $row->n;		if ($num > 0) {			$s = wfMsg('number_of_watching_users_pageview', $num);		} else {			$s = '';		}		return cbt_value( $s, 'dynamic' );	}		function credits() {		global $wgMaxCredits;		if ( !$wgMaxCredits ) return '';				if ( $this->isCurrentArticleView() ) {			require_once("Credits.php");			global $wgArticle, $wgShowCreditsIfMax;			$credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);		} else {			$credits = '';		}		return cbt_value( $credits, 'view dynamic' );	}		function normalcopyright() {		return $this->getCopyright( 'normal' );	}	function historycopyright() {		return $this->getCopyright( 'history' );	}	function is_currentview() {		global $wgRequest;		return cbt_value( (string)$this->isCurrentArticleView(), 'view' );	}	function usehistorycopyright() {		global $wgRequest;		if ( wfMsgForContent( 'history_copyright' ) == '-' ) return '';				$oldid = $this->getOldId();		$diff = $this->getDiff();		$use = (string)(!is_null( $oldid ) && is_null( $diff ));		return cbt_value( $use, 'nonview dynamic' );	}		function privacy() {		return cbt_value( $this->privacyLink(), 'lang' );	}	function about() {		return cbt_value( $this->aboutLink(), 'lang' );	}	function disclaimer() {		return cbt_value( $this->disclaimerLink(), 'lang' );	}	function tagline() { 		# A reference to this tag existed in the old MonoBook.php, but the		# template data wasn't set anywhere		return ''; 	}	function reporttime() {		return cbt_value( $this->mOut->reportTime(), 'dynamic' );	}		function msg( $name ) {		return cbt_value( wfMsg( $name ), 'lang' );	}		function fallbackmsg( $name, $fallback ) {		$text = wfMsg( $name );		if ( wfEmptyMsg( $name, $text ) ) {			$text = $fallback;		}		return cbt_value( $text,  'lang' );	}	/******************************************************	 * Utility functions                                  *	 ******************************************************/	/** Return true if this request is a valid, secure CSS preview */	function isCssPreview() {		if ( !isset( $this->mCssPreview ) ) {			global $wgRequest, $wgAllowUserCss, $wgUser;			$this->mCssPreview = 				$wgAllowUserCss &&				$wgUser->isLoggedIn() &&				$this->mTitle->isCssSubpage() && 				$this->userCanPreview( $this->getAction() );		}		return $this->mCssPreview;	}	/** Return true if this request is a valid, secure JS preview */	function isJsPreview() {		if ( !isset( $this->mJsPreview ) ) {			global $wgRequest, $wgAllowUserJs, $wgUser;			$this->mJsPreview = 				$wgAllowUserJs &&				$wgUser->isLoggedIn() &&				$this->mTitle->isJsSubpage() && 				$this->userCanPreview( $this->getAction() );		}		return $this->mJsPreview;	}	/** Get the title of the $wgUser's user page */	function getUserPageTitle() {		if ( !isset( $this->mUserPageTitle ) ) {			global $wgUser;			$this->mUserPageTitle = $wgUser->getUserPage();		}		return $this->mUserPageTitle;	}	/** Get the text of the user page title */	function getUserPageText() {		if ( !isset( $this->mUserPageText ) ) {			$userPage = $this->getUserPageTitle();			$this->mUserPageText = $userPage->getPrefixedText();		}		return $this->mUserPageText;	}	/** Make an HTML element for a stylesheet link */	function makeStylesheetLink( $url ) {		return '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars( $url ) . "\"/>";	}	/** Make an XHTML element for inline CSS */	function makeStylesheetCdata( $style ) {		return "<style type=\"text/css\"> /*<![CDATA[*/ {$style} /*]]>*/ </style>";	}	/** Get the edit URL for this page */	function getEditUrl() {		if ( !isset( $this->mEditUrl ) ) {			$this->mEditUrl = $this->mTitle->getLocalUrl( $this->editUrlOptions() );		}		return $this->mEditUrl;	}	/** Get the prefixed DB key for this page */	function getThisPDBK() {		if ( !isset( $this->mThisPDBK ) ) {			$this->mThisPDBK = $this->mTitle->getPrefixedDbKey();		}		return $this->mThisPDBK;	}	function getThisTitleUrlForm() {		if ( !isset( $this->mThisTitleUrlForm ) ) {			$this->mThisTitleUrlForm = $this->mTitle->getPrefixedURL();		}		return $this->mThisTitleUrlForm;	}	/** 	 * If the current page is a user page, get the user's ID and IP. Otherwise return array(0,false)	 */	function getUserPageIdIp() {		if ( !isset( $this->mUserPageId ) ) {			if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {				$this->mUserPageId = User::idFromName($this->mTitle->getText());				$this->mUserPageIp = User::isIP($this->mTitle->getText());			} else {				$this->mUserPageId = 0;				$this->mUserPageIp = false;			}		}		return array( $this->mUserPageId, $this->mUserPageIp );	}		/**	 * Returns a permalink URL, or false if the current page is already a 	 * permalink, or blank if a permalink shouldn't be displayed	 */	function getPermalink() {		if ( !isset( $this->mPermalink ) ) {			global $wgRequest, $wgArticle;			$action = $this->getAction();			$oldid = $this->getOldId();			$url = '';			if( $this->mTitle->getNamespace() !== NS_SPECIAL 					&& $this->mTitle->getArticleId() != 0					&& ($action == '' || $action == 'view' || $action == 'purge' ) ) 			{				if ( !$oldid ) {					$revid = $wgArticle->getLatest();								$url = $this->mTitle->getLocalURL( "oldid=$revid" );				} else {					$url = false;				}			} else {				$url = '';			}		}		return $url;	}	/**	 * Returns true if the current page is an article, not a special page,	 * and we are viewing a revision, not a diff	 */	function isArticleView() {		global $wgOut, $wgArticle, $wgRequest;		if ( !isset( $this->mIsArticleView ) ) {			$oldid = $this->getOldId();			$diff = $this->getDiff();			$this->mIsArticleView = $wgOut->isArticle() and 				(!is_null( $oldid ) or is_null( $diff )) and 0 != $wgArticle->getID();		}		return $this->mIsArticleView;	}	function isCurrentArticleView() {		if ( !isset( $this->mIsCurrentArticleView ) ) {			global $wgOut, $wgArticle, $wgRequest;			$oldid = $this->getOldId();			$this->mIsCurrentArticleView = $wgOut->isArticle() && is_null( $oldid ) && 0 != $wgArticle->getID();		}		return $this->mIsCurrentArticleView;	}	/**	 * Return true if the current page is editable; if edit section on right 	 * click should be enabled.	 */	function isEditable() {		global $wgRequest;		$action = $this->getAction();		return ($this->mTitle->getNamespace() != NS_SPECIAL and !($action == 'edit' or $action == 'submit'));	}	/** Return true if the user is logged in */	function isLoggedIn() {		global $wgUser;		return $wgUser->isLoggedIn();	}	/** Get the local URL of the current page */	function getPageUrl() {		if ( !isset( $this->mPageUrl ) ) {			$this->mPageUrl = $this->mTitle->getLocalURL();		} 		return $this->mPageUrl;	}	/** Make a link to a title using a template */	function makeTemplateLink( $template, $key, $title, $text ) {		$url = $title->getLocalUrl();		return strtr( $template, 			array( 				'$key' => $key,				'$classactive' => ($url == $this->getPageUrl()) ? 'class="active"' : '',				'$class' => $title->getArticleID() == 0 ? 'class="new"' : '', 				'$href' => htmlspecialchars( $url ),				'$text' => $text			 ) );	}	/** Make a link to a URL using a template */	function makeTemplateLinkUrl( $template, $key, $url, $text ) {		return strtr( $template, 			array( 				'$key' => $key,				'$classactive' => ($url == $this->getPageUrl()) ? 'class="active"' : '',				'$class' => '', 				'$href' => htmlspecialchars( $url ),				'$text' => $text			 ) );	}	/** Make a link to a special page using a template */	function makeSpecialTemplateLink( $template, $key, $specialName, $text, $query = '' ) {		$url = $this->makeSpecialUrl( $specialName, $query );		// Ignore the query when comparing		$active = ($this->mTitle->getNamespace() == NS_SPECIAL && $this->mTitle->getDBkey() == $specialName);		return strtr( $template, 			array( 				'$key' => $key,				'$classactive' => $active ? 'class="active"' : '',				'$class' => '', 				'$href' => htmlspecialchars( $url ),				'$text' => $text			 ) );	}	function loadRequestValues() {		global $wgRequest;		$this->mAction = $wgRequest->getText( 'action' );		$this->mOldId = $wgRequest->getVal( 'oldid' );		$this->mDiff = $wgRequest->getVal( 'diff' );		$this->mSection = $wgRequest->getVal( 'section' );		$this->mSearch = $wgRequest->getVal( 'search' );		$this->mRequestValuesLoaded = true;	}			/** Get the action parameter of the request */	function getAction() {		if ( !isset( $this->mRequestValuesLoaded ) ) {			$this->loadRequestValues();		}		return $this->mAction;	}	/** Get the oldid parameter */	function getOldId() {		if ( !isset( $this->mRequestValuesLoaded ) ) {			$this->loadRequestValues();		}		return $this->mOldId;	}	/** Get the diff parameter */	function getDiff() {		if ( !isset( $this->mRequestValuesLoaded ) ) {			$this->loadRequestValues();		}		return $this->mDiff;	}	function getSection() {		if ( !isset( $this->mRequestValuesLoaded ) ) {			$this->loadRequestValues();		}		return $this->mSection;	}	function getSearch() {		if ( !isset( $this->mRequestValuesLoaded ) ) {			$this->loadRequestValues();		}		return $this->mSearch;	}	/** Make a special page URL of the form [[Special:Somepage/{title_urlform}]] */	function makeSpecialParamUrl( $name, $query = '', $param = '{title_urlform}' ) {		// Abuse makeTitle's lax validity checking to slip a control character into the URL		$title = Title::makeTitle( NS_SPECIAL, "$name/\x1a" );		$url = cbt_escape( $title->getLocalURL( $query ) );		// Now replace it with the parameter		return str_replace( '%1A', $param, $url );	}	function getSubjectPage() {		if ( !isset( $this->mSubjectPage ) ) {			$this->mSubjectPage = $this->mTitle->getSubjectPage();		}		return $this->mSubjectPage;	}	function getTalkPage() {		if ( !isset( $this->mTalkPage ) ) {			$this->mTalkPage = $this->mTitle->getTalkPage();		}		return $this->mTalkPage;	}}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?