public $action = 'submit';
/** @var bool Whether an edit conflict needs to be resolved. Detected based on whether
- * $editRevId is different from the current revision. When a conflict has successfully
+ * $editRevId is different than the latest revision. When a conflict has successfully
* been resolved by a 3-way-merge, this field is set to false.
*/
public $isConflict = false;
/** @var string */
public $formtype;
- /** @var bool */
+ /** @var bool
+ * True the first time the edit form is rendered, false after re-rendering
+ * with diff, save prompts, etc.
+ */
public $firsttime;
/** @var bool|stdClass */
/** @var bool */
public $recreate = false;
- /** @var string */
+ /** @var string
+ * Page content input field.
+ */
public $textbox1 = '';
/** @var string */
/** @var string */
public $summary = '';
- /** @var bool */
+ /** @var bool
+ * If true, hide the summary field.
+ */
public $nosummary = false;
- /** @var string */
+ /** @var string
+ * Timestamp of the latest revision of the page when editing was initiated
+ * on the client.
+ */
public $edittime = '';
- /** @var int ID of the current revision at the time editing was initiated on the client.
- * This is used to detect and resolve edit conflicts.
+ /** @var int Revision ID of the latest revision of the page when editing
+ * was initiated on the client. This is used to detect and resolve edit
+ * conflicts.
*
* @note 0 if the page did not exist at that time.
* @note When starting an edit from an old revision, this still records the current
- * revision at the time , not the one the edit is based on.
+ * revision at the time, not the one the edit is based on.
*
* @see $oldid
* @see getBaseRevision()
/** @var string */
public $sectiontitle = '';
- /** @var string */
+ /** @var string
+ * Timestamp from the first time the edit form was rendered.
+ */
public $starttime = '';
/** @var int Revision ID the edit is based on, or 0 if it's the current revision.
+ * FIXME: This isn't used in conflict resolution--provide a better
+ * justification or merge with parentRevId.
* @see $editRevId
*/
public $oldid = 0;
* @since 1.21
*/
protected function getContentObject( $def_content = null ) {
- global $wgContLang;
-
$content = false;
$user = $this->context->getUser();
if ( $undoMsg === null ) {
$oldContent = $this->page->getContent( Revision::RAW );
- $popts = ParserOptions::newFromUserAndLang( $user, $wgContLang );
+ $popts = ParserOptions::newFromUserAndLang(
+ $user, MediaWikiServices::getInstance()->getContentLanguage() );
$newContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
if ( $newContent->getModel() !== $oldContent->getModel() ) {
// The undo may change content
* Returns the revision that was current at the time editing was initiated on the client,
* even if the edit was based on an old revision.
*
- * @warning: this method is very poorly named. If the user opened the form with ?oldid=X,
+ * @warning this method is very poorly named. If the user opened the form with ?oldid=X,
* one might think of X as the "base revision", which is NOT what this returns,
* see oldid for that. One might further assume that this corresponds to the $baseRevId
* parameter of WikiPage::doEditContent, which is not the case either.
}
/**
- * Helper function for summary input functions, which returns the neccessary
+ * Helper function for summary input functions, which returns the necessary
* attributes for the input.
*
* @param array|null $inputAttrs Array of attrs to use on the input
* save and then make a comparison.
*/
public function showDiff() {
- global $wgContLang;
-
$oldtitlemsg = 'currentrev';
# if message does not exist, show diff against the preloaded default
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists() ) {
Hooks::run( 'EditPageGetDiffContent', [ $this, &$newContent ] );
$user = $this->context->getUser();
- $popts = ParserOptions::newFromUserAndLang( $user, $wgContLang );
+ $popts = ParserOptions::newFromUserAndLang( $user,
+ MediaWikiServices::getInstance()->getContentLanguage() );
$newContent = $newContent->preSaveTransform( $this->mTitle, $user, $popts );
}
* Get the Limit report for page previews
*
* @since 1.22
- * @param ParserOutput $output ParserOutput object from the parse
+ * @param ParserOutput|null $output ParserOutput object from the parse
* @return string HTML
*/
- public static function getPreviewLimitReport( $output ) {
+ public static function getPreviewLimitReport( ParserOutput $output = null ) {
global $wgLang;
if ( !$output || !$output->getLimitReportData() ) {
}
/**
+ * Get the last log record of this page being deleted, if ever. This is
+ * used to detect whether a delete occured during editing.
* @return bool|stdClass
*/
protected function getLastDelete() {
* @return string
*/
public static function getEditToolbar( $title = null ) {
- global $wgContLang, $wgOut;
- global $wgEnableUploads, $wgForeignFileRepos;
+ global $wgOut, $wgEnableUploads, $wgForeignFileRepos;
$imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos );
$showSignature = true;
$showSignature = MWNamespace::wantSignatures( $title->getNamespace() );
}
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+
/**
* $toolarray is an array of arrays each of which includes the
* opening tag, the closing tag, optionally a sample text that is
],
$imagesAvailable ? [
'id' => 'mw-editbutton-image',
- 'open' => '[[' . $wgContLang->getNsText( NS_FILE ) . ':',
+ 'open' => '[[' . $contLang->getNsText( NS_FILE ) . ':',
'close' => ']]',
'sample' => wfMessage( 'image_sample' )->text(),
'tip' => wfMessage( 'image_tip' )->text(),
] : false,
$imagesAvailable ? [
'id' => 'mw-editbutton-media',
- 'open' => '[[' . $wgContLang->getNsText( NS_MEDIA ) . ':',
+ 'open' => '[[' . $contLang->getNsText( NS_MEDIA ) . ':',
'close' => ']]',
'sample' => wfMessage( 'media_sample' )->text(),
'tip' => wfMessage( 'media_tip' )->text(),
]
];
- $script = 'mw.loader.using("mediawiki.toolbar", function () {';
+ $script = '';
foreach ( $toolarray as $tool ) {
if ( !$tool ) {
continue;
);
}
- $script .= '});';
-
$toolbar = '<div id="toolbar"></div>';
if ( Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] ) ) {
// Only add the old toolbar cruft to the page payload if the toolbar has not
// been over-written by a hook caller
$nonce = $wgOut->getCSPNonce();
- $wgOut->addScript( ResourceLoader::makeInlineScript( $script, $nonce ) );
+ $wgOut->addScript( Html::inlineScript(
+ ResourceLoader::makeInlineCodeWithModule( 'mediawiki.toolbar', $script ),
+ $nonce
+ ) );
};
return $toolbar;