renamed emptyContent to makeEmptyContent
[lhc/web/wiklou.git] / includes / ContentHandler.php
1 <?php
2
3 class MWContentSerializationException extends MWException {
4
5 }
6
7
8 /**
9 * A content handler knows how do deal with a specific type of content on a wiki page.
10 * Content is stored in the database in a serialized form (using a serialization format aka mime type)
11 * and is be unserialized into it's native PHP represenation (the content model), which is wrappe in
12 * an instance of the appropriate subclass of Content.
13 *
14 * ContentHandler instances are stateless singletons that serve, among other things, as a factory for
15 * Content objects. Generally, there is one subclass of ContentHandler and one subclass of Content
16 * for every type of content model.
17 *
18 * Some content types have a flat model, that is, their native represenation is the
19 * same as their serialized form. Examples would be JavaScript and CSS code. As of now,
20 * this also applies to wikitext (mediawiki's default content type), but wikitext
21 * content may be represented by a DOM or AST structure in the future.
22 */
23 abstract class ContentHandler {
24
25 /**
26 * Conveniance function for getting flat text from a Content object. This shleould only
27 * be used in the context of backwards compatibility with code that is not yet able
28 * to handle Content objects!
29 *
30 * If $content is equal to null or false, this method returns the empty string.
31 *
32 * If $content is an instance of TextContent, this method returns the flat text as returned by $content->getnativeData().
33 *
34 * If $content is not a TextContent object, the bahaviour of this method depends on the global $wgContentHandlerTextFallback:
35 * If $wgContentHandlerTextFallback is 'fail' and $content is not a TextContent object, an MWException is thrown.
36 * If $wgContentHandlerTextFallback is 'serialize' and $content is not a TextContent object, $content->serialize()
37 * is called to get a string form of the content.
38 * Otherwise, this method returns null.
39 *
40 * @static
41 * @param Content|null $content
42 * @return null|string the textual form of $content, if available
43 * @throws MWException if $content is not an instance of TextContent and $wgContentHandlerTextFallback was set to 'fail'.
44 */
45 public static function getContentText( Content $content = null ) {
46 global $wgContentHandlerTextFallback;
47
48 if ( is_null( $content ) ) {
49 return '';
50 }
51
52 if ( $content instanceof TextContent ) {
53 return $content->getNativeData();
54 }
55
56 if ( $wgContentHandlerTextFallback == 'fail' ) {
57 throw new MWException( "Attempt to get text from Content with model " . $content->getModelName() );
58 }
59
60 if ( $wgContentHandlerTextFallback == 'serialize' ) {
61 return $content->serialize();
62 }
63
64 return null;
65 }
66
67 /**
68 * Conveniance function for creating a Content object from a given textual representation.
69 *
70 * $text will be deserialized into a Content object of the model specified by $modelName (or,
71 * if that is not given, $title->getContentModelName()) using the given format.
72 *
73 * @static
74 * @param $text the textual represenation, will be unserialized to create the Content object
75 * @param Title $title the title of the page this text belongs to, required as a context for deserialization
76 * @param null|String $modelName the model to deserialize to. If not provided, $title->getContentModelName() is used.
77 * @param null|String $format the format to use for deserialization. If not given, the model's default format is used.
78 *
79 * @return Content a Content object representing $text
80 */
81 public static function makeContent( $text, Title $title, $modelName = null, $format = null ) {
82
83 if ( is_null( $modelName ) ) {
84 $modelName = $title->getContentModelName();
85 }
86
87 $handler = ContentHandler::getForModelName( $modelName );
88 return $handler->unserializeContent( $text, $format );
89 }
90
91 /**
92 * Returns the name of the default content model to be used for the page with the given title.
93 *
94 * Note: There should rarely be need to call this method directly.
95 * To determine the actual content model for a given page, use Title::getContentModelName().
96 *
97 * Which model is to be used per default for the page is determined based on several factors:
98 * * The global setting $wgNamespaceContentModels specifies a content model per namespace.
99 * * The hook DefaultModelFor may be used to override the page's default model.
100 * * Pages in NS_MEDIAWIKI and NS_USER default to the CSS or JavaScript model if they end in .js or .css, respectively.
101 * * Pages in NS_MEDIAWIKI default to the wikitext model otherwise.
102 * * The hook TitleIsCssOrJsPage may be used to force a page to use the CSS or JavaScript model if they end in .js or .css, respectively.
103 * * The hook TitleIsWikitextPage may be used to force a page to use the wikitext model.
104 *
105 * If none of the above applies, the wikitext model is used.
106 *
107 * Note: this is used by, and may thus not use, Title::getContentModelName()
108 *
109 * @static
110 * @param Title $title
111 * @return null|string default model name for the page given by $title
112 */
113 public static function getDefaultModelFor( Title $title ) {
114 global $wgNamespaceContentModels;
115
116 // NOTE: this method must not rely on $title->getContentModelName() directly or indirectly,
117 // because it is used to initialized the mContentModelName memebr.
118
119 $ns = $title->getNamespace();
120
121 $ext = false;
122 $m = null;
123 $model = null;
124
125 if ( !empty( $wgNamespaceContentModels[ $ns ] ) ) {
126 $model = $wgNamespaceContentModels[ $ns ];
127 }
128
129 // hook can determin default model
130 if ( !wfRunHooks( 'DefaultModelFor', array( $title, &$model ) ) ) { #FIXME: document new hook!
131 if ( !is_null( $model ) ) {
132 return $model;
133 }
134 }
135
136 // Could this page contain custom CSS or JavaScript, based on the title?
137 $isCssOrJsPage = NS_MEDIAWIKI == $ns && preg_match( '!\.(css|js)$!u', $title->getText(), $m );
138 if ( $isCssOrJsPage ) {
139 $ext = $m[1];
140 }
141
142 // hook can force js/css
143 wfRunHooks( 'TitleIsCssOrJsPage', array( $title, &$isCssOrJsPage ) );
144
145 // Is this a .css subpage of a user page?
146 $isJsCssSubpage = NS_USER == $ns && !$isCssOrJsPage && preg_match( "/\\/.*\\.(js|css)$/", $title->getText(), $m );
147 if ( $isJsCssSubpage ) {
148 $ext = $m[1];
149 }
150
151 // is this wikitext, according to $wgNamespaceContentModels or the DefaultModelFor hook?
152 $isWikitext = is_null( $model ) || $model == CONTENT_MODEL_WIKITEXT;
153 $isWikitext = $isWikitext && !$isCssOrJsPage && !$isJsCssSubpage;
154
155 // hook can override $isWikitext
156 wfRunHooks( 'TitleIsWikitextPage', array( $title, &$isWikitext ) );
157
158 if ( !$isWikitext ) {
159 switch ( $ext ) {
160 case 'js':
161 return CONTENT_MODEL_JAVASCRIPT;
162 case 'css':
163 return CONTENT_MODEL_CSS;
164 default:
165 return is_null( $model ) ? CONTENT_MODEL_TEXT : $model;
166 }
167 }
168
169 // we established that is must be wikitext
170
171 return CONTENT_MODEL_WIKITEXT;
172 }
173
174 /**
175 * returns the appropriate ContentHandler singleton for the given title
176 *
177 * @static
178 * @param Title $title
179 * @return ContentHandler
180 */
181 public static function getForTitle( Title $title ) {
182 $modelName = $title->getContentModelName();
183 return ContentHandler::getForModelName( $modelName );
184 }
185
186 /**
187 * returns the appropriate ContentHandler singleton for the given Content object
188 *
189 * @static
190 * @param Content $content
191 * @return ContentHandler
192 */
193 public static function getForContent( Content $content ) {
194 $modelName = $content->getModelName();
195 return ContentHandler::getForModelName( $modelName );
196 }
197
198 /**
199 * returns the ContentHandler singleton for the given model name. Use the CONTENT_MODEL_XXX constants to
200 * identify the desired content model.
201 *
202 * ContentHandler singletons are take from the global $wgContentHandlers array. Keys in that array are
203 * model names, the values are either ContentHandler singleton objects, or strings specifying the appropriate
204 * subclass of ContentHandler.
205 *
206 * If a class name in encountered when looking up the singleton for a given model name, the class is
207 * instantiated and the class name is replaced by te resulting singleton in $wgContentHandlers.
208 *
209 * If no ContentHandler is defined for the desired $modelName, the ContentHandler may be provided by the
210 * a ContentHandlerForModelName hook. if no Contenthandler can be determined, an MWException is raised.
211 *
212 * @static
213 * @param $modelName String the name of the content model for which to get a handler. Use CONTENT_MODEL_XXX constants.
214 * @return ContentHandler the ContentHandler singleton for handling the model given by $modelName
215 * @throws MWException if no handler is known for $modelName.
216 */
217 public static function getForModelName( $modelName ) {
218 global $wgContentHandlers;
219
220 if ( empty( $wgContentHandlers[$modelName] ) ) {
221 $handler = null;
222
223 // TODO: document new hook
224 wfRunHooks( 'ContentHandlerForModelName', array( $modelName, &$handler ) );
225
226 if ( $handler ) { // NOTE: may be a string or an object, either is fine!
227 $wgContentHandlers[$modelName] = $handler;
228 } else {
229 throw new MWException( "No handler for model $modelName registered in \$wgContentHandlers" );
230 }
231 }
232
233 if ( is_string( $wgContentHandlers[$modelName] ) ) {
234 $class = $wgContentHandlers[$modelName];
235 $wgContentHandlers[$modelName] = new $class( $modelName );
236 }
237
238 return $wgContentHandlers[$modelName];
239 }
240
241 // ----------------------------------------------------------------------------------------------------------
242
243 /**
244 * Constructor, initializing the ContentHandler instance with it's model name and a list of supported formats.
245 * Values for the parameters are typically provided as literals by subclasses' constructors.
246 *
247 * @param String $modelName (use CONTENT_MODEL_XXX constants).
248 * @param array $formats list for supported serialization formats (typically as MIME types)
249 */
250 public function __construct( $modelName, $formats ) {
251 $this->mModelName = $modelName;
252 $this->mSupportedFormats = $formats;
253 }
254
255
256 /**
257 * Serializes Content object of the type supported by this ContentHandler.
258 *
259 * @abstract
260 * @param Content $content the Content object to serialize
261 * @param null $format the desired serialization format
262 * @return String serialized form of the content
263 */
264 public abstract function serializeContent( Content $content, $format = null );
265
266 /**
267 * Unserializes a Content object of the type supported by this ContentHandler.
268 *
269 * @abstract
270 * @param $blob String serialized form of the content
271 * @param null $format the format used for serialization
272 * @return Content the Content object created by deserializing $blob
273 */
274 public abstract function unserializeContent( $blob, $format = null );
275
276 /**
277 * Creates an empty Content object of the type supported by this ContentHandler.
278 *
279 */
280 public abstract function makeEmptyContent();
281
282 /**
283 * Returns the model name that identifies the content model this ContentHandler can handle.
284 * Use with the CONTENT_MODEL_XXX constants.
285 *
286 * @return String the model name
287 */
288 public function getModelName() {
289 return $this->mModelName;
290 }
291
292 /**
293 * Throws an MWException if $modelName is not the content model handeled by this ContentHandler.
294 *
295 * @param $modelName the model name to check
296 */
297 protected function checkModelName( $modelName ) {
298 if ( $modelName !== $this->mModelName ) {
299 throw new MWException( "Bad content model: expected " . $this->mModelName . " but got found " . $modelName );
300 }
301 }
302
303 /**
304 * Returns a list of serialization formats supported by the serializeContent() and unserializeContent() methods of
305 * this ContentHandler.
306 *
307 * @return array of serialization formats as MIME type like strings
308 */
309 public function getSupportedFormats() {
310 return $this->mSupportedFormats;
311 }
312
313 /**
314 * The format used for serialization/deserialization per default by this ContentHandler.
315 *
316 * This default implementation will return the first element of the array of formats
317 * that was passed to the constructor.
318 *
319 * @return String the name of the default serialiozation format as a MIME type
320 */
321 public function getDefaultFormat() {
322 return $this->mSupportedFormats[0];
323 }
324
325 /**
326 * Returns true if $format is a serialization format supported by this ContentHandler,
327 * and false otherwise.
328 *
329 * Note that if $format is null, this method always returns true, because null
330 * means "use the default format".
331 *
332 * @param $format the serialization format to check
333 * @return bool
334 */
335 public function isSupportedFormat( $format ) {
336
337 if ( !$format ) {
338 return true; // this means "use the default"
339 }
340
341 return in_array( $format, $this->mSupportedFormats );
342 }
343
344 /**
345 * Throws an MWException if isSupportedFormat( $format ) is not true. Convenient
346 * for checking whether a format provided as a parameter is actually supported.
347 *
348 * @param $format the serialization format to check
349 */
350 protected function checkFormat( $format ) {
351 if ( !$this->isSupportedFormat( $format ) ) {
352 throw new MWException( "Format $format is not supported for content model " . $this->getModelName() );
353 }
354 }
355
356 /**
357 * Returns overrides for action handlers.
358 * Classes listed here will be used instead of the default one when
359 * (and only when) $wgActions[$action] === true. This allows subclasses
360 * to override the default actiuon handlers.
361 *
362 * @return Array
363 */
364 public function getActionOverrides() {
365 return array();
366 }
367
368 /**
369 * Return an Article object suitable for viewing the given object
370 *
371 * NOTE: does *not* do special handling for Image and Category pages!
372 * Use Article::newFromTitle() for that!
373 *
374 * @param Title $title
375 * @return Article
376 * @todo Article is being refactored into an action class, keep track of that
377 * @todo Article really defines the view of the content... rename this method to createViewPage ?
378 */
379 public function createArticle( Title $title ) {
380 $this->checkModelName( $title->getContentModelName() );
381
382 $article = new Article($title);
383 return $article;
384 }
385
386 /**
387 * Return an EditPage object suitable for editing the given object
388 *
389 * @param Article $article
390 * @return EditPage
391 */
392 public function createEditPage( Article $article ) {
393 $this->checkModelName( $article->getContentModelName() );
394
395 $editPage = new EditPage( $article );
396 return $editPage;
397 }
398
399 /**
400 * Return an ExternalEdit object suitable for editing the given object
401 *
402 * @param IContextSource $context
403 * @return ExternalEdit
404 * @todo does anyone or anythign actually use the external edit facility? Can we just deprecate and ignore it?
405 */
406 public function createExternalEdit( IContextSource $context ) {
407 $this->checkModelName( $context->getTitle()->getModelName() );
408
409 $externalEdit = new ExternalEdit( $context );
410 return $externalEdit;
411 }
412
413 /**
414 * Factory
415 * @param $context IContextSource context to use, anything else will be ignored
416 * @param $old Integer old ID we want to show and diff with.
417 * @param $new String either 'prev' or 'next'.
418 * @param $rcid Integer ??? FIXME (default 0)
419 * @param $refreshCache boolean If set, refreshes the diff cache
420 * @param $unhide boolean If set, allow viewing deleted revs
421 *
422 * @return DifferenceEngine
423 * @todo rename to createDifferenceEngine for consistency.
424 */
425 public function getDifferenceEngine( IContextSource $context, $old = 0, $new = 0, $rcid = 0, #FIMXE: use everywhere!
426 $refreshCache = false, $unhide = false ) {
427
428 $this->checkModelName( $context->getTitle()->getModelName() );
429
430 $diffEngineClass = $this->getDiffEngineClass();
431
432 return new $diffEngineClass( $context, $old, $new, $rcid, $refreshCache, $unhide );
433 }
434
435 /**
436 * Returns the name of the diff engine to use.
437 *
438 * @since 0.1
439 *
440 * @return string
441 */
442 protected function getDiffEngineClass() {
443 return 'DifferenceEngine';
444 }
445
446 /**
447 * attempts to merge differences between three versions.
448 * Returns a new Content object for a clean merge and false for failure or a conflict.
449 *
450 * This default implementation always returns false.
451 *
452 * @param $oldContent String
453 * @param $myContent String
454 * @param $yourContent String
455 * @return Content|Bool
456 */
457 public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
458 return false;
459 }
460
461 /**
462 * Return an applicable autosummary if one exists for the given edit.
463 *
464 * @param $oldContent Content|null: the previous text of the page.
465 * @param $newContent Content|null: The submitted text of the page.
466 * @param $flags Int bitmask: a bitmask of flags submitted for the edit.
467 *
468 * @return string An appropriate autosummary, or an empty string.
469 */
470 public function getAutosummary( Content $oldContent = null, Content $newContent = null, $flags ) {
471 global $wgContLang;
472
473 // Decide what kind of autosummary is needed.
474
475 // Redirect autosummaries
476
477 $ot = !empty( $ot ) ? $oldContent->getRedirectTarget() : false;
478 $rt = !empty( $rt ) ? $newContent->getRedirectTarget() : false;
479
480 if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) {
481
482 $truncatedtext = $newContent->getTextForSummary(
483 250
484 - strlen( wfMsgForContent( 'autoredircomment' ) )
485 - strlen( $rt->getFullText() ) );
486
487 return wfMsgForContent( 'autoredircomment', $rt->getFullText(), $truncatedtext );
488 }
489
490 // New page autosummaries
491 if ( $flags & EDIT_NEW && $newContent->getSize() > 0 ) {
492 // If they're making a new article, give its text, truncated, in the summary.
493
494 $truncatedtext = $newContent->getTextForSummary(
495 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) );
496
497 return wfMsgForContent( 'autosumm-new', $truncatedtext );
498 }
499
500 // Blanking autosummaries
501 if ( $oldContent->getSize() > 0 && $newContent->getSize() == 0 ) {
502 return wfMsgForContent( 'autosumm-blank' );
503 } elseif ( $oldContent->getSize() > 10 * $newContent->getSize() && $newContent->getSize() < 500 ) {
504 // Removing more than 90% of the article
505
506 $truncatedtext = $newContent->getTextForSummary(
507 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) );
508
509 return wfMsgForContent( 'autosumm-replace', $truncatedtext );
510 }
511
512 // If we reach this point, there's no applicable autosummary for our case, so our
513 // autosummary is empty.
514
515 return '';
516 }
517
518 /**
519 * Auto-generates a deletion reason
520 *
521 * @param $title Title: the page's title
522 * @param &$hasHistory Boolean: whether the page has a history
523 * @return mixed String containing deletion reason or empty string, or boolean false
524 * if no revision occurred
525 *
526 * @todo &$hasHistory is extremely ugly, it's here because WikiPage::getAutoDeleteReason() and Article::getReason() have it / want it.
527 */
528 public function getAutoDeleteReason( Title $title, &$hasHistory ) {
529 $dbw = wfGetDB( DB_MASTER );
530
531 // Get the last revision
532 $rev = Revision::newFromTitle( $title );
533
534 if ( is_null( $rev ) ) {
535 return false;
536 }
537
538 // Get the article's contents
539 $content = $rev->getContent();
540 $blank = false;
541
542 // If the page is blank, use the text from the previous revision,
543 // which can only be blank if there's a move/import/protect dummy revision involved
544 if ( $content->getSize() == 0 ) {
545 $prev = $rev->getPrevious();
546
547 if ( $prev ) {
548 $content = $rev->getContent();
549 $blank = true;
550 }
551 }
552
553 // Find out if there was only one contributor
554 // Only scan the last 20 revisions
555 $res = $dbw->select( 'revision', 'rev_user_text',
556 array( 'rev_page' => $title->getArticleID(), $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ),
557 __METHOD__,
558 array( 'LIMIT' => 20 )
559 );
560
561 if ( $res === false ) {
562 // This page has no revisions, which is very weird
563 return false;
564 }
565
566 $hasHistory = ( $res->numRows() > 1 );
567 $row = $dbw->fetchObject( $res );
568
569 if ( $row ) { // $row is false if the only contributor is hidden
570 $onlyAuthor = $row->rev_user_text;
571 // Try to find a second contributor
572 foreach ( $res as $row ) {
573 if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999
574 $onlyAuthor = false;
575 break;
576 }
577 }
578 } else {
579 $onlyAuthor = false;
580 }
581
582 // Generate the summary with a '$1' placeholder
583 if ( $blank ) {
584 // The current revision is blank and the one before is also
585 // blank. It's just not our lucky day
586 $reason = wfMsgForContent( 'exbeforeblank', '$1' );
587 } else {
588 if ( $onlyAuthor ) {
589 $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor );
590 } else {
591 $reason = wfMsgForContent( 'excontent', '$1' );
592 }
593 }
594
595 if ( $reason == '-' ) {
596 // Allow these UI messages to be blanked out cleanly
597 return '';
598 }
599
600 // Max content length = max comment length - length of the comment (excl. $1)
601 $text = $content->getTextForSummary( 255 - ( strlen( $reason ) - 2 ) );
602
603 // Now replace the '$1' placeholder
604 $reason = str_replace( '$1', $text, $reason );
605
606 return $reason;
607 }
608
609 /**
610 * Get the Content object that needs to be saved in order to undo all revisions
611 * between $undo and $undoafter. Revisions must belong to the same page,
612 * must exist and must not be deleted
613 * @param $undo Revision
614 * @param $undoafter null|Revision Must be an earlier revision than $undo
615 * @return mixed string on success, false on failure
616 */
617 public function getUndoContent( Revision $current, Revision $undo, Revision $undoafter = null ) {
618 $cur_content = $current->getContent();
619
620 if ( empty( $cur_content ) ) {
621 return false; // no page
622 }
623
624 $undo_content = $undo->getContent();
625 $undoafter_content = $undoafter->getContent();
626
627 if ( $cur_content->equals( $undo_content ) ) {
628 // No use doing a merge if it's just a straight revert.
629 return $undoafter_content;
630 }
631
632 $undone_content = $this->merge3( $undo_content, $undoafter_content, $cur_content );
633
634 return $undone_content;
635 }
636 }
637
638
639 abstract class TextContentHandler extends ContentHandler {
640
641 public function __construct( $modelName, $formats ) {
642 parent::__construct( $modelName, $formats );
643 }
644
645 public function serializeContent( Content $content, $format = null ) {
646 $this->checkFormat( $format );
647 return $content->getNativeData();
648 }
649
650 /**
651 * attempts to merge differences between three versions.
652 * Returns a new Content object for a clean merge and false for failure or a conflict.
653 *
654 * This text-based implementation uses wfMerge().
655 *
656 * @param $oldContent String
657 * @param $myContent String
658 * @param $yourContent String
659 * @return Content|Bool
660 */
661 public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
662 $this->checkModelName( $oldContent->getModelName() );
663 #TODO: check that all Content objects have the same content model! #XXX: what to do if they don't?
664
665 $format = $this->getDefaultFormat();
666
667 $old = $this->serializeContent( $oldContent, $format );
668 $mine = $this->serializeContent( $myContent, $format );
669 $yours = $this->serializeContent( $yourContent, $format );
670
671 $ok = wfMerge( $old, $mine, $yours, $result );
672
673 if ( !$ok ) {
674 return false;
675 }
676
677 if ( !$result ) {
678 return $this->makeEmptyContent();
679 }
680
681 $mergedContent = $this->unserializeContent( $result, $format );
682 return $mergedContent;
683 }
684
685
686 }
687 class WikitextContentHandler extends TextContentHandler {
688
689 public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) {
690 parent::__construct( $modelName, array( 'application/x-wikitext' ) ); #FIXME: mime
691 }
692
693 public function unserializeContent( $text, $format = null ) {
694 $this->checkFormat( $format );
695
696 return new WikitextContent( $text );
697 }
698
699 public function makeEmptyContent() {
700 return new WikitextContent( '' );
701 }
702
703
704 }
705
706 #TODO: make ScriptContentHandler base class with plugin interface for syntax highlighting!
707
708 class JavaScriptContentHandler extends TextContentHandler {
709
710 public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) {
711 parent::__construct( $modelName, array( 'text/javascript' ) ); #XXX: or use $wgJsMimeType? this is for internal storage, not HTTP...
712 }
713
714 public function unserializeContent( $text, $format = null ) {
715 return new JavaScriptContent( $text );
716 }
717
718 public function makeEmptyContent() {
719 return new JavaScriptContent( '' );
720 }
721 }
722
723 class CssContentHandler extends TextContentHandler {
724
725 public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) {
726 parent::__construct( $modelName, array( 'text/css' ) );
727 }
728
729 public function unserializeContent( $text, $format = null ) {
730 return new CssContent( $text );
731 }
732
733 public function makeEmptyContent() {
734 return new CssContent( '' );
735 }
736
737 }