All pastes #622214 Raw Edit

Untitled

public php v1 · immutable
·published 2007-07-16 18:49 UTC
rendered paste body
<?phpif( !defined( 'MEDIAWIKI' ) ) {  echo( "This file is part of an extension to the MediaWiki software and cannot be used standalone.\n" );  die( true );}$wgExtensionCredits['other'][] = array(                                       'name' => 'PatchOutput + HTMLets + BoilerPlateSelection = GenDoc',                                       'version' => '1.0',                                       'author' => 'User:RV1971, User:Dtsig, Daniel Kinzler, Brian Mingus ',                                       'url' => 'http://grey.colorado.edu',                                       'description' => 'Insert an Iframe if the page title matches an available gendoc page in /usr/local/gendoc.'                                       );global $wgHooks;#$wgHooks['OutputPageBeforeHTML'][] = 'GendocInsertIframe';#$wgHooks['OutputPageBeforeHTML'][] = array( &$wgExtPatchOutput,"onOutputPageBeforeHTML" );global $wgTitle;global $gendocTitle;# Robchurch: This doesnt work$gendocTitle = split('/',$wgTitle->getPrefixedText());if(sizeof($gendocTitle) == 2) {  $gendocTitle[0] = strtolower($gendocTitle[0]);  $gendocTitle = implode('/',$gendocTitle);} else {  $gendocTitle = false;}echo "Gendoc Title: ".$gendocTitle;function GendocMatchArticleTitle( &$outputPage, &$text ) {    global $wgTitle;    $subdirs = array('bp','cs','leabra','pdp','so','ta');    $status = false;    # Robchurch: This does    $path = split('/',$wgTitle->getPrefixedText());    # Have to jump through a hoop for lowercase first letter of titles    # See: http://en.wikipedia.org/wiki/Wikipedia:Naming_conventions_(technical_restrictions)#Lower_case_first_letter                                                                                                                                                     if(sizeof($path) == 2) {      $path[0] = strtolower($path[0]);      $path = implode('/',$path);      $this_file = '/usr/local/gendoc/'.$path;      echo $this_file;      if(file_exists($this_file)) {        $status = true;      }    }    return $status;}function GenDocInsertIframe( &$outputPage, &$text ) {  $dir = "http://grey.colorado.edu/gendoc/";  $output = "<iframe src=\"".$dir.$name.".html\" width=\"100%\" name=\"".$name."\" style=\"frameborder:0;marginwidth:0;marginheight:0;scrolling:no;\" title=\"".$dir.$name."\">[Your user agent does not support frames or is currently configured not to display fra\mes. However, you may visit <a href=\"".$dir.$name."\">The original page</a></iframe>";  $wgExtPatchOutputTable = array( '</p><p><br />' => $output.'</p><p><br />' );  $wgExtPatchOutput = new ExtPatchOutput();  return true;}class ExtPatchOutput {  public function onOutputPageBeforeHTML( &$out, &$text ) {    global $wgExtPatchOutputTable;    if((GendocMatchArticleTitle($outputPage, $text))) {      foreach( $wgExtPatchOutputTable as $from => $to )        $text =& str_replace( $from, $to, $text );    }    return true;  }}?>