MediaWiki  1.23.8
ContentHandler.php
Go to the documentation of this file.
1 <?php
34 }
35 
55 abstract class ContentHandler {
63  protected static $enableDeprecationWarnings = false;
64 
94  public static function getContentText( Content $content = null ) {
95  global $wgContentHandlerTextFallback;
96 
97  if ( is_null( $content ) ) {
98  return '';
99  }
100 
101  if ( $content instanceof TextContent ) {
102  return $content->getNativeData();
103  }
104 
105  wfDebugLog( 'ContentHandler', 'Accessing ' . $content->getModel() . ' content as text!' );
106 
107  if ( $wgContentHandlerTextFallback == 'fail' ) {
108  throw new MWException(
109  "Attempt to get text from Content with model " .
110  $content->getModel()
111  );
112  }
113 
114  if ( $wgContentHandlerTextFallback == 'serialize' ) {
115  return $content->serialize();
116  }
117 
118  return null;
119  }
120 
144  public static function makeContent( $text, Title $title = null,
145  $modelId = null, $format = null ) {
146  if ( is_null( $modelId ) ) {
147  if ( is_null( $title ) ) {
148  throw new MWException( "Must provide a Title object or a content model ID." );
149  }
150 
151  $modelId = $title->getContentModel();
152  }
153 
154  $handler = ContentHandler::getForModelID( $modelId );
155 
156  return $handler->unserializeContent( $text, $format );
157  }
158 
193  public static function getDefaultModelFor( Title $title ) {
194  // NOTE: this method must not rely on $title->getContentModel() directly or indirectly,
195  // because it is used to initialize the mContentModel member.
196 
197  $ns = $title->getNamespace();
198 
199  $ext = false;
200  $m = null;
202 
203  // Hook can determine default model
204  if ( !wfRunHooks( 'ContentHandlerDefaultModelFor', array( $title, &$model ) ) ) {
205  if ( !is_null( $model ) ) {
206  return $model;
207  }
208  }
209 
210  // Could this page contain custom CSS or JavaScript, based on the title?
211  $isCssOrJsPage = NS_MEDIAWIKI == $ns && preg_match( '!\.(css|js)$!u', $title->getText(), $m );
212  if ( $isCssOrJsPage ) {
213  $ext = $m[1];
214  }
215 
216  // Hook can force JS/CSS
217  wfRunHooks( 'TitleIsCssOrJsPage', array( $title, &$isCssOrJsPage ) );
218 
219  // Is this a .css subpage of a user page?
220  $isJsCssSubpage = NS_USER == $ns
221  && !$isCssOrJsPage
222  && preg_match( "/\\/.*\\.(js|css)$/", $title->getText(), $m );
223  if ( $isJsCssSubpage ) {
224  $ext = $m[1];
225  }
226 
227  // Is this wikitext, according to $wgNamespaceContentModels or the DefaultModelFor hook?
228  $isWikitext = is_null( $model ) || $model == CONTENT_MODEL_WIKITEXT;
229  $isWikitext = $isWikitext && !$isCssOrJsPage && !$isJsCssSubpage;
230 
231  // Hook can override $isWikitext
232  wfRunHooks( 'TitleIsWikitextPage', array( $title, &$isWikitext ) );
233 
234  if ( !$isWikitext ) {
235  switch ( $ext ) {
236  case 'js':
238  case 'css':
239  return CONTENT_MODEL_CSS;
240  default:
241  return is_null( $model ) ? CONTENT_MODEL_TEXT : $model;
242  }
243  }
244 
245  // We established that it must be wikitext
246 
247  return CONTENT_MODEL_WIKITEXT;
248  }
249 
259  public static function getForTitle( Title $title ) {
260  $modelId = $title->getContentModel();
261 
262  return ContentHandler::getForModelID( $modelId );
263  }
264 
275  public static function getForContent( Content $content ) {
276  $modelId = $content->getModel();
277 
278  return ContentHandler::getForModelID( $modelId );
279  }
280 
284  protected static $handlers;
285 
311  public static function getForModelID( $modelId ) {
312  global $wgContentHandlers;
313 
314  if ( isset( ContentHandler::$handlers[$modelId] ) ) {
315  return ContentHandler::$handlers[$modelId];
316  }
317 
318  if ( empty( $wgContentHandlers[$modelId] ) ) {
319  $handler = null;
320 
321  wfRunHooks( 'ContentHandlerForModelID', array( $modelId, &$handler ) );
322 
323  if ( $handler === null ) {
324  throw new MWException( "No handler for model '$modelId' registered in \$wgContentHandlers" );
325  }
326 
327  if ( !( $handler instanceof ContentHandler ) ) {
328  throw new MWException( "ContentHandlerForModelID must supply a ContentHandler instance" );
329  }
330  } else {
331  $class = $wgContentHandlers[$modelId];
332  $handler = new $class( $modelId );
333 
334  if ( !( $handler instanceof ContentHandler ) ) {
335  throw new MWException( "$class from \$wgContentHandlers is not " .
336  "compatible with ContentHandler" );
337  }
338  }
339 
340  wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId
341  . ': ' . get_class( $handler ) );
342 
343  ContentHandler::$handlers[$modelId] = $handler;
344 
345  return ContentHandler::$handlers[$modelId];
346  }
347 
360  public static function getLocalizedName( $name ) {
361  // Messages: content-model-wikitext, content-model-text,
362  // content-model-javascript, content-model-css
363  $key = "content-model-$name";
364 
365  $msg = wfMessage( $key );
366 
367  return $msg->exists() ? $msg->plain() : $name;
368  }
369 
370  public static function getContentModels() {
371  global $wgContentHandlers;
372 
373  return array_keys( $wgContentHandlers );
374  }
375 
376  public static function getAllContentFormats() {
377  global $wgContentHandlers;
378 
379  $formats = array();
380 
381  foreach ( $wgContentHandlers as $model => $class ) {
382  $handler = ContentHandler::getForModelID( $model );
383  $formats = array_merge( $formats, $handler->getSupportedFormats() );
384  }
385 
386  $formats = array_unique( $formats );
387 
388  return $formats;
389  }
390 
391  // ------------------------------------------------------------------------
392 
396  protected $mModelID;
397 
401  protected $mSupportedFormats;
402 
412  public function __construct( $modelId, $formats ) {
413  $this->mModelID = $modelId;
414  $this->mSupportedFormats = $formats;
415 
416  $this->mModelName = preg_replace( '/(Content)?Handler$/', '', get_class( $this ) );
417  $this->mModelName = preg_replace( '/[_\\\\]/', '', $this->mModelName );
418  $this->mModelName = strtolower( $this->mModelName );
419  }
420 
431  abstract public function serializeContent( Content $content, $format = null );
432 
443  abstract public function unserializeContent( $blob, $format = null );
444 
453  abstract public function makeEmptyContent();
454 
472  public function makeRedirectContent( Title $destination, $text = '' ) {
473  return null;
474  }
475 
484  public function getModelID() {
485  return $this->mModelID;
486  }
487 
496  protected function checkModelID( $model_id ) {
497  if ( $model_id !== $this->mModelID ) {
498  throw new MWException( "Bad content model: " .
499  "expected {$this->mModelID} " .
500  "but got $model_id." );
501  }
502  }
503 
513  public function getSupportedFormats() {
515  }
516 
528  public function getDefaultFormat() {
529  return $this->mSupportedFormats[0];
530  }
531 
545  public function isSupportedFormat( $format ) {
546  if ( !$format ) {
547  return true; // this means "use the default"
548  }
549 
550  return in_array( $format, $this->mSupportedFormats );
551  }
552 
560  protected function checkFormat( $format ) {
561  if ( !$this->isSupportedFormat( $format ) ) {
562  throw new MWException(
563  "Format $format is not supported for content model "
564  . $this->getModelID()
565  );
566  }
567  }
568 
579  public function getActionOverrides() {
580  return array();
581  }
582 
597  public function createDifferenceEngine( IContextSource $context, $old = 0, $new = 0,
598  $rcid = 0, //FIXME: Deprecated, no longer used
599  $refreshCache = false, $unhide = false ) {
600  $diffEngineClass = $this->getDiffEngineClass();
601 
602  return new $diffEngineClass( $context, $old, $new, $rcid, $refreshCache, $unhide );
603  }
604 
624  public function getPageLanguage( Title $title, Content $content = null ) {
626  $pageLang = $wgContLang;
627 
628  if ( $title->getNamespace() == NS_MEDIAWIKI ) {
629  // Parse mediawiki messages with correct target language
630  list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() );
631  $pageLang = wfGetLangObj( $lang );
632  }
633 
634  wfRunHooks( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) );
635 
636  return wfGetLangObj( $pageLang );
637  }
638 
659  public function getPageViewLanguage( Title $title, Content $content = null ) {
660  $pageLang = $this->getPageLanguage( $title, $content );
661 
662  if ( $title->getNamespace() !== NS_MEDIAWIKI ) {
663  // If the user chooses a variant, the content is actually
664  // in a language whose code is the variant code.
665  $variant = $pageLang->getPreferredVariant();
666  if ( $pageLang->getCode() !== $variant ) {
667  $pageLang = Language::factory( $variant );
668  }
669  }
670 
671  return $pageLang;
672  }
673 
690  public function canBeUsedOn( Title $title ) {
691  $ok = true;
692 
693  wfRunHooks( 'ContentModelCanBeUsedOn', array( $this->getModelID(), $title, &$ok ) );
694 
695  return $ok;
696  }
697 
705  protected function getDiffEngineClass() {
706  return 'DifferenceEngine';
707  }
708 
723  public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
724  return false;
725  }
726 
738  public function getAutosummary( Content $oldContent = null, Content $newContent = null,
739  $flags ) {
740  // Decide what kind of auto-summary is needed.
741 
742  // Redirect auto-summaries
743 
749  $ot = !is_null( $oldContent ) ? $oldContent->getRedirectTarget() : null;
750  $rt = !is_null( $newContent ) ? $newContent->getRedirectTarget() : null;
751 
752  if ( is_object( $rt ) ) {
753  if ( !is_object( $ot )
754  || !$rt->equals( $ot )
755  || $ot->getFragment() != $rt->getFragment()
756  ) {
757  $truncatedtext = $newContent->getTextForSummary(
758  250
759  - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() )
760  - strlen( $rt->getFullText() ) );
761 
762  return wfMessage( 'autoredircomment', $rt->getFullText() )
763  ->rawParams( $truncatedtext )->inContentLanguage()->text();
764  }
765  }
766 
767  // New page auto-summaries
768  if ( $flags & EDIT_NEW && $newContent->getSize() > 0 ) {
769  // If they're making a new article, give its text, truncated, in
770  // the summary.
771 
772  $truncatedtext = $newContent->getTextForSummary(
773  200 - strlen( wfMessage( 'autosumm-new' )->inContentLanguage()->text() ) );
774 
775  return wfMessage( 'autosumm-new' )->rawParams( $truncatedtext )
776  ->inContentLanguage()->text();
777  }
778 
779  // Blanking auto-summaries
780  if ( !empty( $oldContent ) && $oldContent->getSize() > 0 && $newContent->getSize() == 0 ) {
781  return wfMessage( 'autosumm-blank' )->inContentLanguage()->text();
782  } elseif ( !empty( $oldContent )
783  && $oldContent->getSize() > 10 * $newContent->getSize()
784  && $newContent->getSize() < 500
785  ) {
786  // Removing more than 90% of the article
787 
788  $truncatedtext = $newContent->getTextForSummary(
789  200 - strlen( wfMessage( 'autosumm-replace' )->inContentLanguage()->text() ) );
790 
791  return wfMessage( 'autosumm-replace' )->rawParams( $truncatedtext )
792  ->inContentLanguage()->text();
793  }
794 
795  // If we reach this point, there's no applicable auto-summary for our
796  // case, so our auto-summary is empty.
797  return '';
798  }
799 
815  public function getAutoDeleteReason( Title $title, &$hasHistory ) {
816  $dbw = wfGetDB( DB_MASTER );
817 
818  // Get the last revision
820 
821  if ( is_null( $rev ) ) {
822  return false;
823  }
824 
825  // Get the article's contents
826  $content = $rev->getContent();
827  $blank = false;
828 
829  // If the page is blank, use the text from the previous revision,
830  // which can only be blank if there's a move/import/protect dummy
831  // revision involved
832  if ( !$content || $content->isEmpty() ) {
833  $prev = $rev->getPrevious();
834 
835  if ( $prev ) {
836  $rev = $prev;
837  $content = $rev->getContent();
838  $blank = true;
839  }
840  }
841 
842  $this->checkModelID( $rev->getContentModel() );
843 
844  // Find out if there was only one contributor
845  // Only scan the last 20 revisions
846  $res = $dbw->select( 'revision', 'rev_user_text',
847  array(
848  'rev_page' => $title->getArticleID(),
849  $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0'
850  ),
851  __METHOD__,
852  array( 'LIMIT' => 20 )
853  );
854 
855  if ( $res === false ) {
856  // This page has no revisions, which is very weird
857  return false;
858  }
859 
860  $hasHistory = ( $res->numRows() > 1 );
861  $row = $dbw->fetchObject( $res );
862 
863  if ( $row ) { // $row is false if the only contributor is hidden
864  $onlyAuthor = $row->rev_user_text;
865  // Try to find a second contributor
866  foreach ( $res as $row ) {
867  if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999
868  $onlyAuthor = false;
869  break;
870  }
871  }
872  } else {
873  $onlyAuthor = false;
874  }
875 
876  // Generate the summary with a '$1' placeholder
877  if ( $blank ) {
878  // The current revision is blank and the one before is also
879  // blank. It's just not our lucky day
880  $reason = wfMessage( 'exbeforeblank', '$1' )->inContentLanguage()->text();
881  } else {
882  if ( $onlyAuthor ) {
883  $reason = wfMessage(
884  'excontentauthor',
885  '$1',
886  $onlyAuthor
887  )->inContentLanguage()->text();
888  } else {
889  $reason = wfMessage( 'excontent', '$1' )->inContentLanguage()->text();
890  }
891  }
892 
893  if ( $reason == '-' ) {
894  // Allow these UI messages to be blanked out cleanly
895  return '';
896  }
897 
898  // Max content length = max comment length - length of the comment (excl. $1)
899  $text = $content ? $content->getTextForSummary( 255 - ( strlen( $reason ) - 2 ) ) : '';
900 
901  // Now replace the '$1' placeholder
902  $reason = str_replace( '$1', $text, $reason );
903 
904  return $reason;
905  }
906 
920  public function getUndoContent( Revision $current, Revision $undo, Revision $undoafter ) {
921  $cur_content = $current->getContent();
922 
923  if ( empty( $cur_content ) ) {
924  return false; // no page
925  }
926 
927  $undo_content = $undo->getContent();
928  $undoafter_content = $undoafter->getContent();
929 
930  if ( !$undo_content || !$undoafter_content ) {
931  return false; // no content to undo
932  }
933 
934  $this->checkModelID( $cur_content->getModel() );
935  $this->checkModelID( $undo_content->getModel() );
936  $this->checkModelID( $undoafter_content->getModel() );
937 
938  if ( $cur_content->equals( $undo_content ) ) {
939  // No use doing a merge if it's just a straight revert.
940  return $undoafter_content;
941  }
942 
943  $undone_content = $this->merge3( $undo_content, $undoafter_content, $cur_content );
944 
945  return $undone_content;
946  }
947 
962  public function makeParserOptions( $context ) {
963  global $wgContLang, $wgEnableParserLimitReporting;
964 
965  if ( $context instanceof IContextSource ) {
967  } elseif ( $context instanceof User ) { // settings per user (even anons)
968  $options = ParserOptions::newFromUser( $context );
969  } elseif ( $context === 'canonical' ) { // canonical settings
971  } else {
972  throw new MWException( "Bad context for parser options: $context" );
973  }
974 
975  $options->enableLimitReport( $wgEnableParserLimitReporting ); // show inclusion/loop reports
976  $options->setTidy( true ); // fix bad HTML
977 
978  return $options;
979  }
980 
989  public function isParserCacheSupported() {
990  return false;
991  }
992 
1002  public function supportsSections() {
1003  return false;
1004  }
1005 
1015  public function supportsRedirects() {
1016  return false;
1017  }
1018 
1032  public static function deprecated( $func, $version, $component = false ) {
1033  if ( self::$enableDeprecationWarnings ) {
1034  wfDeprecated( $func, $version, $component, 3 );
1035  }
1036  }
1037 
1055  public static function runLegacyHooks( $event, $args = array(),
1056  $warn = null
1057  ) {
1058 
1059  if ( $warn === null ) {
1061  }
1062 
1063  if ( !Hooks::isRegistered( $event ) ) {
1064  return true; // nothing to do here
1065  }
1066 
1067  if ( $warn ) {
1068  // Log information about which handlers are registered for the legacy hook,
1069  // so we can find and fix them.
1070 
1071  $handlers = Hooks::getHandlers( $event );
1072  $handlerInfo = array();
1073 
1075 
1076  foreach ( $handlers as $handler ) {
1077  if ( is_array( $handler ) ) {
1078  if ( is_object( $handler[0] ) ) {
1079  $info = get_class( $handler[0] );
1080  } else {
1081  $info = $handler[0];
1082  }
1083 
1084  if ( isset( $handler[1] ) ) {
1085  $info .= '::' . $handler[1];
1086  }
1087  } elseif ( is_object( $handler ) ) {
1088  $info = get_class( $handler[0] );
1089  $info .= '::on' . $event;
1090  } else {
1091  $info = $handler;
1092  }
1093 
1094  $handlerInfo[] = $info;
1095  }
1096 
1098 
1099  wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()! Handlers: " .
1100  implode( ', ', $handlerInfo ), 2 );
1101  }
1102 
1103  // convert Content objects to text
1104  $contentObjects = array();
1105  $contentTexts = array();
1106 
1107  foreach ( $args as $k => $v ) {
1108  if ( $v instanceof Content ) {
1109  /* @var Content $v */
1110 
1111  $contentObjects[$k] = $v;
1112 
1113  $v = $v->serialize();
1114  $contentTexts[$k] = $v;
1115  $args[$k] = $v;
1116  }
1117  }
1118 
1119  // call the hook functions
1120  $ok = wfRunHooks( $event, $args );
1121 
1122  // see if the hook changed the text
1123  foreach ( $contentTexts as $k => $orig ) {
1124  /* @var Content $content */
1125 
1126  $modified = $args[$k];
1127  $content = $contentObjects[$k];
1128 
1129  if ( $modified !== $orig ) {
1130  // text was changed, create updated Content object
1131  $content = $content->getContentHandler()->unserializeContent( $modified );
1132  }
1133 
1134  $args[$k] = $content;
1135  }
1136 
1137  return $ok;
1138  }
1139 }
ContentHandler\deprecated
static deprecated( $func, $version, $component=false)
Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if self::$enableDeprecationWa...
Definition: ContentHandler.php:1030
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:67
ContentHandler
A content handler knows how do deal with a specific type of content on a wiki page.
Definition: ContentHandler.php:55
ContentHandler\getForModelID
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Definition: ContentHandler.php:311
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
ContentHandler\getAutosummary
getAutosummary(Content $oldContent=null, Content $newContent=null, $flags)
Return an applicable auto-summary if one exists for the given edit.
Definition: ContentHandler.php:736
ContentHandler\getAllContentFormats
static getAllContentFormats()
Definition: ContentHandler.php:376
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Hooks\getHandlers
static getHandlers( $name)
Returns an array of all the event functions attached to a hook This combines functions registered via...
Definition: Hooks.php:103
ContentHandler\makeParserOptions
makeParserOptions( $context)
Get parser options suitable for rendering and caching the article.
Definition: ContentHandler.php:960
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
Revision\getContent
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Definition: Revision.php:999
CONTENT_MODEL_CSS
const CONTENT_MODEL_CSS
Definition: Defines.php:285
ContentHandler\getActionOverrides
getActionOverrides()
Returns overrides for action handlers.
Definition: ContentHandler.php:577
ContentHandler\checkModelID
checkModelID( $model_id)
Definition: ContentHandler.php:494
MWNamespace\getNamespaceContentModel
static getNamespaceContentModel( $index)
Get the default content model for a namespace This does not mean that all pages in that namespace hav...
Definition: Namespace.php:430
ContentHandler\getAutoDeleteReason
getAutoDeleteReason(Title $title, &$hasHistory)
Auto-generates a deletion reason.
Definition: ContentHandler.php:813
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1040
ContentHandler\unserializeContent
unserializeContent( $blob, $format=null)
Unserializes a Content object of the type supported by this ContentHandler.
ContentHandler\$handlers
static $handlers
Definition: ContentHandler.php:284
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
ContentHandler\getPageViewLanguage
getPageViewLanguage(Title $title, Content $content=null)
Get the language in which the content of this page is written when viewed by user.
Definition: ContentHandler.php:657
ContentHandler\$mSupportedFormats
string[] $mSupportedFormats
Definition: ContentHandler.php:399
ContentHandler\getForTitle
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Definition: ContentHandler.php:259
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:283
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
ContentHandler\serializeContent
serializeContent(Content $content, $format=null)
Serializes a Content object of the type supported by this ContentHandler.
ContentHandler\supportsSections
supportsSections()
Returns true if this content model supports sections.
Definition: ContentHandler.php:1000
ContentHandler\runLegacyHooks
static runLegacyHooks( $event, $args=array(), $warn=null)
Call a legacy hook that uses text instead of Content objects.
Definition: ContentHandler.php:1053
ContentHandler\isSupportedFormat
isSupportedFormat( $format)
Returns true if $format is a serialization format supported by this ContentHandler,...
Definition: ContentHandler.php:543
ContentHandler\getLocalizedName
static getLocalizedName( $name)
Returns the localized name for a given content model.
Definition: ContentHandler.php:360
ContentHandler\createDifferenceEngine
createDifferenceEngine(IContextSource $context, $old=0, $new=0, $rcid=0, $refreshCache=false, $unhide=false)
Factory for creating an appropriate DifferenceEngine for this content model.
Definition: ContentHandler.php:595
ContentHandler\canBeUsedOn
canBeUsedOn(Title $title)
Determines whether the content type handled by this ContentHandler can be used on the given page.
Definition: ContentHandler.php:688
Revision
Definition: Revision.php:26
ContentHandler\supportsRedirects
supportsRedirects()
Returns true if this content model supports redirects.
Definition: ContentHandler.php:1013
ContentHandler\getDefaultModelFor
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
Definition: ContentHandler.php:193
ContentHandler\$enableDeprecationWarnings
static $enableDeprecationWarnings
Switch for enabling deprecation warnings.
Definition: ContentHandler.php:63
MWException
MediaWiki exception.
Definition: MWException.php:26
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1127
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
ContentHandler\getContentModels
static getContentModels()
Definition: ContentHandler.php:370
ParserOptions\newFromUserAndLang
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
Definition: ParserOptions.php:386
$blob
$blob
Definition: testCompression.php:61
MWContentSerializationException
Exception representing a failure to serialize or unserialize a content object.
Definition: ContentHandler.php:33
wfMessage
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 after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4010
wfGetLangObj
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
Definition: GlobalFunctions.php:1352
ContentHandler\merge3
merge3(Content $oldContent, Content $myContent, Content $yourContent)
Attempts to merge differences between three versions.
Definition: ContentHandler.php:721
ContentHandler\makeEmptyContent
makeEmptyContent()
Creates an empty Content object of the type supported by this ContentHandler.
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
MessageCache\singleton
static singleton()
Get the signleton instance of this class.
Definition: MessageCache.php:101
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:144
ContentHandler\getPageLanguage
getPageLanguage(Title $title, Content $content=null)
Get the language in which the content of the given page is written.
Definition: ContentHandler.php:622
$options
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 & $options
Definition: hooks.txt:1530
$ok
$ok
Definition: UtfNormalTest.php:71
ContentHandler\isParserCacheSupported
isParserCacheSupported()
Returns true for content models that support caching using the ParserCache mechanism.
Definition: ContentHandler.php:987
Revision\newFromTitle
static newFromTitle( $title, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given title.
Definition: Revision.php:106
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
ContentHandler\getDefaultFormat
getDefaultFormat()
The format used for serialization/deserialization by default by this ContentHandler.
Definition: ContentHandler.php:526
ParserOptions\newFromContext
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
Definition: ParserOptions.php:396
ContentHandler\getDiffEngineClass
getDiffEngineClass()
Returns the name of the diff engine to use.
Definition: ContentHandler.php:703
$version
$version
Definition: parserTests.php:86
ContentHandler\$mModelID
string $mModelID
Definition: ContentHandler.php:395
TextContent
Content object implementation for representing flat text.
Definition: TextContent.php:35
IContextSource
Interface for objects which can provide a context on request.
Definition: IContextSource.php:29
Content
Base interface for content objects.
Definition: Content.php:34
EDIT_NEW
const EDIT_NEW
Definition: Defines.php:189
Hooks\isRegistered
static isRegistered( $name)
Returns true if a hook has a function registered to it.
Definition: Hooks.php:89
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1337
$args
if( $line===false) $args
Definition: cdb.php:62
Title
Represents a title within MediaWiki.
Definition: Title.php:35
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
ContentHandler\makeRedirectContent
makeRedirectContent(Title $destination, $text='')
Creates a new Content object that acts as a redirect to the given page, or null of redirects are not ...
Definition: ContentHandler.php:470
ContentHandler\checkFormat
checkFormat( $format)
Convenient for checking whether a format provided as a parameter is actually supported.
Definition: ContentHandler.php:558
ContentHandler\getContentText
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
Definition: ContentHandler.php:94
$ext
$ext
Definition: NoLocalSettings.php:34
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
NS_USER
const NS_USER
Definition: Defines.php:81
Content\getModel
getModel()
Returns the ID of the content model used by this Content object.
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:184
wfWarn
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
Definition: GlobalFunctions.php:1141
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:87
CONTENT_MODEL_JAVASCRIPT
const CONTENT_MODEL_JAVASCRIPT
Definition: Defines.php:284
ContentHandler\__construct
__construct( $modelId, $formats)
Constructor, initializing the ContentHandler instance with its model ID and a list of supported forma...
Definition: ContentHandler.php:410
CONTENT_MODEL_TEXT
const CONTENT_MODEL_TEXT
Definition: Defines.php:286
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
ContentHandler\getUndoContent
getUndoContent(Revision $current, Revision $undo, Revision $undoafter)
Get the Content object that needs to be saved in order to undo all revisions between $undo and $undoa...
Definition: ContentHandler.php:918
$res
$res
Definition: database.txt:21
ContentHandler\getSupportedFormats
getSupportedFormats()
Returns a list of serialization formats supported by the serializeContent() and unserializeContent() ...
Definition: ContentHandler.php:511
ContentHandler\getModelID
getModelID()
Returns the model id that identifies the content model this ContentHandler can handle.
Definition: ContentHandler.php:482
ContentHandler\getForContent
static getForContent(Content $content)
Returns the appropriate ContentHandler singleton for the given Content object.
Definition: ContentHandler.php:275
ParserOptions\newFromUser
static newFromUser( $user)
Get a ParserOptions object from a given user.
Definition: ParserOptions.php:375