Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/prepareFunctions.php
<?php
/* Funktion fuer die Vorbereitung des Datenbank-Contents fuer die Darstellung
in Edit-Formularen
$parsemode = global var $parse
$string = global var fuer die zu parsenden Artikeltext-Inhalte
$param = zusaetzlicher Parameter fuer diverse Dinge ... (jetzt benutzt nur
fuer optionales Einparsen von Zeilenumbruechen in HTML_PLAIN Mode)
 */
function prepareDisplay($parsemode,$string,$param){
     global $cbDirUploads,$cmsPath;
 		if($parsemode == HTML_PLAIN) {        # Modus 'plain HTML'

			if($param == 1) {    # autom. Einfuegen von <br>-Tags fuer HTML-Mode
				$string = eregi_replace("\r\n","\n",$string);
				$string = eregi_replace("\n","<br />",$string);
			}

		} elseif($parsemode == TEXT_PLAIN) {     # plain text mode ...
			$string = htmlspecialchars($string);
			$string = eregi_replace("\r\n","\n",$string);
			$string = eregi_replace("\n","<br />",$string);

		} elseif($parsemode == BBCODE) {   # TAG modus: wie Forum
			$string = eregi_replace("<br />","\n",$string);
			$content = eregi_replace("<img src=\"([^\[]+)\" border=\"0\">","[img]\\1[/img]",$string);
			$string = eregi_replace("<b>([^[]+)</b>","\[b\]\\1\[/b\]",$string);
			$string = eregi_replace("<li>([^[]+)</li>","[li]\\1[/li]",$string);
			$string = eregi_replace("<i>([^[]+)</i>","[i]\\1[/i]",$string);
			$string = eregi_replace("<u>([^[]+)</u>","[u]\\1[/u]",$string);
			$string = ereg_replace("<img align=\"right\" src=\"","[image align=right]",$string);
			$string = ereg_replace("<img align=\"left\" src=\"","[image align=left]",$string);
			$string = ereg_replace("\" border=\"0\" alt=\"\[\]\">","[/image]",$string);
			$string = ereg_replace("<a href=\"([^\[]+)\" target=\"([^\[]+)\">([^\[]+)</a>","[link url=\\1 target=\\2]\\3[/link]",$string);
			$string = ereg_replace("<a href=\"([^\[]+)\">([^\[]+)</a>","[link url=\\1]\\2[/link]",$string);
			$string = preg_replace("/<ul>(.*?)<\/ul>/is","[ul]\\1[/ul]",$string);
			$string = preg_replace("/<a href=\"(http|https|ftp)(:\/\/\S+)(\">)(.+?)<\/a>/is" , "[url=\\2\\3\]\\5[/url]" , $string);
			$string = preg_replace("/(\[URL=)(\S+)(\])(.+?)(\[\/URL])/is" , "<a href=\"\\2\">\\4</a>" , $string);								
			
		} elseif($parsemode == DHTML_MS) {   # MSIE integrated WYSIWIG-Editor
		    //$internUploadIdent=getUploadDir();
		    $internUploadIdent=$cmsPath.$cbDirUploads;
	        // jetzt werden die Bilder-Referenzen ersetzt ...
            $search="src=\"".$internUploadIdent;
	        $replace="src=\"". SITEROOT;
	        //trigger_error("\$search=".$search." \$replace=".$replace,E_USER_WARNING);
	        stripslashes(stripslashes(trim($string)));
	        $string=eregi_replace($search,$replace,$string);
	        // .. und jetzt die lokalen Links  ...
            $search="href=\"".$internUploadIdent;
	        $replace="href=\"". SITEROOT;
	        stripslashes(stripslashes(trim($string)));
	        $string=eregi_replace($search,$replace,$string);
        }
        
        stripslashes(stripslashes(trim($string)));

        return $string;
}  // function prepareDisplay

function prepareForSave($parsemode,$string,$param){
     global $cbDirUploads;
			if($parsemode == HTML_PLAIN) {
				if($param == 1) {
					$string = eregi_replace("\r\n","\n",$string);
					$string = eregi_replace("\n","<br />",$string);
				}

			} elseif($parsemode == TEXT_PLAIN) {
				$content = htmlspecialchars($string);
				$string = eregi_replace("\r\n","\n",$string);
				$string = eregi_replace("\n","<br />",$string);

			} elseif($parsemode == BBCODE) {
				$string = eregi_replace("<br />","\n",$string);
				$string = htmlspecialchars($string);
				$string = eregi_replace("\r\n","\n",$string);
				$string = eregi_replace("\n","<br />",$string);
				$string = eregi_replace("\[img\]([^\[]+)\[/img\]","<img src=\"\\1\" border=\"0\">",$string);
				$string = eregi_replace("\[b\]([^[]+)\[/b\]","<b>\\1</b>",$string);
				$string = eregi_replace("\[li\]([^[]+)\[/li\]","<li>\\1</li>",$string);
				$string = eregi_replace("\[i\]([^[]+)\[/i\]","<i>\\1</i>",$string);
				$string = eregi_replace("\[u\]([^[]+)\[/u\]","<u>\\1</u>",$string);
				$string = ereg_replace("\[image align=right\]","<img align=\"right\" src=\"",$string);
				$string = ereg_replace("\[image align=left\]","<img align=\"left\" src=\"",$string);
				$string = ereg_replace("\[/image\]","\" border=\"0\" alt=\"\[\]\">",$string);
				$string = ereg_replace("\[link url=([^\[]+) target=([^\[]+)\]([^\[]+)\[/link\]","<a href=\"\\1\" target=\"\\2\">\\3</a>",$string);
				$string = ereg_replace("\[link url=([^\[]+)\]([^\[]+)\[/link\]","<a href=\"\\1\">\\2</a>",$string);
				$string = preg_replace("/\[ul\](.*?)\[\/ul\]/is", "<ul>\\1</ul>", $string);
				$string = preg_replace("/(\[URL=)(http|https|ftp)(:\/\/\S+)(])(.+?)(\[\/URL\])/is", "<a href=\"\\2\\3\">\\5</a>" , $string);
				$string = preg_replace("/(\[URL=)(\S+)(\])(.+?)(\[\/URL])/is", "<a href=\"\\2\">\\4</a>" , $string);
			}
     return $string;
}   // function prepareForSave

/*  function to remove domain-Name of actual server from Links
* (get path-compatibility when removing to another server)
 */
function removeLocalDomainname($string){
	$string=ereg_replace("http://".$_SERVER["HTTP_HOST"],"",$string);
	return $string;
}  // function removeLocalDomainname($string)

?>

Return current item: Content*Builder