i wrote this code to allow to easily add comments to the discussion page. it's a special page function that will take a 'target' and 'comment' request parameters and add a wrapped text to the discussion page of 'target'. the entry will be something like: <!-- start entry ---> <div id="discussion_entry"> <table width="100%"> <tr> <td width="50%" valign="top" class="discussion_entry_user">[[User:Root|Root]] said:</td> <td align="right" width="50%" class="discussion_entry_date">On 09:48, 8 January 2007 (IST)<br/></td> </tr> <tr> <td colspan=2 class="discussion_entry_comment">"foobar"</td> </tr> <tr> <td colspan="2" class="discussion_entry_date" padding=5>[[User talk:Root#post|Reply to Root]] </td> </tr> </table> </div> <!-- end entry -->
(the entry layout and use of a special page are from wikihow)
now all i need is to figure out how to add an input box and button without too much hacking to the skin files.
here is the function:
function qwfSpecialPostcomment() { global $wgRequest, $wgOut, $wgUser, $wgContLang, $wgLocaltimezone; $comment = $wgRequest->getVal( 'comment' ); $title = $wgRequest->getVal( 'target' );
# $wgOut->addWikiText("Got $title, $comment"); $titleObj = Title::newFromUrl($title); $talkTitleObj = $titleObj->getTalkPage();
$article = new Article($talkTitleObj);
#$article->insertNewArticle($comment, "new comment", false, false, false, true); $rev = Revision::newFromTitle($article->getTitle());
$oldtext = $rev->getText();
$date = $wgContLang->timeanddate( date( 'YmdHis' ), false, false) . ' (' . date( 'T' ) . ')';
$username = $wgUser->getName(); $nickname = $wgUser->getOption( 'nickname' ); $nickname = $nickname === '' ? $username : $nickname; $userpage = $wgUser->getUserPage(); $sig = '[[' . $userpage->getPrefixedText() . '|' . wfEscapeWikiText( $nickname ) . ']] ' ; $reply = '[[' . $userpage->getTalkPage()->getPrefixedText() . '#post|Reply to ' . wfEscapeWikiText( $nickname ) . ']] ';
$commentEntry = <<<COMMENT <!-- start entry ---> <div id="discussion_entry"> <table width="100%"> <tr> <td width="50%" valign="top" class="discussion_entry_user">$sig said:</td> <td align="right" width="50%" class="discussion_entry_date">On $date<br/></td> </tr> <tr> <td colspan=2 class="discussion_entry_comment">$comment</td> </tr> <tr> <td colspan="2" class="discussion_entry_date" padding=5>$reply</td> </tr> </table> </div> <!-- end entry --> COMMENT; $text = $oldtext . "\n\n" . $commentEntry;
$article->updateArticle($text, '', false, false);
$wgOut->redirect($titleObj->getFullUrl()); return; }
Rob Church wrote:
On 28/12/06, Ittay Dror ittayd@qlusters.com wrote:
Can i have an easy 'comment on this page' link at the bottom of each page?
You've got one in the content actions bar for discussion pages; use of the __NEWSECTIONLINK__ magic word will also force this to appear for normal pages. Using this throws up a standard "add section" editor where the user enters a subject and their comment, and can then sign this and hit Save.
In the default skin, Monobook, this "add section" link shows up as a "+" sign next to the standard "edit" tab.
Rob Church _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l