/**
* Record an image upload in the upload log and the image table
*/
- function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '' ) {
+ function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false ) {
global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList;
global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList;
$descTitle = $this->getTitle();
$purgeURLs = array();
- if ( $dbw->affectedRows() ) {
- # Successfully inserted, this is a new image
- $id = $descTitle->getArticleID();
-
- if ( $id == 0 ) {
- $article = new Article( $descTitle );
- $article->insertNewArticle( $textdesc, $desc, false, false, true );
- }
- } else {
+ if( $dbw->affectedRows() == 0 ) {
# Collision, this is an update of an image
# Insert previous contents into oldimage
$dbw->insertSelect( 'oldimage', 'image',
'img_name' => $this->name
), $fname
);
+ }
+
+ $article = new Article( $descTitle );
+ $minor = false;
+ $watch = $watch || $wgUser->isWatched( $descTitle );
+ $suppressRC = true; // There's already a log entry, so don't double the RC load
+
+ if( $descTitle->exists() ) {
+ // TODO: insert a null revision into the page history for this update.
+ if( $watch ) {
+ $wgUser->addWatch( $descTitle );
+ }
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$purgeURLs[] = $descTitle->getInternalURL();
+ } else {
+ // New image; create the description page.
+ $article->insertNewArticle( $textdesc, $desc, $minor, $watch, $suppressRC );
}
-
+
# Invalidate cache for all pages using this image
$linksTo = $this->getLinksTo();
$this->mUploadDescription = $request->getText( 'wpUploadDescription' );
$this->mLicense = $request->getText( 'wpLicense' );
$this->mUploadCopyStatus = $request->getText( 'wpUploadCopyStatus' );
- $this->mUploadSource = $request->getText( 'wpUploadSource');
+ $this->mUploadSource = $request->getText( 'wpUploadSource' );
+ $this->mWatchthis = $request->getBool( 'wpWatchthis' );
+ wfDebug( "UploadForm: watchthis is: '$this->mWatchthis'\n" );
$this->mAction = $request->getVal( 'action' );
$this->mUploadDescription,
$this->mLicense,
$this->mUploadCopyStatus,
- $this->mUploadSource );
+ $this->mUploadSource,
+ $this->mWatchthis );
if ( $success ) {
$this->showSuccess();
<input type='hidden' name='wpUploadDescription' value=\"" . htmlspecialchars( $this->mUploadDescription ) . "\" />
<input type='hidden' name='wpLicense' value=\"" . htmlspecialchars( $this->mLicense ) . "\" />
<input type='hidden' name='wpDestFile' value=\"" . htmlspecialchars( $this->mDestFile ) . "\" />
+ <input type='hidden' name='wpWatchthis' value=\"" . htmlspecialchars( intval( $this->mWatchthis ) ) . "\" />
{$copyright}
<table border='0'>
<tr>
" ;
}
+ $watchChecked = $wgUser->getOption( 'watchdefault' )
+ ? 'checked="checked"'
+ : '';
+
$wgOut->addHTML( "
<form id='upload' method='post' enctype='multipart/form-data' action=\"$action\">
<table border='0'><tr>
<textarea tabindex='2' name='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>"
. htmlspecialchars( $this->mUploadDescription ) .
"</textarea>
+ </td></tr><tr>
+
+ <td></td><td align='left'>
+ <input type='checkbox' name='wpWatchthis' id='wpWatchthis' $watchChecked value='true' />
+ <label for='wpWatchthis'>" . wfMsgHtml( 'watchthis' ) . "</label>
</td></tr><tr>" );
if ( $licenseshtml != '' ) {