WeakWiki


modules\geshism\geshism.module.php

WeakWiki (WeakWiki GeSHi Support (geshism) module: geshism.module.php) Copyright (C) 2010 Alexander Lang This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . Project Home: http://weakwiki.robnet.wmweb.at/ Contact: robbiblubber@robnet.wmweb.at



/********************************************************************************
WeakWiki (WeakWiki GeSHi Support (geshism) module: geshism.module.php)
Copyright (C) 2010 Alexander Lang

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this
program; if not, see .

Project Home: http://weakwiki.robnet.wmweb.at/
Contact:      robbiblubber@robnet.wmweb.at
********************************************************************************/



require_once('./lib/modules.library.php');
require_once('./modules/geshism/geshi.php');



/** This is class implements the log manager (logm) module.						*/
class GeSHiSupportModule extends __Module
{	
	/** Returns the module name.
		@return		Module name.												*/
	public function getName()
	{
		return "geshism";
	}
	
	/** Returns the module version.
		@return		Module name.												*/
	public function getVersion()
	{
		return _VERSION;
	}
	
	/** Returns a description of the module.
		@return		Module description.											*/
	public function getDescription()
	{
		return "GeSHi Support Module";
	}
	
	/** Returns the module's parse mode.
		@return		Parse mode.													*/
	public function getParseMode()
	{
		return MOD_MODE_PARSE;
	}
	
	/** Returns a detail page for the module.
		@return		Module detail page.											*/
	public function getDetails()
	{
		return "geshism
WeakWiki GeSHi Support Module Version " . $this->getVersion() . "
by Alexander Lang
Copyright (C) 2010 Alexander Lang

" . "This module uses GeSHi by Nigel McNie and Benny Baumann
" . "see http://qbnz.com/highlighter/"; } /** Method is called before text is parsed. @param $input Unparsed text. @return Parsed text. */ public function parse($input) { return _parseBraced($input, "[[[@C", "]]]", "
\n", "\n
", Array(), "_geshi_parse"); } } /** Translates table flags into CSS classes. @param $startTag Start tag. @param $text Text. @return Parsed start tag. */ function _geshi_parse($startTag, &$text) { $n = trim(str_replace("
", "", substr($text, 0, strpos($text, "\n")))); $text = substr($text, strpos($text, "\n")); $rval = "code"; $n = explode(':', $n); if(strpos($n[0], "r") !== false) { $rval = "code bg_red"; } if(strpos($n[0], "g") !== false) { $rval = "code bg_green"; } if(strpos($n[0], "b") !== false) { $rval = "code bg_blue"; } if(strpos($n[0], "G") !== false) { $rval = "code bg_grey"; } if(strpos($n[0], "y") !== false) { $rval = "code bg_yellow"; } if(strpos($n[0], "w") !== false) { $rval = "code bg_white"; } $sh = new GeSHi($text, $n[1]); $text = ">>@ignore<<" . $sh->parse_code() . ">>@/ignore<<"; return str_replace("%FLAGS%", $rval, $startTag); } ?>

WeakWiki