* @return Return the text of this revision
*/
function getContent( $noredir ) {
- global $wgRequest, $wgUser;
+ global $wgRequest, $wgUser, $wgOut;
# Get variables from query string :P
$action = $wgRequest->getText( 'action', 'view' );
$section = $wgRequest->getText( 'section' );
+ $preload = $wgRequest->getText( 'preload' );
$fname = 'Article::getContent';
wfProfileIn( $fname );
if ( 0 == $this->getID() ) {
if ( 'edit' == $action ) {
wfProfileOut( $fname );
- return ''; # was "newarticletext", now moved above the box)
+
+ # If requested, preload some text.
+ $text=$this->getPreloadedText($preload);
+
+ # We used to put MediaWiki:Newarticletext here if
+ # $text was empty at this point.
+ # This is now shown above the edit box instead.
+ return $text;
}
wfProfileOut( $fname );
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
return wfMsg( 'noarticletext' );
} else {
$this->loadContent( $noredir );
if($section!='') {
if($section=='new') {
wfProfileOut( $fname );
- return '';
+ $text=$this->getPreloadedText($preload);
+ return $text;
}
# strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
}
}
+ /**
+ This function accepts a title string as parameter
+ ($preload). If this string is non-empty, it attempts
+ to fetch the current revision text.
+ */
+ function getPreloadedText($preload) {
+ if($preload) {
+ $preloadTitle=Title::newFromText($preload);
+ if(isset($preloadTitle) && $preloadTitle->userCanRead()) {
+ $rev=Revision::newFromTitle($preloadTitle);
+ if($rev) {
+ return $rev->getText();
+ }
+ }
+ }
+ return '';
+ }
+
/**
* This function returns the text of a section, specified by a number ($section).
* A section is text under a heading like == Heading == or <h1>Heading</h1>, or
*/
function &getDB() {
#if ( $this->mForUpdate ) {
- return wfGetDB( DB_MASTER );
+ $ret =& wfGetDB( DB_MASTER );
#} else {
- # return wfGetDB( DB_SLAVE );
+ # $ret =& wfGetDB( DB_SLAVE );
#}
+ return $ret;
}
/**
function view() {
global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgLang;
global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol;
- global $wgEnotif, $wgParser, $wgParserCache;
+ global $wgEnotif, $wgParser, $wgParserCache, $wgUseTrackbacks;
$sk = $wgUser->getSkin();
$fname = 'Article::view';
);
}
+ # Trackbacks
+ if ($wgUseTrackbacks)
+ $this->addTrackbacks();
+
# Put link titles into the link cache
$wgOut->transformBuffer();
wfProfileOut( $fname );
}
+ function addTrackbacks() {
+ global $wgOut, $wgUser;
+
+ $dbr = wfGetDB(DB_SLAVE);
+ $tbs = $dbr->select(
+ /* FROM */ 'trackbacks',
+ /* SELECT */ array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'),
+ /* WHERE */ array('tb_page' => $this->getID())
+ );
+
+ if (!$dbr->numrows($tbs))
+ return;
+
+ $tbtext = "";
+ while ($o = $dbr->fetchObject($tbs)) {
+ $rmvtext = "";
+ if ($wgUser->isSysop()) {
+ $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid="
+ . $o->tb_id . "&token=" . $wgUser->editToken());
+ $rmvtxt = wfMsg('trackbackremove', $delurl);
+ }
+ $tbtext .= wfMsg(strlen($o->tb_ex) ? 'trackbackexcerpt' : 'trackback',
+ $o->tb_title,
+ $o->tb_url,
+ $o->tb_ex,
+ $o->tb_name,
+ $rmvtxt);
+ }
+ $wgOut->addWikitext(wfMsg('trackbackbox', $tbtext));
+ }
+
+ function deletetrackback() {
+ global $wgUser, $wgRequest, $wgOut, $wgTitle;
+
+ if (!$wgUser->matchEditToken($wgRequest->getVal('token'))) {
+ $wgOut->addWikitext(wfMsg('sessionfailure'));
+ return;
+ }
+
+ if ((!$wgUser->isAllowed('delete'))) {
+ $wgOut->sysopRequired();
+ return;
+ }
+
+ if (wfReadOnly()) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+
+ $db = wfGetDB(DB_MASTER);
+ $db->delete('trackbacks', array('tb_id' => $wgRequest->getInt('tbid')));
+ $wgTitle->invalidateCache();
+ $wgOut->addWikiText(wfMsg('trackbackdeleteok'));
+ }
+
+ function render() {
+ global $wgOut;
+
+ $wgOut->setArticleBodyOnly(true);
+ $this->view();
+ }
+
/**
* Insert a new empty page record for this article.
* This *must* be followed up by creating a revision
* errors at some point.
* @private
*/
- function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false ) {
+ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) {
global $wgOut, $wgUser;
global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
$ns = $this->mTitle->getNamespace();
$ttl = $this->mTitle->getDBkey();
+
+ # If this is a comment, add the summary as headline
+ if($comment && $summary!="") {
+ $text="== {$summary} ==\n\n".$text;
+ }
$text = $this->preSaveTransform( $text );
$isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0;
$now = wfTimestampNow();
function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
global $wgOut, $wgUser;
global $wgDBtransactions, $wgMwRedir;
- global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList;
+ global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList, $wgUseFileCache;
$fname = 'Article::updateArticle';
$good = true;
array_push( $wgPostCommitUpdateList, $u );
}
+ # File cache
+ if ( $wgUseFileCache ) {
+ $cm = new CacheManager($this->mTitle);
+ @unlink($cm->fileCacheName());
+ }
+
$this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision );
}
return $good;
*/
function doDeleteArticle( $reason ) {
global $wgUser;
- global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer, $wgPostCommitUpdateList;
+ global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer, $wgPostCommitUpdateList;
+ global $wgUseTrackbacks;
$fname = 'Article::doDeleteArticle';
wfDebug( $fname."\n" );
$dbw->delete( 'revision', array( 'rev_page' => $id ), $fname );
$dbw->delete( 'page', array( 'page_id' => $id ), $fname);
+ if ($wgUseTrackbacks)
+ $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), $fname );
+
# Clean up recentchanges entries...
$dbw->delete( 'recentchanges', array( 'rc_namespace' => $ns, 'rc_title' => $t ), $fname );
$u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary,
$minoredit, $timestamp_of_pagechange);
} else {
- $other = User::newFromName($shortTitle);
- if ($other) {
+ $other = User::newFromName( $shortTitle );
+ if( is_null( $other ) && User::isIP( $shortTitle ) ) {
+ // An anonymous user
+ $other = new User();
+ $other->setName( $shortTitle );
+ }
+ if( $other ) {
$other->setNewtalk(1);
$other->saveNewtalk();
}
$db->freeResult( $res );
return $result;
}
-
-
}
-
?>