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.

Installation Instructions
Details are below, but these are required steps:

This will change when I get access to the SVN, but for now: require_once("$IP/extensions/DiscussionThreading/DiscussionThreading.php");
 * 1) Create a new directory extensions/DiscussionThreading
 * 2) Create a new file extensions/DiscussionThreading/DiscussionThreading.php and copy and paste the below code
 * 3) Create a new file extensions/DiscussionThreading/DiscussionThreading.i18n.php and copy and paste the below code
 * 4) Patch EditPage.php according to below instructions
 * 5) Patch Linker.php according to below instructions
 * 6) Patch localsettings.php by adding:

There is something very funky about flushing the PHP compiled cache. I was only able to get the changes made in the Linker.php and the EditPage.php files to take effect by going to a discussion page while I was logged on as an administrator on the patched server and using a browser local to that machine (press the + tab). Somehow, this caused the .php files to recompile and activate for everyone.

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 "replyto=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 $replytosection = '', $replyadded = 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->replytosection = ''; $this->replyadded = 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' ); $replytosection = $wgRequest->getVal( 'replyto' );
 * 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->replytosection = $request->getVal( 'replyto' ); $this->live = $request->getCheck( 'live' ); $this->editintro = $request->getText( 'editintro' );
 * 1) 	Added for discussion threading

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

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

Modified linker.php line 1062
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 $wgSectionThreadingOn; $wgSectionThreadingOn = isset($wgSectionThreadingOn) ? $wgSectionThreadingOn : False; $commenturl = '&section='.$section.'&replyto=yes'; $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'replysectionhint', htmlspecialchars( $hint ) ) . '"'; $curl = $this->makeKnownLinkObj( $nt, wfMsg('replysection'), 'action=edit'.$commenturl, , , '', $hint );

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

DiscussionThreading Extension
extensions/DiscussionThreading.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) get someone who knows regex to clean up the parsing of the subject line
 * 2) 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' ) ) {

require_once( "$IP/extensions/DiscussionThreading/DiscussionThreading.i18n.php" );
 * 1) Internationalisation file

$wgExtensionFunctions[] = 'efDiscussionThreadSetup'; $wgExtensionCredits['other'][] = array( 						'name' => 'DiscussionThreading', 						'author' => 'Jack D. Pond',						'url' => 'http://www.mediawiki.org/wiki/Extension:DiscussionThreading',						'description' => 'Add Threading to discussion (talk) pages' );

global $wgSectionThreadingOn; $wgSectionThreadingOn = True; $wgHooks['EditPage::showEditForm:initial'][] = 'efDiscussionThread'; $wgHooks['EditPage::attemptSave'][] = 'efStampReply';

function efDiscussionThreadSetup { global $wgMessageCache, $wgDiscussionThreadMessages;

foreach( $wgDiscussionThreadMessages as $lang => $messages ) $wgMessageCache->addMessages( $messages, $lang ); }

function efDiscussionThread($efform){ global $wgSectionThreadingOn; $wgSectionThreadingOn = isset($wgSectionThreadingOn) ? $wgSectionThreadingOn : false; if ( $efform->replytosection != '' && $wgSectionThreadingOn && !$efform->replyadded) { wfDebug( "Entered efDiscussionThread - - something in session.\n" ); if ($efform->replytosection != '') { wfDebug( "Entered efDiscussionThread - - something in replytosection.\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->replyadded = true; $efform->textbox1 = $text; }			return (true); }	}	function efStampReply($efform){ global $wgSectionThreadingOn; $wgSectionThreadingOn = isset($wgSectionThreadingOn) ? $wgSectionThreadingOn : false; if ( $efform->section == "new" && $wgSectionThreadingOn && !$efform->replyadded) { $efform->summary = $efform->summary." -- ~"; }		return(true); } } ?>

Internationalisation file DiscussionThreading.i18n.php
I was only completely comfortable with the english translations - looking to others to help me put the correct language translations in.

I would deeply appreciate your help here.

Load into file (in extension DiscussionThreading.i18n.php)

 'reply',	'replysectionhint' => "Reply to this Posting", );

/* Need to add af,br,bs,ca,cs,cy,de,et,eu,fi,fr,ga,gl,he,hr,hsb,id,is,it,ja,kk-kz,kk-tr,kk-cn,kk,lv,nl, no,nn,oc,pt,pt-br,ro,ru,sk,sl,sq,uk,wa,zh-cn,zh-tw,zh-yue,zh-hk,zh-sg

?>

Would add new languages with a new array per, using this array schema for each language:

$wgDiscussionThreadMessages['lang1'] = array(	'replysection' => 'lang1tag',	'replysectionhint' => "lang1hint", );