[Mediawiki-l] User page formatting

Dave Sigafoos davesigafoos at sanmar.com
Tue Aug 7 15:49:41 UTC 2007

Still has all those nasty 'regular experssions' (I love the term regular
expressions .. not sure what is so regular about them <G>)

David Tod Sigafoos | SANMAR Corporation
davesigafoos at sanmar.com 


-----Original Message-----
From: mediawiki-l-bounces at lists.wikimedia.org
[mailto:mediawiki-l-bounces at lists.wikimedia.org] On Behalf Of Jim Hu
Sent: Tuesday, August 07, 2007 6:29
To: MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] User page formatting

Try this!

  * UserPageOnDemand.php - An extension 'module' for the  
PagesOnDemand extension.
  * @author Jim Hu (jimhu at tamu.edu)
  * @version 0.1
  * @copyright Copyright (C) 2007 Jim Hu
  * @license The MIT License - http://www.opensource.org/licenses/mit- 

if ( ! defined( 'MEDIAWIKI' ) ) die();

# Credits
$wgExtensionCredits['other'][] = array(
     'author'=>'Jim Hu &lt;jimhu at tamu.edu&gt;',
     'description'=>'Demo for PagesOnDemand mechanism for generating  
User pages from template on demand.',

# Register hooks ('PagesOnDemand' hook is provided by the  
PagesOnDemand extension).
$wgHooks['PagesOnDemand'][] = 'wfLoadUserPageOnDemand';

* Loads a demo page if the title matches a particular pattern.
* @param Title title The Title to check or create.
function wfLoadUserPageOnDemand( $title, $article ){

	# Short-circuit if $title isn't in the MAIN namespace or doesn't

match the DEMO pattern.
	if ( $title->getNamespace() != NS_USER) {
		return true;
     $template = Revision::newFromTitle(Title::makeTitle(NS_TEMPLATE,  
     if (! $template){
     	$text = "Can't find template page Template:User_page_template";
	    $text = $template->getText();
	    #strip out noinclude sections
	    $text = preg_replace( '/<noinclude>.*?<\/noinclude>/s', '',

$text );
	}	# Create the User page's new text - could be more
complicated, but  
this is just a demo

	# Create the Article, supplying the new text
	$article = new Article($title);
	$article->doEdit( $text, 'Create user page from template via  
PagesOnDemand', EDIT_NEW | EDIT_FORCE_BOT );

	# All done (returning false to kill PoD's wfRunHooks stack)
	return false;

On Aug 7, 2007, at 6:31 AM, Nancy Dailey wrote:

> Thank you. BoilerplateSelection would work but since it takes the  
> user to an edit page so early in the use of the wiki, it overwhelms  
> them. My experience using wikis inside business organizations is  
> that form is far more important than function to get them to early  
> adopt use of wikis as a productivity/team building tool. I will try  
> to modify PagesOnDemand. Thank you so much for your help! Nancy
> <snip>
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128

MediaWiki-l mailing list
MediaWiki-l at lists.wikimedia.org

More information about the MediaWiki-l mailing list