# Pre-fill content with error message so that if something
# fails we'll have something telling us what we intended.
- $this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ), array() ) ; // @todo: this isn't page content but a UI message. horrible.
+ // @todo: this isn't page content but a UI message. horrible.
+ $this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ), array() ) ;
if ( $oldid ) {
# $this->mRevision might already be fetched by getOldIDFromRequest()
throw new MWException( "can't change parser options after they have already been set" );
}
- $this->mParserOptions = clone $options; // clone, so if $options is modified later, it doesn't confuse the parser cache.
+ // clone, so if $options is modified later, it doesn't confuse the parser cache.
+ $this->mParserOptions = clone $options;
}
/**
define( 'CONTENT_FORMAT_CSS', 'text/css' ); // for css pages
define( 'CONTENT_FORMAT_TEXT', 'text/plain' ); // for future use, e.g. with some plain-html messages.
define( 'CONTENT_FORMAT_HTML', 'text/html' ); // for future use, e.g. with some plain-html messages.
-define( 'CONTENT_FORMAT_SERIALIZED', 'application/vnd.php.serialized' ); // for future use with the api, and for use by extensions
+define( 'CONTENT_FORMAT_SERIALIZED', 'application/vnd.php.serialized' ); // for future use with the api and for extensions
define( 'CONTENT_FORMAT_JSON', 'application/json' ); // for future use with the api, and for use by extensions
define( 'CONTENT_FORMAT_XML', 'application/xml' ); // for future use with the api, and for use by extensions
/**@}*/
wfDeprecated( __METHOD__, "1.WD" );
$content = $this->getPreloadedContent( $preload );
- $text = $content->serialize( $this->content_format ); #XXX: really use serialized form? use ContentHandler::getContentText() instead?!
+ $text = $content->serialize( $this->content_format );
+ #XXX: really use serialized form? use ContentHandler::getContentText() instead?!
return $text;
}
return $status;
}
- $content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
+ $content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
+ $this->content_model, $this->content_format );
$result['sectionanchor'] = '';
if ( $this->section == 'new' ) {
$sectionTitle = $this->summary;
}
- $textbox_content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
+ $textbox_content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
+ $this->content_model, $this->content_format );
$content = null;
if ( $this->isConflict ) {
- wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" );
- $content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle, $this->edittime );
+ wfDebug( __METHOD__ . ": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
+ . " (article time '{$timestamp}')\n" );
+
+ $content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content,
+ $sectionTitle, $this->edittime );
} else {
- wfDebug( __METHOD__ . ": getting section '$this->section'\n" );
+ wfDebug( __METHOD__ . ": getting section '{$this->section}'\n" );
$content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle );
}
return $status;
}
- $content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
+ $content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
+ $this->content_model, $this->content_format );
# Handle the user preference to force summaries here, but not for null edits
if ( $this->section != 'new' && !$this->allowBlankSummary
( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) |
( $bot ? EDIT_FORCE_BOT : 0 );
- $doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags, false, null, $this->content_format );
+ $doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags,
+ false, null, $this->content_format );
if ( $doEditStatus->isOK() ) {
$result['redirect'] = $content->isRedirect();
function mergeChangesInto( &$editText ){
wfDebug( __METHOD__, "1.WD" );
- $editContent = ContentHandler::makeContent( $editText, $this->getTitle(), $this->content_model, $this->content_format );
+ $editContent = ContentHandler::makeContent( $editText, $this->getTitle(),
+ $this->content_model, $this->content_format );
$ok = $this->mergeChangesIntoContent( $editContent );
$oldContent = $this->getOriginalContent();
}
+ #XXX: handle parse errors ?
$textboxContent = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
- $this->content_model, $this->content_format ); #XXX: handle parse errors ?
+ $this->content_model, $this->content_format );
$newContent = $this->mArticle->replaceSectionContent(
$this->section, $textboxContent,
if ( $newtext != $newtext_orig ) {
#if the hook changed the text, create a new Content object accordingly.
- $newContent = ContentHandler::makeContent( $newtext, $this->getTitle(), $newContent->getModel() ); #XXX: handle parse errors ?
+ #XXX: handle parse errors ?
+ $newContent = ContentHandler::makeContent( $newtext, $this->getTitle(),
+ $newContent->getModel() );
}
wfRunHooks( 'EditPageGetDiffContent', array( $this, &$newContent ) );
$note = '';
try {
- $content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
+ $content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
+ $this->content_model, $this->content_format );
if ( $this->mTriedSave && !$this->mTokenOk ) {
if ( $this->mTokenOkExceptSuffix ) {
$note = wfMessage( 'edit_form_incomplete' )->text() ;
} else {
$note = wfMessage( 'previewnote' )->text() .
- ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage( 'continue-editing' )->text() . ']]';
+ ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' '
+ . wfMessage( 'continue-editing' )->text() . ']]';
}
$parserOptions = ParserOptions::newFromUser( $wgUser );
if ( $toparse !== $toparse_orig ) {
#hook changed the text, create new Content object
- $content = ContentHandler::makeContent( $toparse, $this->getTitle(), $this->content_model, $this->content_format );
+ $content = ContentHandler::makeContent( $toparse, $this->getTitle(),
+ $this->content_model, $this->content_format );
}
wfRunHooks( 'EditPageGetPreviewContent', array( $this, &$content ) );
$parserOptions->enableLimitReport();
- #XXX: For CSS/JS pages, we should have called the ShowRawCssJs hook here. But it's now deprecated, so never mind
+ #XXX: For CSS/JS pages, we should have called the ShowRawCssJs hook here.
+ # But it's now deprecated, so never mind
$content = $content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
// TODO: might be a saner way to get a meaningfull context here?
}
}
} catch (MWContentSerializationException $ex) {
- $note .= "\n\n" . wfMessage('content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() )->parse();
+ $m = wfMessage('content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() );
+ $note .= "\n\n" . $m->parse();
$previewHTML = '';
}
# if we have a content object, use it to set the model and type
if ( !empty( $row['content'] ) ) {
- if ( !empty( $row['text_id'] ) ) { //@todo: when is that set? test with external store setup! check out insertOn() [dk]
- throw new MWException( "Text already stored in external store (id {$row['text_id']}), can't serialize content object" );
+ //@todo: when is that set? test with external store setup! check out insertOn() [dk]
+ if ( !empty( $row['text_id'] ) ) {
+ throw new MWException( "Text already stored in external store (id {$row['text_id']}), "
+ . "can't serialize content object" );
}
$row['content_model'] = $row['content']->getModel();
$this->mTitle = null; // Load on demand if needed
}
- $this->mCurrent = false; // @todo: XXX: really? we are about to create a revision. it will usually then be the current one.
+ // @todo: XXX: really? we are about to create a revision. it will usually then be the current one.
+ $this->mCurrent = false;
// If we still have no length, see it we have the text to figure it out
if ( !$this->mSize ) {
*
* @return String
*
- * @deprecated since 1.WD. Instead, use Revision::getContent( Revision::RAW ) or Revision::getSerializedData() as appropriate.
+ * @deprecated since 1.WD. Instead, use Revision::getContent( Revision::RAW )
+ * or Revision::getSerializedData() as appropriate.
*/
public function getRawText() {
wfDeprecated( __METHOD__, "1.WD" );
if ( $this->getContentModel() != $defaultModel ) {
$t = $title->getPrefixedDBkey();
- throw new MWException( "Can't save non-default content model with \$wgContentHandlerUseDB disabled: model is $model , default for $t is $defaultModel" );
+ throw new MWException( "Can't save non-default content model with \$wgContentHandlerUseDB disabled: "
+ . "model is $model , default for $t is $defaultModel" );
}
if ( $this->getContentFormat() != $defaultFormat ) {
$t = $title->getPrefixedDBkey();
- throw new MWException( "Can't use non-default content format with \$wgContentHandlerUseDB disabled: format is $format, default for $t is $defaultFormat" );
+ throw new MWException( "Can't use non-default content format with \$wgContentHandlerUseDB disabled: "
+ . "format is $format, default for $t is $defaultFormat" );
}
}
}
} else {
# Fail safe (not a redirect after all. strange.)
- wfDebug( __METHOD__ . ": failsafe: database sais " . $nt->getPrefixedDBkey() . " is a redirect, but it doesn't contain a valid redirect.\n" );
+ wfDebug( __METHOD__ . ": failsafe: database sais " . $nt->getPrefixedDBkey() .
+ " is a redirect, but it doesn't contain a valid redirect.\n" );
return false;
}
}
if ( in_array( 'include_old', $options ) ) {
$old_cmp = '>=';
}
- if ( in_array( 'include_new', $options ) ) {\r
- $new_cmp = '<=';\r
- }\r
- if ( in_array( 'include_both', $options ) ) {\r
- $old_cmp = '>=';\r
+ if ( in_array( 'include_new', $options ) ) {
+ $new_cmp = '<=';
+ }
+ if ( in_array( 'include_both', $options ) ) {
+ $old_cmp = '>=';
$new_cmp = '<=';
}
// No DB query needed if $old and $new are the same or successive revisions:
return ( $old_cmp === '>' && $new_cmp === '<' ) ? 0 : 1;
}
return ( $old->getRawUserText() === $new->getRawUserText() ) ? 1 : 2;
- }\r
+ }
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'revision', 'DISTINCT rev_user_text',
array(
$this->mLatest = $revision->getId();
$this->mIsRedirect = (bool)$rt;
# Update the LinkCache.
- LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect, $this->mLatest, $revision->getContentModel() );
+ LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect,
+ $this->mLatest, $revision->getContentModel() );
}
wfProfileOut( __METHOD__ );
throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() );
}
- $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); # could even make section title, but that's not required.
+ # could even make section title, but that's not required.
+ $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() );
$newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle, $edittime );
* Compatibility note: this function previously returned a boolean value indicating success/failure
*
* @deprecated since 1.WD: use doEditContent() instead.
+ * @todo: use doEditContent() instead everywhere
*/
- public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { #@todo: use doEditContent() instead
+ public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
wfDeprecated( __METHOD__, '1.WD' );
$content = ContentHandler::makeContent( $text, $this->getTitle() );
}
DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
- DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) ); #TODO: let the search engine decide what to do with the content object
+ DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) );
+ #@TODO: let the search engine decide what to do with the content object
# If this is another user's talk page, update newtalk.
# Don't do this if $options['changed'] = false (null-edits) nor if
}
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- $msgtext = $content->getWikitextForTransclusion(); #XXX: could skip pseudo-messages like js/css here, based on content model.
+ #XXX: could skip pseudo-messages like js/css here, based on content model.
+ $msgtext = $content->getWikitextForTransclusion();
if ( $msgtext === false || $msgtext === null ) $msgtext = '';
MessageCache::singleton()->replace( $shortTitle, $msgtext );
function doWork() {
global $wgUseFileCache;
- // @todo: several of the methods called on $this->page are not declared in Page, but present in WikiPage and delegated by Article.
+ // @todo: several of the methods called on $this->page are not declared in Page, but present
+ // in WikiPage and delegated by Article.
$isCurrent = $this->revid === $this->page->getLatest();
if ( $this->content !== null ) {
$content = $this->content;
} elseif ( $isCurrent ) {
- $content = $this->page->getContent( Revision::RAW ); #XXX: why use RAW audience here, and PUBLIC (default) below?
+ #XXX: why use RAW audience here, and PUBLIC (default) below?
+ $content = $this->page->getContent( Revision::RAW );
} else {
$rev = Revision::newFromTitle( $this->page->getTitle(), $this->revid );
if ( $rev === null ) {
return false;
}
- $content = $rev->getContent(); #XXX: why use PUBLIC audience here (default), and RAW above?
+
+ #XXX: why use PUBLIC audience here (default), and RAW above?
+ $content = $rev->getContent();
}
$time = - microtime( true );
$name = $titleObj->getPrefixedDBkey();
$model = $contentHandler->getModelID();
- $this->dieUsage( "The requested format $contentFormat is not supported for content model $model used by $name", 'badformat' );
+ $this->dieUsage( "The requested format $contentFormat is not supported for content model ".
+ " $model used by $name", 'badformat' );
}
$apiResult = $this->getResult();
if ( !( $content instanceof TextContent ) ) {
// @todo: ContentHandler should have an isFlat() method or some such
- // @todo: XXX: or perhaps there should be Content::append(), Content::prepend() and Content::supportsConcatenation()
+ // @todo: XXX: or perhaps there should be Content::append(), Content::prepend()
+ // @todo: ...and Content::supportsConcatenation()
$mode = $contentHandler->getModelID();
$this->dieUsage( "Can't append to pages using content model $mode", 'appendnotsupported' );
}
array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ),
array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ),
array( 'code' => 'sectionsnotsupported', 'info' => 'Sections are not supported for this type of page.' ),
- array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using the text based edit API.' ),
- array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending or prepending text.' ),
- array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to the page\'s content model' ),
+ array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using '
+ . 'the text based edit API.' ),
+ array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending '
+ . 'or prepending text.' ),
+ array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to '
+ . 'the page\'s content model' ),
array( 'customcssprotected' ),
array( 'customjsprotected' ),
)
return;
}
// Not cached (save or load)
- $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts ); #FIXME: use Content object¡
+ #FIXME: use Content object!
+ $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts );
}
$result_array = array();
$model = $content->getModel();
$name = $title->getPrefixedDBkey();
- $this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
+ $this->dieUsage( "The requested format {$this->contentFormat} is not supported ".
+ "for content model $model used by $name", 'badformat' );
}
$text = $content->serialize( $format );
if ( !is_null( $this->difftotext ) ) {
$model = $title->getContentModel();
- if ( $this->contentFormat && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
+ if ( $this->contentFormat
+ && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
+
$name = $title->getPrefixedDBkey();
- $this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
+ $this->dieUsage( "The requested format {$this->contentFormat} is not supported for ".
+ "content model $model used by $name", 'badformat' );
}
$difftocontent = ContentHandler::makeContent( $this->difftotext, $title, $model, $this->contentFormat );
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'nosuchrevid', 'diffto' ),
- array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).' ),
- array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.' ),
+ array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options '
+ . '(limit, startid, endid, dirNewer, start, end).' ),
+ array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, '
+ . ' but the limit, startid, endid, dirNewer, user, excludeuser, '
+ . 'start and end parameters may only be used on a single page.' ),
array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
- array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to the page\'s content model' ),
+ array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied '
+ . ' to the page\'s content model' ),
) );
}
public function getExamples() {
return array(
- 'api.php?action=setnotificationtimestamp&entirewatchlist=&token=ABC123' => 'Reset the notification status for the entire watchlist',
- 'api.php?action=setnotificationtimestamp&titles=Main_page&token=ABC123' => 'Reset the notification status for "Main page"',
- 'api.php?action=setnotificationtimestamp&titles=Main_page×tamp=2012-01-01T00:00:00Z&token=ABC123' => 'Set the notification timestamp for "Main page" so all edits since 1 January 2012 are unviewed',
+ 'api.php?action=setnotificationtimestamp&entirewatchlist=&token=ABC123'
+ => 'Reset the notification status for the entire watchlist',
+ 'api.php?action=setnotificationtimestamp&titles=Main_page&token=ABC123'
+ => 'Reset the notification status for "Main page"',
+ 'api.php?action=setnotificationtimestamp&titles=Main_page×tamp=2012-01-01T00:00:00Z&token=ABC123'
+ => 'Set the notification timestamp for "Main page" so all edits since 1 January 2012 are unviewed',
);
}
wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title} ($code)" );
$message = null; // no negative caching
} else {
- $message = $content->getWikitextForTransclusion(); #XXX: is this the reight way to turn a Content object into a mesage?
+ #XXX: is this the reight way to turn a Content object into a mesage?
+ $message = $content->getWikitextForTransclusion();
if ( $message === false || $message === null ) {
- wfDebugLog( 'MessageCache', __METHOD__ . ": message content doesn't provide wikitext (content model: #" . $content->getContentHandler() . ")" );
+ wfDebugLog( 'MessageCache', __METHOD__ . ": message content doesn't provide wikitext "
+ . "(content model: #" . $content->getContentHandler() . ")" );
+
$message = false; // negative caching
} else {
$this->mCache[$code][$title] = ' ' . $message;
$out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
$out->setArticleFlag( true );
- if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) { #NOTE: only needed for B/C: custom rendering of JS/CSS via hook
+ #NOTE: only needed for B/C: custom rendering of JS/CSS via hook
+ if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
// Stolen from Article::view --AG 2007-10-11
// Give hooks a chance to customise the output
// @TODO: standardize this crap into one function
if ( !Hook::isRegistered( 'ShowRawCssJs' )
- || wfRunHooks( 'ShowRawCssJs', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) { #NOTE: deperecated hook, B/C only
+ || wfRunHooks( 'ShowRawCssJs', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) {
+ // NOTE: deprecated hook, B/C only
// use the content object's own rendering
$po = $this->mContentObject->getParserOutput();
$out->addHTML( $po->getText() );
} elseif( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
// Handled by extension
} elseif( Hooks::isRegistered( 'ArticleViewCustom' )
- && !wfRunHooks( 'ArticleViewCustom', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) { #NOTE: deperecated hook, B/C only
+ && !wfRunHooks( 'ArticleViewCustom', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) {
+ // NOTE: deprecated hook, B/C only
// Handled by extension
} else {
// Normal page
$mTimestamp; # Timestamp of the revision
private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
- private $mSecondaryDataUpdates = array(); # List of instances of DataUpdate, used to cause some information extracted from the page in a custom place.
+ private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else.
const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
*
* @since 1.20
*
- * @param $title Title of the page we're updating. If not given, a title object will be created based on $this->getTitleText()
+ * @param $title Title The 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?
*
* @return Array. An array of instances of DataUpdate
protected function initText() {
if ( !isset( $this->mText ) ) {
if ( $this->mRevision != null ) {
+ //TODO: don't use the text, but the content object!
$content = $this->mRevision->getContent();
- $this->mText = $content->getTextForSearchIndex(); //XXX: maybe we don't even need the text, but the content object?
+ $this->mText = $content->getTextForSearchIndex();
} else { // TODO: can we fetch raw wikitext for commons images?
$this->mText = '';
}
function getTextSnippet( $terms ) {
global $wgUser, $wgAdvancedSearchHighlighting;
$this->initText();
+
+ // TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter.
list( $contextlines, $contextchars ) = SearchEngine::userHighlightPrefs( $wgUser );
- $h = new SearchHighlighter(); // TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter.
+ $h = new SearchHighlighter();
if ( $wgAdvancedSearchHighlighting )
return $h->highlightText( $this->mText, $terms, $contextlines, $contextchars );
else
$title = Title::makeTitleSafe( NS_PROJECT, $page ); # Show list in content language
if( is_object( $title ) && $title->exists() ) {
$rev = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
- $this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) ); #FIXME: need a way to do this via ContentHandler (or enforce flat text-based content)
+ #FIXME: need a way to do this via ContentHandler (or enforce flat text-based content)
+ $this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) );
return true;
}
protected function feedItemDesc( $row ) {
$revision = Revision::newFromId( $row->rev_id );
if( $revision ) {
+ //XXX: include content model/type in feed item?
return '<p>' . htmlspecialchars( $revision->getUserText() ) .
$this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
"</p>\n<hr />\n<div>" .
- nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>"; //TODO: include content model/type in feed item?
+ nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>";
}
return '';
}
$out->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER, $user ), $this->mTargetObj, true );
}
+ //FIXME: ContentHandler will have to provide some specialized magic for reviewing content before undeletion
+
$out->addHTML(
Xml::element( 'textarea', array(
'readonly' => 'readonly',
'cols' => intval( $user->getOption( 'cols' ) ),
'rows' => intval( $user->getOption( 'rows' ) ) ),
- $rev->getText( Revision::FOR_THIS_USER, $user ) . "\n" ) . //FIXME: ContentHandler will have to provide some specialized magic to do this
+ $rev->getText( Revision::FOR_THIS_USER, $user ) . "\n" ) .
Xml::openElement( 'div' ) .
Xml::openElement( 'form', array(
'method' => 'post',
if ( $expected ) {
$this->assertNotNull( $name, "no name found for content model $id" );
- $this->assertTrue( preg_match( $expected, $name ) > 0 , "content model name for #$id did not match pattern $expected" );
+ $this->assertTrue( preg_match( $expected, $name ) > 0 ,
+ "content model name for #$id did not match pattern $expected" );
} else {
- $this->assertEquals( $id, $name, "localization of unknown model $id should have fallen back to use the model id directly." );
+ $this->assertEquals( $id, $name, "localization of unknown model $id should have "
+ . "fallen back to use the model id directly." );
}
}
public function dataGetParserOutput() {
return array(
- array("MediaWiki:Test.js", "hello <world>\n", "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
+ array("MediaWiki:Test.js", "hello <world>\n",
+ "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
// @todo: more...?
);
}
$this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields');
if ( $wgContentHandlerUseDB ) {
- $this->assertTrue( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields');
- $this->assertTrue( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields');
+ $this->assertTrue( in_array( 'rev_content_model', $fields ),
+ 'missing rev_content_model in list of fields');
+ $this->assertTrue( in_array( 'rev_content_format', $fields ),
+ 'missing rev_content_format in list of fields');
} else {
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
- $orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
+ $orig = $this->makeRevision( array( 'text' => 'hello hello.',
+ 'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
$rev = Revision::newFromId( $orig->getId() );
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
- $orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT, 'content_format' => CONTENT_FORMAT_JAVASCRIPT ) );
+ $orig = $this->makeRevision( array( 'text' => 'hello hello.',
+ 'content_model' => CONTENT_MODEL_JAVASCRIPT,
+ 'content_format' => CONTENT_FORMAT_JAVASCRIPT ) );
$rev = Revision::newFromId( $orig->getId() );
$this->assertEquals( CONTENT_FORMAT_JAVASCRIPT, $rev->getContentFormat() );
$this->assertNull( $rev1->getPrevious() );
- $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ), 'second rev testGetPrevious' );
+ $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ),
+ 'second rev testGetPrevious' );
$rev2 = $page->getRevision();
$this->assertNotNull( $rev2->getPrevious() );
$this->assertNull( $rev1->getNext() );
- $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ), 'second rev testGetNext' );
+ $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ),
+ 'second rev testGetNext' );
$rev2 = $page->getRevision();
$this->assertNotNull( $rev1->getNext() );
$dbw = wfGetDB( DB_MASTER );
$rev = Revision::newNullRevision( $dbw, $page->getId(), 'a null revision', false );
- $this->assertNotEquals( $orig->getId(), $rev->getId(), 'new null revision shold have a different id from the original revision' );
- $this->assertEquals( $orig->getTextId(), $rev->getTextId(), 'new null revision shold have the same text id as the original revision' );
+ $this->assertNotEquals( $orig->getId(), $rev->getId(),
+ 'new null revision shold have a different id from the original revision' );
+ $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
+ 'new null revision shold have the same text id as the original revision' );
$this->assertEquals( 'some testing text', $rev->getContent()->getNativeData() );
}
}
$page = $this->newPage( $title );
$content = ContentHandler::makeContent( "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
- . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
- $title );
+ . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+ $title );
$page->doEditContent( $content, "[[testing]] 1" );
"2",
"== TEST ==\nmore fun",
null,
- trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", WikiPageTest::$sections ) )
+ trim( preg_replace( '/^== test ==.*== foo ==/sm',
+ "== TEST ==\nmore fun\n\n== foo ==",
+ WikiPageTest::$sections ) )
),
array( 'WikiPageTest_testReplaceSection',
WikiPageTest::$sections,
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "section one", EDIT_NEW, false, $admin );
+ $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
+ "section one", EDIT_NEW, false, $admin );
$user1 = new User();
$user1->setName( "127.0.1.11" );
$text .= "\n\ntwo";
$page = new WikiPage( $page->getTitle() );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section two", 0, false, $user1 );
+ $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section two", 0, false, $user1 );
$user2 = new User();
$user2->setName( "127.0.2.13" );
$text .= "\n\nthree";
$page = new WikiPage( $page->getTitle() );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section three", 0, false, $user2 );
+ $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section three", 0, false, $user2 );
# we are having issues with doRollback spuriously failing. apparently the last revision somehow goes missing
# or not committed under some circumstances. so, make sure the last revision has the right user name.
}
$page = new WikiPage( $page->getTitle() );
- $this->assertEquals( $rev2->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision" );
+ $this->assertEquals( $rev2->getSha1(), $page->getRevision()->getSha1(),
+ "rollback did not revert to the correct revision" );
$this->assertEquals( "one\n\ntwo", $page->getContent()->getNativeData() );
}
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "section one", EDIT_NEW, false, $admin );
+ $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
+ "section one", EDIT_NEW, false, $admin );
$rev1 = $page->getRevision();
$user1 = new User();
$user1->setName( "127.0.1.11" );
$text .= "\n\ntwo";
$page = new WikiPage( $page->getTitle() );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section two", 0, false, $user1 );
+ $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section two", 0, false, $user1 );
# now, try the rollback
$admin->addGroup( "sysop" ); #XXX: make the test user a sysop...
}
$page = new WikiPage( $page->getTitle() );
- $this->assertEquals( $rev1->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision" );
+ $this->assertEquals( $rev1->getSha1(), $page->getRevision()->getSha1(),
+ "rollback did not revert to the correct revision" );
$this->assertEquals( "one", $page->getContent()->getNativeData() );
}
$summary = $page->getAutosummary( $old, $new, $flags );
- $this->assertTrue( (bool)preg_match( $expected, $summary ), "Autosummary didn't match expected pattern $expected: $summary" );
+ $this->assertTrue( (bool)preg_match( $expected, $summary ),
+ "Autosummary didn't match expected pattern $expected: $summary" );
}
public function dataGetAutoDeleteReason( ) {
$reason = $page->getAutoDeleteReason( $hasHistory );
if ( is_bool( $expectedResult ) || is_null( $expectedResult ) ) $this->assertEquals( $expectedResult, $reason );
- else $this->assertTrue( (bool)preg_match( $expectedResult, $reason ), "Autosummary didn't match expected pattern $expectedResult: $reason" );
+ else $this->assertTrue( (bool)preg_match( $expectedResult, $reason ),
+ "Autosummary didn't match expected pattern $expectedResult: $reason" );
- $this->assertEquals( $expectedHistory, $hasHistory, "expected \$hasHistory to be " . var_export( $expectedHistory, true ) );
+ $this->assertEquals( $expectedHistory, $hasHistory,
+ "expected \$hasHistory to be " . var_export( $expectedHistory, true ) );
$page->doDeleteArticle( "done" );
}