Extension:DiscussionThreading/doc

Title:  Modify Discussion Functionality to be more threadlike

Description:

See formal extension description

The thread-like nature of discussions is highly valuable. To make MediaWiki look more like this, we should do the following:


 * 1) Add a [reply] button to the header that creates a sub-post to that section.
 * 2) Automatically add a signature in at the top of the section - preferably in the header bar to show up in TOC

This required patches to 2 files, EditPage.php and Linker.php. Also created two new hooks and loaded them as an extension.

Patches Required
Will absolutely not work below 1.6.0, requires features added with that release.

The "reply" feature requires a new parameter passed to the EditPage. This parameter is "comment=yes" when the user is replying to a previous post.

To do this, have to patch the following (instructions are for 1.9.3, future or past releases will, of course vary with line numbers and locations):

Modified EditPage.php at line 43
# Form values var $save = false, $preview = false, $diff = false; var $minoredit = false, $watchthis = false, $recreate = false; var $textbox1 = , $textbox2 = , $summary = ''; var $edittime = , $section = , $starttime = ''; var $oldid = 0, $editintro = '', $scrolltop = null; var $commentsection = '', $commentadded = false;
 * 1) Added URL parameter value for Discussion threading

Modified EditPage.php line 71
# Placeholders for text injection by hooks (empty per default) $this->editFormPageTop = $this->editFormTextTop = $this->editFormTextAfterWarn = $this->editFormTextAfterTools = $this->editFormTextBottom = ""; $this->commentsection = ''; $this->commentadded = false;
 * 1) Added URL parameter value for Discussion threading

Modified EditPage.php line 87
# Get variables from query string :P $section = $wgRequest->getVal( 'section' ); $preload = $wgRequest->getVal( 'preload' ); $undo = $wgRequest->getVal( 'undo' ); $commentsection = $wgRequest->getVal( 'comment' );
 * 1) Added URL parameter value for Discussion threading

wfProfileIn( __METHOD__ );

Modified EditPage.php line 556
# Section edit can come from either the form or a link $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) ); $this->commentsection = $request->getVal( 'comment' ); $this->live = $request->getCheck( 'live' ); $this->editintro = $request->getText( 'editintro' );
 * 1) 	Added for discussion threading

Modified linker.php line 1035
public function editSectionLinkForOther( $title, $section ) { global$wgContLang; $title = Title::newFromText( $title ); $editurl = '&section='.$section; $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl ); global $wgSectionCommentOn; $SectionCommentOn = isset($wgSectionCommentOn) ? $wgSectionCommentOn : False; $commenturl = '&section='.$section.'&comment=yes'; $curl = $this->makeKnownLinkObj( $title, wfMsg('replysection'), 'action=edit'.$commenturl );
 * 1) Added and Modified for threaded discussion

if($SectionCommentOn && $title->isTalkPage ) { return "[".$url."][".$curl."] "; }		else{ return "[".$url."] "; }	}

Modified linker.php line 1035
public function editSectionLink( $nt, $section, $hint='' ) { global$wgContLang; $editurl = '&section='.$section; $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"'; $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, , , '', $hint );


 * 1) Added and Modified for threaded discussion

global $wgSectionCommentOn; $SectionCommentOn = isset($wgSectionCommentOn) ? $wgSectionCommentOn : False; $commenturl = '&section='.$section.'&comment=yes'; $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'replysectionhint', htmlspecialchars( $hint ) ) . '"'; $curl = $this->makeKnownLinkObj( $nt, wfMsg('replysection'), 'action=edit'.$commenturl, , , '', $hint );

if($SectionCommentOn && $nt->isTalkPage ) { return "[".$url."][".$curl."] "; }		else{ return "[".$url."] "; }	}

AddSectionComments Extension
extensions/AddSectionComments.php

This extension implements a discussion threading process. This threading will only be seen on the talk pages, unless explicity invoked in the command line.

It adds a [reply] link on the header line. Each time a new posting is entered or a posting is replied to, the comment will automatically be tagged (and appear in the TOC too). Of course direct editing can occur, but this really makes it a lot easier to organize discussions in a threading view that most are familiar with.

To do:
 * 1) Internationalize
 * 2) get someone who knows regex to clean up the parsing of the subject line
 * 3) Assess to see if there's an easier way to do this

 * @addtogroup Extensions * @copyright © 2007 Jack D. pond * @licence GNU General Public Licence 2.0 or later */

if( defined( 'MEDIAWIKI' ) ) {

$wgExtensionFunctions[] = 'efAddSectionCommentSetup'; $wgExtensionCredits['other'][] = array( 		'name' => 'AddSectionComments', 		'author' => 'Jack D. Pond',		'url' => 'http://www.mediawiki.org/w/index.php?title=Extension:DiscussionThread_Article&action=edit',		'description' => 'Add Tagged Comments to Section Capability' );

global $wgSectionCommentOn; $wgSectionCommentOn = True; $wgHooks['EditPage::showEditForm:initial'][] = 'efAddSectionComment'; $wgHooks['EditPage::attemptSave'][] = 'efStampComment';

function efaddSectionCommentSetup { global $wgMessageCache;

$wgMessageCache->addMessage( 'replysection', 'reply' ); $wgMessageCache->addMessage( 'replysectionhint', "Reply to this Posting" ); }

function efAddSectionComment($efform){ global $wgSectionCommentOn; $SectionCommentOn = isset($wgSectionCommentOn) ? $wgSectionCommentOn : false; if ( $efform->commentsection != '' && $wgSectionCommentOn && !$efform->commentadded) { wfDebug( "Entered efAddSectionComment - - something in session.\n" ); if ($efform->commentsection != '') { wfDebug( "Entered efAddSectionComment - - something in commentsection.\n" ); $text = $efform->textbox1; $matches = array; preg_match( "/^(=+)(.+)\\1/mi",					$efform->textbox1,					$matches ); if( !empty( $matches[2] ) ) { preg_match( "/.*(-+)\\1/mi",$matches[2],$matchsign); if (!empty($matchsign[0]) ){ $text = $text."\n\n".$matches[1]."=Re: ".trim($matchsign[0])." ~".$matches[1]."="; } else { $text = $text."\n\n".$matches[1]."=Re: ".trim($matches[2])." -- ~".$matches[1]."="; }				} else { $text = $text." -- ~ \n\n"; }				$efform->commentadded = true; $efform->textbox1 = $text; }			return (true); }	}	function efStampComment($efform){ global $wgSectionCommentOn; $SectionCommentOn = isset($wgSectionCommentOn) ? $wgSectionCommentOn : false; if ( $efform->section == "new" && $wgSectionCommentOn && !$efform->commentadded) { $efform->summary = $efform->summary." -- ~"; }		return(true); } } ?>