* @param $title Reference to a Title object.
* @param $oldId Integer revision ID, null to fetch from request, zero for current
*/
- function __construct( &$title, $oldId = null ) {
+ function __construct( Title $title, $oldId = null ) {
$this->mTitle =& $title;
$this->mOldId = $oldId;
$this->clear();
global $wgUser, $wgOut, $wgRequest, $wgContLang;
global $wgEnableParserCache, $wgStylePath, $wgParser;
global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies;
+ global $wgDefaultRobotPolicy;
$sk = $wgUser->getSkin();
wfProfileIn( __METHOD__ );
# Honour customised robot policies for this namespace
$policy = $wgNamespaceRobotPolicies[$ns];
} else {
- # Default to encourage indexing and following links
- $policy = 'index,follow';
+ $policy = $wgDefaultRobotPolicy;
}
$wgOut->setRobotPolicy( $policy );
$this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
if( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
- $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) );
+ $wgOut->addWikiMsg( 'rev-deleted-text-permission' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
return;
} else {
- $wgOut->addWikiText( wfMsg( 'rev-deleted-text-view' ) );
+ $wgOut->addWikiMsg( 'rev-deleted-text-view' );
// and we are allowed to see...
}
}
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
if( $ns == NS_USER_TALK &&
User::isIP( $this->mTitle->getText() ) ) {
- $wgOut->addWikiText( wfMsg('anontalkpagetext') );
+ $wgOut->addWikiMsg('anontalkpagetext');
}
# If we have been passed an &rcid= parameter, we want to give the user a
$o->tb_name,
$rmvtxt);
}
- $wgOut->addWikitext(wfMsg('trackbackbox', $tbtext));
+ $wgOut->addWikiMsg( 'trackbackbox', $tbtext );
}
function deletetrackback() {
global $wgUser, $wgRequest, $wgOut, $wgTitle;
if (!$wgUser->matchEditToken($wgRequest->getVal('token'))) {
- $wgOut->addWikitext(wfMsg('sessionfailure'));
+ $wgOut->addWikiMsg( 'sessionfailure' );
return;
}
$db = wfGetDB(DB_MASTER);
$db->delete('trackbacks', array('tb_id' => $wgRequest->getInt('tbid')));
$wgTitle->invalidateCache();
- $wgOut->addWikiText(wfMsg('trackbackdeleteok'));
+ $wgOut->addWikiMsg('trackbackdeleteok');
}
function render() {
$update = SquidUpdate::newSimplePurge( $this->mTitle );
$update->doUpdate();
}
+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
+ global $wgMessageCache;
+ if ( $this->getID() == 0 ) {
+ $text = false;
+ } else {
+ $text = $this->getContent();
+ }
+ $wgMessageCache->replace( $this->mTitle->getDBkey(), $text );
+ }
$this->view();
}
# The user made this edit, and can't patrol it
# Tell them so, and then back off
$wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) );
- $wgOut->addWikiText( wfMsgNoTrans( 'markedaspatrollederror-noautopatrol' ) );
+ $wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
$wgOut->returnToMain( false, $return );
return;
}
# Inform the user
$wgOut->setPageTitle( wfMsg( 'markedaspatrolled' ) );
- $wgOut->addWikiText( wfMsgNoTrans( 'markedaspatrolledtext' ) );
+ $wgOut->addWikiMsg( 'markedaspatrolledtext' );
$wgOut->returnToMain( false, $return );
}
$wgOut->setPagetitle( wfMsg( 'addedwatch' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
- $link = wfEscapeWikiText( $this->mTitle->getPrefixedText() );
- $text = wfMsg( 'addedwatchtext', $link );
- $wgOut->addWikiText( $text );
+ $wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() );
}
$wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
$wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
- $link = wfEscapeWikiText( $this->mTitle->getPrefixedText() );
- $text = wfMsg( 'removedwatchtext', $link );
- $wgOut->addWikiText( $text );
+ $wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() );
}
$wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
$expiry_description = '';
if ( $encodedExpiry != 'infinity' ) {
- $expiry_description = ' (' . wfMsgForContent( 'protect-expiring', $wgContLang->timeanddate( $expiry ) ).')';
+ $expiry_description = ' (' . wfMsgForContent( 'protect-expiring', $wgContLang->timeanddate( $expiry, false, false ) ).')';
}
# Prepare a null revision to be added to the history
$comment .= "$expiry_description";
if ( $cascade )
$comment .= "$cascade_description";
-
+
# Update restrictions table
foreach( $limit as $action => $restrictions ) {
if ($restrictions != '' ) {
'pr_type' => $action ), __METHOD__ );
}
}
- if($dbw->affectedRows() == 0)
- // No change
- return true;
# Insert a null revision
$nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true );
# Update the protection log
$log = new LogPage( 'protect' );
+
+
if( $protect ) {
$log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason . " [$updated]$cascade_description$expiry_description" ) );
return;
}
- $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
-
+ $wgOut->setPagetitle( wfMsg( 'delete-confirm', $this->mTitle->getPrefixedText() ) );
+
# Better double-check that it hasn't been deleted yet!
$dbw = wfGetDB( DB_MASTER );
$conds = $this->mTitle->pageCond();
$bigHistory = $this->isBigDeletion();
if( $bigHistory && !$this->mTitle->userCan( 'bigdelete' ) ) {
global $wgLang, $wgDeleteRevisionsLimit;
- $wgOut->addWikiText( "<div class='error'>\n" .
- wfMsg( 'delete-toobig',
- $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) .
- "</div>\n" );
+ $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n",
+ array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
return;
}
$wgOut->addHTML( '<strong>' . wfMsg( 'historywarning' ) . ' ' . $skin->historyLink() . '</strong>' );
if( $bigHistory ) {
global $wgLang, $wgDeleteRevisionsLimit;
- $wgOut->addWikiText( "<div class='error'>\n" .
- wfMsg( 'delete-warning-toobig',
- $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) .
- "</div>\n" );
+ $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n",
+ array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
}
}
/**
* Output deletion confirmation dialog
+ * @param $par string FIXME: do we need this parameter? One Call from Article::delete with '' only.
+ * @param $reason string Prefilled reason
*/
function confirmDelete( $par, $reason ) {
- global $wgOut, $wgUser;
+ global $wgOut, $wgUser, $wgContLang;
+ $align = $wgContLang->isRtl() ? 'left' : 'right';
wfDebug( "Article::confirmDelete\n" );
- $sub = htmlspecialchars( $this->mTitle->getPrefixedText() );
- $wgOut->setSubtitle( wfMsg( 'deletesub', $sub ) );
+ $wgOut->setSubtitle( wfMsg( 'delete-backlink', $wgUser->getSkin()->makeKnownLinkObj( $this->mTitle ) ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
- $wgOut->addWikiText( wfMsg( 'confirmdeletetext' ) );
-
- $formaction = $this->mTitle->escapeLocalURL( 'action=delete' . $par );
-
- $confirm = htmlspecialchars( wfMsg( 'deletepage' ) );
- $delcom = Xml::label( wfMsg( 'deletecomment' ), 'wpDeleteReasonList' );
- $token = htmlspecialchars( $wgUser->editToken() );
- $watch = Xml::checkLabel( wfMsg( 'watchthis' ), 'wpWatch', 'wpWatch', $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching(), array( 'tabindex' => '2' ) );
-
- $mDeletereasonother = Xml::label( wfMsg( 'deleteotherreason' ), 'wpReason' );
- $mDeletereasonotherlist = wfMsgHtml( 'deletereasonotherlist' );
- $scDeleteReasonList = wfMsgForContent( 'deletereason-dropdown' );
-
- $deleteReasonList = '';
- if ( $scDeleteReasonList != '' && $scDeleteReasonList != '-' ) {
- $deleteReasonList = "<option value=\"other\">$mDeletereasonotherlist</option>";
- $optgroup = "";
- foreach ( explode( "\n", $scDeleteReasonList ) as $option) {
- $value = trim( htmlspecialchars($option) );
- if ( $value == '' ) {
- continue;
- } elseif ( substr( $value, 0, 1) == '*' && substr( $value, 1, 1) != '*' ) {
- // A new group is starting ...
- $value = trim( substr( $value, 1 ) );
- $deleteReasonList .= "$optgroup<optgroup label=\"$value\">";
- $optgroup = "</optgroup>";
- } elseif ( substr( $value, 0, 2) == '**' ) {
- // groupmember
- $selected = "";
- $value = trim( substr( $value, 2 ) );
- if ( $this->DeleteReasonList === $value)
- $selected = ' selected="selected"';
- $deleteReasonList .= "<option value=\"$value\"$selected>$value</option>";
- } else {
- // groupless delete reason
- $selected = "";
- if ( $this->DeleteReasonList === $value)
- $selected = ' selected="selected"';
- $deleteReasonList .= "$optgroup<option value=\"$value\"$selected>$value</option>";
- $optgroup = "";
- }
- }
- $deleteReasonList .= $optgroup;
- }
- $wgOut->addHTML( "
-<form id='deleteconfirm' method='post' action=\"{$formaction}\">
- <table border='0'>
- <tr id=\"wpDeleteReasonListRow\" name=\"wpDeleteReasonListRow\">
- <td align='right'>
- $delcom:
- </td>
- <td align='left'>
- <select tabindex='1' id='wpDeleteReasonList' name=\"wpDeleteReasonList\">
- $deleteReasonList
- </select>
- </td>
- </tr>
- <tr id=\"wpDeleteReasonRow\" name=\"wpDeleteReasonRow\">
- <td>
- $mDeletereasonother
- </td>
- <td align='left'>
- <input type='text' maxlength='255' size='60' name='wpReason' id='wpReason' value=\"" . htmlspecialchars( $reason ) . "\" tabindex=\"2\" />
- </td>
- </tr>
- <tr>
- <td> </td>
- <td>$watch</td>
- </tr>
- <tr>
- <td> </td>
- <td>
- <input type='submit' name='wpConfirmB' id='wpConfirmB' value=\"{$confirm}\" tabindex=\"3\" />
- </td>
- </tr>
- </table>
- <input type='hidden' name='wpEditToken' value=\"{$token}\" />
-</form>\n" );
-
- $wgOut->returnToMain( false, $this->mTitle );
-
+ $wgOut->addWikiMsg( 'confirmdeletetext' );
+
+ $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->mTitle->getLocalURL( 'action=delete' . $par ), 'id' => 'deleteconfirm' ) ) .
+ Xml::openElement( 'fieldset' ) .
+ Xml::element( 'legend', array(), wfMsg( 'delete-legend' ) ) .
+ Xml::openElement( 'table' ) .
+ "<tr id=\"wpDeleteReasonListRow\">
+ <td align='$align'>" .
+ Xml::label( wfMsg( 'deletecomment' ), 'wpDeleteReasonList' ) .
+ "</td>
+ <td>" .
+ Xml::listDropDown( 'wpDeleteReasonList',
+ wfMsgForContent( 'deletereason-dropdown' ),
+ wfMsgForContent( 'deletereasonotherlist' ), '', 'wpReasonDropDown', 1 ) .
+ "</td>
+ </tr>
+ <tr id=\"wpDeleteReasonRow\">
+ <td align='$align'>" .
+ Xml::label( wfMsg( 'deleteotherreason' ), 'wpReason' ) .
+ "</td>
+ <td>" .
+ Xml::input( 'wpReason', 60, $reason, array( 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ) ) .
+ "</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>" .
+ Xml::checkLabel( wfMsg( 'watchthis' ), 'wpWatch', 'wpWatch', $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching(), array( 'tabindex' => '3' ) ) .
+ "</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>" .
+ Xml::submitButton( wfMsg( 'deletepage' ), array( 'name' => 'wpConfirmB', 'id' => 'wpConfirmB', 'tabindex' => '4' ) ) .
+ "</td>
+ </tr>" .
+ Xml::closeElement( 'table' ) .
+ Xml::closeElement( 'fieldset' ) .
+ Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
+ Xml::closeElement( 'form' );
+
+ $wgOut->addHTML( $form );
$this->showLogExtract( $wgOut );
}
if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) {
if ( $this->doDeleteArticle( $reason ) ) {
- $deleted = wfEscapeWikiText( $this->mTitle->getPrefixedText() );
+ $deleted = $this->mTitle->getPrefixedText();
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
- $loglink = '[[Special:Log/delete|' . wfMsg( 'deletionlog' ) . ']]';
- $text = wfMsg( 'deletedtext', $deleted, $loglink );
+ $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
- $wgOut->addWikiText( $text );
+ $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink );
$wgOut->returnToMain( false );
wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason));
} else {
if( $title->getNamespace() == NS_MEDIAWIKI) {
$wgMessageCache->replace( $title->getDBkey(), false );
}
+ if( $title->getNamespace() == NS_IMAGE ) {
+ $update = new HTMLCacheUpdate( $title, 'imagelinks' );
+ $update->doUpdate();
+ }
}
/**
return $result;
}
+ /**
+ * Returns a list of hidden categories this page is a member of.
+ * Uses the page_props and categorylinks tables.
+ *
+ * @return array Array of Title objects
+ */
+ function getHiddenCategories() {
+ $result = array();
+ $id = $this->mTitle->getArticleID();
+ if( $id == 0 ) {
+ return array();
+ }
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ),
+ array( 'cl_to' ),
+ array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat',
+ 'page_namespace' => NS_CATEGORY, 'page_title=cl_to'),
+ 'Article:getHiddenCategories' );
+ if ( false !== $res ) {
+ if ( $dbr->numRows( $res ) ) {
+ while ( $row = $dbr->fetchObject( $res ) ) {
+ $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to );
+ }
+ }
+ }
+ $dbr->freeResult( $res );
+ return $result;
+ }
+
/**
* Return an auto-generated summary if the text provided is a redirect.
*