示例#1
0
 protected function _htmlblock($codecid, $file = null, $firstline = 1)
 {
     $string = $this->codecblocks[$codecid . ':html'];
     //$string = htmlentities($string);
     // > Highlight Modul Funktion checken ob sie existerit.
     if (function_exists("highlight_html")) {
         $string = highlight_html($string, $this->info['BlockCodeFarbe']);
     }
     $string = str_replace("\t", '   ', $string);
     $string = str_replace('  ', '  ', $string);
     $string = str_replace('  ', '  ', $string);
     $string = nl2br($string);
     return $this->_addcodecontainer($string, 'HTML', $file, $firstline);
 }
示例#2
0
function save_code($textinfo)
{
    global $apx, $codecache, $replacement;
    static $count;
    ++$count;
    $hash = md5(microtime());
    $type = strtoupper($textinfo[1]);
    //$text=stripslashes(trim($textinfo[2]));
    $text = trim($textinfo[2], "\n\r\t\v");
    $linecount = substr_count($text, "\n") + 1;
    //PHP-Code
    if ($type == 'PHP') {
        $removetags = false;
        if (strtolower(substr($text, 0, 5)) != '<?php') {
            $text = "<?php " . $text . " ?>";
            $removetags = true;
        }
        $phpcode = highlight_string($text, true);
        //PHP-Tags wieder entfernen
        if ($removetags) {
            $phpcode = preg_replace('#<font color="\\#([0-9ABCDEF]{6})">' . "\n" . '<font color="\\#([0-9ABCDEF]{6})">&lt;\\?php#', '<font color="#\\1"><font color="#\\2">', $phpcode);
            $phpcode = str_replace('?&gt;</font>' . "\n" . '</font>', '</font></font>', $phpcode);
        }
        //PHP-Highlight fügt nur &nbsp; am Anfang der Zeile an
        //create_whitespace() ist daher nicht notwendig!
        $marker = '[PHP_' . $count . '_' . $hash . ']';
        $insert['{CODE}'] = $phpcode;
        $insert['{HEADLINE}'] = $apx->lang->get('PHPCODE');
    } elseif ($type == 'HTML') {
        $htmlcode = highlight_html($text);
        $htmlcode = create_whitespace($htmlcode);
        $marker = '[HEML_' . $count . '_' . $hash . ']';
        $insert['{CODE}'] = $htmlcode;
        $insert['{HEADLINE}'] = $apx->lang->get('HTMLCODE');
    } else {
        $normalcode = nl2br(compatible_hsc($text));
        $normalcode = create_whitespace($normalcode);
        $marker = '[CODE_' . $count . '_' . $hash . ']';
        //$insert['{CODE}']=nl2br(str_replace(' ','&nbsp;',str_replace("\t",'&nbsp;&nbsp;',compatible_hsc($text))));
        $insert['{CODE}'] = $normalcode;
        $insert['{HEADLINE}'] = $apx->lang->get('CODE');
    }
    //Zeilennummern generieren
    $lines = '1';
    for ($i = 2; $i <= $linecount; $i++) {
        $lines .= '<br />' . $i;
    }
    $insert['{LINES}'] = $lines;
    if (!$_REQUEST['print']) {
        $insert['{HEIGHT}'] = iif($linecount > 30, 'height:360px;');
    }
    $codecache[$marker] = strtr($replacement['code'], $insert);
    return $marker;
}