}
}
function addScript( $script ) {
- $this->mScripts .= "\t\t" . $script . "\n";
+ $this->mScripts .= $script . "\n";
}
/**
* addStyle() and draws from the /skins folder.
*/
public function addExtensionStyle( $url ) {
- $linkarr = array( 'rel' => 'stylesheet', 'href' => $url, 'type' => 'text/css' );
- array_push( $this->mExtStyles, $linkarr );
+ array_push( $this->mExtStyles, $url );
}
/**
* @param string $file filename in skins/common or complete on-server path (/foo/bar.js)
*/
function addScriptFile( $file ) {
- global $wgStylePath, $wgStyleVersion, $wgJsMimeType, $wgScript, $wgUser;
+ global $wgStylePath, $wgScript, $wgUser;
global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgEnableScriptLoader, $wgScriptPath;
if( substr( $file, 0, 1 ) == '/' ) {
}
// if the script loader did not find a way to add the script than add using addScript
- $this->addScript(
- Xml::element( 'script',
- array(
- 'type' => $wgJsMimeType,
- 'src' => wfAppendQuery( $path, $this->getURIDparam() ),
- ),
- '', false
- )
- );
+ $this->addScript( Html::linkedScript( wfAppendQuery( $path, $this->getURIDparam() ) ) );
}
/**
* different page load types (edit, upload, view, etc)
*/
function addCoreScripts2Top(){
- global $wgEnableScriptLoader, $wgStyleVersion, $wgJSAutoloadLocalClasses, $wgJsMimeType, $wgScriptPath, $wgEnableJS2system;
+ global $wgEnableScriptLoader, $wgJSAutoloadLocalClasses, $wgScriptPath, $wgEnableJS2system;
//@@todo we should deprecate wikibits in favor of mv_embed and native jQuery functions
if( $wgEnableJS2system ){
$so = '';
foreach( $core_classes as $s ){
if( isset( $wgJSAutoloadLocalClasses[$s] ) ){
- $so.= Xml::element( 'script', array(
- 'type' => $wgJsMimeType,
- 'src' => "{$wgScriptPath}/{$wgJSAutoloadLocalClasses[$s]}?" . $this->getURIDparam()
- ),
- '', false
- );
+ $so .= Html::linkedScript( "{$wgScriptPath}/{$wgJSAutoloadLocalClasses[$s]}?" . $this->getURIDparam() );
}
}
$this->mScripts = $so . $this->mScripts;
*/
function addScriptClass( $js_class ){
global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses,
- $wgJsMimeType, $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath;
+ $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath;
if( isset( $wgJSAutoloadClasses[$js_class] ) || isset( $wgJSAutoloadLocalClasses[$js_class] ) ){
if( $wgEnableScriptLoader ){
}else if( isset( $wgJSAutoloadLocalClasses[$js_class] ) ){
$path.= $wgJSAutoloadLocalClasses[$js_class];
}
- $urlApend = ( $wgDebugJavaScript) ? time() : $wgStyleVersion;
- $this->addScript(
- Xml::element( 'script',
- array(
- 'type' => $wgJsMimeType,
- 'src' => "$path?" . $urlApend,
- ),
- '', false
- )
- );
+ $urlAppend = ( $wgDebugJavaScript ) ? time() : $wgStyleVersion;
+ $this->addScript( Html::linkedScript( "$path?$urlAppend" ) );
}
return true;
}
* @param $forcClassAry Boolean: false by default
*/
function getScriptLoaderJs( $forceClassAry = false ){
- global $wgJsMimeType, $wgStyleVersion, $wgRequest, $wgDebugJavaScript;
+ global $wgRequest, $wgDebugJavaScript;
if( !$forceClassAry ){
$class_list = implode( ',', $this->mScriptLoaderClassList );
//generate the unique request param (combine with the most recent revision id of any wiki page with the $wgStyleVersion var)
-
- return Xml::element( 'script',
- array(
- 'type' => $wgJsMimeType,
- 'src' => wfScript( 'mwScriptLoader' ) . "?class={$class_list}{$debug_param}&".$this->getURIDparam(),
- ),
- '', false
- );
+ return Html::linkedScript( wfScript( 'mwScriptLoader' ) . "?class={$class_list}{$debug_param}&" . $this->getURIDparam() );
}
function getURIDparam(){
* @param string $script JavaScript text, no <script> tags
*/
function addInlineScript( $script ) {
- global $wgJsMimeType;
- $this->mScripts .= "\t\t<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n\t\t$script\n\t\t/*]]>*/</script>\n";
+ $this->mScripts .= Html::inlineScript( "\n$script\n" ) . "\n";
}
function getScript() {
* @return null
*/
public function setRobotPolicy( $policy ) {
- $policy = explode( ',', $policy );
- $policy = array_map( 'trim', $policy );
-
- # The default policy is follow, so if nothing is said explicitly, we
- # do that.
- if( in_array( 'nofollow', $policy ) ) {
- $this->mFollowPolicy = 'nofollow';
- } else {
- $this->mFollowPolicy = 'follow';
- }
+ $policy = Article::formatRobotPolicy( $policy );
- if( in_array( 'noindex', $policy ) ) {
- $this->mIndexPolicy = 'noindex';
- } else {
- $this->mIndexPolicy = 'index';
- }
+ if( isset( $policy['index'] ) ){
+ $this->setIndexPolicy( $policy['index'] );
+ }
+ if( isset( $policy['follow'] ) ){
+ $this->setFollowPolicy( $policy['follow'] );
+ }
}
/**
$this->mNewSectionLink = $parserOutput->getNewSection();
$this->mHideNewSectionLink = $parserOutput->getHideNewSection();
- if( is_null( $wgExemptFromUserRobotsControl ) ) {
- $bannedNamespaces = $wgContentNamespaces;
- } else {
- $bannedNamespaces = $wgExemptFromUserRobotsControl;
- }
- if( !in_array( $this->getTitle()->getNamespace(), $bannedNamespaces ) ) {
- # FIXME (bug 14900): This overrides $wgArticleRobotPolicies, and it
- # shouldn't
- $this->setIndexPolicy( $parserOutput->getIndexPolicy() );
- }
-
$this->mParseWarnings = $parserOutput->getWarnings();
if ( $parserOutput->getCacheTime() == -1 ) {
$this->enableClientCache( false );
public function output() {
global $wgUser, $wgOutputEncoding, $wgRequest;
global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
- global $wgJsMimeType, $wgUseAjax, $wgAjaxWatch;
+ global $wgUseAjax, $wgAjaxWatch;
global $wgEnableMWSuggest, $wgUniversalEditButton;
global $wgArticle;
$this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ));
}
- $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
+ $dir = $wgContLang->getDir();
if ( $wgHtml5 ) {
$ret .= "<!doctype html>\n";
$ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
}
- $ret .= "<head>\n\t<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n\t";
+ $ret .= "<head>\n";
+ $ret .= "<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
$ret .= implode( "\n", array(
$this->getHeadLinks(),
$this->buildCssLinks(),
$this->getHeadItems(),
));
if( $sk->usercss ){
- $ret .= "<style type='text/css'>{$sk->usercss}</style>";
+ $ret .= Html::inlineStyle( $sk->usercss );
}
if( $wgEnableScriptLoader )
}
}
- return implode( "\n\t", $tags ) . "\n";
+ return implode( "\n", $tags ) . "\n";
}
/**
*/
public function addStyle( $style, $media='', $condition='', $dir='' ) {
$options = array();
- // In Opera, fullscreen mode is treated as projection mode, and it causes
- // styles set for screen to not be loaded - thus breaking the page - so
- // we can just append projection to the media attribute when it's screen
- // so the browser is happy and - with no side-effects on other browsers.
- // Also - even though we expect the media type to be lowercase, but here
- // we force it to lowercase to be safe.
- if ( strtolower( $media ) == 'screen' )
- $media .= ',projection';
+ // Even though we expect the media type to be lowercase, but here we
+ // force it to lowercase to be safe.
if( $media )
$options['media'] = $media;
if( $condition )
* @param $style_css Mixed: inline CSS
*/
public function addInlineStyle( $style_css ){
- $this->mScripts .= "<style type=\"text/css\">$style_css</style>";
+ $this->mScripts .= Html::inlineStyle( $style_css );
}
/**
$links[] = $link;
}
- return "\t" . implode( "\n\t", $links );
+ return implode( "\n", $links );
}
protected function styleLink( $style, $options ) {
if( isset( $options['dir'] ) ) {
global $wgContLang;
- $siteDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
+ $siteDir = $wgContLang->getDir();
if( $siteDir != $options['dir'] )
return '';
}
return '';
}
} else {
- $media = '';
+ $media = null;
}
if( substr( $style, 0, 1 ) == '/' ||
$url = $wgStylePath . '/' . $style . '?' . $wgStyleVersion;
}
- $attribs = array(
- 'rel' => 'stylesheet',
- 'href' => $url,
- 'type' => 'text/css' );
- if( $media ) {
- $attribs['media'] = $media;
- }
-
- $link = Xml::element( 'link', $attribs );
+ $link = Html::linkedStyle( $url, $media );
if( isset( $options['condition'] ) ) {
$condition = htmlspecialchars( $options['condition'] );