cvs: pres2 / objects.php

From: Date: Sat, 02 Nov 2002 07:06:11 +0000
Subject: cvs: pres2 / objects.php
Groups: php.pres 
Request: Send a blank email to pres+get-476@lists.php.net to get a copy of this message
sterling Sat Nov 2 02:06:11 2002 EDT Modified files: /pres2 objects.php Log: add error checking for the formats that require special programs for highlighting, defaulting to plain text when the program is not present. Add a utility function that displays plain text, and is used in all the cases that require it. Index: pres2/objects.php diff -u pres2/objects.php:1.124 pres2/objects.php:1.125 --- pres2/objects.php:1.124 Fri Nov 1 16:12:19 2002 +++ pres2/objects.php Sat Nov 2 02:06:11 2002 @@ -857,6 +857,11 @@ $this->$mode(); } + function _highlight_none($fn) { + $data = file_get_contents($fn); + echo '<pre>' . htmlspecialchars($data) . "</pre>\n"; + } + // {{{ highlight() function highlight() { global $slideDir; @@ -873,30 +878,46 @@ case 'system': highlight_file($_html_filename); break; - case 'shell': - $_html_file = file_get_contents($_html_filename); - echo '<pre>'.htmlspecialchars($_html_file)."</pre>\n"; - break; case 'c': - print cat {$_html_filename} | c2html -cs; + $prog = trim(which c2html); + if (!empty($prog)) { + print cat {$_html_filename} | $prog -cs; + } else { + $this->_highlight_none($_html_filename); + } break; case 'perl': - print cat {$_html_filename} | perl2html -cs; + $prog = trim(which perl2html); + if (!empty($prog)) { + print cat {$_html_filename} | $prog -cs; + } else { + $this->_highlight_none($_html_filename); + } break; case 'java': - print cat {$_html_filename} | java2html -cs; + $prog = trim(which java2html); + if (!empty($prog)) { + print cat {$_html_filename} | java2html -cs; + } else { + $this->_highlight_none($_html_filename); + } break; case 'python': - print py2html -stdout -format:rawhtml $_html_filename; + $prog = trim(which py2html); + if (!empty($prog)) { + print $prog -stdout -format:rawhtml $_html_filename; + } else { + $this->_highlight_none($_html_filename); + } break; case 'html': $_html_file = file_get_contents($_html_filename); echo $_html_file."\n"; break; - + + case 'shell': default: - $_html_file = file_get_contents($_html_filename); - echo "<pre>".htmlspecialchars($_html_file)."</pre>\n"; + $this->_highlight_none($_html_filename); break; } } else {

« previous php.pres (#476) next »