SpecialManPage/code

for MW 1.20

 * /SpecialManPage.php
 * /SpecialManPage.main.php
 * /SpecialManPage.i18n.php

for MW 1.18
This never did display properly in the Special:SpecialPages listing, but otherwise it worked properly.  'Special:ManPage',	'url' => 'http://htyp.org/SpecialManPage',        'path' => __FILE__,        'description' => 'special page for displaying manpages', //        'descriptionmsg' => 'special-manpage',        'author' => 'Woozle',	'version' => '1.0 2012-01-17' ); $messages['en'] = array( 'specialmanpage' => 'Special:ManPage', //Ignore 'specialmanpage-desc' => "ManPage Viewer", 'specialpages-group-referencetools' => 'Reference Tools' );

if (!defined('LIBMGR')) { require('libmgr.php'); } clsLibMgr::Add('menus',		KFP_MW_LIB.'/menu.php',__FILE__,__LINE__); clsLibMgr::Add('richtext',	KFP_MW_LIB.'/richtext.php',__FILE__,__LINE__); clsLibMgr::Load('menus'		,__FILE__,__LINE__); clsLibMgr::Load('richtext'	,__FILE__,__LINE__); /* define('KS_CHAR_URL_ASSIGN',':');	// character used for encoding values in wiki-internal URLs function wfSpecialManPage { // This registers the page's class. I think. global $wgRequest;

$app = new SpecialManPage($wgRequest); }

//require_once( $wgScriptPath.'includes/SpecialPage.php' );

class SpecialManPage extends SpecialPageApp { //======= // STATIC static private $objDB;

/*   static public function Setting($iName) { global $wgSpamFerretSettings;

return $wgSpamFerretSettings[$iName]; } //======= // DYNAMIC

protected $args;

public function __construct { global $wgOut, $wgMessageCache;

parent::__construct( 'ManPage' ); $this->includable( false ); //$wgMessageCache->addMessage('manpage', 'manpage display'); //       parent::SpecialPage('ManPage','',true,false,'default',true); //$wgOut->setPagetitle("ManPage Viewer"); } function execute( $par ) { global $wgUser;

$this->setHeaders; $this->GetArgs($par);

if ($wgUser->isAllowed('editinterface')) { $this->doAdmin; } else { $this->doUser; } }  public function doAdmin { global $wgOut; /*	PURPOSE: do stuff that only admins are allowed to do For now, admins have no special powers, so just call doUser. $this->doUser; // display menu } public function doUser { global $wgOut; /*	PURPOSE: do only stuff that regular users are allowed to do	$page = nzArr($this->args,'page'); $sect = nzArr($this->args,'section');

$carg = $page; if (!is_null($sect)) { $carg = $sect.' '.$carg; }

$txtCmd = 'man --html=cat '.$carg; exec($txtCmd,$arCmdOut,$intCmdStat); $intLines = count($arCmdOut); $wgOut->AddHTML(' '); $wgOut->AddHTML('Page: '.$page.' | '); $wgOut->AddHTML('Status: '.$intCmdStat.'| '); $wgOut->AddHTML('Lines: '.$intLines.' | '); $wgOut->AddHTML('Command: '.$txtCmd.' '); foreach($arCmdOut as $txtLine) { $txtLine = str_replace(' ',NULL,$txtLine); $txtLine = str_replace(' ',NULL,$txtLine); $txtLine = str_replace(' ',NULL,$txtLine); $txtLine = str_replace(' ',NULL,$txtLine); $wgOut->AddHTML($txtLine."\n"); } } } function nzArr($iArr=NULL,$iKey,$iDefault=NULL) { if (is_null($iArr)) { return $iDefault; } else { if (array_key_exists($iKey,$iArr)) { return $iArr[$iKey]; } else { return $iDefault; }   } }