protected $model_name;
/**
+ * @since WD.1
+ *
* @return String a string representing the content in a way useful for building a full text search index.
* If no useful representation exists, this method returns an empty string.
*/
public abstract function getTextForSearchIndex( );
/**
+ * @since WD.1
+ *
* @return String the wikitext to include when another page includes this content, or false if the content is not
* includable in a wikitext page.
*
/**
* Returns a textual representation of the content suitable for use in edit summaries and log messages.
*
+ * @since WD.1
+ *
* @param int $maxlength maximum length of the summary text
* @return String the summary text
*/
* Returns native represenation of the data. Interpretation depends on the data model used,
* as given by getDataModel().
*
+ * @since WD.1
+ *
* @return mixed the native representation of the content. Could be a string, a nested array
* structure, an object, a binary blob... anything, really.
*
* Returns the name of the content model used by this content objects.
* Corresponds to the CONTENT_MODEL_XXX constants.
*
+ * @since WD.1
+ *
* @return String the model name
*/
public function getModelName() {
*
* Shorthand for ContentHandler::getForContent( $this )
*
+ * @since WD.1
+ *
* @return ContentHandler
*/
public function getContentHandler() {
*
* Shorthand for $this->getContentHandler()->getDefaultFormat()
*
+ * @since WD.1
+ *
* @return ContentHandler
*/
public function getDefaultFormat() {
*
* Shorthand for $this->getContentHandler()->getSupportedFormats()
*
+ * @since WD.1
+ *
* @return array of supported serialization formats
*/
public function getSupportedFormats() {
*
* Shorthand for $this->getContentHandler()->isSupportedFormat( $format )
*
+ * @since WD.1
+ *
* @param String $format the format to check
* @return bool whether the format is supported
*/
*
* Shorthand for $this->getContentHandler()->serializeContent( $this, $format )
*
+ * @since WD.1
+ *
* @param null|String $format the desired serialization format (or null for the default format).
* @return String serialized form of this Content object
*/
/**
* Returns true if this Content object represents empty content.
*
+ * @since WD.1
+ *
* @return bool whether this Content object is empty
*/
public function isEmpty() {
* * $a->equals( $b ) <=> $b->equals( $b )
* * $a->equals( $b ) && $b->equals( $c ) ==> $a->equals( $c )
*
+ * @since WD.1
+ *
* @param Content $that the Content object to compare to
* @return bool true if this Content object is euqual to $that, false otherwise.
*/
* return $this. That is, $copy === $original may be true, but only for imutable content
* objects.
*
+ * @since WD.1
+ *
* @return Content. A copy of this object
*/
public abstract function copy( );
* 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).
*
+ * @since WD.1
+ *
* @param $hasLinks Bool: if it is known whether this content contains links, provide this information here,
* to avoid redundant parsing to find out.
* @return boolean
* the result of calling getText() on the ParserOutput object returned by
* this method is undefined.
*
+ * @since WD.1
+ *
* @return ParserOutput
*/
public abstract function getParserOutput( IContextSource $context, $revId = null, ParserOptions $options = NULL, $generateHtml = true );
* The last element in the array is the final destination after all redirects
* have been resolved (up to $wgMaxRedirects times).
*
+ * @since WD.1
+ *
* @return Array of Titles, with the destination last
*/
public function getRedirectChain() {
* This will only return the immediate redirect target, useful for
* the redirect table and other checks that don't need full recursion.
*
+ * @since WD.1
+ *
* @return Title: The corresponding Title
*/
public function getRedirectTarget() {
* 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.
*
+ * @since WD.1
+ *
* @return Title
*/
public function getUltimateRedirectTarget() {
return null;
}
+ /**
+ * @since WD.1
+ *
+ * @return bool
+ */
public function isRedirect() {
- return $this->getRedirectTarget() != null;
+ return $this->getRedirectTarget() !== null;
}
/**
*
* The default implementation returns null.
*
+ * @since WD.1
+ *
* @param String $sectionId the section's id, given as a numeric string. The id "0" retrieves the section before
* the first heading, "1" the text between the first heading (inluded) and the second heading (excluded), etc.
* @return Content|Boolean|null the section, or false if no such section exist, or null if sections are not supported
/**
* Replaces a section of the content and returns a Content object with the section replaced.
*
+ * @since WD.1
+ *
* @param $section empty/null/false or a section number (0, 1, 2, T1, T2...), or "new"
* @param $with Content: new content of the section
* @param $sectionTitle String: new section's subject, only if $section is 'new'
/**
* Returns a Content object with pre-save transformations applied (or this object if no transformations apply).
*
+ * @since WD.1
+ *
* @param Title $title
* @param User $user
* @param null|ParserOptions $popts
* 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.
*
+ * @since WD.1
+ *
* @param $header String
* @return Content
*/
/**
* Returns a Content object with preload transformations applied (or this object if no transformations apply).
*
+ * @since WD.1
+ *
* @param Title $title
* @param null|ParserOptions $popts
* @return Content
* Content object implementation for representing flat text.
*
* TextContent instances are imutable
+ *
+ * @since WD.1
*/
abstract class TextContent extends Content {
}
+/**
+ * @since WD.1
+ */
class WikitextContent extends TextContent {
public function __construct( $text ) {
}
+/**
+ * @since WD.1
+ */
class MessageContent extends TextContent {
public function __construct( $msg_key, $params = null, $options = null ) {
parent::__construct(null, CONTENT_MODEL_WIKITEXT); #XXX: messages may be wikitext, html or plain text! and maybe even something else entirely.
}
-
+/**
+ * @since WD.1
+ */
class JavaScriptContent extends TextContent {
public function __construct( $text ) {
parent::__construct($text, CONTENT_MODEL_JAVASCRIPT);
}
+/**
+ * @since WD.1
+ */
class CssContent extends TextContent {
public function __construct( $text ) {
parent::__construct($text, CONTENT_MODEL_CSS);
* * If $wgContentHandlerTextFallback is 'ignore' and $content is not a TextContent object, this method returns null.
* * otherwise, the behaviour is undefined.
*
+ * @since WD.1
+ *
* @static
* @param Content|null $content
* @return null|string the textual form of $content, if available
* $text will be deserialized into a Content object of the model specified by $modelName (or,
* if that is not given, $title->getContentModelName()) using the given format.
*
+ * @since WD.1
+ *
* @static
* @param string $text the textual represenation, will be unserialized to create the Content object
* @param Title $title the title of the page this text belongs to, required as a context for deserialization
*
* Note: this is used by, and may thus not use, Title::getContentModelName()
*
+ * @since WD.1
+ *
* @static
* @param Title $title
* @return null|string default model name for the page given by $title
/**
* returns the appropriate ContentHandler singleton for the given title
*
+ * @since WD.1
+ *
* @static
* @param Title $title
* @return ContentHandler
/**
* returns the appropriate ContentHandler singleton for the given Content object
*
+ * @since WD.1
+ *
* @static
* @param Content $content
* @return ContentHandler
* If no ContentHandler is defined for the desired $modelName, the ContentHandler may be provided by the
* a ContentHandlerForModelName hook. if no Contenthandler can be determined, an MWException is raised.
*
+ * @since WD.1
+ *
* @static
* @param $modelName String the name of the content model for which to get a handler. Use CONTENT_MODEL_XXX constants.
* @return ContentHandler the ContentHandler singleton for handling the model given by $modelName
/**
* Serializes Content object of the type supported by this ContentHandler.
*
+ * @since WD.1
+ *
* @abstract
* @param Content $content the Content object to serialize
* @param null $format the desired serialization format
/**
* Unserializes a Content object of the type supported by this ContentHandler.
*
+ * @since WD.1
+ *
* @abstract
* @param $blob String serialized form of the content
* @param null $format the format used for serialization
/**
* Creates an empty Content object of the type supported by this ContentHandler.
*
+ * @since WD.1
+ *
* @return Content
*/
public abstract function makeEmptyContent();
* Returns the model name that identifies the content model this ContentHandler can handle.
* Use with the CONTENT_MODEL_XXX constants.
*
+ * @since WD.1
+ *
* @return String the model name
*/
public function getModelName() {
/**
* Throws an MWException if $modelName is not the content model handeled by this ContentHandler.
*
+ * @since WD.1
+ *
* @param String $modelName the model name to check
*/
protected function checkModelName( $modelName ) {
* Returns a list of serialization formats supported by the serializeContent() and unserializeContent() methods of
* this ContentHandler.
*
+ * @since WD.1
+ *
* @return array of serialization formats as MIME type like strings
*/
public function getSupportedFormats() {
* This default implementation will return the first element of the array of formats
* that was passed to the constructor.
*
+ * @since WD.1
+ *
* @return String the name of the default serialiozation format as a MIME type
*/
public function getDefaultFormat() {
* Note that if $format is null, this method always returns true, because null
* means "use the default format".
*
+ * @since WD.1
+ *
* @param String $format the serialization format to check
* @return bool
*/
* (and only when) $wgActions[$action] === true. This allows subclasses
* to override the default action handlers.
*
+ * @since WD.1
+ *
* @return Array
*/
public function getActionOverrides() {
* NOTE: does *not* do special handling for Image and Category pages!
* Use Article::newFromTitle() for that!
*
+ * @since WD.1
+ *
* @param Title $title
* @return Article
* @todo Article is being refactored into an action class, keep track of that
/**
* Return an EditPage object suitable for editing the given object
*
+ * @since WD.1
+ *
* @param Article $article
* @return EditPage
*/
/**
* Return an ExternalEdit object suitable for editing the given object
*
+ * @since WD.1
+ *
* @param IContextSource $context
* @return ExternalEdit
* @todo does anyone or anythign actually use the external edit facility? Can we just deprecate and ignore it?
/**
* Factory
+ * @since WD.1
+ *
* @param $context IContextSource context to use, anything else will be ignored
* @param $old Integer old ID we want to show and diff with.
* @param $new String either 'prev' or 'next'.
/**
* Returns the name of the diff engine to use.
*
- * @since 0.1
+ * @since WD.1
*
* @return string
*/
*
* This default implementation always returns false.
*
+ * @since WD.1
+ *
* @param $oldContent String
* @param $myContent String
* @param $yourContent String
/**
* Return an applicable autosummary if one exists for the given edit.
*
+ * @since WD.1
+ *
* @param $oldContent Content|null: the previous text of the page.
* @param $newContent Content|null: The submitted text of the page.
* @param $flags Int bitmask: a bitmask of flags submitted for the edit.
/**
* Auto-generates a deletion reason
*
+ * @since WD.1
+ *
* @param $title Title: the page's title
* @param &$hasHistory Boolean: whether the page has a history
* @return mixed String containing deletion reason or empty string, or boolean false
* Get the Content object that needs to be saved in order to undo all revisions
* between $undo and $undoafter. Revisions must belong to the same page,
* must exist and must not be deleted
+ *
+ * @since WD.1
+ *
* @param $current Revision the current text
* @param $undo Revision the revision to undo
* @param $undoafter Revision Must be an earlier revision than $undo
+ *
* @return mixed string on success, false on failure
*/
public function getUndoContent( Revision $current, Revision $undo, Revision $undoafter ) {
* Returns true for content models that support caching using the ParserCache mechanism.
* See WikiPage::isParserCacheUser().
*
+ * @since WD.1
+ *
* @return bool
*/
public function isParserCacheSupported() {
}
/**
+ * @since WD.1
+ *
* @param $page WikiPage the page that was deleted (note: $page->getId() must still return the old page ID!)
*
* @return array a list of SecondaryDataUpdate instances that will clean up the database ofter deletion.
}
}
-
+/**
+ * @since WD.1
+ */
abstract class TextContentHandler extends ContentHandler {
public function __construct( $modelName, $formats ) {
}
+
+/**
+ * @since WD.1
+ */
class WikitextContentHandler extends TextContentHandler {
public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) {
#XXX: make ScriptContentHandler base class with plugin interface for syntax highlighting?
+/**
+ * @since WD.1
+ */
class JavaScriptContentHandler extends TextContentHandler {
public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) {
}
}
+/**
+ * @since WD.1
+ */
class CssContentHandler extends TextContentHandler {
public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) {
*
* Abstract base class for update jobs that put some secondary data extracted
* from article content into the database.
+ *
+ * @since WD.1
*/
abstract class SecondaryDBDataUpdate extends SecondaryDataUpdate {
*
* Because nested transactions are not supportred by the Database class, this implementation
* checked Database::trxLevel() and only opens a transaction if none is yet active.
+ *
+ * @since WD.1
*/
public function beginTransaction() {
// NOTE: nested transactions are not supported, only start a transaction if none is open
/**
* Commit the database transaction started via beginTransaction (if any).
+ *
+ * @since WD.1
*/
public function commitTransaction() {
if ( $this->mHasTransaction ) {
/**
* Abort the database transaction started via beginTransaction (if any).
+ *
+ * @since WD.1
*/
public function abortTransaction() {
if ( $this->mHasTransaction ) {
* Invalidate the cache of a list of pages from a single namespace.
* This is intended for use by subclasses.
*
+ * @since WD.1
+ *
* @param $namespace Integer
* @param $dbkeys Array
*/
*
* @todo: add support for transactions
*
+ * @since WD.1
*/
abstract class SecondaryDataUpdate implements DeferrableUpdate {
/**
* Begin an appropriate transaction, if any.
* This default implementation does nothing.
+ *
+ * @since WD.1
*/
public function beginTransaction() {
//noop
/**
* Commit the transaction started via beginTransaction, if any.
* This default implementation does nothing.
+ *
+ * @since WD.1
*/
public function commitTransaction() {
//noop
/**
* Abort / roll back the transaction started via beginTransaction, if any.
* This default implementation does nothing.
+ *
+ * @since WD.1
*/
public function rollbackTransaction() {
//noop
* This allows for limited transactional logic across multiple baceknds for storing
* secondary data.
*
+ * @since WD.1
+ *
* @static
* @param $updates array a list of SecondaryDataUpdate instances
*/
* Adds an update job to the output. Any update jobs added to the output will eventually bexecuted in order to
* store any secondary information extracted from the page's content.
*
+ * @since WD.1
+ *
* @param SecondaryDataUpdate $update
*/
public function addSecondaryDataUpdate( SecondaryDataUpdate $update ) {
* extracted from the page's content, includingt a LinksUpdate object for all links stopred in
* this ParserOutput object.
*
+ * @since WD.1
+ *
* @param $title Title of the page we're updating. If not given, a title object will be created based on $this->getTitleText()
* @param $recursive Boolean: queue jobs for recursive updates?
*