Partage
  • Partager sur Facebook
  • Partager sur Twitter

SyntaxHighlighte et nukedf klan

integrer le patch il marche pas de pb le seul truc c'est

    30 avril 2009 à 19:48:32

    Bonjour a tous,
    Voila j'utilise le CMS Nukd klan v1.7.7 pour gérer mon site, cela va faire une semaine que j'essaye d'intégrer correctement le patch SyntaxHighlighte à mon bbcode. Donc j'ai réussi à integrer le patch il marche pour php, sql et css par contre en xhtml et js j'ai les couleurs tout nikel mais j'ai des <br> qui se mettent dans le code à chaque fin de ligne et impossible de les enlever.. je vous met la parti de mon code ici :

    function BBcode($texte, $imgMaxWidth = 0, $imgClic = FALSE)
    {
        global $bgcolor3, $bgcolor1;
    
    	echo "<script type=\"text/javascript\" src=\"js/bbcode.js\"></script>\n";	
    	echo "<link title=\"style\" type=\"text/css\" rel=\"stylesheet\" href=\"css/csszone.css\" />";
    	$rand = rand(1, 50);
    	$rand2 = rand(50, 100);
    	
        if ($texte != "")
        {
    	//$texte = nl2br($texte);
    
            if (!eregi("[html]", $texte) && !eregi("[css]", $texte) && !eregi("[php]", $texte) && !eregi("[js]", $texte) && !eregi("[sql]", $texte))
    		{
    			$texte = str_replace("\n", "<br />", $texte);
    		}
    		else
    		{
    			$texte = nl2brPre($texte);
    		}	
    
            $texte = " " . $texte;
            $texte = preg_replace("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="\2://\3"  onclick="window.open(this.href); return false;">\2://\3</a>', $texte);
            $texte = preg_replace("#([\t\r\n ])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="http://\2.\3"  onclick="window.open(this.href); return false;">\2.\3</a>', $texte);
            $texte = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $texte);
    
    		$texte = str_replace("\r", "", $texte);
    
            $texte = preg_replace("/\[color=(.*?)\](.*?)\[\/color\]/i", "<span style=\"color: \\1;\">\\2</span>", $texte);
            $texte = preg_replace("/\[size=(.*?)\](.*?)\[\/size\]/i", "<span style=\"font-size: \\1px;\">\\2</span>", $texte);
            $texte = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/i", "<span style=\"font-family: \\1;\">\\2</span>", $texte);
            $texte = preg_replace("/\[align=(.*?)\](.*?)\[\/align\]/i", "<div style=\"text-align: \\1;\">\\2</div>", $texte);
            $texte = str_replace("[b]", "<b>", $texte);
            $texte = str_replace("[/b]", "</b>", $texte);
            $texte = str_replace("[i]", "<i>", $texte);
            $texte = str_replace("[/i]", "</i>", $texte);
            $texte = str_replace("[li]", "<ul><li>", $texte);
            $texte = str_replace("[/li]", "</li></ul>", $texte);
            $texte = str_replace("[u]", "<span style=\"text-decoration: underline;\">", $texte);
            $texte = str_replace("[/u]", "</span>", $texte);
            $texte = str_replace("[center]", "<div style=\"text-align: center;\">", $texte);
            $texte = str_replace("[/center]", "</div>", $texte);
            $texte = str_replace("[strike]", "<span style=\"text-decoration: line-through;\">", $texte);
            $texte = str_replace("[/strike]", "</span>", $texte);
            $texte = str_replace("[blink]", "<span style=\"text-decoration: blink;\">", $texte);
            $texte = str_replace("[/blink]", "</span>", $texte);
            $texte = preg_replace("/\[flip\](.*?)\[\/flip\]/i", "<div style=\"width: 100%;filter: FlipV;\">\\1</div>", $texte);
            $texte = preg_replace("/\[blur\](.*?)\[\/blur\]/i", "<div style=\"width: 100%;filter: blur();\">\\1</div>", $texte);
            $texte = preg_replace("/\[glow\](.*?)\[\/glow\]/i", "<div style=\"width: 100%;filter: glow(color=red);\">\\1</div>", $texte);
            $texte = preg_replace("/\[glow=(.*?)\](.*?)\[\/glow\]/i", "<div style=\"width: 100%;filter: glow(color=\\1);\">\\2</div>", $texte);
            $texte = preg_replace("/\[shadow\](.*?)\[\/shadow\]/i", "<div style=\"width: 100%;filter: shadow(color=red);\">\\1</div>", $texte);
            $texte = preg_replace("/\[shadow=(.*?)\](.*?)\[\/shadow\]/i", "<div style=\"width: 100%;filter: shadow(color=\\1);\">\\2</div>", $texte);
            $texte = preg_replace("/\[email\](.*?)\[\/email\]/i", "<a href=\"mailto:\\1\">\\1</a>", $texte);
            $texte = preg_replace("/\[email=(.*?)\](.*?)\[\/email\]/i", "<a href=\"mailto:\\1\">\\2</a>", $texte);
            $texte = str_replace("[quote]", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><div id=\"quote\" style=\"border: 0; overflow: auto;\"><b>" . _QUOTE . " :</b><br />", $texte);
            $texte = preg_replace("/\[quote=(.*?)\]/i", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><div id=\"quote\" style=\"border: 0; overflow: auto;\"><b>\\1 " . _HASWROTE . " :</b></div>", $texte);
            $texte = str_replace("[/quote]", "</div></td></tr></table><br />", $texte);
    		$texte = str_replace("[code]", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><b>" . _CODE . " :</b><pre>", $texte);
            $texte = str_replace("[/code]", "</pre></td></tr></table>", $texte);
            if ($imgMaxWidth>0)
    		{
    			if ($imgClic == TRUE) $texte = preg_replace_callback('/\[img\](.*?)\[\/img\]/i', create_function('$var', '$img = "<a href=\"" . checkimg($var[1]) . "\" class=\"thickbox\" alt=\"\"><img style=\"border: 0; overflow: auto; max-width: ' . $imgMaxWidth . 'px;  width: expression(this.scrollWidth >= ' . $imgMaxWidth . '? \'' . $imgMaxWidth . 'px\' : \'auto\');\" src=\"" . checkimg($var[1]) . "\" alt=\"\" /></a>";return $img;'), $texte);
    			else $texte = preg_replace_callback('/\[img\](.*?)\[\/img\]/i', create_function('$var', '$img = "<img style=\"border: 0; overflow: auto; max-width: ' . $imgMaxWidth . 'px;  width: expression(this.scrollWidth >= ' . $imgMaxWidth . '? \'' . $imgMaxWidth . 'px\' : \'auto\');\" src=\"" . checkimg($var[1]) . "\" alt=\"\" />";return $img;'), $texte);
    		}
    		else
    		{
    			$texte = preg_replace_callback('/\[img\](.*?)\[\/img\]/i', create_function('$var', '$img = "<img style=\"border: 0;\" src=\"" . checkimg($var[1]) . "\" alt=\"\" />";return $img;'), $texte);
    		}
    		$texte = preg_replace_callback('/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/i', create_function('$var', '$img = "<a href=\"" . checkimg($var[3]) . "\" class=\"thickbox\" alt=\"\"><img style=\"border: 0;\" width=\"" . $var[1] . "\" height=\"" . $var[2] . "\" src=\"" . checkimg($var[3]) . "\" alt=\"\" /></a>";return $img;'), $texte);
    		$texte = preg_replace("/\[flash\](.*?)\[\/flash\]/i", "<object type=\"application/x-shockwave-flash\" data=\"\\1\"><param name=\"movie\" value=\"\\1\" /><param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" /></object>", $texte);
            $texte = preg_replace("/\[flash=(.*?)x(.*?)\](.*?)\[\/flash\]/i", "<object type=\"application/x-shockwave-flash\" data=\"\\3\" width=\"\\1\" height=\"\\2\"><param name=\"movie\" value=\"\\3\" /><param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" /></object>", $texte);
    		$texte = preg_replace("/\[url\]www.(.*?)\[\/url\]/i", "<a href=\"http://www.\\1\" onclick=\"window.open(this.href); return false;\">\\1</a>", $texte);
            $texte = preg_replace("/\[url\](.*?)\[\/url\]/i", "<a href=\"\\1\" onclick=\"window.open(this.href); return false;\">\\1</a>", $texte);
            $texte = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/i", "<a href=\"\\1\" onclick=\"window.open(this.href); return false;\">\\2</a>", $texte);
            $texte = preg_replace("#\[s\](http://)?(.*?)\[/s\]#si", "<img style=\"border: 0;\" src=\"images/icones/\\2\" alt=\"\" />", $texte);
    		$texte = preg_replace("/\[spoiler](.*?)\[\/spoiler\]/i", "<div class=\"container\"><table class=\"bor\" onclick=\"javascript:montrer_spoiler('spoiler" . $rand . "')\" style=\"cursor: pointer;\"><tbody><tr class=\"none\"><td><b class=\"s1Topic\">Spoiler :</b><br /><br /><div class=\"spoiler\" id=\"spoiler" . $rand . "\"><p>\\1</p></div></td></tr></tbody></table></div>", $texte);
    		$texte = preg_replace("/\[spoiler=(.*?)\](.*?)\[\/spoiler\]/i", "<div class=\"container\"><table class=\"bor\" onclick=\"javascript:montrer_spoiler('spoiler" . $rand2 . "')\" style=\"cursor: pointer;\"><tbody><tr class=\"none\"><td><b class=\"s1Topic\">\\1</b><br /><br /><div class=\"spoiler\" id=\"spoiler" . $rand2 . "\"><p>\\2</p></div></td></tr></tbody></table></div>", $texte);
    		$texte = preg_replace('#\[table( align=)((right|left|center))?( cellspacing=)([0-3])?( border=)([0-3])?](.*?)\[/table]#Usi', '<table class=\"tablecss\"\\1"\\2" \\4"\\5" \\6"\\7">\\8</table>', $texte);
    		$texte = preg_replace("#\[tr\](.*?)\[/tr\]#i", "<tr>\\1</tr>", $texte);
    		$texte = preg_replace("#\[td( colspan=[0-9])?( rowspan=[0-9])?\](.*?)\[/td\]#i", "<td class=\"tdcss\"\\1\\2>\\3</td>", $texte);
    		$texte = preg_replace("#\[th( colspan=[0-9])?( rowspan=[0-9])?\](.*?)\[/th\]#i", "<th class=\"thcss\" align=\"center\"\\1\\2>\\3</th>", $texte);
    		$texte = preg_replace_callback("#\[hide lvl=([0-9])\](.*?)\[/hide\]#i", "hide", $texte);
    		
    		// Ajout BBCode Note		
    ?>
    		<style type="text/css">
    			.noteclassique {background-color:#EEEEFF;}
    			.noteimportant {background-color:#FFFFCC;}
    			.noteattention {background-color:#FFDDDD;}
    			.notetuyau {background-color:#DDFFDD;}
    			.noteclassique, .noteimportant, .noteattention, .notetuyau {color: black; margin:2em;margin-left:auto;margin-right:auto;width:90% !important;min-height:40px;clear:both;text-align:justify;vertical-align:middle;border-collapse:collapse;padding:15px 20px 15px 80px;background-position:20px 50%;background-repeat:no-repeat;-moz-border-radius:20px;-khtml-border-radius:20px;border-radius:20px;}
           </style>   
    <?php
    		
    		$texte = preg_replace("/\[note=(.*?)\]/i", "<table align=\"center\"class=\"note$1\" cellpadding=\"3\" cellspacing=\"1\" border=\"0\"><tr><td style=\"padding-left: 15px;\"><img src=\"images/$1.png\" /></td><td style=\"padding-right: 20px;\">", $texte);
            $texte = str_replace("[/note]", "</td></tr></table>", $texte);
    	
    		$texte = ltrim($texte);
        } 
        return($texte);
    } 
    
    function ChangeBR($retour)
    {
    	$retour[1] = preg_replace("`\<br((\s*)\/?)\>`ims", '[[br]]', $retour[1]);
    
    	return $retour[1];
    }
    
    function nl2brCallback($retour)
    {
    	$retour[1] = preg_replace("`\<br((\s*)\/?)\>`ims", '', $retour[1]);
    	$retour[1] = preg_replace("`\[\[br\]\]+`ims", '<br />', $retour[1]);
    
    	return $retour[1];
    }
    
    function nl2brPre($texte)
    {
    	$texte = preg_replace_callback("`(\[(as|php|css)\]+(.*?)\[\/(as|php|css)\])`isSm", 'ChangeBR', $texte);
    	$texte = nl2br($texte);
    	$texte = preg_replace_callback("`(\[(as|php|css)\]+(.*?)\[\/(as|php|css)\])`isSm", 'nl2brCallback', $texte);
    	$texte = str_replace("[html]", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><div id=\"code\" style=\"border: 0;\"><pre class=\"brush: xhtml;\">", $texte);
        $texte = str_replace("[/html]", "</pre></div></td></tr></table>", $texte);
    	$texte = str_replace("[css]", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><div id=\"code\" style=\"border: 0;\"><pre class=\"brush: css;\">", $texte);
        $texte = str_replace("[/css]", "</pre></div></td></tr></table>", $texte);
    	$texte = str_replace("[php]", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><div id=\"code\" style=\"border: 0;\"><pre class=\"brush: php;\">", $texte);
        $texte = str_replace("[/php]", "</pre></div></td></tr></table>", $texte);
    	$texte = str_replace("[js]", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><div id=\"code\" style=\"border: 0;\"><pre class=\"brush: js;\">", $texte);
        $texte = str_replace("[/js]", "</pre></div></td></tr></table>", $texte);
    	$texte = str_replace("[sql]", "<br /><table style=\"background: " . $bgcolor3 . ";\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" border=\"0\"><tr><td style=\"background: #FFFFFF;color: #000000\"><div id=\"code\" style=\"border: 0;\"><pre class=\"brush: sql;\">", $texte);
        $texte = str_replace("[/sql]", "</pre></div></td></tr></table>", $texte);
    
        return $texte;
    }
    

    • Partager sur Facebook
    • Partager sur Twitter

    SyntaxHighlighte et nukedf klan

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown