*
* @return ContentHandler
*
- * @since 1.WD
+ * @since 1.21
*/
public function getContentHandler() {
return ContentHandler::getForModelID( $this->getContentModel() );
*
* @return String
*
- * @since 1.WD
+ * @since 1.21
*/
public function getContentModel() {
if ( $this->exists() ) {
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to $wgUser
* Revision::RAW get the text regardless of permissions
+ * @param $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return Content|null The content of the current revision
*
- * @since 1.WD
+ * @since 1.21
*/
- public function getContent( $audience = Revision::FOR_PUBLIC ) {
+ public function getContent( $audience = Revision::FOR_PUBLIC, User $user = null ) {
$this->loadLastEdit();
if ( $this->mLastRevision ) {
return $this->mLastRevision->getContent( $audience );
*
* @param $audience Integer: one of:
* Revision::FOR_PUBLIC to be displayed to all users
- * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
+ * @param $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return String|false The text of the current revision
- * @deprecated as of 1.WD, getContent() should be used instead.
+ * @deprecated as of 1.21, getContent() should be used instead.
*/
- public function getText( $audience = Revision::FOR_PUBLIC ) { #@todo: deprecated, replace usage!
- wfDeprecated( __METHOD__, '1.WD' );
-
+ public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { #@todo: deprecated, replace usage!
+ wfDeprecated( __METHOD__, '1.21' );
$this->loadLastEdit();
if ( $this->mLastRevision ) {
- return $this->mLastRevision->getText( $audience );
+ return $this->mLastRevision->getText( $audience, $user );
}
return false;
}
* Get the text of the current revision. No side-effects...
*
* @return String|bool The text of the current revision. False on failure
- * @deprecated as of 1.WD, getContent() should be used instead.
+ * @deprecated as of 1.21, getContent() should be used instead.
*/
public function getRawText() {
- wfDeprecated( __METHOD__, '1.WD' );
+ wfDeprecated( __METHOD__, '1.21' );
return $this->getText( Revision::RAW );
}
/**
* @param $audience Integer: one of:
* Revision::FOR_PUBLIC to be displayed to all users
- * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
+ * @param $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return int user ID for the user that made the last article revision
*/
- public function getUser( $audience = Revision::FOR_PUBLIC ) {
+ public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
$this->loadLastEdit();
if ( $this->mLastRevision ) {
- return $this->mLastRevision->getUser( $audience );
+ return $this->mLastRevision->getUser( $audience, $user );
} else {
return -1;
}
* Get the User object of the user who created the page
* @param $audience Integer: one of:
* Revision::FOR_PUBLIC to be displayed to all users
- * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
+ * @param $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return User|null
*/
- public function getCreator( $audience = Revision::FOR_PUBLIC ) {
+ public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
$revision = $this->getOldestRevision();
if ( $revision ) {
- $userName = $revision->getUserText( $audience );
+ $userName = $revision->getUserText( $audience, $user );
return User::newFromName( $userName, false );
} else {
return null;
/**
* @param $audience Integer: one of:
* Revision::FOR_PUBLIC to be displayed to all users
- * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
+ * @param $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return string username of the user that made the last article revision
*/
- public function getUserText( $audience = Revision::FOR_PUBLIC ) {
+ public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
$this->loadLastEdit();
if ( $this->mLastRevision ) {
- return $this->mLastRevision->getUserText( $audience );
+ return $this->mLastRevision->getUserText( $audience, $user );
} else {
return '';
}
/**
* @param $audience Integer: one of:
* Revision::FOR_PUBLIC to be displayed to all users
- * Revision::FOR_THIS_USER to be displayed to $wgUser
+ * Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
+ * @param $user User object to check for, only if FOR_THIS_USER is passed
+ * to the $audience parameter
* @return string Comment stored for the last article revision
*/
- public function getComment( $audience = Revision::FOR_PUBLIC ) {
+ public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
$this->loadLastEdit();
if ( $this->mLastRevision ) {
- return $this->mLastRevision->getComment( $audience );
+ return $this->mLastRevision->getComment( $audience, $user );
} else {
return '';
}
return $ret;
}
- /**
- * Get the content 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
- * @param $undo Revision
- * @param $undoafter Revision Must be an earlier revision than $undo
- * @return mixed string on success, false on failure
- * @since 1.WD
- * Before we had the Content object, this was done in getUndoText
- */
- public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
- $handler = $undo->getContentHandler();
- return $handler->getUndoContent( $this->getRevision(), $undo, $undoafter );
- }
+ /**
+ * Get the content 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
+ * @param $undo Revision
+ * @param $undoafter Revision Must be an earlier revision than $undo
+ * @return mixed string on success, false on failure
+ * @since 1.21
+ * Before we had the Content object, this was done in getUndoText
+ */
+ public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
+ $handler = $undo->getContentHandler();
+ return $handler->getUndoContent( $this->getRevision(), $undo, $undoafter );
+ }
/**
* Get the text that needs to be saved in order to undo all revisions
* @param $undo Revision
* @param $undoafter Revision Must be an earlier revision than $undo
* @return mixed string on success, false on failure
- * @deprecated since 1.WD: use ContentHandler::getUndoContent() instead.
+ * @deprecated since 1.21: use ContentHandler::getUndoContent() instead.
*/
public function getUndoText( Revision $undo, Revision $undoafter = null ) {
- wfDeprecated( __METHOD__, '1.WD' );
+ wfDeprecated( __METHOD__, '1.21' );
$this->loadLastEdit();
* @param $edittime String: revision timestamp or null to use the current revision
* @return String new complete article text, or null if error
*
- * @deprecated since 1.WD, use replaceSectionContent() instead
+ * @deprecated since 1.21, use replaceSectionContent() instead
*/
public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) {
- wfDeprecated( __METHOD__, '1.WD' );
+ wfDeprecated( __METHOD__, '1.21' );
if ( strval( $section ) == '' ) { //NOTE: keep condition in sync with condition in replaceSectionContent!
// Whole-page edit; let the whole text through
*
* @return Content new complete article content, or null if error
*
- * @since 1.WD
+ * @since 1.21
*/
public function replaceSectionContent( $section, Content $sectionContent, $sectionTitle = '', $edittime = null ) {
wfProfileIn( __METHOD__ );
*
* Compatibility note: this function previously returned a boolean value indicating success/failure
*
- * @deprecated since 1.WD: use doEditContent() instead.
- * @todo: use doEditContent() instead everywhere
+ * @deprecated since 1.21: use doEditContent() instead.
*/
public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
- wfDeprecated( __METHOD__, '1.WD' );
+ wfDeprecated( __METHOD__, '1.21' );
$content = ContentHandler::makeContent( $text, $this->getTitle() );
* new: Boolean indicating if the function attempted to create a new article
* revision: The revision object for the inserted revision, or null
*
- * @since 1.WD
+ * @since 1.21
*/
public function doEditContent( Content $content, $summary, $flags = 0, $baseRevId = false,
User $user = null, $serialisation_format = null ) {
/**
* Get parser options suitable for rendering the primary article wikitext
- * @param User|string $user User object or 'canonical'
+ *
+ * @see ContentHandler::makeParserOptions
+ *
+ * @param IContextSource|User|string $context One of the following:
+ * - IContextSource: Use the User and the Language of the provided
+ * context
+ * - User: Use the provided User object and $wgLang for the language,
+ * so use an IContextSource object if possible.
+ * - 'canonical': Canonical options (anonymous user with default
+ * preferences and content language).
* @return ParserOptions
*/
- public function makeParserOptions( $user ) {
- global $wgContLang;
- if ( $user instanceof User ) { // settings per user (even anons)
- $options = ParserOptions::newFromUser( $user );
- } else { // canonical settings
- $options = ParserOptions::newFromUserAndLang( new User, $wgContLang );
+ public function makeParserOptions( $context ) {
+ $options = $this->getContentHandler()->makeParserOptions( $context );
+
+ if ( $this->getTitle()->isConversionTable() ) {
+ //@todo: ConversionTable should become a separate content model, so we don't need special cases like this one.
+ $options->disableContentConversion();
}
- $options->enableLimitReport(); // show inclusion/loop reports
- $options->setTidy( true ); // fix bad HTML
+
return $options;
}
* Prepare text which is about to be saved.
* Returns a stdclass with source, pst and output members
*
- * @deprecated in 1.WD: use prepareContentForEdit instead.
+ * @deprecated in 1.21: use prepareContentForEdit instead.
*/
public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
- wfDeprecated( __METHOD__, '1.WD' );
+ wfDeprecated( __METHOD__, '1.21' );
$content = ContentHandler::makeContent( $text, $this->getTitle() );
return $this->prepareContentForEdit( $content, $revid , $user );
}
*
* @return bool|object
*
- * @since 1.WD
+ * @since 1.21
*/
public function prepareContentForEdit( Content $content, $revid = null, User $user = null, $serialization_format = null ) {
global $wgParser, $wgContLang, $wgUser;
$user = is_null( $user ) ? $wgUser : $user;
- // @TODO fixme: check $user->getId() here???
+ //XXX: check $user->getId() here???
if ( $this->mPreparedEdit
&& $this->mPreparedEdit->newContent
* @param $comment String: comment submitted
* @param $minor Boolean: whereas it's a minor modification
*
- * @deprecated since 1.WD, use doEditContent() instead.
+ * @deprecated since 1.21, use doEditContent() instead.
*/
public function doQuickEdit( $text, User $user, $comment = '', $minor = 0 ) {
- wfDeprecated( __METHOD__, "1.WD" );
+ wfDeprecated( __METHOD__, "1.21" );
$content = ContentHandler::makeContent( $text, $this->getTitle() );
return $this->doQuickEditContent( $content, $user, $comment , $minor );
$dbw->commit( __METHOD__ );
}
- wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$user, $reason, $id ) );
+ wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$user, $reason, $id, $content, $logEntry ) );
$status->value = $logid;
return $status;
}
* @param $flags Int bitmask: a bitmask of flags submitted for the edit.
* @return string An appropriate autosummary, or an empty string.
*
- * @deprecated since 1.WD, use ContentHandler::getAutosummary() instead
+ * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
*/
public static function getAutosummary( $oldtext, $newtext, $flags ) {
# NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
- wfDeprecated( __METHOD__, '1.WD' );
+ wfDeprecated( __METHOD__, '1.21' );
$handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT );
$oldContent = is_null( $oldtext ) ? null : $handler->unserializeContent( $oldtext );