コード例 #1
0
ファイル: display.php プロジェクト: rickogden/web-pres2
 function _link(&$link)
 {
     if (empty($link->text)) {
         $link->text = $link->href;
     }
     if (!empty($link->leader)) {
         $leader = $link->leader;
     } else {
         $leader = '';
     }
     if (empty($link->target)) {
         $link->target = '_self';
     }
     if (!empty($link->text)) {
         echo "{$leader}<a href=\"{$link->href}\" target=\"{$link->target}\">" . markup_text($link->text) . "</a><br />\n";
     }
 }
コード例 #2
0
ファイル: objects.php プロジェクト: rickogden/web-pres2
 function highlight($slideDir)
 {
     static $temap = array('py' => 'python', 'pl' => 'perl', 'php' => 'php', 'inc' => 'php', 'html' => 'html', 'sql' => 'sql', 'java' => 'java', 'xml' => 'xml', 'js' => 'javascript', 'c' => 'c');
     if (!empty($this->filename)) {
         $_html_filename = preg_replace('/\\?.*$/', '', $slideDir . $this->filename);
         if ($this->type == 'php') {
             $p = pathinfo($this->filename);
             $this->type = @$temap[$p['extension']];
         }
         switch ($this->type) {
             case 'php':
             case 'genimage':
             case 'iframe':
             case 'link':
             case 'nlink':
             case 'embed':
             case 'flash':
             case 'system':
                 if ($this->linenumbers) {
                     ob_start();
                     highlight_file($_html_filename);
                     $contents = ob_get_contents();
                     ob_end_clean();
                     echo add_line_numbers($contents);
                 } else {
                     highlight_file($_html_filename);
                 }
                 break;
             case 'c':
                 $prog = trim(`which c2html`);
                 if (!empty($prog)) {
                     print `cat {$_html_filename} | {$prog} -cs`;
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             case 'perl':
                 $prog = trim(`which perl2html`);
                 if (!empty($prog)) {
                     print `cat {$_html_filename} | {$prog} -cs`;
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             case 'java':
                 $prog = trim(`which java2html`);
                 if (!empty($prog)) {
                     print `cat {$_html_filename} | java2html -cs`;
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             case 'python':
                 $prog = trim(`which code2html`);
                 if (!empty($prog)) {
                     print nl2br(trim(`{$prog} -lpython --no-header -ohtml {$_html_filename} | sed -e 's/\t/\\&nbsp\\;\\&nbsp;\\&nbsp\\; /g'`));
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             case 'javascript':
                 $prog = trim(`which code2html`);
                 if (!empty($prog)) {
                     print nl2br(trim(`{$prog} -ljavascript -ohtml-light --no-header {$_html_filename} | sed -e 's/  /\\&nbsp\\;\\&nbsp; /g'`));
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             case 'sql':
                 $prog = trim(`which code2html`);
                 if (!empty($prog)) {
                     print "<pre>";
                     print `{$prog} --no-header -lsql {$_html_filename}`;
                     print "</pre>";
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             case 'xml':
                 $prog = trim(`which code2html`);
                 if (!empty($prog)) {
                     print "<pre>";
                     print `{$prog} --no-header -lhtml {$_html_filename}`;
                     print "</pre>";
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             case 'html':
                 $_html_file = file_get_contents($_html_filename);
                 echo $_html_file . "\n";
                 break;
             case 'shell':
             default:
                 $this->_highlight_none($_html_filename);
                 break;
         }
     } else {
         switch ($this->type) {
             case 'marked':
                 echo "<pre>";
                 echo preg_replace('/^\\|(.*)$/m', '<font color="#802000">\\1</font>', htmlspecialchars($this->text));
                 echo "</pre>";
                 break;
             case 'php':
                 if ($this->linenumbers) {
                     $text = add_line_numbers($this->text);
                     highlight_string($text);
                 } else {
                     highlight_string($this->text);
                 }
                 break;
             case 'shell':
                 echo '<pre>' . markup_text(htmlspecialchars($this->text)) . "</pre>\n";
                 break;
             case 'html':
                 echo $this->text . "\n";
                 break;
             case 'perl':
                 $text = str_replace('"', '\\"', $this->text);
                 print `echo "{$text}" | perl2html -cs`;
                 break;
             case 'c':
                 $text = str_replace('"', '\'', $this->text);
                 $text = str_replace('\\n', '', $text);
                 print `echo "{$text}" | c2html -cs`;
                 break;
             case 'xml':
                 $prog = trim(`which code2html`);
                 if (!empty($prog)) {
                     $text = str_replace('"', '\\"', $this->text);
                     echo "<pre>\n";
                     print `echo "{$text}" | code2html -lhtml --no-header`;
                     echo "</pre>";
                 } else {
                     echo "<pre>" . htmlspecialchars($this->text) . "</pre>\n";
                 }
                 break;
             case 'javascript':
                 $prog = trim(`which code2html`);
                 if (!empty($prog)) {
                     $text = str_replace('"', '\\"', $this->text);
                     echo "<pre>\n";
                     print `echo "{$text}" | {$prog} -ljavascript -ohtml-light --no-header | sed -e 's/  /\\&nbsp\\;\\&nbsp; /g'`;
                     echo "</pre>";
                 } else {
                     $this->_highlight_none($_html_filename);
                 }
                 break;
             default:
                 echo "<pre>" . htmlspecialchars($this->text) . "</pre>\n";
                 break;
         }
     }
 }