Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved [How To?] Noparse
#5
Not Solved
(2011-06-04, 07:28 PM)Ad Bakker Wrote: And indeed, it does not work!!!!

Since I did not like the noparsing solution mentioned before anyway, because is involves changes in the source code, I started to try my own solution. Although I have programming experience since 1968, this was only in FORTRAN and related languages. I had never done sometjing in html/php or even C. After studying the source of some programs, and some manual pages on internet I managed to get something to work. This code is:

<?php
/************************************************************
* author       : Ad Bakker
* plugin       : Noparse BBCode
* last_mod     : 06.10.2011 (June 10th 2011)
* version      : 1.0
*************************************************************/
if(!defined('IN_MYBB'))
{
	die("This file cannot be accessed");
}

//
// make sure "noparse_run" is called at the start op the parsing process
//
$plugins->add_hook("parse_message_start", "noparse_run");

function noparse_info () {
	return array (
		"name"		=> "Tag [noparse]",
		"description"	=> "Tag [noparse], MyCode source",
		"author"	=> "Ad Bakker",
		"version"	=> "1.0",
	);
}

function noparse_activate () {
// Activate plugin
// no action required
}

function noparse_deactivate () {
// Deactivate plugin
// no action required
}

function noparse_run ($message) {
//
// In between the [noparse] and [/noparse] tags all square bracket characters
// "[" and "]" are replaced by the Unicode equivalemts &#91 and &#93, respectively.  
// By that they remain their "looks" but BBCode tags are no longer recognized as  
// such by the BBCode parsing process
//
	$match_pattern = '#\[noparse\](.*?)\[/noparse\]#is';
	if (preg_match_all($match_pattern,$message,$matches,PREG_SET_ORDER)) {
		foreach ($matches as $found) {
//
//			remove noparse tags
//
			$replace = preg_replace($match_pattern,"$1",$found[0]);
//
//			replace square brackets by Unicode equivalents
//
			$replace = str_replace(array('[',']'),array('&#91','&#93'),$replace);
//
//                      replace text in between noparse tags by text with converted brackets
//
			$message = preg_replace($match_pattern,$replace,$message,1);
		}
	}
	return $message;
}

?>

Save the above as "noparse.php", copy it to the /inc/plugins folder and activate it in the Plugins Admin control panel, and it works!!
There are still quite som things that I do not understand in php programming, but I learned a lot of it.

Regards,

Ad Bakker


Messages In This Thread
Noparse - by gcrock - 2011-02-21, 11:26 PM
RE: Noparse - by Joshua Mayer - 2011-02-22, 05:29 AM
RE: Noparse - by gcrock - 2011-02-22, 12:31 PM
RE: Noparse - by Ad Bakker - 2011-06-04, 07:28 PM
RE: Noparse - by Ad Bakker - 2011-06-10, 05:25 PM
RE: Noparse - by ranjani - 2011-06-10, 05:37 PM
RE: Noparse - by Ad Bakker - 2011-06-10, 06:40 PM
RE: Noparse - by Ad Bakker - 2011-08-10, 06:10 AM
RE: Noparse - by ranjani - 2011-08-10, 06:24 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)