<?php
-
/**
* 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.
public abstract function getTextForSummary( $maxlength = 250 );
/**
- * Returns native represenation of the data. Interpretation depends on the data model used,
+ * Returns native representation of the data. Interpretation depends on the data model used,
* as given by getDataModel().
*
* @since WD.1
* supported by this Content object.
*
* @param int $model_id the model to check
+ *
+ * @throws MWException
*/
protected function checkModelID( $model_id ) {
if ( $model_id !== $this->model_id ) {
}
/**
- * Conveniance method that returns the ContentHandler singleton for handling the content
+ * Convenience method that returns the ContentHandler singleton for handling the content
* model this Content object uses.
*
* Shorthand for ContentHandler::getForContent( $this )
}
/**
- * Conveniance method that returns the default serialization format for the content model
+ * Convenience method that returns the default serialization format for the content model
* model this Content object uses.
*
* Shorthand for $this->getContentHandler()->getDefaultFormat()
}
/**
- * Conveniance method that returns the list of serialization formats supported
+ * Convenience method that returns the list of serialization formats supported
* for the content model model this Content object uses.
*
* Shorthand for $this->getContentHandler()->getSupportedFormats()
}
/**
- * Conveniance method for serializing this Content object.
+ * Convenience method for serializing this Content object.
*
* Shorthand for $this->getContentHandler()->serializeContent( $this, $format )
*
*
* Will returns false if $that is null.
* Will return true if $that === $this.
- * Will return false if $that->getModleName() != $this->getModel().
+ * Will return false if $that->getModelName() != $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( $b )
+ * * $a->equals( $b ) <=> $b->equals( $a )
* * $a->equals( $b ) && $b->equals( $c ) ==> $a->equals( $c )
*
* @since WD.1
* * $original->getModel() === $copy->getModel()
* * $original->equals( $copy )
*
- * If and only if the Content object is imutable, the copy() method can and should
- * return $this. That is, $copy === $original may be true, but only for imutable content
+ * 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.
*
* @since WD.1
*
* @return ParserOutput
*/
- public abstract function getParserOutput( Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true );
+ public abstract function getParserOutput( Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true ); #TODO: move to ContentHandler; #TODO: rename to getRenderOutput()
+ #TODO: make RenderOutput and RenderOptions base classes
/**
* 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 infomration about the new content.
+ * need to be made to replace information about the old content with information about the new content.
*
* This default implementation calls $this->getParserOutput( $title, null, null, false ), and then
* calls getSecondaryDataUpdates( $title, $recursive ) on the resulting ParserOutput object.
}
/**
- * Construct the redirect destination from this content and return an
- * array of Titles, or null if this content doesn't represent a redirect.
+ * 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.
*
* @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.
+ * the first heading, "1" the text between the first heading (included) 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
*/
public function getSection( $sectionId ) {
/**
* Content object implementation for representing flat text.
*
- * TextContent instances are imutable
+ * TextContent instances are immutable
*
* @since WD.1
*/
}
public function copy() {
- return $this; #NOTE: this is ok since TextContent are imutable.
+ return $this; #NOTE: this is ok since TextContent are immutable.
}
public function getTextForSummary( $maxlength = 250 ) {
/**
* Returns a generic ParserOutput object, wrapping the HTML returned by getHtml().
*
+ * @param Title $title context title for parsing
+ * @param int|null $revId revision id (the parser wants that for some reason)
+ * @param ParserOptions|null $options parser options
+ * @param bool $generateHtml whether or not to generate HTML
+ *
* @return ParserOutput representing the HTML form of the text
*/
public function getParserOutput( Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
return $po;
}
+ /**
+ * Generates an HTML version of the content, for display.
+ * Used by getParserOutput() to construct a ParserOutput object
+ *
+ * @return String
+ */
protected abstract function getHtml( );
/**
$ota = explode( "\n", $wgContLang->segmentForDiff( $otext ) );
$nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
- $diffs = new Diff( $ota, $nta );
+ $diff = new Diff( $ota, $nta );
return $diff;
}
/**
* Returns a ParserOutput object resulting from parsing the content's text using $wgParser.
*
- * @since WikiData1
+ * @since WD.1
*
- * @param IContextSource|null $context
- * @param null $revId
+ * @param \Title $title
+ * @param null $revId
* @param null|ParserOptions $options
- * @param bool $generateHtml
+ * @param bool $generateHtml
*
+ * @internal param \IContextSource|null $context
* @return ParserOutput representing the HTML form of the text
*/
public function getParserOutput( Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
/**
* Returns the section with the given id.
*
- * @param String $sectionId the section's id
+ * @param String $section
+ *
+ * @internal param String $sectionId the section's id
* @return Content|false|null the section, or false if no such section exist, or null if sections are not supported
*/
public function getSection( $section ) {
/**
* Replaces a section in the wikitext
*
- * @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 $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'
+ *
+ * @throws MWException
* @return Content Complete article content, or null if error
*/
public function replaceSection( $section, Content $with, $sectionTitle = '' ) {
* @param ParserOptions $popts
* @return Content
*/
- public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
+ public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) { #FIXME: also needed for JS/CSS!
global $wgParser, $wgConteLang;
$text = $this->getNativeData();
/**
* Returns true if this content is not a redirect, and this content's text is countable according to
- * the criteria defiend by $wgArticleCountMethod.
+ * the criteria defined by $wgArticleCountMethod.
*
- * @param Bool $hasLinks if it is known whether this content contains links, provide this information here,
- * to avoid redundant parsing to find out.
- * @param IContextSource $context context for parsing if necessary
+ * @param Bool $hasLinks if it is known whether this content contains links, provide this information here,
+ * to avoid redundant parsing to find out.
+ * @param null|\Title $title
+ *
+ * @internal param \IContextSource $context context for parsing if necessary
*
* @return bool true if the content is countable
*/
/**
* Returns the message as rendered HTML, using the options supplied to the constructor plus "parse".
+ * @return String the message text, parsed
*/
protected function getHtml( ) {
$opt = array_merge( $this->mOptions, array('parse') );
/**
* Returns the message as raw text, using the options supplied to the constructor minus "parse" and "parseinline".
+ *
+ * @return String the message text, unparsed.
*/
public function getNativeData( ) {
$opt = array_diff( $this->mOptions, array('parse', 'parseinline') );