MediaWiki REL1_31
CssContent.php
Go to the documentation of this file.
1<?php
33class CssContent extends TextContent {
34
38 private $redirectTarget = false;
39
44 public function __construct( $text, $modelId = CONTENT_MODEL_CSS ) {
45 parent::__construct( $text, $modelId );
46 }
47
60 public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
61 global $wgParser;
62 // @todo Make pre-save transformation optional for script pages
63
64 $text = $this->getNativeData();
65 $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
66
67 return new static( $pst );
68 }
69
73 protected function getHtml() {
74 $html = "";
75 $html .= "<pre class=\"mw-code mw-css\" dir=\"ltr\">\n";
76 $html .= htmlspecialchars( $this->getNativeData() );
77 $html .= "\n</pre>\n";
78
79 return $html;
80 }
81
86 public function updateRedirect( Title $target ) {
87 if ( !$this->isRedirect() ) {
88 return $this;
89 }
90
91 return $this->getContentHandler()->makeRedirectContent( $target );
92 }
93
97 public function getRedirectTarget() {
98 if ( $this->redirectTarget !== false ) {
100 }
101 $this->redirectTarget = null;
102 $text = $this->getNativeData();
103 if ( strpos( $text, '/* #REDIRECT */' ) === 0 ) {
104 // Extract the title from the url
105 preg_match( '/title=(.*?)&action=raw/', $text, $matches );
106 if ( isset( $matches[1] ) ) {
107 $title = Title::newFromText( $matches[1] );
108 if ( $title ) {
109 // Have a title, check that the current content equals what
110 // the redirect content should be
111 if ( $this->equals( $this->getContentHandler()->makeRedirectContent( $title ) ) ) {
112 $this->redirectTarget = $title;
113 }
114 }
115 }
116 }
117
119 }
120
121}
$wgParser
Definition Setup.php:917
equals(Content $that=null)
Content object for CSS pages.
preSaveTransform(Title $title, User $user, ParserOptions $popts)
Returns a Content object with pre-save transformations applied using Parser::preSaveTransform().
__construct( $text, $modelId=CONTENT_MODEL_CSS)
bool Title null $redirectTarget
updateRedirect(Title $target)
getRedirectTarget()
Set options of the Parser.
Content object implementation for representing flat text.
getNativeData()
Returns the text represented by this Content object, as a string.
Represents a title within MediaWiki.
Definition Title.php:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:53
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:2013
const CONTENT_MODEL_CSS
Definition Defines.php:247