<?php
/*
Nucleus Codeviewer Plugin V1.0
(C) 2004 by Edelpils om3ega.com / ditnetwel.nl
 
Version history
 
	v1.0 First release of this PHP source code viewer
 
Known issues (for now ;) )
 
	- You cannot use [PHPCODE] in the comments
	- You can use [PHPCODE] only 2 times per post (1 time in the body , and 1 time in the extended text)
	- You cannot display ASP code or C++ , only PHP
 
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 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
Contact me : om3ega@walla.com
 
You may use and distribute this freely as long as you leave the copyrights intact.
*/
 
class NP_Codeviewer extends NucleusPlugin {
        function getName() {
                return 'Codeviewer';
        }
 
        function getAuthor()  {
                return 'Edelpils / OM3EGA / www.ditnetwel.nl';
        }
 
        function getURL()
        {
                return 'http://www.ditnetwel.nl/plugins/';
        }
 
 
        function getVersion() {
                return '1.0';
        }
 
        function getDescription() {
                return 'Will display PHP source-code in colour without giving a DISALLOWED (text) warning. Write your PHP code between [phpcode] and [/phpcode]';
        }
 
 
function install() {
$this->createOption('enablephp','Enable PHP sourcecode display in posts?','yesno','yes');
}
 
function getEventList() { 
		return array('PreItem'); 
	}
 
	function doconvert(&$data) {
 
		$startsearch = "[phpcode]";
		$endsearch = "[/phpcode]";
		$String = $data;
		$StartCode = strpos($String, $startsearch);
		$EndCode = strpos($String, $endsearch);
		$EndCode2 = ($EndCode - $StartCode);
		$content2 = substr($String, $StartCode, $EndCode2);
		$String1 = substr($String, 0, $StartCode);
		$String2 = substr($String, $EndCode);
		$search = array ("[phpcode]", "[/phpcode]");
		$replace = array ("", "");
		$content1 = str_replace($search, $replace, $String1);
		$content3 = str_replace($search, $replace, $String2);
		$content2 = str_replace($search, $replace, $content2);
		$content2 = str_replace("<br />\r","",$content2);
 
			if ($content2) {
			$content2 = highlight_string($content2, true);
			}
 
		$data = $content1.$content2.$content3;
		return $data;
			    }
 
 
 
			function event_PreItem($data) 	{
 
				if ($this->getOption('enablephp') != 'yes') 
				return;
 
				$this->doconvert($data['item']->body);
				$this->doconvert($data['item']->more);	
						}
 
 
		}
 
?>
np_codeviewer_code.txt · Last modified: 2007/10/31 03:59 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki