2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 //This code is not being used. Place holder for some utilities to fix the [code] blocks
16 //in the visual html editor.
18 define("PATTERN", "/<\/p>[\W]*<p>/");
19 define("REPLACE", "\n");
20 define("CODESTART", "[code]");
21 define("CODEEND", "[/code]");
23 class ContentOutputUtils {
25 * Recursive function which strips </p><p> tags from between [code] tags and
26 * replaces them with line feeds
31 public function stripPtags($text) {
32 $codestart = strpos($text, CODESTART);
33 if ($codestart == FALSE) {
37 $codestart += strlen(CODESTART);
38 $firstpart = substr($text, 0, $codestart);
40 $codeend = strpos($text, CODEEND) + strlen(CODEEND);
41 $lastpart = substr($text, $codeend);
43 $codetext = substr($text, $codestart, $codeend - $codestart);
44 $newcodetext = preg_replace(PATTERN, REPLACE, $codetext);
45 $result = $firstpart.$newcodetext.$this->stripPtags($lastpart);