'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 = ""; $wgExtPatchOutputTable = array( '


' => $output.'


' ); $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; } } ?>