function getContent( $noredir = false )
{
- global $action,$wgTitle; # From query string
+ global $action,$section,$count,$wgTitle; # From query string
wfProfileIn( "Article::getContent" );
if ( 0 == $this->getID() ) {
)
{
return $this->mContent . "\n" .wfMsg("anontalkpagetext"); }
- else {
+ else {
+ if($action=="edit") {
+ if($section!="") {
+
+ $secs=preg_split("/(^=+.*?=+)/m",
+ $this->mContent, -1,
+ PREG_SPLIT_DELIM_CAPTURE);
+ if($section==0) {
+ return trim($secs[0]);
+ } else {
+ return trim($secs[$section*2-1] . $secs[$section*2]);
+ }
+ }
+ }
return $this->mContent;
}
}
global $wgOut, $wgUser, $wgTitle;
global $wpTextbox1, $wpSummary, $wpWatchthis;
global $wpSave, $wpPreview;
- global $wpMinoredit, $wpEdittime, $wpTextbox2;
- global $oldid, $redirect;
+ global $wpMinoredit, $wpEdittime, $wpTextbox2, $wpSection;
+ global $oldid, $redirect, $section;
global $wgLang;
+ if(isset($wpSection)) { $section=$wpSection; }
+
$sk = $wgUser->getSkin();
$isConflict = false;
$wpTextbox1 = rtrim ( $wpTextbox1 ) ; # To avoid text getting longer on each preview
}
if ( ! $isConflict ) {
# All's well: update the article here
- $this->updateArticle( $wpTextbox1, $wpSummary, $wpMinoredit, $wpWatchthis );
+ $this->updateArticle( $wpTextbox1, $wpSummary, $wpMinoredit, $wpWatchthis, $wpSection );
return;
}
}
} else {
$s = str_replace( "$1", $wgTitle->getPrefixedText(),
wfMsg( "editing" ) );
+
+ if($section!="") { $s.=wfMsg("sectionedit");}
$wgOut->setPageTitle( $s );
if ( $oldid ) {
$this->setOldSubtitle();
$wgOut->addHTML($previewhead);
$wgOut->addWikiText( $this->preSaveTransform( $previewtext ) ."\n\n");
}
+ $wgOut->addHTML( "<br clear=\"all\" />\n" );
}
$wgOut->addHTML( "
<form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
<input tabindex=6 type=submit value=\"{$prev}\" name=\"wpPreview\">
<em>{$cancel}</em> | <em>{$edithelp}</em>
<br><br>{$copywarn}
+<input type=hidden value=\"{$section}\" name=\"wpSection\">
<input type=hidden value=\"{$wpEdittime}\" name=\"wpEdittime\">\n" );
if ( $isConflict ) {
$now = wfTimestampNow();
$won = wfInvertTimestamp( $now );
+ wfSeedRandom();
+ $rand = number_format( mt_rand() / mt_getrandmax(), 12, ".", "" );
$sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
"cur_comment,cur_user,cur_timestamp,cur_minor_edit,cur_counter," .
"cur_restrictions,cur_user_text,cur_is_redirect," .
wfStrencode( $summary ) . "', '" .
$wgUser->getID() . "', '{$now}', " .
( $isminor ? 1 : 0 ) . ", 0, '', '" .
- wfStrencode( $wgUser->getName() ) . "', $redir, 1, RAND(), '{$now}', '{$won}')";
+ wfStrencode( $wgUser->getName() ) . "', $redir, 1, $rand, '{$now}', '{$won}')";
$res = wfQuery( $sql, $fname );
$newid = wfInsertId();
$this->showArticle( $text, wfMsg( "newarticle" ) );
}
- function updateArticle( $text, $summary, $minor, $watchthis )
+ function updateArticle( $text, $summary, $minor, $watchthis, $section )
{
global $wgOut, $wgUser, $wgTitle, $wgLinkCache;
global $wgDBtransactions;
$fname = "Article::updateArticle";
+ // insert updated section into old text if we have only edited part
+ // of the article
+ if ($section != "") {
+ $oldtext=$this->getContent();
+ $secs=preg_split("/(^=+.*?=+)/m",$oldtext,-1,PREG_SPLIT_DELIM_CAPTURE);
+ $secs[$section*2]=$text."\n\n"; // replace with edited
+ if($section) { $secs[$section*2-1]=""; } // erase old headline
+ $text=join("",$secs);
+ }
if ( $this->mMinorEdit ) { $me1 = 1; } else { $me1 = 0; }
if ( $minor ) { $me2 = 1; } else { $me2 = 0; }
if ( preg_match( "/^(#redirect[^\\n]+)/i", $text, $m ) ) {
function showArticle( $text, $subtitle )
{
- global $wgOut, $wgTitle, $wgUser, $wgLinkCache;
+ global $wgOut, $wgTitle, $wgUser, $wgLinkCache, $wgUseBetterLinksUpdate;
$wgLinkCache = new LinkCache();
- $wgOut->addWikiText( $text ); # Just to update links
+
+ # Get old version of link table to allow incremental link updates
+ if ( $wgUseBetterLinksUpdate ) {
+ $wgLinkCache->preFill( $wgTitle );
+ $wgLinkCache->clear();
+ }
+
+ # Now update the link cache by parsing the text
+ $wgOut->addWikiText( $text );
$this->editUpdates( $text );
if( preg_match( "/^#redirect/i", $text ) )
# we select the text because it might be useful below
$sql="SELECT old_text FROM old WHERE old_namespace=0 and old_title='" . wfStrencode($wgTitle->getPrefixedDBkey())."' ORDER BY inverse_timestamp LIMIT 1";
$res=wfQuery($sql,$fname);
- if( $old=wfFetchObject($res)) {
+ if( ($old=wfFetchObject($res)) && !$wpConfirm ) {
$skin=$wgUser->getSkin();
$wgOut->addHTML("<B>".wfMsg("historywarning"));
$wgOut->addHTML( $skin->historyLink() ."</B><P>");
# this should not happen, since it is not possible to store an empty, new
# page. Let's insert a standard text in case it does, though
- if($length==0) { $wpreason=wfmsg("exblank");}
+ if($length==0 && !$wpReason) { $wpReason=wfmsg("exblank");}
- if($length < 500) {
+ if($length < 500 && !$wpReason) {
# comment field=255, let's grep the first 150 to have some user
# space left
if(isset($wgLocaltimezone)) {
$oldtz = getenv("TZ"); putenv("TZ=$wgLocaltimezone");
}
- $d = $wgLang->timeanddate( wfTimestampNow(), false ) .
+ /* Note: this is an ugly timezone hack for the European wikis */
+ $d = $wgLang->timeanddate( date( "YmdHis" ), false ) .
" (" . date( "T" ) . ")";
if(isset($wgLocaltimezone)) putenv("TZ=$oldtz");
global $wgUser, $wgCacheEpoch;
if(!file_exists( $fn = $this->fileCacheName() ) ) return false;
$cachetime = wfUnix2Timestamp( filemtime( $fn ) );
- $good = ( $this->mTouched <= $cachetime ) &&
- ($wgCacheEpoch <= $cachetime );
+ $good = (( $this->mTouched <= $cachetime ) &&
+ ($wgCacheEpoch <= $cachetime ));
wfDebug(" isFileCacheGood() - cachetime $cachetime, touched {$this->mTouched} epoch {$wgCacheEpoch}, good $good\n");
return $good;
}
function loadFromFileCache() {
- global $wgUseGzip;
+ global $wgUseGzip, $wgOut;
wfDebug(" loadFromFileCache()\n");
$filename=$this->fileCacheName();
$filenamegz = "{$filename}.gz";
+ $wgOut->sendCacheControl();
if( $wgUseGzip
&& wfClientAcceptsGzip()
&& file_exists( $filenamegz)
function saveToFileCache( $text ) {
global $wgUseGzip, $wgCompressByDefault;
- wfDebug(" saveToFileCache()\n");
+ wfDebug(" saveToFileCache()\n", false);
$filename=$this->fileCacheName();
$mydir2=substr($filename,0,strrpos($filename,"/")); # subdirectory level 2
$mydir1=substr($mydir2,0,strrpos($mydir2,"/")); # subdirectory level 1
- if(!file_exists($mydir1)) { mkdir($mydir1,0777); } # create if necessary
- if(!file_exists($mydir2)) { mkdir($mydir2,0777); }
+ if(!file_exists($mydir1)) { mkdir($mydir1,0775); } # create if necessary
+ if(!file_exists($mydir2)) { mkdir($mydir2,0775); }
+
$f = fopen( $filename, "w" );
if($f) {
$now = wfTimestampNow();
} else {
wfDebug(" failed to write gzip, still sending\n" );
}
- header( "Content-Encoding: gzip" );
- header( "Vary: Accept-Encoding" );
- return $gzout;
+ if(wfClientAcceptsGzip()) {
+ header( "Content-Encoding: gzip" );
+ header( "Vary: Accept-Encoding" );
+ wfDebug(" sending NEW gzip now...\n" );
+ return $gzout;
+ }
}
}
return $text;