[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
A content object represents page content, e.g. the text to show on a page. Content objects have no knowledge about how they relate to wiki pages. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Author: | Daniel Kinzler |
File Size: | 523 lines (17 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Content:: (32 methods):
getTextForSearchIndex()
getWikitextForTransclusion()
getTextForSummary()
getNativeData()
getSize()
getModel()
getContentHandler()
getDefaultFormat()
getSupportedFormats()
isSupportedFormat()
serialize()
isEmpty()
isValid()
equals()
copy()
isCountable()
getParserOutput()
getSecondaryDataUpdates()
getRedirectChain()
getRedirectTarget()
getUltimateRedirectTarget()
isRedirect()
updateRedirect()
getSection()
replaceSection()
preSaveTransform()
addSectionHeader()
preloadTransform()
prepareSave()
getDeletionUpdates()
matchMagicWord()
convert()
getTextForSearchIndex() X-Ref |
return: string A string representing the content in a way useful for |
getWikitextForTransclusion() X-Ref |
return: string|bool The wikitext to include when another page includes this |
getTextForSummary( $maxLength = 250 ) X-Ref |
Returns a textual representation of the content suitable for use in edit summaries and log messages. param: int $maxLength Maximum length of the summary text. return: string The summary text. |
getNativeData() X-Ref |
Returns native representation of the data. Interpretation depends on the data model used, as given by getDataModel(). return: mixed The native representation of the content. Could be a |
getSize() X-Ref |
Returns the content's nominal size in "bogo-bytes". return: int |
getModel() X-Ref |
Returns the ID of the content model used by this Content object. Corresponds to the CONTENT_MODEL_XXX constants. return: string The model id |
getContentHandler() X-Ref |
Convenience method that returns the ContentHandler singleton for handling the content model that this Content object uses. Shorthand for ContentHandler::getForContent( $this ) return: ContentHandler |
getDefaultFormat() X-Ref |
Convenience method that returns the default serialization format for the content model that this Content object uses. Shorthand for $this->getContentHandler()->getDefaultFormat() return: string |
getSupportedFormats() X-Ref |
Convenience method that returns the list of serialization formats supported for the content model that this Content object uses. Shorthand for $this->getContentHandler()->getSupportedFormats() return: string[] List of supported serialization formats |
isSupportedFormat( $format ) X-Ref |
Returns true if $format is a supported serialization format for this Content object, false if it isn't. Note that this should always return true if $format is null, because null stands for the default serialization. Shorthand for $this->getContentHandler()->isSupportedFormat( $format ) param: string $format The serialization format to check. return: bool Whether the format is supported |
serialize( $format = null ) X-Ref |
Convenience method for serializing this Content object. Shorthand for $this->getContentHandler()->serializeContent( $this, $format ) param: string $format The desired serialization format, or null for the default format. return: string Serialized form of this Content object. |
isEmpty() X-Ref |
Returns true if this Content object represents empty content. return: bool Whether this Content object is empty |
isValid() X-Ref |
Returns whether the content is valid. This is intended for local validity checks, not considering global consistency. Content needs to be valid before it can be saved. This default implementation always returns true. return: bool |
equals( Content $that = null ) X-Ref |
Returns true if this Content objects is conceptually equivalent to the given Content object. Contract: - Will return false if $that is null. - Will return true if $that === $this. - Will return false if $that->getModel() != $this->getModel(). - Will return false if $that->getNativeData() is not equal to $this->getNativeData(), where the meaning of "equal" depends on the actual data model. Implementations should be careful to make equals() transitive and reflexive: - $a->equals( $b ) <=> $b->equals( $a ) - $a->equals( $b ) && $b->equals( $c ) ==> $a->equals( $c ) param: Content $that The Content object to compare to. return: bool True if this Content object is equal to $that, false otherwise. |
copy() X-Ref |
Return a copy of this Content object. The following must be true for the object returned: if $copy = $original->copy() - get_class($original) === get_class($copy) - $original->getModel() === $copy->getModel() - $original->equals( $copy ) If and only if the Content object is immutable, the copy() method can and should return $this. That is, $copy === $original may be true, but only for immutable content objects. return: Content A copy of this object |
isCountable( $hasLinks = null ) X-Ref |
Returns true if this content is countable as a "real" wiki page, provided that it's also in a countable location (e.g. a current revision in the main namespace). param: bool $hasLinks If it is known whether this content contains return: bool |
getParserOutput( Title $title, $revId = null,ParserOptions $options = null, $generateHtml = true ) X-Ref |
Parse the Content object and generate a ParserOutput from the result. $result->getText() can be used to obtain the generated HTML. If no HTML is needed, $generateHtml can be set to false; in that case, $result->getText() may return null. param: Title $title The page title to use as a context for rendering. param: int $revId Optional revision ID being rendered. param: ParserOptions $options Any parser options. param: bool $generateHtml Whether to generate HTML (default: true). If false, return: ParserOutput |
getSecondaryDataUpdates( Title $title, Content $old = null,$recursive = true, ParserOutput $parserOutput = null ) X-Ref |
Returns a list of DataUpdate objects for recording information about this Content in some secondary data store. If the optional second argument, $old, is given, the updates may model only the changes that need to be made to replace information about the old content with information about the new content. This default implementation calls $this->getParserOutput( $content, $title, null, null, false ), and then calls getSecondaryDataUpdates( $title, $recursive ) on the resulting ParserOutput object. Subclasses may implement this to determine the necessary updates more efficiently, or make use of information about the old content. param: Title $title The context for determining the necessary updates param: Content $old An optional Content object representing the param: bool $recursive Whether to include recursive updates (default: param: ParserOutput $parserOutput Optional ParserOutput object. return: DataUpdate[] A list of DataUpdate objects for putting information |
getRedirectChain() X-Ref |
Construct the redirect destination from this content and return an array of Titles, or null if this content doesn't represent a redirect. The last element in the array is the final destination after all redirects have been resolved (up to $wgMaxRedirects times). return: Title[]|null List of Titles, with the destination last. |
getRedirectTarget() X-Ref |
Construct the redirect destination from this content and return a Title, or null if this content doesn't represent a redirect. This will only return the immediate redirect target, useful for the redirect table and other checks that don't need full recursion. return: Title|null The corresponding Title. |
getUltimateRedirectTarget() X-Ref |
Construct the redirect destination from this content and return the Title, or null if this content doesn't represent a redirect. This will recurse down $wgMaxRedirects times or until a non-redirect target is hit in order to provide (hopefully) the Title of the final destination instead of another redirect. There is usually no need to override the default behavior, subclasses that want to implement redirects should override getRedirectTarget(). return: Title|null |
isRedirect() X-Ref |
Returns whether this Content represents a redirect. Shorthand for getRedirectTarget() !== null. return: bool |
updateRedirect( Title $target ) X-Ref |
If this Content object is a redirect, this method updates the redirect target. Otherwise, it does nothing. param: Title $target The new redirect target return: Content A new Content object with the updated redirect (or $this |
getSection( $sectionId ) X-Ref |
Returns the section with the given ID. param: string|number $sectionId Section identifier as a number or string return: Content|bool|null The section, or false if no such section |
replaceSection( $sectionId, Content $with, $sectionTitle = '' ) X-Ref |
Replaces a section of the content and returns a Content object with the section replaced. param: string|number|null|bool $sectionId Section identifier as a number or string param: Content $with New content of the section param: string $sectionTitle New section's subject, only if $section is 'new' return: string|null Complete article text, or null if error |
preSaveTransform( Title $title, User $user, ParserOptions $parserOptions ) X-Ref |
Returns a Content object with pre-save transformations applied (or this object if no transformations apply). param: Title $title param: User $user param: ParserOptions $parserOptions return: Content |
addSectionHeader( $header ) X-Ref |
Returns a new WikitextContent object with the given section heading prepended, if supported. The default implementation just returns this Content object unmodified, ignoring the section header. param: string $header return: Content |
preloadTransform( Title $title, ParserOptions $parserOptions, $params = array() X-Ref |
Returns a Content object with preload transformations applied (or this object if no transformations apply). param: Title $title param: ParserOptions $parserOptions param: array $params return: Content |
prepareSave( WikiPage $page, $flags, $baseRevId, User $user ) X-Ref |
Prepare Content for saving. Called before Content is saved by WikiPage::doEditContent() and in similar places. This may be used to check the content's consistency with global state. This function should NOT write any information to the database. Note that this method will usually be called inside the same transaction bracket that will be used to save the new revision. Note that this method is called before any update to the page table is performed. This means that $page may not yet know a page ID. param: WikiPage $page The page to be saved. param: int $flags Bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent() param: int $baseRevId The ID of the current revision param: User $user return: Status A status object indicating whether the content was |
getDeletionUpdates( WikiPage $page,ParserOutput $parserOutput = null ) X-Ref |
Returns a list of updates to perform when this content is deleted. The necessary updates may be taken from the Content object, or depend on the current state of the database. param: WikiPage $page The deleted page param: ParserOutput $parserOutput Optional parser output object return: DataUpdate[] A list of DataUpdate instances that will clean up the |
matchMagicWord( MagicWord $word ) X-Ref |
Returns true if this Content object matches the given magic word. param: MagicWord $word The magic word to match return: bool Whether this Content object matches the given magic word. |
convert( $toModel, $lossy = '' ) X-Ref |
Converts this content object into another content object with the given content model, if that is possible. param: string $toModel The desired content model, use the CONTENT_MODEL_XXX flags. param: string $lossy Optional flag, set to "lossy" to allow lossy conversion. If lossy return: Content|bool A content object with the content model $toModel, or false if |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |