diff options
author | andi <andi@splitbrain.org> | 2005-01-12 21:24:54 +0100 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-01-12 21:24:54 +0100 |
commit | f3f0262c480d7e509b008d37c90aed884532bba8 (patch) | |
tree | 40b7e7dbf9f52a6b48af7b2f4090ab4cd2fd3f1e /inc | |
download | rpg-f3f0262c480d7e509b008d37c90aed884532bba8.tar.gz rpg-f3f0262c480d7e509b008d37c90aed884532bba8.tar.bz2 |
Initial revision.
darcs-hash:20050112202454-9977f-60936f24fe2092a30223627e0683de2df61d0c4a.gz
Diffstat (limited to 'inc')
53 files changed, 18570 insertions, 0 deletions
diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php new file mode 100644 index 000000000..a4af4b193 --- /dev/null +++ b/inc/DifferenceEngine.php @@ -0,0 +1,1057 @@ +<?php + +// A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3) +// +// Copyright (C) 2000, 2001 Geoffrey T. Dairiki <dairiki@dairiki.org> +// You may copy this code freely under the conditions of the GPL. +// + +define('USE_ASSERTS', function_exists('assert')); + +class _DiffOp { + var $type; + var $orig; + var $closing; + + function reverse() { + trigger_error("pure virtual", E_USER_ERROR); + } + + function norig() { + return $this->orig ? sizeof($this->orig) : 0; + } + + function nclosing() { + return $this->closing ? sizeof($this->closing) : 0; + } +} + +class _DiffOp_Copy extends _DiffOp { + var $type = 'copy'; + + function _DiffOp_Copy ($orig, $closing = false) { + if (!is_array($closing)) + $closing = $orig; + $this->orig = $orig; + $this->closing = $closing; + } + + function reverse() { + return new _DiffOp_Copy($this->closing, $this->orig); + } +} + +class _DiffOp_Delete extends _DiffOp { + var $type = 'delete'; + + function _DiffOp_Delete ($lines) { + $this->orig = $lines; + $this->closing = false; + } + + function reverse() { + return new _DiffOp_Add($this->orig); + } +} + +class _DiffOp_Add extends _DiffOp { + var $type = 'add'; + + function _DiffOp_Add ($lines) { + $this->closing = $lines; + $this->orig = false; + } + + function reverse() { + return new _DiffOp_Delete($this->closing); + } +} + +class _DiffOp_Change extends _DiffOp { + var $type = 'change'; + + function _DiffOp_Change ($orig, $closing) { + $this->orig = $orig; + $this->closing = $closing; + } + + function reverse() { + return new _DiffOp_Change($this->closing, $this->orig); + } +} + + +/** + * Class used internally by Diff to actually compute the diffs. + * + * The algorithm used here is mostly lifted from the perl module + * Algorithm::Diff (version 1.06) by Ned Konz, which is available at: + * http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip + * + * More ideas are taken from: + * http://www.ics.uci.edu/~eppstein/161/960229.html + * + * Some ideas are (and a bit of code) are from from analyze.c, from GNU + * diffutils-2.7, which can be found at: + * ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz + * + * closingly, some ideas (subdivision by NCHUNKS > 2, and some optimizations) + * are my own. + * + * @author Geoffrey T. Dairiki + * @access private + */ +class _DiffEngine +{ + function diff ($from_lines, $to_lines) { + $n_from = sizeof($from_lines); + $n_to = sizeof($to_lines); + + $this->xchanged = $this->ychanged = array(); + $this->xv = $this->yv = array(); + $this->xind = $this->yind = array(); + unset($this->seq); + unset($this->in_seq); + unset($this->lcs); + + // Skip leading common lines. + for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) { + if ($from_lines[$skip] != $to_lines[$skip]) + break; + $this->xchanged[$skip] = $this->ychanged[$skip] = false; + } + // Skip trailing common lines. + $xi = $n_from; $yi = $n_to; + for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) { + if ($from_lines[$xi] != $to_lines[$yi]) + break; + $this->xchanged[$xi] = $this->ychanged[$yi] = false; + } + + // Ignore lines which do not exist in both files. + for ($xi = $skip; $xi < $n_from - $endskip; $xi++) + $xhash[$from_lines[$xi]] = 1; + for ($yi = $skip; $yi < $n_to - $endskip; $yi++) { + $line = $to_lines[$yi]; + if ( ($this->ychanged[$yi] = empty($xhash[$line])) ) + continue; + $yhash[$line] = 1; + $this->yv[] = $line; + $this->yind[] = $yi; + } + for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { + $line = $from_lines[$xi]; + if ( ($this->xchanged[$xi] = empty($yhash[$line])) ) + continue; + $this->xv[] = $line; + $this->xind[] = $xi; + } + + // Find the LCS. + $this->_compareseq(0, sizeof($this->xv), 0, sizeof($this->yv)); + + // Merge edits when possible + $this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged); + $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); + + // Compute the edit operations. + $edits = array(); + $xi = $yi = 0; + while ($xi < $n_from || $yi < $n_to) { + USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]); + USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]); + + // Skip matching "snake". + $copy = array(); + while ( $xi < $n_from && $yi < $n_to + && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { + $copy[] = $from_lines[$xi++]; + ++$yi; + } + if ($copy) + $edits[] = new _DiffOp_Copy($copy); + + // Find deletes & adds. + $delete = array(); + while ($xi < $n_from && $this->xchanged[$xi]) + $delete[] = $from_lines[$xi++]; + + $add = array(); + while ($yi < $n_to && $this->ychanged[$yi]) + $add[] = $to_lines[$yi++]; + + if ($delete && $add) + $edits[] = new _DiffOp_Change($delete, $add); + elseif ($delete) + $edits[] = new _DiffOp_Delete($delete); + elseif ($add) + $edits[] = new _DiffOp_Add($add); + } + return $edits; + } + + + /* Divide the Largest Common Subsequence (LCS) of the sequences + * [XOFF, XLIM) and [YOFF, YLIM) into NCHUNKS approximately equally + * sized segments. + * + * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an + * array of NCHUNKS+1 (X, Y) indexes giving the diving points between + * sub sequences. The first sub-sequence is contained in [X0, X1), + * [Y0, Y1), the second in [X1, X2), [Y1, Y2) and so on. Note + * that (X0, Y0) == (XOFF, YOFF) and + * (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). + * + * This function assumes that the first lines of the specified portions + * of the two files do not match, and likewise that the last lines do not + * match. The caller must trim matching lines from the beginning and end + * of the portions it is going to specify. + */ + function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) { + $flip = false; + + if ($xlim - $xoff > $ylim - $yoff) { + // Things seems faster (I'm not sure I understand why) + // when the shortest sequence in X. + $flip = true; + list ($xoff, $xlim, $yoff, $ylim) + = array( $yoff, $ylim, $xoff, $xlim); + } + + if ($flip) + for ($i = $ylim - 1; $i >= $yoff; $i--) + $ymatches[$this->xv[$i]][] = $i; + else + for ($i = $ylim - 1; $i >= $yoff; $i--) + $ymatches[$this->yv[$i]][] = $i; + + $this->lcs = 0; + $this->seq[0]= $yoff - 1; + $this->in_seq = array(); + $ymids[0] = array(); + + $numer = $xlim - $xoff + $nchunks - 1; + $x = $xoff; + for ($chunk = 0; $chunk < $nchunks; $chunk++) { + if ($chunk > 0) + for ($i = 0; $i <= $this->lcs; $i++) + $ymids[$i][$chunk-1] = $this->seq[$i]; + + $x1 = $xoff + (int)(($numer + ($xlim-$xoff)*$chunk) / $nchunks); + for ( ; $x < $x1; $x++) { + $line = $flip ? $this->yv[$x] : $this->xv[$x]; + if (empty($ymatches[$line])) + continue; + $matches = $ymatches[$line]; + reset($matches); + while (list ($junk, $y) = each($matches)) + if (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k-1]; + break; + } + while (list ($junk, $y) = each($matches)) { + if ($y > $this->seq[$k-1]) { + USE_ASSERTS && assert($y < $this->seq[$k]); + // Optimization: this is a common case: + // next match is just replacing previous match. + $this->in_seq[$this->seq[$k]] = false; + $this->seq[$k] = $y; + $this->in_seq[$y] = 1; + } + else if (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k-1]; + } + } + } + } + + $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); + $ymid = $ymids[$this->lcs]; + for ($n = 0; $n < $nchunks - 1; $n++) { + $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); + $y1 = $ymid[$n] + 1; + $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); + } + $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); + + return array($this->lcs, $seps); + } + + function _lcs_pos ($ypos) { + $end = $this->lcs; + if ($end == 0 || $ypos > $this->seq[$end]) { + $this->seq[++$this->lcs] = $ypos; + $this->in_seq[$ypos] = 1; + return $this->lcs; + } + + $beg = 1; + while ($beg < $end) { + $mid = (int)(($beg + $end) / 2); + if ( $ypos > $this->seq[$mid] ) + $beg = $mid + 1; + else + $end = $mid; + } + + USE_ASSERTS && assert($ypos != $this->seq[$end]); + + $this->in_seq[$this->seq[$end]] = false; + $this->seq[$end] = $ypos; + $this->in_seq[$ypos] = 1; + return $end; + } + + /* Find LCS of two sequences. + * + * The results are recorded in the vectors $this->{x,y}changed[], by + * storing a 1 in the element for each line that is an insertion + * or deletion (ie. is not in the LCS). + * + * The subsequence of file 0 is [XOFF, XLIM) and likewise for file 1. + * + * Note that XLIM, YLIM are exclusive bounds. + * All line numbers are origin-0 and discarded lines are not counted. + */ + function _compareseq ($xoff, $xlim, $yoff, $ylim) { + // Slide down the bottom initial diagonal. + while ($xoff < $xlim && $yoff < $ylim + && $this->xv[$xoff] == $this->yv[$yoff]) { + ++$xoff; + ++$yoff; + } + + // Slide up the top initial diagonal. + while ($xlim > $xoff && $ylim > $yoff + && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { + --$xlim; + --$ylim; + } + + if ($xoff == $xlim || $yoff == $ylim) + $lcs = 0; + else { + // This is ad hoc but seems to work well. + //$nchunks = sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); + //$nchunks = max(2,min(8,(int)$nchunks)); + $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1; + list ($lcs, $seps) + = $this->_diag($xoff,$xlim,$yoff, $ylim,$nchunks); + } + + if ($lcs == 0) { + // X and Y sequences have no common subsequence: + // mark all changed. + while ($yoff < $ylim) + $this->ychanged[$this->yind[$yoff++]] = 1; + while ($xoff < $xlim) + $this->xchanged[$this->xind[$xoff++]] = 1; + } + else { + // Use the partitions to split this problem into subproblems. + reset($seps); + $pt1 = $seps[0]; + while ($pt2 = next($seps)) { + $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]); + $pt1 = $pt2; + } + } + } + + /* Adjust inserts/deletes of identical lines to join changes + * as much as possible. + * + * We do something when a run of changed lines include a + * line at one end and has an excluded, identical line at the other. + * We are free to choose which identical line is included. + * `compareseq' usually chooses the one at the beginning, + * but usually it is cleaner to consider the following identical line + * to be the "change". + * + * This is extracted verbatim from analyze.c (GNU diffutils-2.7). + */ + function _shift_boundaries ($lines, &$changed, $other_changed) { + $i = 0; + $j = 0; + + USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); + $len = sizeof($lines); + $other_len = sizeof($other_changed); + + while (1) { + /* + * Scan forwards to find beginning of another run of changes. + * Also keep track of the corresponding point in the other file. + * + * Throughout this code, $i and $j are adjusted together so that + * the first $i elements of $changed and the first $j elements + * of $other_changed both contain the same number of zeros + * (unchanged lines). + * Furthermore, $j is always kept so that $j == $other_len or + * $other_changed[$j] == false. + */ + while ($j < $other_len && $other_changed[$j]) + $j++; + + while ($i < $len && ! $changed[$i]) { + USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $i++; $j++; + while ($j < $other_len && $other_changed[$j]) + $j++; + } + + if ($i == $len) + break; + + $start = $i; + + // Find the end of this run of changes. + while (++$i < $len && $changed[$i]) + continue; + + do { + /* + * Record the length of this run of changes, so that + * we can later determine whether the run has grown. + */ + $runlength = $i - $start; + + /* + * Move the changed region back, so long as the + * previous unchanged line matches the last changed one. + * This merges with previous changed regions. + */ + while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) { + $changed[--$start] = 1; + $changed[--$i] = false; + while ($start > 0 && $changed[$start - 1]) + $start--; + USE_ASSERTS && assert('$j > 0'); + while ($other_changed[--$j]) + continue; + USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + } + + /* + * Set CORRESPONDING to the end of the changed run, at the last + * point where it corresponds to a changed run in the other file. + * CORRESPONDING == LEN means no such point has been found. + */ + $corresponding = $j < $other_len ? $i : $len; + + /* + * Move the changed region forward, so long as the + * first changed line matches the following unchanged one. + * This merges with following changed regions. + * Do this second, so that if there are no merges, + * the changed region is moved forward as far as possible. + */ + while ($i < $len && $lines[$start] == $lines[$i]) { + $changed[$start++] = false; + $changed[$i++] = 1; + while ($i < $len && $changed[$i]) + $i++; + + USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $j++; + if ($j < $other_len && $other_changed[$j]) { + $corresponding = $i; + while ($j < $other_len && $other_changed[$j]) + $j++; + } + } + } while ($runlength != $i - $start); + + /* + * If possible, move the fully-merged run of changes + * back to a corresponding run in the other file. + */ + while ($corresponding < $i) { + $changed[--$start] = 1; + $changed[--$i] = 0; + USE_ASSERTS && assert('$j > 0'); + while ($other_changed[--$j]) + continue; + USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + } + } + } +} + +/** + * Class representing a 'diff' between two sequences of strings. + */ +class Diff +{ + var $edits; + + /** + * Constructor. + * Computes diff between sequences of strings. + * + * @param $from_lines array An array of strings. + * (Typically these are lines from a file.) + * @param $to_lines array An array of strings. + */ + function Diff($from_lines, $to_lines) { + $eng = new _DiffEngine; + $this->edits = $eng->diff($from_lines, $to_lines); + //$this->_check($from_lines, $to_lines); + } + + /** + * Compute reversed Diff. + * + * SYNOPSIS: + * + * $diff = new Diff($lines1, $lines2); + * $rev = $diff->reverse(); + * @return object A Diff object representing the inverse of the + * original diff. + */ + function reverse () { + $rev = $this; + $rev->edits = array(); + foreach ($this->edits as $edit) { + $rev->edits[] = $edit->reverse(); + } + return $rev; + } + + /** + * Check for empty diff. + * + * @return bool True iff two sequences were identical. + */ + function isEmpty () { + foreach ($this->edits as $edit) { + if ($edit->type != 'copy') + return false; + } + return true; + } + + /** + * Compute the length of the Longest Common Subsequence (LCS). + * + * This is mostly for diagnostic purposed. + * + * @return int The length of the LCS. + */ + function lcs () { + $lcs = 0; + foreach ($this->edits as $edit) { + if ($edit->type == 'copy') + $lcs += sizeof($edit->orig); + } + return $lcs; + } + + /** + * Get the original set of lines. + * + * This reconstructs the $from_lines parameter passed to the + * constructor. + * + * @return array The original sequence of strings. + */ + function orig() { + $lines = array(); + + foreach ($this->edits as $edit) { + if ($edit->orig) + array_splice($lines, sizeof($lines), 0, $edit->orig); + } + return $lines; + } + + /** + * Get the closing set of lines. + * + * This reconstructs the $to_lines parameter passed to the + * constructor. + * + * @return array The sequence of strings. + */ + function closing() { + $lines = array(); + + foreach ($this->edits as $edit) { + if ($edit->closing) + array_splice($lines, sizeof($lines), 0, $edit->closing); + } + return $lines; + } + + /** + * Check a Diff for validity. + * + * This is here only for debugging purposes. + */ + function _check ($from_lines, $to_lines) { + if (serialize($from_lines) != serialize($this->orig())) + trigger_error("Reconstructed original doesn't match", E_USER_ERROR); + if (serialize($to_lines) != serialize($this->closing())) + trigger_error("Reconstructed closing doesn't match", E_USER_ERROR); + + $rev = $this->reverse(); + if (serialize($to_lines) != serialize($rev->orig())) + trigger_error("Reversed original doesn't match", E_USER_ERROR); + if (serialize($from_lines) != serialize($rev->closing())) + trigger_error("Reversed closing doesn't match", E_USER_ERROR); + + + $prevtype = 'none'; + foreach ($this->edits as $edit) { + if ( $prevtype == $edit->type ) + trigger_error("Edit sequence is non-optimal", E_USER_ERROR); + $prevtype = $edit->type; + } + + $lcs = $this->lcs(); + trigger_error("Diff okay: LCS = $lcs", E_USER_NOTICE); + } +} + +/** + * FIXME: bad name. + */ +class MappedDiff +extends Diff +{ + /** + * Constructor. + * + * Computes diff between sequences of strings. + * + * This can be used to compute things like + * case-insensitve diffs, or diffs which ignore + * changes in white-space. + * + * @param $from_lines array An array of strings. + * (Typically these are lines from a file.) + * + * @param $to_lines array An array of strings. + * + * @param $mapped_from_lines array This array should + * have the same size number of elements as $from_lines. + * The elements in $mapped_from_lines and + * $mapped_to_lines are what is actually compared + * when computing the diff. + * + * @param $mapped_to_lines array This array should + * have the same number of elements as $to_lines. + */ + function MappedDiff($from_lines, $to_lines, + $mapped_from_lines, $mapped_to_lines) { + + assert(sizeof($from_lines) == sizeof($mapped_from_lines)); + assert(sizeof($to_lines) == sizeof($mapped_to_lines)); + + $this->Diff($mapped_from_lines, $mapped_to_lines); + + $xi = $yi = 0; + for ($i = 0; $i < sizeof($this->edits); $i++) { + $orig = &$this->edits[$i]->orig; + if (is_array($orig)) { + $orig = array_slice($from_lines, $xi, sizeof($orig)); + $xi += sizeof($orig); + } + + $closing = &$this->edits[$i]->closing; + if (is_array($closing)) { + $closing = array_slice($to_lines, $yi, sizeof($closing)); + $yi += sizeof($closing); + } + } + } +} + +/** + * A class to format Diffs + * + * This class formats the diff in classic diff format. + * It is intended that this class be customized via inheritance, + * to obtain fancier outputs. + */ +class DiffFormatter +{ + /** + * Number of leading context "lines" to preserve. + * + * This should be left at zero for this class, but subclasses + * may want to set this to other values. + */ + var $leading_context_lines = 0; + + /** + * Number of trailing context "lines" to preserve. + * + * This should be left at zero for this class, but subclasses + * may want to set this to other values. + */ + var $trailing_context_lines = 0; + + /** + * Format a diff. + * + * @param $diff object A Diff object. + * @return string The formatted output. + */ + function format($diff) { + + $xi = $yi = 1; + $block = false; + $context = array(); + + $nlead = $this->leading_context_lines; + $ntrail = $this->trailing_context_lines; + + $this->_start_diff(); + + foreach ($diff->edits as $edit) { + if ($edit->type == 'copy') { + if (is_array($block)) { + if (sizeof($edit->orig) <= $nlead + $ntrail) { + $block[] = $edit; + } + else{ + if ($ntrail) { + $context = array_slice($edit->orig, 0, $ntrail); + $block[] = new _DiffOp_Copy($context); + } + $this->_block($x0, $ntrail + $xi - $x0, + $y0, $ntrail + $yi - $y0, + $block); + $block = false; + } + } + $context = $edit->orig; + } + else { + if (! is_array($block)) { + $context = array_slice($context, sizeof($context) - $nlead); + $x0 = $xi - sizeof($context); + $y0 = $yi - sizeof($context); + $block = array(); + if ($context) + $block[] = new _DiffOp_Copy($context); + } + $block[] = $edit; + } + + if ($edit->orig) + $xi += sizeof($edit->orig); + if ($edit->closing) + $yi += sizeof($edit->closing); + } + + if (is_array($block)) + $this->_block($x0, $xi - $x0, + $y0, $yi - $y0, + $block); + + return $this->_end_diff(); + } + + function _block($xbeg, $xlen, $ybeg, $ylen, &$edits) { + $this->_start_block($this->_block_header($xbeg, $xlen, $ybeg, $ylen)); + foreach ($edits as $edit) { + if ($edit->type == 'copy') + $this->_context($edit->orig); + elseif ($edit->type == 'add') + $this->_added($edit->closing); + elseif ($edit->type == 'delete') + $this->_deleted($edit->orig); + elseif ($edit->type == 'change') + $this->_changed($edit->orig, $edit->closing); + else + trigger_error("Unknown edit type", E_USER_ERROR); + } + $this->_end_block(); + } + + function _start_diff() { + ob_start(); + } + + function _end_diff() { + $val = ob_get_contents(); + ob_end_clean(); + return $val; + } + + function _block_header($xbeg, $xlen, $ybeg, $ylen) { + if ($xlen > 1) + $xbeg .= "," . ($xbeg + $xlen - 1); + if ($ylen > 1) + $ybeg .= "," . ($ybeg + $ylen - 1); + + return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg; + } + + function _start_block($header) { + echo $header; + } + + function _end_block() { + } + + function _lines($lines, $prefix = ' ') { + foreach ($lines as $line) + echo "$prefix $line\n"; + } + + function _context($lines) { + $this->_lines($lines); + } + + function _added($lines) { + $this->_lines($lines, ">"); + } + function _deleted($lines) { + $this->_lines($lines, "<"); + } + + function _changed($orig, $closing) { + $this->_deleted($orig); + echo "---\n"; + $this->_added($closing); + } +} + + +/** + * Additions by Axel Boldt follow, partly taken from diff.php, phpwiki-1.3.3 + * + */ + +define('NBSP', "\xA0"); // iso-8859-x non-breaking space. + +class _HWLDF_WordAccumulator { + function _HWLDF_WordAccumulator () { + $this->_lines = array(); + $this->_line = ''; + $this->_group = ''; + $this->_tag = ''; + } + + function _flushGroup ($new_tag) { + if ($this->_group !== '') { + if ($this->_tag == 'mark') + $this->_line .= '<span class="diffchange">'.$this->_group.'</span>'; + else + $this->_line .= $this->_group; + } + $this->_group = ''; + $this->_tag = $new_tag; + } + + function _flushLine ($new_tag) { + $this->_flushGroup($new_tag); + if ($this->_line != '') + $this->_lines[] = $this->_line; + $this->_line = ''; + } + + function addWords ($words, $tag = '') { + if ($tag != $this->_tag) + $this->_flushGroup($tag); + + foreach ($words as $word) { + // new-line should only come as first char of word. + if ($word == '') + continue; + if ($word[0] == "\n") { + $this->_group .= NBSP; + $this->_flushLine($tag); + $word = substr($word, 1); + } + assert(!strstr($word, "\n")); + $this->_group .= $word; + } + } + + function getLines() { + $this->_flushLine('~done'); + return $this->_lines; + } +} + +class WordLevelDiff extends MappedDiff +{ + function WordLevelDiff ($orig_lines, $closing_lines) { + list ($orig_words, $orig_stripped) = $this->_split($orig_lines); + list ($closing_words, $closing_stripped) = $this->_split($closing_lines); + + + $this->MappedDiff($orig_words, $closing_words, + $orig_stripped, $closing_stripped); + } + + function _split($lines) { + // FIXME: fix POSIX char class. +# if (!preg_match_all('/ ( [^\S\n]+ | [[:alnum:]]+ | . ) (?: (?!< \n) [^\S\n])? /xs', + if (!preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs', + implode("\n", $lines), + $m)) { + return array(array(''), array('')); + } + return array($m[0], $m[1]); + } + + function orig () { + $orig = new _HWLDF_WordAccumulator; + + foreach ($this->edits as $edit) { + if ($edit->type == 'copy') + $orig->addWords($edit->orig); + elseif ($edit->orig) + $orig->addWords($edit->orig, 'mark'); + } + return $orig->getLines(); + } + + function closing () { + $closing = new _HWLDF_WordAccumulator; + + foreach ($this->edits as $edit) { + if ($edit->type == 'copy') + $closing->addWords($edit->closing); + elseif ($edit->closing) + $closing->addWords($edit->closing, 'mark'); + } + return $closing->getLines(); + } +} + +/** + * "Unified" diff formatter. + * + * This class formats the diff in classic "unified diff" format. + */ +class UnifiedDiffFormatter extends DiffFormatter +{ + function UnifiedDiffFormatter($context_lines = 4) { + $this->leading_context_lines = $context_lines; + $this->trailing_context_lines = $context_lines; + } + + function _block_header($xbeg, $xlen, $ybeg, $ylen) { + if ($xlen != 1) + $xbeg .= "," . $xlen; + if ($ylen != 1) + $ybeg .= "," . $ylen; + return "@@ -$xbeg +$ybeg @@\n"; + } + + function _added($lines) { + $this->_lines($lines, "+"); + } + function _deleted($lines) { + $this->_lines($lines, "-"); + } + function _changed($orig, $final) { + $this->_deleted($orig); + $this->_added($final); + } +} + +/** + * Wikipedia Table style diff formatter. + * + */ +class TableDiffFormatter extends DiffFormatter +{ + function TableDiffFormatter() { + $this->leading_context_lines = 2; + $this->trailing_context_lines = 2; + } + + function _pre($text){ + $text = htmlspecialchars($text); + $text = str_replace(' ',' ',$text); + return $text; + } + + function _block_header( $xbeg, $xlen, $ybeg, $ylen ) { + global $lang; + $l1 = $lang['line'].' '.$xbeg; + $l2 = $lang['line'].' '.$ybeg; + $r = '<tr><td class="diff-blockheader" colspan="2">'.$l1.":</td>\n" . + '<td class="diff-blockheader" colspan="2">'.$l2.":</td></tr>\n"; + return $r; + } + + function _start_block( $header ) { + print( $header ); + } + + function _end_block() { + } + + function _lines( $lines, $prefix=' ', $color="white" ) { + } + + function addedLine( $line ) { + $line = str_replace(' ',' ',$line); + return '<td>+</td><td class="diff-addedline">' . + $line.'</td>'; + } + + function deletedLine( $line ) { + $line = str_replace(' ',' ',$line); + return '<td>-</td><td class="diff-deletedline">' . + $line.'</td>'; + } + + function emptyLine() { + $line = str_replace(' ',' ',$line); + return '<td colspan="2"> </td>'; + } + + function contextLine( $line ) { + $line = str_replace(' ',' ',$line); + return '<td> </td><td class="diff-context">'.$line.'</td>'; + } + + function _added($lines) { + foreach ($lines as $line) { + print( '<tr>' . $this->emptyLine() . + $this->addedLine( $line ) . "</tr>\n" ); + } + } + + function _deleted($lines) { + foreach ($lines as $line) { + print( '<tr>' . $this->deletedLine( $line ) . + $this->emptyLine() . "</tr>\n" ); + } + } + + function _context( $lines ) { + foreach ($lines as $line) { + print( '<tr>' . $this->contextLine( $line ) . + $this->contextLine( $line ) . "</tr>\n" ); + } + } + + function _changed( $orig, $closing ) { + $diff = new WordLevelDiff( $orig, $closing ); + $del = $diff->orig(); + $add = $diff->closing(); + + while ( $line = array_shift( $del ) ) { + $aline = array_shift( $add ); + print( '<tr>' . $this->deletedLine( $line ) . + $this->addedLine( $aline ) . "</tr>\n" ); + } + $this->_added( $add ); # If any leftovers + } +} + +?> diff --git a/inc/auth.php b/inc/auth.php new file mode 100644 index 000000000..825ecb9d2 --- /dev/null +++ b/inc/auth.php @@ -0,0 +1,290 @@ +<? +require_once("inc/common.php"); +require_once("inc/io.php"); +# load the the auth functions +require_once('inc/auth_'.$conf['authtype'].'.php'); + +# some ACL level defines +define('AUTH_NONE',0); +define('AUTH_READ',1); +define('AUTH_EDIT',2); +define('AUTH_CREATE',4); +define('AUTH_UPLOAD',8); +define('AUTH_GRANT',255); + +if($conf['useacl']){ + auth_login($_REQUEST['u'],$_REQUEST['p']); + # load ACL into a global array + $AUTH_ACL = file('conf/acl.auth'); +} + +/** + * This tries to login the user based on the sent auth credentials + * + * The authentication works like this: if a username was given + * a new login is assumed and user/password are checked - if they + * are correct a random authtoken is created which is stored in + * the session _and_ in a cookie. + * The user stays logged in as long as the session and the cookie + * match. This still isn't the securest method but requires an + * attacker to steal an existing session _and_ the authtoken + * cookie. The actual password is only transfered once per login. + * + * On a successful login $_SERVER[REMOTE_USER] and $USERINFO + * are set. +*/ +function auth_login($user,$pass){ + global $USERINFO; + global $conf; + global $lang; + $cookie = $_COOKIE['AUTHTOKEN']; + $session = $_SESSION[$conf['title']]['authtoken']; + + if(isset($user)){ + if (auth_checkPass($user,$pass)){ + //make username available as REMOTE_USER + $_SERVER['REMOTE_USER'] = $user; + //set global user info + $USERINFO = auth_getUserData($user); + //set authtoken + $token = md5(uniqid(rand(), true)); + $_SESSION[$conf['title']]['user'] = $user; + $_SESSION[$conf['title']]['authtoken'] = $token; + setcookie('AUTHTOKEN', $token); + }else{ + //invalid credentials - log off + msg($lang['badlogin'],-1); + auth_logoff(); + } + }elseif(isset($cookie) && isset($session)){ + if($cookie == $session){ + //make username available as REMOTE_USER + $_SERVER['REMOTE_USER'] = $_SESSION[$conf['title']]['user']; + //set global user info + $USERINFO = auth_getUserData($_SERVER['REMOTE_USER']); + }else{ + //bad token + auth_logoff(); + } + }else{ + //just to be sure + auth_logoff(); + } +} + +/** + * This clears all authenticationdata and thus log the user + * off + */ +function auth_logoff(){ + global $conf; + global $USERINFO; + unset($_SESSION[$conf['title']]['authtoken']); + unset($_SESSION[$conf['title']]['user']); + unset($_SERVER['REMOTE_USER']); + $USERINFO=null; +} + +/** + * Convinience function for auth_aclcheck + */ +function auth_quickaclcheck($id){ + global $conf; + global $USERINFO; + # if no ACL is used always return upload rights + if(!$conf['useacl']) return AUTH_UPLOAD; + return auth_aclcheck($id,$_SERVER['REMOTE_USER'],$USERINFO['grps']); +} + +/** + * Returns the maximum rights a user has for + * the given ID or its namespace + */ +function auth_aclcheck($id,$user,$groups){ + global $conf; + global $AUTH_ACL; + + # if no ACL is used always return upload rights + if(!$conf['useacl']) return AUTH_UPLOAD; + + $ns = getNS($id); + $perm = -1; + + if($user){ + //prepend groups with @ + for($i=0; $i<count($groups); $i++){ + $groups[$i] = '@'.$groups[$i]; + } + //add ALL group + $groups[] = '@ALL'; + //add User + $groups[] = $user; + //build regexp + $regexp = join('|',$groups); + }else{ + $regexp = '@ALL'; + } + + //check exact match first + $matches = preg_grep('/^'.$id.'\s+('.$regexp.')\s+/',$AUTH_ACL); + if(count($matches)){ + foreach($matches as $match){ + $match = preg_replace('/#.*$/','',$match); //ignore comments + $acl = preg_split('/\s+/',$match); + if($acl[2] > $perm){ + $perm = $acl[2]; + } + } + if($perm > -1){ + //we had a match - return it + return $perm; + } + } + + //still here? do the namespace checks + if($ns){ + $path = $ns.':\*'; + }else{ + $path = '\*'; //root document + } + + do{ + $matches = preg_grep('/^'.$path.'\s+('.$regexp.')\s+/',$AUTH_ACL); + if(count($matches)){ + foreach($matches as $match){ + $match = preg_replace('/#.*$/','',$match); //ignore comments + $acl = preg_split('/\s+/',$match); + if($acl[2] > $perm){ + $perm = $acl[2]; + } + } + //we had a match - return it + return $perm; + } + + //get next higher namespace + $ns = getNS($ns); + + if($path != '\*'){ + $path = $ns.':\*'; + if($path == ':\*') $path = '\*'; + }else{ + //we did this already + //looks like there is something wrong with the ACL + //break here + return $perm; + } + }while(1); //this should never loop endless +} + +/** + * Create a pronouncable password + * + * @see: http://www.phpbuilder.com/annotate/message.php3?id=1014451 + */ +function auth_pwgen(){ + $pw = ''; + $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones + $v = 'aeiou'; //vowels + $a = $c.$v; //both + + //use two syllables... + for($i=0;$i < 2; $i++){ + $pw .= $c[rand(0, strlen($c)-1)]; + $pw .= $v[rand(0, strlen($v)-1)]; + $pw .= $a[rand(0, strlen($a)-1)]; + } + //... and add a nice number + $pw .= rand(10,99); + + return $pw; +} + +/** + * Sends a password to the given user + * + * returns true on success + */ +function auth_sendPassword($user,$password){ + global $conf; + global $lang; + $users = auth_loadUserData(); + $hdrs = ''; + + if(!$users[$user]['mail']) return false; + + $text = rawLocale('password'); + $text = str_replace('@DOKUWIKIURL@',getBaseURL(true),$text); + $text = str_replace('@FULLNAME@',$users[$user]['name'],$text); + $text = str_replace('@LOGIN@',$user,$text); + $text = str_replace('@PASSWORD@',$password,$text); + $text = str_replace('@TITLE@',$conf['title'],$text); + + if (!empty($conf['mailfrom'])) { + $hdrs = 'From: '.$conf['mailfrom']."\n"; + } + return @mail($users[$user]['mail'],$lang['regpwmail'],$text,$hdrs); +} + +/** + * The new user registration - we get our info directly from + * $_POST + * + * It returns true on success and false on any error + */ +function register(){ + global $lang; + global $conf; + + if(!$_POST['save']) return false; + if(!$conf['openregister']) return false; + + //clean username + $_POST['login'] = preg_replace('/.*:/','',$_POST['login']); + $_POST['login'] = cleanID($_POST['login']); + //clean fullname and email + $_POST['fullname'] = trim(str_replace(':','',$_POST['fullname'])); + $_POST['email'] = trim(str_replace(':','',$_POST['email'])); + + if( empty($_POST['login']) || + empty($_POST['fullname']) || + empty($_POST['email']) ){ + msg($lang['regmissing'],-1); + return false; + } + + //check mail + if(!isvalidemail($_POST['email'])){ + msg($lang['regbadmail'],-1); + return false; + } + + //okay try to create the user + $pass = auth_createUser($_POST['login'],$_POST['fullname'],$_POST['email']); + if(empty($pass)){ + msg($lang['reguexists'],-1); + return false; + } + + //send him the password + if (auth_sendPassword($_POST['login'],$pass)){ + msg($lang['regsuccess'],1); + return true; + }else{ + msg($lang['regmailfail'],-1); + return false; + } +} + +/** + * Uses a regular expresion to check if a given mail address is valid + * + * @see http://www.webmasterworld.com/forum88/135.htm + * + * May not be completly RFC conform! + */ +function isvalidemail($email){ + return eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email); +} + +?> diff --git a/inc/auth_ldap.php b/inc/auth_ldap.php new file mode 100644 index 000000000..2872e710f --- /dev/null +++ b/inc/auth_ldap.php @@ -0,0 +1,137 @@ +<?php +/** + * This is used to authenticate against an LDAP server + * + * tested with openldap 2.x on Debian only + * + * PHPs LDAP extension is needed + */ + +/** + * connects to the ldap server and holds the connection + * in global scope for multiple use + */ +function auth_ldap_connect(){ + global $LDAP_CONNECTION; + global $conf; + $cnf = $conf['auth']['ldap']; + + if(!$LDAP_CONNECTION){ + $LDAP_CONNECTION = @ldap_connect($cnf['server']); + if(!$LDAP_CONNECTION){ + msg("LDAP: couldn't connect to LDAP server",-1); + return false; + } + if($cnf['version']){ + if(!@ldap_set_option($LDAP_CONNECTION, + LDAP_OPT_PROTOCOL_VERSION, + $cnf['version'])){ + msg('Setting LDAP Protocol version '.$cnf['version'].' failed',-1); + } + } + } + return $LDAP_CONNECTION; +} + +/** + * required auth function + * + * Checks if the given user exists and the given + * plaintext password is correct + * + * It does so by trying to connect to the LDAP server + */ +function auth_checkPass($user,$pass){ + global $conf; + $cnf = $conf['auth']['ldap']; + + //connect to LDAP Server + $conn = auth_ldap_connect(); + if(!$conn) return false; + + //get dn for given user + $info = auth_getUserData($user); + $dn = $info['dn']; + if(!$dn) return false; + + //try to bind with dn + if(@ldap_bind($conn,$dn,$pass)){ + return true; + } + return false; +} + +/** + * Required auth function + * + * Returns info about the given user needs to contain + * at least these fields: + * + * name string full name of the user + * mail string email addres of the user + * grps array list of groups the user is in + * + * This LDAP specific function returns the following + * addional fields + * + * dn string distinguished name (DN) + * uid string Posix User ID + */ +function auth_getUserData($user){ + global $conf; + $cnf = $conf['auth']['ldap']; + + //connect to LDAP Server + $conn = auth_ldap_connect(); + if(!$conn) return false; + + //anonymous bind to lookup userdata + if(!@ldap_bind($conn)){ + msg("LDAP: can not bind anonymously",-1); + return false; + } + + //get info for given user + $filter = str_replace('%u',$user,$cnf['userfilter']); + $base = str_replace('%u',$user,$cnf['usertree']); + $sr = ldap_search($conn, $base, $filter);; + $result = ldap_get_entries($conn, $sr); + if($result['count'] != 1){ + return false; //user not found + } + + //general user info + $info['dn'] = $result[0]['dn']; + $info['mail']= $result[0]['mail'][0]; + $info['name']= $result[0]['cn'][0]; + $info['uid'] = $result[0]['uid'][0]; + + //primary group id + $gid = $result[0]['gidnumber'][0]; + + //get groups for given user + $filter = "(&(objectClass=posixGroup)(|(gidNumber=$gid)(memberUID=".$info['uid'].")))"; + $sr = @ldap_search($conn, $cnf['grouptree'], $filter); + if(!$sr){ + msg("LDAP: Reading group memberships failed",-1); + return false; + } + $result = ldap_get_entries($conn, $sr); + foreach($result as $grp){ + if(!empty($grp['cn'][0])) + $info['grps'][] = $grp['cn'][0]; + } + return $info; +} + +/** + * Required auth function + * + * Not implemented + */ +function auth_createUser($user,$name,$mail){ + msg("Sorry. Creating users is not supported by the LDAP backend",-1); + return null; +} + +?> diff --git a/inc/auth_mysql.php b/inc/auth_mysql.php new file mode 100644 index 000000000..213c4a852 --- /dev/null +++ b/inc/auth_mysql.php @@ -0,0 +1,98 @@ +<?php +/** + * This is used to authenticate against an MySQL server + * + * PHPs MySQL extension is needed + */ + +/** + * Executes SQL statements and returns the results as list + * of hashes. Returns false on error. Returns auto_increment + * IDs on INSERT statements. + */ +function auth_mysql_runsql($sql_string) { + global $conf; + $cnf = $conf['auth']['mysql']; + + $link = @mysql_connect ($cnf['server'], $cnf['user'], $cnf['password']); + if(!$link){ + msg('MySQL: Connection to database failed!',-1); + return false; + } + $result = @mysql_db_query($cnf['database'],$sql_string,$link); + if(!$result){ + msg('MySQL: '.mysql_error($link)); + return false; + } + + //mysql_db_query returns 1 on a insert statement -> no need to ask for results + if ($result != 1) { + for($i=0; $i< mysql_num_rows($result); $i++) { + $temparray = mysql_fetch_assoc($result); + $resultarray[]=$temparray; + } + mysql_free_result ($result); + } + if (mysql_insert_id($link)) { + $resultarray = mysql_insert_id($link); //give back ID on insert + } + mysql_close ($link); + return $resultarray; +} + +/** + * required auth function + * + * Checks if a user with the given password exists + */ +function auth_checkPass($user,$pass){ + global $conf; + $cnf = $conf['auth']['mysql']; + + $sql = str_replace('%u',addslashes($user),$cnf['passcheck']); + $sql = str_replace('%p',addslashes($pass),$sql); + $result = auth_mysql_runsql($sql); + return(count($result)); +} + +/** + * Required auth function + * + * Returns info about the given user needs to contain + * at least these fields: + * + * name string full name of the user + * mail string email addres of the user + * grps array list of groups the user is in + * + */ +function auth_getUserData($user){ + global $conf; + $cnf = $conf['auth']['mysql']; + + $sql = str_replace('%u',addslashes($user),$cnf['userinfo']); + $result = auth_mysql_runsql($sql); + if(!count($result)) return false; + $info = $result[0]; + + $sql = str_replace('%u',addslashes($user),$cnf['groups']); + $result = auth_mysql_runsql($sql); + if(!count($result)) return false; + foreach($result as $row){ + $info['grps'][] = $row['group']; + } + + return $info; +} + +/** + * Required auth function + * + * Not implemented + */ +function auth_createUser($user,$name,$mail){ + msg("Sorry. Creating users is not supported by the MySQL backend, yet",-1); + return null; +} + +?> diff --git a/inc/auth_plain.php b/inc/auth_plain.php new file mode 100644 index 000000000..2b45b94ca --- /dev/null +++ b/inc/auth_plain.php @@ -0,0 +1,100 @@ +<?php + +/** + * If you want to authenticate against something + * else then the builtin flatfile auth system + * you have to reimplement the "required auth + * functions" + */ + + +/** + * required auth function + * + * Checks if the given user exists and the given + * plaintext password is correct + */ +function auth_checkPass($user,$pass){ + $users = auth_loadUserData(); + $pass = md5($pass); //encode pass + + if($users[$user]['pass'] == $pass){ + return true; + }else{ + return false; + } +} + +/** + * Required auth function + * + * Returns info about the given user needs to contain + * at least these fields: + * + * name string full name of the user + * mail string email addres of the user + * grps array list of groups the user is in + */ +function auth_getUserData($user){ + $users = auth_loadUserData(); + return $users[$user]; +} + +/** + * Required auth function + * + * Creates a new user. + * + * Returns false if the user already exists, null when an error + * occured and the cleartext password of the new user if + * everything went well. + * + * The new user HAS TO be added to the default group by this + * function! + */ +function auth_createUser($user,$name,$mail){ + global $conf; + + $users = auth_loadUserData(); + if(isset($users[$user])) return false; + + $pass = auth_pwgen(); + $userline = join(':',array($user, + md5($pass), + $name, + $mail, + $conf['defaultgroup'])); + $userline .= "\n"; + $fh = fopen('conf/users.auth','a'); + if($fh){ + fwrite($fh,$userline); + fclose($fh); + return $pass; + } + msg('The users.auth file is not writable. Please inform the Wiki-Admin',-1); + return null; +} + +/** + * used by the plaintext auth functions + * loads the user file into a datastructure + */ +function auth_loadUserData(){ + $data = array(); + $lines = file('conf/users.auth'); + foreach($lines as $line){ + $line = preg_replace('/#.*$/','',$line); //ignore comments + $line = trim($line); + if(empty($line)) continue; + + $row = split(":",$line,5); + $groups = split(",",$row[4]); + $data[$row[0]]['pass'] = $row[1]; + $data[$row[0]]['name'] = urldecode($row[2]); + $data[$row[0]]['mail'] = $row[3]; + $data[$row[0]]['grps'] = $groups; + } + return $data; +} + +?> diff --git a/inc/common.php b/inc/common.php new file mode 100644 index 000000000..c64d08898 --- /dev/null +++ b/inc/common.php @@ -0,0 +1,831 @@ +<? +require_once("conf/dokuwiki.php"); +require_once("inc/io.php"); + +//set up error reporting to sane values +error_reporting(E_ALL ^ E_NOTICE); + +//make session rewrites XHTML compliant +ini_set('arg_separator.output', '&'); + +//init session +session_name("DokuWiki"); +session_start(); + +//kill magic quotes +if (get_magic_quotes_gpc()) { + if (!empty($_GET)) remove_magic_quotes($_GET); + if (!empty($_POST)) remove_magic_quotes($_POST); + if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE); + if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST); + if (!empty($_SESSION)) remove_magic_quotes($_SESSION); + ini_set('magic_quotes_gpc', 0); +} +set_magic_quotes_runtime(0); +ini_set('magic_quotes_sybase',0); + +function remove_magic_quotes(&$array) { + foreach (array_keys($array) as $key) { + if (is_array($array[$key])) { + remove_magic_quotes($array[$key]); + }else { + $array[$key] = stripslashes($array[$key]); + } + } +} + +//disable gzip if not available +if($conf['usegzip'] && !function_exists('gzopen')){ + $conf['usegzip'] = 0; +} + +/* ---------------------------------------------------------------------------------- */ + +/** + * This returns the full absolute URL to the directory where + * DokuWiki is installed in (includes a trailing slash) + */ +function getBaseURL($abs=false){ + global $conf; + //if canonical url enabled always return absolute + if($conf['canonical']) $abs = true; + + //relative URLs are easy + if(!$abs){ + $dir = dirname($_SERVER['PHP_SELF']).'/'; + $dir = preg_replace('#//#','/',$dir); + $dir = preg_replace('#\/$#','/',$dir); #bugfix for weird WIN behaviour + return $dir; + } + + $port = ':'.$_SERVER['SERVER_PORT']; + //remove port from hostheader as sent by IE + $host = preg_replace('/:.*$/','',$_SERVER['HTTP_HOST']); + + // see if HTTPS is enabled - apache leaves this empty when not available, + // IIS sets it to 'off', 'false' and 'disabled' are just guessing + if (preg_match('/^(|off|false|disabled)$/i',$_SERVER['HTTPS'])){ + $proto = 'http://'; + if ($_SERVER['SERVER_PORT'] == '80') { + $port=''; + } + }else{ + $proto = 'https://'; + if ($_SERVER['SERVER_PORT'] == '443') { + $port=''; + } + } + $dir = (dirname($_SERVER['PHP_SELF'])).'/'; + $dir = preg_replace('#//#','/',$dir); + $dir = preg_replace('#\/$#','/',$dir); #bugfix for weird WIN behaviour + + return $proto.$host.$port.$dir; +} + +/** + * Returns info about the current document as associative + * array. + */ +function pageinfo(){ + global $ID; + global $REV; + global $USERINFO; + global $conf; + + if($_SERVER['REMOTE_USER']){ + $info['user'] = $_SERVER['REMOTE_USER']; + $info['userinfo'] = $USERINFO; + $info['perm'] = auth_quickaclcheck($ID); + }else{ + $info['user'] = ''; + $info['perm'] = auth_aclcheck($ID,'',null); + } + + $info['namespace'] = getNS($ID); + $info['locked'] = checklock($ID); + $info['filepath'] = realpath(wikiFN($ID,$REV)); + $info['exists'] = @file_exists($info['filepath']); + if($REV && !$info['exists']){ + //check if current revision was meant + $cur = wikiFN($ID); + if(@file_exists($cur) && (@filemtime($cur) == $REV)){ + $info['filepath'] = realpath($cur); + $info['exists'] = true; + $REV = ''; + } + } + if($info['exists']){ + $info['writable'] = (is_writable($info['filepath']) && + ($info['perm'] >= AUTH_EDIT)); + }else{ + $info['writable'] = ($info['perm'] >= AUTH_CREATE); + } + $info['editable'] = ($info['writable'] && empty($info['lock'])); + $info['lastmod'] = @filemtime($info['filepath']); + + return $info; +} + +/** + * adds a message to the global message array + * + * Levels can be: + * + * -1 error + * 0 info + * 1 success + */ +function msg($message,$lvl=0){ + global $MSG; + $errors[-1] = 'error'; + $errors[0] = 'info'; + $errors[1] = 'success'; + + if(!isset($MSG)) $MSG = array(); + $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); +} + +/** + * This builds the breadcrumbstrail and returns it as array + */ +function breadcrumbs(){ + global $ID; + global $ACT; + global $conf; + $crumbs = $_SESSION[$conf['title']]['bc']; + + //first visit? + if (!is_array($crumbs)){ + $crumbs = array(); + } + //we only save on show and existing wiki documents + if($ACT != 'show' || !@file_exists(wikiFN($ID))){ + $_SESSION[$conf['title']]['bc'] = $crumbs; + return $crumbs; + } + //remove ID from array + $pos = array_search($ID,$crumbs); + if($pos !== false && $pos !== null){ + array_splice($crumbs,$pos,1); + } + + //add to array + $crumbs[] =$ID; + //reduce size + while(count($crumbs) > $conf['breadcrumbs']){ + array_shift($crumbs); + } + //save to session + $_SESSION[$conf['title']]['bc'] = $crumbs; + return $crumbs; +} + +/** + * This is run on a ID before it is outputted somewhere + * currently used to replace the colon with something else + * on Windows systems and to have proper URL encoding + */ +function idfilter($id){ + global $conf; + if ($conf['useslash'] && $conf['userewrite']){ + $id = strtr($id,':','/'); + }elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && + $conf['userewrite']) { + $id = strtr($id,':',';'); + } + $id = urlencode($id); + $id = str_replace('%3A',':',$id); //keep as colon + $id = str_replace('%2F','/',$id); //keep as slash + return $id; +} + +/** + * This builds a link to a wikipage (using getBaseURL) + */ +function wl($id='',$more='',$script='doku.php',$canonical=false){ + global $conf; + $more = str_replace(',','&',$more); + + $id = idfilter($id); + $xlink = getBaseURL($canonical); + + if(!$conf['userewrite']){ + $xlink .= $script; + $xlink .= '?id='.$id; + if($more) $xlink .= '&'.$more; + }else{ + $xlink .= $id; + if($more) $xlink .= '?'.$more; + } + + return $xlink; +} + +/** + * Just builds a link to a script + */ +function script($script='doku.php'){ + $link = getBaseURL(); + $link .= $script; + return $link; +} + +/** + * Return namespacepart of a wiki ID + */ +function getNS($id){ + if(strpos($id,':')!==false){ + return substr($id,0,strrpos($id,':')); + } + return false; +} + +/** + * Returns the id without the namespace + */ +function noNS($id){ + return preg_replace('/.*:/','',$id); +} + +/** + * Checks the wikitext against a list of blocked expressions + * returns true if the text contains any bad words + */ +function checkwordblock(){ + global $TEXT; + global $conf; + + if(!$conf['usewordblock']) return false; + + $blocks = file('conf/wordblock.conf'); + $re = array(); + #build regexp from blocks + foreach($blocks as $block){ + $block = preg_replace('/#.*$/','',$block); + $block = trim($block); + if(empty($block)) continue; + $re[] = $block; + } + if(preg_match('#('.join('|',$re).')#si',$TEXT)) return true; + return false; +} + +/** + * Returns the IP of the client including X-Forwarded-For + * Proxy Headers + */ +function clientIP(){ + $my = $_SERVER['REMOTE_ADDR']; + if($_SERVER['HTTP_X_FORWARDED_FOR']){ + $my .= ' ('.$_SERVER['HTTP_X_FORWARDED_FOR'].')'; + } + return $my; +} + +/** + * Checks if a given page is currently locked by anyone for editing. + * removes stale lockfiles + */ +function checklock($id){ + global $conf; + $lock = wikiFN($id).'.lock'; + + //no lockfile + if(!@file_exists($lock)) return false; + + //lockfile expired + if((time() - filemtime($lock)) > $conf['locktime']){ + unlink($lock); + return false; + } + + //my own lock + $ip = io_readFile($lock); + if( ($ip == clientIP()) || ($ip == $_SERVER['REMOTE_USER']) ){ + return false; + } + + return $ip; +} + +/** + * Locks a page for editing + */ +function lock($id){ + $lock = wikiFN($id).'.lock'; + if($_SERVER['REMOTE_USER']){ + io_saveFile($lock,$_SERVER['REMOTE_USER']); + }else{ + io_saveFile($lock,clientIP()); + } +} + +/** + * Unlocks a page if it was locked by the user + * + * return true if a lock was removed + */ +function unlock($id){ + $lock = wikiFN($id).'.lock'; + if(@file_exists($lock)){ + $ip = io_readFile($lock); + if( ($ip == clientIP()) || ($ip == $_SERVER['REMOTE_USER']) ){ + @unlink($lock); + return true; + } + } + return false; +} + +/** + * Cleans a given ID to only use allowed characters. Accented characters are + * converted to unaccented ones + */ +function cleanID($id){ + global $conf; + global $lang; + $id = trim($id); + $id = strtolower($id); + + //alternative namespace seperator + $id = strtr($id,';',':'); + $id = strtr($id,'/',':'); + + if(!$conf['localnames']){ + if($lang['encoding'] == 'iso-8859-15'){ + // replace accented chars with unaccented ones + // this may look strange on your terminal - just don't touch + $id = strtr( + strtr($id, + 'ŠŽšžŸÀÁÂÃÅÇÈÉÊËÌÍÎÏÑÒÓÔÕØÙÚÛÝàáâãåçèéêëìíîïñòóôõøùúûýÿ', + 'szszyaaaaaceeeeiiiinooooouuuyaaaaaceeeeiiiinooooouuuyy'), + array('Þ' => 'th', 'þ' => 'th', 'Ð' => 'dh', 'ð' => 'dh', 'ß' => 'ss', + 'Œ' => 'oe', 'œ' => 'oe', 'Æ' => 'ae', 'æ' => 'ae', 'µ' => 'u', + 'ü' => 'ue', 'ö' => 'oe', 'ä' => 'ae', 'Ü' => 'ue', 'Ö' => 'ö', + 'Ä' => 'ae')); + } + $WORD = 'a-z'; + }else{ + $WORD = '\w'; + } + + //special chars left will be converted to _ + $id = preg_replace('#[^'.$WORD.'0-9:\-\.]#','_',$id); + $id = preg_replace('#__#','_',$id); + $id = preg_replace('#:+#',':',$id); + $id = trim($id,':._-'); + $id = preg_replace('#:[:\._\-]+#',':',$id); + + return($id); +} + +/** + * returns the full path to the datafile specified by ID and + * optional revision + */ +function wikiFN($id,$rev=''){ + global $conf; + $id = cleanID($id); + $id = str_replace(':','/',$id); + if(empty($rev)){ + return $conf['datadir'].'/'.$id.'.txt'; + }else{ + $fn = $conf['olddir'].'/'.$id.'.'.$rev.'.txt'; + if(!$conf['usegzip'] || @file_exists($fn)){ + //return plaintext if exists or gzip is disabled + return $fn; + }else{ + return $fn.'.gz'; + } + } +} + +/** + * Returns the full filepath to a localized textfile if local + * version isn't found the english one is returned + */ +function localeFN($id){ + global $conf; + $file = './lang/'.$conf['lang'].'/'.$id.'.txt'; + if(!@file_exists($file)){ + //fall back to english + $file = './lang/en/'.$id.'.txt'; + } + return cleanText($file); +} + +/** + * convert line ending to unix format + * + * @see: formText() for 2crlf conversion + */ +function cleanText($text){ + $text = preg_replace("/(\015\012)|(\015)/","\012",$text); + return $text; +} + +/** + * Prepares text for print in Webforms by encoding special chars. + * It also converts line endings to Windows format which is + * pseudo standard for webforms. + * + * @see: cleanText() for 2unix conversion + */ +function formText($text){ + $text = preg_replace("/\012/","\015\012",$text); + return htmlspecialchars($text); +} + +/** + * Returns the specified textfile in parsed format + */ +function parsedLocale($id){ + //disable section editing + global $parser; + $se = $parser['secedit']; + $parser['secedit'] = false; + //fetch parsed locale + $html = io_cacheParse(localeFN($id)); + //reset section editing + $parser['secedit'] = $se; + return $html; +} + +/** + * Returns the specified textfile in parsed format + */ +function rawLocale($id){ + return io_readFile(localeFN($id)); +} + + +/** + * Returns the parsed Wikitext for the given id and revision. If $excuse + * is true an explanation is returned if the file wasn't found + */ +function parsedWiki($id,$rev='',$excuse=true){ + $file = wikiFN($id,$rev); + $ret = ''; + + //ensure $id is in global $ID (needed for parsing) + global $ID; + $ID = $id; + + if($rev){ + if(@file_exists($file)){ + $ret = parse(io_readFile($file)); + }elseif($excuse){ + $ret = parsedLocale('norev'); + } + }else{ + if(@file_exists($file)){ + $ret = io_cacheParse($file); + }elseif($excuse){ + $ret = parsedLocale('newpage'); + } + } + return $ret; +} + +/** + * Returns the raw WikiText + */ +function rawWiki($id,$rev=''){ + return io_readFile(wikiFN($id,$rev)); +} + +/** + * Returns the raw Wiki Text in three slices. The range parameter + * Need to have the form "from-to" and gives the range of the section. + * The returned order is prefix, section and suffix. + */ +function rawWikiSlices($range,$id,$rev=''){ + list($from,$to) = split('-',$range,2); + $text = io_readFile(wikiFN($id,$rev)); + $text = split("\n",$text); + if(!$from) $from = 0; + if(!$to) $to = count($text); + + $slices[0] = join("\n",array_slice($text,0,$from)); + $slices[1] = join("\n",array_slice($text,$from,$to + 1 - $from)); + $slices[2] = join("\n",array_slice($text,$to+1)); + + return $slices; +} + +/** + * function to join the text slices with correct lineendings again. + * When the pretty parameter is set to true it adds additional empty + * lines between sections if needed (used on saving). + */ +function con($pre,$text,$suf,$pretty=false){ + + if($pretty){ + if($pre && substr($pre,-1) != "\n") $pre .= "\n"; + if($suf && substr($text,-1) != "\n") $text .= "\n"; + } + + if($pre) $pre .= "\n"; + if($suf) $text .= "\n"; + return $pre.$text.$suf; +} + +/** + * little function to print the content of a var + */ +function dbg($msg,$hidden=false){ + (!$hidden) ? print '<pre class="dbg">' : print "<!--\n"; + print_r($msg); + (!$hidden) ? print '</pre>' : print "\n-->"; +} + +/** + * Add's an entry to the changelog + */ +function addLogEntry($id,$summary=""){ + global $conf; + $id = cleanID($id); + $date = time(); + $remote = $_SERVER['REMOTE_ADDR']; + $user = $_SERVER['REMOTE_USER']; + + $logline = join("\t",array($date,$remote,$id,$user,$summary))."\n"; + + $fh = fopen($conf['changelog'],'a'); + if($fh){ + fwrite($fh,$logline); + fclose($fh); + } +} + +/** + * returns an array of recently changed files using the + * changelog + */ +function getRecents($num=0,$incdel=false){ + global $conf; + $recent = array(); + if(!$num) $num = $conf['recent']; + + $loglines = file($conf['changelog']); + rsort($loglines); //reverse sort on timestamp + + foreach ($loglines as $line){ + $line = rtrim($line); //remove newline + if(empty($line)) continue; //skip empty lines + $info = split("\t",$line); //split into parts + //add id if not in yet and file still exists and is allowed to read + if(!$recent[$info[2]] && + (@file_exists(wikiFN($info[2])) || $incdel) && + (auth_quickaclcheck($info[2]) >= AUTH_READ) + ){ + $recent[$info[2]]['date'] = $info[0]; + $recent[$info[2]]['ip'] = $info[1]; + $recent[$info[2]]['user'] = $info[3]; + $recent[$info[2]]['sum'] = $info[4]; + $recent[$info[2]]['del'] = !@file_exists(wikiFN($info[2])); + } + if(count($recent) >= $num){ + break; //finish if enough items found + } + } + return $recent; +} + +/** + * Saves a wikitext by calling io_saveFile + */ +function saveWikiText($id,$text,$summary){ + global $conf; + global $lang; + umask($conf['umask']); + // ignore if no changes were made + if($text == rawWiki($id,'')){ + return; + } + + $file = wikiFN($id); + $old = saveOldRevision($id); + + if (empty($text)){ + // remove empty files + @unlink($file); + $del = true; + $summary = $lang['deleted']; //autoset summary on deletion + }else{ + // save file (datadir is created in io_saveFile) + io_saveFile($file,$text); + $del = false; + } + + addLogEntry($id,$summary); + notify($id,$old,$summary); + + //purge cache on add by updating the purgefile + if($conf['purgeonadd'] && (!$old || $del)){ + io_saveFile($conf['datadir'].'/.cache/purgefile',time()); + } +} + +/** + * moves the current version to the attic and returns its + * revision date + */ +function saveOldRevision($id){ + global $conf; + umask($conf['umask']); + $oldf = wikiFN($id); + if(!@file_exists($oldf)) return ''; + $date = filemtime($oldf); + $newf = wikiFN($id,$date); + if(substr($newf,-3)=='.gz'){ + io_saveFile($newf,rawWiki($id)); + }else{ + io_makeFileDir($newf); + copy($oldf, $newf); + } + return $date; +} + +/** + * Sends a notify mail to the wikiadmin when a page was + * changed + */ +function notify($id,$rev="",$summary=""){ + global $lang; + global $conf; + $hdrs =''; + if(empty($conf['notify'])) return; //notify enabled? + + $text = rawLocale('mailtext'); + $text = str_replace('@DATE@',date($conf['dformat']),$text); + $text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text); + $text = str_replace('@IPADDRESS@',$_SERVER['REMOTE_ADDR'],$text); + $text = str_replace('@HOSTNAME@',gethostbyaddr($_SERVER['REMOTE_ADDR']),$text); + $text = str_replace('@NEWPAGE@',wl($id,'','',true),$text); + $text = str_replace('@DOKUWIKIURL@',getBaseURL(true),$text); + $text = str_replace('@SUMMARY@',$summary,$text); + + if($rev){ + $subject = $lang['mail_changed'].' '.$id; + $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",'',true),$text); + require_once("inc/DifferenceEngine.php"); + $df = new Diff(split("\n",rawWiki($id,$rev)), + split("\n",rawWiki($id))); + $dformat = new UnifiedDiffFormatter(); + $diff = $dformat->format($df); + }else{ + $subject=$lang['mail_newpage'].' '.$id; + $text = str_replace('@OLDPAGE@','none',$text); + $diff = rawWiki($id); + } + $text = str_replace('@DIFF@',$diff,$text); + + if (!empty($conf['mailfrom'])) { + $hdrs = 'From: '.$conf['mailfrom']."\n"; + } + @mail($conf['notify'],$subject,$text,$hdrs); +} + +function getRevisions($id){ + $revd = dirname(wikiFN($id,'foo')); + $revs = array(); + $clid = cleanID($id); + if(strrpos($clid,':')) $clid = substr($clid,strrpos($clid,':')+1); //remove path + + if (is_dir($revd) && $dh = opendir($revd)) { + while (($file = readdir($dh)) !== false) { + if (is_dir($revd.'/'.$file)) continue; + if (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){ + $revs[]=$match[1]; + } + } + closedir($dh); + } + rsort($revs); + return $revs; +} + +/** + * downloads a file from the net and saves it to the given location + */ +function download($url,$file){ + $fp = @fopen($url,"rb"); + if(!$fp) return false; + + while(!feof($fp)){ + $cont.= fread($fp,1024); + } + fclose($fp); + + $fp2 = @fopen($file,"w"); + if(!$fp2) return false; + fwrite($fp2,$cont); + fclose($fp2); + return true; +} + +/** + * extracts the query from a google referer + */ +function getGoogleQuery(){ + $url = parse_url($_SERVER['HTTP_REFERER']); + + if(!preg_match("#google\.#i",$url['host'])) return ''; + $query = array(); + parse_str($url['query'],$query); + + return $query['q']; +} + +/** + * This function tries the locales given in the + * language file + */ +function setCorrectLocale(){ + global $conf; + global $lang; + + $enc = strtoupper($lang['encoding']); + foreach ($lang['locales'] as $loc){ + //try locale + if(@setlocale(LC_ALL,$loc)) return; + //try loceale with encoding + if(@setlocale(LC_ALL,"$loc.$enc")) return; + } + //still here? try to set from environment + @setlocale(LC_ALL,""); +} + +/** +* Return the human readable size of a file +* +* @param int $size A file size +* @param int $dec A number of decimal places +* @author Martin Benjamin <b.martin@cybernet.ch> +* @author Aidan Lister <aidan@php.net> +* @version 1.0.0 +*/ +function filesize_h($size, $dec = 1) +{ + $sizes = array('B', 'KB', 'MB', 'GB'); + $count = count($sizes); + $i = 0; + + while ($size >= 1024 && ($i < $count - 1)) { + $size /= 1024; + $i++; + } + + return round($size, $dec) . ' ' . $sizes[$i]; +} + +function check(){ + global $conf; + global $INFO; + + if(is_writable($conf['changelog'])){ + msg('Changelog is writable',1); + }else{ + msg('Changelog is not writable',-1); + } + + if(is_writable($conf['datadir'])){ + msg('Datadir is writable',1); + }else{ + msg('Datadir is not writable',-1); + } + + if(is_writable($conf['olddir'])){ + msg('Attic is writable',1); + }else{ + msg('Attic is not writable',-1); + } + + if(is_writable($conf['mediadir'])){ + msg('Mediadir is writable',1); + }else{ + msg('Mediadir is not writable',-1); + } + + if(is_writable('conf/users.auth')){ + msg('conf/users.auth is writable',1); + }else{ + msg('conf/users.auth is not writable',0); + } + + msg('Your current permission for this page is '.$INFO['perm'],0); + + if(is_writable($INFO['filepath'])){ + msg('The current page is writable by the webserver',0); + }else{ + msg('The current page is not writable by the webserver',0); + } + + if($INFO['writable']){ + msg('The current page is writable by you',0); + }else{ + msg('The current page is not writable you',0); + } +} +?> diff --git a/inc/feedcreator.class.php b/inc/feedcreator.class.php new file mode 100644 index 000000000..dbd1edc95 --- /dev/null +++ b/inc/feedcreator.class.php @@ -0,0 +1,1548 @@ +<?php +/*************************************************************************** + +FeedCreator class v1.7.1 +originally (c) Kai Blankenhorn +www.bitfolge.de +kaib@bitfolge.de +v1.3 work by Scott Reynen (scott@randomchaos.com) and Kai Blankenhorn +v1.5 OPML support by Dirk Clemens + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details: <http://www.gnu.org/licenses/gpl.txt> + +**************************************************************************** + + +Changelog: + +v1.7.1 + fixed a syntax bug + fixed left over debug code + +v1.7 + added HTML and JavaScript feeds (configurable via CSS) (thanks to Pascal Van Hecke) + added HTML descriptions for all feed formats (thanks to Pascal Van Hecke) + added a switch to select an external stylesheet (thanks to Pascal Van Hecke) + changed default content-type to application/xml + added character encoding setting + fixed numerous smaller bugs (thanks to Sören Fuhrmann of golem.de) + improved changing ATOM versions handling (thanks to August Trometer) + improved the UniversalFeedCreator's useCached method (thanks to Sören Fuhrmann of golem.de) + added charset output in HTTP headers (thanks to Sören Fuhrmann of golem.de) + added Slashdot namespace to RSS 1.0 (thanks to Sören Fuhrmann of golem.de) + +v1.6 05-10-04 + added stylesheet to RSS 1.0 feeds + fixed generator comment (thanks Kevin L. Papendick and Tanguy Pruvot) + fixed RFC822 date bug (thanks Tanguy Pruvot) + added TimeZone customization for RFC8601 (thanks Tanguy Pruvot) + fixed Content-type could be empty (thanks Tanguy Pruvot) + fixed author/creator in RSS1.0 (thanks Tanguy Pruvot) + +v1.6 beta 02-28-04 + added Atom 0.3 support (not all features, though) + improved OPML 1.0 support (hopefully - added more elements) + added support for arbitrary additional elements (use with caution) + code beautification :-) + considered beta due to some internal changes + +v1.5.1 01-27-04 + fixed some RSS 1.0 glitches (thanks to Stéphane Vanpoperynghe) + fixed some inconsistencies between documentation and code (thanks to Timothy Martin) + +v1.5 01-06-04 + added support for OPML 1.0 + added more documentation + +v1.4 11-11-03 + optional feed saving and caching + improved documentation + minor improvements + +v1.3 10-02-03 + renamed to FeedCreator, as it not only creates RSS anymore + added support for mbox + tentative support for echo/necho/atom/pie/??? + +v1.2 07-20-03 + intelligent auto-truncating of RSS 0.91 attributes + don't create some attributes when they're not set + documentation improved + fixed a real and a possible bug with date conversions + code cleanup + +v1.1 06-29-03 + added images to feeds + now includes most RSS 0.91 attributes + added RSS 2.0 feeds + +v1.0 06-24-03 + initial release + + + +***************************************************************************/ + +/*** GENERAL USAGE ********************************************************* + +include("feedcreator.class.php"); + +$rss = new UniversalFeedCreator(); +$rss->useCached(); // use cached version if age<1 hour +$rss->title = "PHP news"; +$rss->description = "daily news from the PHP scripting world"; + +//optional +$rss->descriptionTruncSize = 500; +$rss->descriptionHtmlSyndicated = true; + +$rss->link = "http://www.dailyphp.net/news"; +$rss->syndicationURL = "http://www.dailyphp.net/".$_SERVER["PHP_SELF"]; + +$image = new FeedImage(); +$image->title = "dailyphp.net logo"; +$image->url = "http://www.dailyphp.net/images/logo.gif"; +$image->link = "http://www.dailyphp.net"; +$image->description = "Feed provided by dailyphp.net. Click to visit."; + +//optional +$image->descriptionTruncSize = 500; +$image->descriptionHtmlSyndicated = true; + +$rss->image = $image; + +// get your news items from somewhere, e.g. your database: +mysql_select_db($dbHost, $dbUser, $dbPass); +$res = mysql_query("SELECT * FROM news ORDER BY newsdate DESC"); +while ($data = mysql_fetch_object($res)) { + $item = new FeedItem(); + $item->title = $data->title; + $item->link = $data->url; + $item->description = $data->short; + + //optional + item->descriptionTruncSize = 500; + item->descriptionHtmlSyndicated = true; + + $item->date = $data->newsdate; + $item->source = "http://www.dailyphp.net"; + $item->author = "John Doe"; + + $rss->addItem($item); +} + +// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), +// MBOX, OPML, ATOM, ATOM0.3, HTML, JS +echo $rss->saveFeed("RSS1.0", "news/feed.xml"); + + +*************************************************************************** +* A little setup * +**************************************************************************/ + +// your local timezone, set to "" to disable or for GMT +define("TIME_ZONE","+01:00"); + + + + +/** + * Version string. + **/ +define("FEEDCREATOR_VERSION", "FeedCreator 1.7.1"); + + + +/** + * A FeedItem is a part of a FeedCreator feed. + * + * @author Kai Blankenhorn <kaib@bitfolge.de> + * @since 1.3 + */ +class FeedItem extends HtmlDescribable { + /** + * Mandatory attributes of an item. + */ + var $title, $description, $link; + + /** + * Optional attributes of an item. + */ + var $author, $authorEmail, $image, $category, $comments, $guid, $source, $creator; + + /** + * Publishing date of an item. May be in one of the following formats: + * + * RFC 822: + * "Mon, 20 Jan 03 18:05:41 +0400" + * "20 Jan 03 18:05:41 +0000" + * + * ISO 8601: + * "2003-01-20T18:05:41+04:00" + * + * Unix: + * 1043082341 + */ + var $date; + + /** + * Any additional elements to include as an assiciated array. All $key => $value pairs + * will be included unencoded in the feed item in the form + * <$key>$value</$key> + * Again: No encoding will be used! This means you can invalidate or enhance the feed + * if $value contains markup. This may be abused to embed tags not implemented by + * the FeedCreator class used. + */ + var $additionalElements = Array(); + + // on hold + // var $source; +} + + + +/** + * An FeedImage may be added to a FeedCreator feed. + * @author Kai Blankenhorn <kaib@bitfolge.de> + * @since 1.3 + */ +class FeedImage extends HtmlDescribable { + /** + * Mandatory attributes of an image. + */ + var $title, $url, $link; + + /** + * Optional attributes of an image. + */ + var $width, $height, $description; +} + + + +/** + * An HtmlDescribable is an item within a feed that can have a description that may + * include HTML markup. + */ +class HtmlDescribable { + /** + * Indicates whether the description field should be rendered in HTML. + */ + var $descriptionHtmlSyndicated; + + /** + * Indicates whether and to how many characters a description should be truncated. + */ + var $descriptionTruncSize; + + /** + * Returns a formatted description field, depending on descriptionHtmlSyndicated and + * $descriptionTruncSize properties + * @return string the formatted description + */ + function getDescription() { + $descriptionField = new FeedHtmlField($this->description); + $descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated; + $descriptionField->truncSize = $this->descriptionTruncSize; + return $descriptionField->output(); + } + +} + + +/** + * An FeedHtmlField describes and generates + * a feed, item or image html field (probably a description). Output is + * generated based on $truncSize, $syndicateHtml properties. + * @author Pascal Van Hecke <feedcreator.class.php@vanhecke.info> + * @version 1.6 + */ +class FeedHtmlField { + /** + * Mandatory attributes of a FeedHtmlField. + */ + var $rawFieldContent; + + /** + * Optional attributes of a FeedHtmlField. + * + */ + var $truncSize, $syndicateHtml; + + /** + * Creates a new instance of FeedHtmlField. + * @param $string: if given, sets the rawFieldContent property + */ + function FeedHtmlField($parFieldContent) { + if ($parFieldContent) { + $this->rawFieldContent = $parFieldContent; + } + } + + + /** + * Creates the right output, depending on $truncSize, $syndicateHtml properties. + * @return string the formatted field + */ + function output() { + // when field available and syndicated in html we assume + // - valid html in $rawFieldContent and we enclose in CDATA tags + // - no truncation (truncating risks producing invalid html) + if (!$this->rawFieldContent) { + $result = ""; + } elseif ($this->syndicateHtml) { + $result = "<![CDATA[".$this->rawFieldContent."]]>"; + } else { + if ($this->truncSize and is_int($this->truncSize)) { + $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent),$this->truncSize); + } else { + $result = htmlspecialchars($this->rawFieldContent); + } + } + return $result; + } + +} + + + +/** + * UniversalFeedCreator lets you choose during runtime which + * format to build. + * For general usage of a feed class, see the FeedCreator class + * below or the example above. + * + * @since 1.3 + * @author Kai Blankenhorn <kaib@bitfolge.de> + */ +class UniversalFeedCreator extends FeedCreator { + var $_feed; + + function _setFormat($format) { + switch (strtoupper($format)) { + + case "2.0": + // fall through + case "RSS2.0": + $this->_feed = new RSSCreator20(); + break; + + case "1.0": + // fall through + case "RSS1.0": + $this->_feed = new RSSCreator10(); + break; + + case "0.91": + // fall through + case "RSS0.91": + $this->_feed = new RSSCreator091(); + break; + + case "PIE0.1": + $this->_feed = new PIECreator01(); + break; + + case "MBOX": + $this->_feed = new MBOXCreator(); + break; + + case "OPML": + $this->_feed = new OPMLCreator(); + break; + + case "ATOM": + // fall through: always the latest ATOM version + + case "ATOM0.3": + $this->_feed = new AtomCreator03(); + break; + + case "HTML": + $this->_feed = new HTMLCreator(); + break; + + case "JS": + // fall through + case "JAVASCRIPT": + $this->_feed = new JSCreator(); + break; + + default: + $this->_feed = new RSSCreator091(); + break; + } + + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + // prevent overwriting of properties "contentType", "encoding"; do not copy "_feed" itself + if (!in_array($key, array("_feed", "contentType", "encoding"))) { + $this->_feed->{$key} = $this->{$key}; + } + } + } + + /** + * Creates a syndication feed based on the items previously added. + * + * @see FeedCreator::addItem() + * @param string format format the feed should comply to. Valid values are: + * "PIE0.1", "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3", "HTML", "JS" + * @return string the contents of the feed. + */ + function createFeed($format = "RSS0.91") { + $this->_setFormat($format); + return $this->_feed->createFeed(); + } + + + + /** + * Saves this feed as a file on the local disk. After the file is saved, an HTTP redirect + * header may be sent to redirect the use to the newly created file. + * @since 1.4 + * + * @param string format format the feed should comply to. Valid values are: + * "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM", "ATOM0.3", "HTML", "JS" + * @param string filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). + * @param boolean displayContents optional send the content of the file or not. If true, the file will be sent in the body of the response. + */ + function saveFeed($format="RSS0.91", $filename="", $displayContents=true) { + $this->_setFormat($format); + $this->_feed->saveFeed($filename, $displayContents); + } + + + /** + * Turns on caching and checks if there is a recent version of this feed in the cache. + * If there is, an HTTP redirect header is sent. + * To effectively use caching, you should create the FeedCreator object and call this method + * before anything else, especially before you do the time consuming task to build the feed + * (web fetching, for example). + * + * @param string format format the feed should comply to. Valid values are: + * "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3". + * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). + * @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) + */ + function useCached($format="RSS0.91", $filename="", $timeout=3600) { + $this->_setFormat($format); + $this->_feed->useCached($filename, $timeout); + } + +} + + +/** + * FeedCreator is the abstract base implementation for concrete + * implementations that implement a specific format of syndication. + * + * @abstract + * @author Kai Blankenhorn <kaib@bitfolge.de> + * @since 1.4 + */ +class FeedCreator extends HtmlDescribable { + + /** + * Mandatory attributes of a feed. + */ + var $title, $description, $link; + + + /** + * Optional attributes of a feed. + */ + var $syndicationURL, $image, $language, $copyright, $pubDate, $lastBuildDate, $editor, $editorEmail, $webmaster, $category, $docs, $ttl, $rating, $skipHours, $skipDays; + + /** + * The url of the external xsl stylesheet used to format the naked rss feed. + * Ignored in the output when empty. + */ + var $xslStyleSheet = ""; + + + /** + * @access private + */ + var $items = Array(); + + + /** + * This feed's MIME content type. + * @since 1.4 + * @access private + */ + var $contentType = "application/xml"; + + + /** + * This feed's character encoding. + * @since 1.6.1 + **/ + var $encoding = "ISO-8859-1"; + + + /** + * Any additional elements to include as an assiciated array. All $key => $value pairs + * will be included unencoded in the feed in the form + * <$key>$value</$key> + * Again: No encoding will be used! This means you can invalidate or enhance the feed + * if $value contains markup. This may be abused to embed tags not implemented by + * the FeedCreator class used. + */ + var $additionalElements = Array(); + + + /** + * Adds an FeedItem to the feed. + * + * @param object FeedItem $item The FeedItem to add to the feed. + * @access public + */ + function addItem($item) { + $this->items[] = $item; + } + + + /** + * Truncates a string to a certain length at the most sensible point. + * First, if there's a '.' character near the end of the string, the string is truncated after this character. + * If there is no '.', the string is truncated after the last ' ' character. + * If the string is truncated, " ..." is appended. + * If the string is already shorter than $length, it is returned unchanged. + * + * @static + * @param string string A string to be truncated. + * @param int length the maximum length the string should be truncated to + * @return string the truncated string + */ + function iTrunc($string, $length) { + if (strlen($string)<=$length) { + return $string; + } + + $pos = strrpos($string,"."); + if ($pos>=$length-4) { + $string = substr($string,0,$length-4); + $pos = strrpos($string,"."); + } + if ($pos>=$length*0.4) { + return substr($string,0,$pos+1)." ..."; + } + + $pos = strrpos($string," "); + if ($pos>=$length-4) { + $string = substr($string,0,$length-4); + $pos = strrpos($string," "); + } + if ($pos>=$length*0.4) { + return substr($string,0,$pos)." ..."; + } + + return substr($string,0,$length-4)." ..."; + + } + + + /** + * Creates a comment indicating the generator of this feed. + * The format of this comment seems to be recognized by + * Syndic8.com. + */ + function _createGeneratorComment() { + return "<!-- generator=\"".FEEDCREATOR_VERSION."\" -->\n"; + } + + + /** + * Creates a string containing all additional elements specified in + * $additionalElements. + * @param elements array an associative array containing key => value pairs + * @param indentString string a string that will be inserted before every generated line + * @return string the XML tags corresponding to $additionalElements + */ + function _createAdditionalElements($elements, $indentString="") { + $ae = ""; + if (is_array($elements)) { + foreach($elements AS $key => $value) { + $ae.= $indentString."<$key>$value</$key>\n"; + } + } + return $ae; + } + + function _createStylesheetReferences() { + $xml = ""; + if ($this->cssStyleSheet) $xml .= "<?xml-stylesheet href=\"".$this->cssStyleSheet."\" type=\"text/css\"?>\n"; + if ($this->xslStyleSheet) $xml .= "<?xml-stylesheet href=\"".$this->xslStyleSheet."\" type=\"text/xsl\"?>\n"; + return $xml; + } + + + /** + * Builds the feed's text. + * @abstract + * @return string the feed's complete text + */ + function createFeed() { + } + + /** + * Generate a filename for the feed cache file. The result will be $_SERVER["PHP_SELF"] with the extension changed to .xml. + * For example: + * + * echo $_SERVER["PHP_SELF"]."\n"; + * echo FeedCreator::_generateFilename(); + * + * would produce: + * + * /rss/latestnews.php + * latestnews.xml + * + * @return string the feed cache filename + * @since 1.4 + * @access private + */ + function _generateFilename() { + $fileInfo = pathinfo($_SERVER["PHP_SELF"]); + return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".xml"; + } + + + /** + * @since 1.4 + * @access private + */ + function _redirect($filename) { + // attention, heavily-commented-out-area + + // maybe use this in addition to file time checking + //Header("Expires: ".date("r",time()+$this->_timeout)); + + /* no caching at all, doesn't seem to work as good: + Header("Cache-Control: no-cache"); + Header("Pragma: no-cache"); + */ + + // HTTP redirect, some feed readers' simple HTTP implementations don't follow it + //Header("Location: ".$filename); + + Header("Content-Type: ".$this->contentType."; charset=".$this->encoding."; filename=".basename($filename)); + Header("Content-Disposition: inline; filename=".basename($filename)); + readfile($filename, "r"); + die(); + } + + /** + * Turns on caching and checks if there is a recent version of this feed in the cache. + * If there is, an HTTP redirect header is sent. + * To effectively use caching, you should create the FeedCreator object and call this method + * before anything else, especially before you do the time consuming task to build the feed + * (web fetching, for example). + * @since 1.4 + * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). + * @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) + */ + function useCached($filename="", $timeout=3600) { + $this->_timeout = $timeout; + if ($filename=="") { + $filename = $this->_generateFilename(); + } + if (@file_exists($filename) AND (time()-filemtime($filename) < $timeout)) { + $this->_redirect($filename); + } + } + + + /** + * Saves this feed as a file on the local disk. After the file is saved, a redirect + * header may be sent to redirect the user to the newly created file. + * @since 1.4 + * + * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). + * @param redirect boolean optional send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file. + */ + function saveFeed($filename="", $displayContents=true) { + if ($filename=="") { + $filename = $this->_generateFilename(); + } + $feedFile = fopen($filename, "w+"); + if ($feedFile) { + fputs($feedFile,$this->createFeed()); + fclose($feedFile); + if ($displayContents) { + $this->_redirect($filename); + } + } else { + echo "<br /><b>Error creating feed file, please check write permissions.</b><br />"; + } + } + +} + + +/** + * FeedDate is an internal class that stores a date for a feed or feed item. + * Usually, you won't need to use this. + */ +class FeedDate { + var $unix; + + /** + * Creates a new instance of FeedDate representing a given date. + * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps. + * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used. + */ + function FeedDate($dateString="") { + if ($dateString=="") $dateString = date("r"); + + if (is_integer($dateString)) { + $this->unix = $dateString; + return; + } + if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",$dateString,$matches)) { + $months = Array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); + $this->unix = mktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]); + if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') { + $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60; + } else { + if (strlen($matches[7])==1) { + $oneHour = 3600; + $ord = ord($matches[7]); + if ($ord < ord("M")) { + $tzOffset = (ord("A") - $ord - 1) * $oneHour; + } elseif ($ord >= ord("M") AND $matches[7]!="Z") { + $tzOffset = ($ord - ord("M")) * $oneHour; + } elseif ($matches[7]=="Z") { + $tzOffset = 0; + } + } + switch ($matches[7]) { + case "UT": + case "GMT": $tzOffset = 0; + } + } + $this->unix += $tzOffset; + return; + } + if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~",$dateString,$matches)) { + $this->unix = mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]); + if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') { + $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60; + } else { + if ($matches[7]=="Z") { + $tzOffset = 0; + } + } + $this->unix += $tzOffset; + return; + } + $this->unix = 0; + } + + /** + * Gets the date stored in this FeedDate as an RFC 822 date. + * + * @return a date in RFC 822 format + */ + function rfc822() { + //return gmdate("r",$this->unix); + $date = gmdate("D, d M Y H:i:s", $this->unix); + if (TIME_ZONE!="") $date .= " ".str_replace(":","",TIME_ZONE); + return $date; + } + + /** + * Gets the date stored in this FeedDate as an ISO 8601 date. + * + * @return a date in ISO 8601 format + */ + function iso8601() { + $date = gmdate("Y-m-d\TH:i:sO",$this->unix); + $date = substr($date,0,22) . ':' . substr($date,-2); + if (TIME_ZONE!="") $date = str_replace("+00:00",TIME_ZONE,$date); + return $date; + } + + /** + * Gets the date stored in this FeedDate as unix time stamp. + * + * @return a date as a unix time stamp + */ + function unix() { + return $this->unix; + } +} + + +/** + * RSSCreator10 is a FeedCreator that implements RDF Site Summary (RSS) 1.0. + * + * @see http://www.purl.org/rss/1.0/ + * @since 1.3 + * @author Kai Blankenhorn <kaib@bitfolge.de> + */ +class RSSCreator10 extends FeedCreator { + + /** + * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0. + * The feed will contain all items previously added in the same order. + * @return string the feed's complete text + */ + function createFeed() { + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; + $feed.= $this->_createGeneratorComment(); + if ($this->cssStyleSheet=="") { + $cssStyleSheet = "http://www.w3.org/2000/08/w3c-synd/style.css"; + } + $feed.= $this->_createStylesheetReferences(); + $feed.= "<rdf:RDF\n"; + $feed.= " xmlns=\"http://purl.org/rss/1.0/\"\n"; + $feed.= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; + $feed.= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; + $feed.= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; + $feed.= " <channel rdf:about=\"".$this->syndicationURL."\">\n"; + $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; + $feed.= " <description>".htmlspecialchars($this->description)."</description>\n"; + $feed.= " <link>".$this->link."</link>\n"; + if ($this->image!=null) { + $feed.= " <image rdf:resource=\"".$this->image->url."\" />\n"; + } + $now = new FeedDate(); + $feed.= " <dc:date>".htmlspecialchars($now->iso8601())."</dc:date>\n"; + $feed.= " <items>\n"; + $feed.= " <rdf:Seq>\n"; + for ($i=0;$i<count($this->items);$i++) { + $feed.= " <rdf:li rdf:resource=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; + } + $feed.= " </rdf:Seq>\n"; + $feed.= " </items>\n"; + $feed.= " </channel>\n"; + if ($this->image!=null) { + $feed.= " <image rdf:about=\"".$this->image->url."\">\n"; + $feed.= " <title>".$this->image->title."</title>\n"; + $feed.= " <link>".$this->image->link."</link>\n"; + $feed.= " <url>".$this->image->url."</url>\n"; + $feed.= " </image>\n"; + } + $feed.= $this->_createAdditionalElements($this->additionalElements, " "); + + for ($i=0;$i<count($this->items);$i++) { + $feed.= " <item rdf:about=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; + //$feed.= " <dc:type>Posting</dc:type>\n"; + $feed.= " <dc:format>text/html</dc:format>\n"; + if ($this->items[$i]->date!=null) { + $itemDate = new FeedDate($this->items[$i]->date); + $feed.= " <dc:date>".htmlspecialchars($itemDate->iso8601())."</dc:date>\n"; + } + if ($this->items[$i]->source!="") { + $feed.= " <dc:source>".htmlspecialchars($this->items[$i]->source)."</dc:source>\n"; + } + if ($this->items[$i]->author!="") { + $feed.= " <dc:creator>".htmlspecialchars($this->items[$i]->author)."</dc:creator>\n"; + } + $feed.= " <title>".htmlspecialchars(strip_tags(strtr($this->items[$i]->title,"\n\r"," ")))."</title>\n"; + $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; + $feed.= " <description>".htmlspecialchars($this->items[$i]->description)."</description>\n"; + $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); + $feed.= " </item>\n"; + } + $feed.= "</rdf:RDF>\n"; + return $feed; + } +} + + + +/** + * RSSCreator091 is a FeedCreator that implements RSS 0.91 Spec, revision 3. + * + * @see http://my.netscape.com/publish/formats/rss-spec-0.91.html + * @since 1.3 + * @author Kai Blankenhorn <kaib@bitfolge.de> + */ +class RSSCreator091 extends FeedCreator { + + /** + * Stores this RSS feed's version number. + * @access private + */ + var $RSSVersion; + + function RSSCreator091() { + $this->_setRSSVersion("0.91"); + $this->contentType = "application/rss+xml"; + } + + /** + * Sets this RSS feed's version number. + * @access private + */ + function _setRSSVersion($version) { + $this->RSSVersion = $version; + } + + /** + * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0. + * The feed will contain all items previously added in the same order. + * @return string the feed's complete text + */ + function createFeed() { + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; + $feed.= $this->_createGeneratorComment(); + $feed.= $this->_createStylesheetReferences(); + $feed.= "<rss version=\"".$this->RSSVersion."\">\n"; + $feed.= " <channel>\n"; + $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</title>\n"; + $this->descriptionTruncSize = 500; + $feed.= " <description>".$this->getDescription()."</description>\n"; + $feed.= " <link>".$this->link."</link>\n"; + $now = new FeedDate(); + $feed.= " <lastBuildDate>".htmlspecialchars($now->rfc822())."</lastBuildDate>\n"; + $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; + + if ($this->image!=null) { + $feed.= " <image>\n"; + $feed.= " <url>".$this->image->url."</url>\n"; + $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->image->title),100)."</title>\n"; + $feed.= " <link>".$this->image->link."</link>\n"; + if ($this->image->width!="") { + $feed.= " <width>".$this->image->width."</width>\n"; + } + if ($this->image->height!="") { + $feed.= " <height>".$this->image->height."</height>\n"; + } + if ($this->image->description!="") { + $feed.= " <description>".$this->image->getDescription()."</description>\n"; + } + $feed.= " </image>\n"; + } + if ($this->language!="") { + $feed.= " <language>".$this->language."</language>\n"; + } + if ($this->copyright!="") { + $feed.= " <copyright>".FeedCreator::iTrunc(htmlspecialchars($this->copyright),100)."</copyright>\n"; + } + if ($this->editor!="") { + $feed.= " <managingEditor>".FeedCreator::iTrunc(htmlspecialchars($this->editor),100)."</managingEditor>\n"; + } + if ($this->webmaster!="") { + $feed.= " <webMaster>".FeedCreator::iTrunc(htmlspecialchars($this->webmaster),100)."</webMaster>\n"; + } + if ($this->pubDate!="") { + $pubDate = new FeedDate($this->pubDate); + $feed.= " <pubDate>".htmlspecialchars($pubDate->rfc822())."</pubDate>\n"; + } + if ($this->category!="") { + $feed.= " <category>".htmlspecialchars($this->category)."</category>\n"; + } + if ($this->docs!="") { + $feed.= " <docs>".FeedCreator::iTrunc(htmlspecialchars($this->docs),500)."</docs>\n"; + } + if ($this->ttl!="") { + $feed.= " <ttl>".htmlspecialchars($this->ttl)."</ttl>\n"; + } + if ($this->rating!="") { + $feed.= " <rating>".FeedCreator::iTrunc(htmlspecialchars($this->rating),500)."</rating>\n"; + } + if ($this->skipHours!="") { + $feed.= " <skipHours>".htmlspecialchars($this->skipHours)."</skipHours>\n"; + } + if ($this->skipDays!="") { + $feed.= " <skipDays>".htmlspecialchars($this->skipDays)."</skipDays>\n"; + } + $feed.= $this->_createAdditionalElements($this->additionalElements, " "); + + for ($i=0;$i<count($this->items);$i++) { + $feed.= " <item>\n"; + $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100)."</title>\n"; + $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; + $feed.= " <description>".$this->items[$i]->getDescription()."</description>\n"; + + if ($this->items[$i]->author!="") { + $feed.= " <author>".htmlspecialchars($this->items[$i]->author)."</author>\n"; + } + /* + // on hold + if ($this->items[$i]->source!="") { + $feed.= " <source>".htmlspecialchars($this->items[$i]->source)."</source>\n"; + } + */ + if ($this->items[$i]->category!="") { + $feed.= " <category>".htmlspecialchars($this->items[$i]->category)."</category>\n"; + } + if ($this->items[$i]->comments!="") { + $feed.= " <comments>".htmlspecialchars($this->items[$i]->comments)."</comments>\n"; + } + if ($this->items[$i]->date!="") { + $itemDate = new FeedDate($this->items[$i]->date); + $feed.= " <pubDate>".htmlspecialchars($itemDate->rfc822())."</pubDate>\n"; + } + if ($this->items[$i]->guid!="") { + $feed.= " <guid>".htmlspecialchars($this->items[$i]->guid)."</guid>\n"; + } + $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); + $feed.= " </item>\n"; + } + $feed.= " </channel>\n"; + $feed.= "</rss>\n"; + return $feed; + } +} + + + +/** + * RSSCreator20 is a FeedCreator that implements RDF Site Summary (RSS) 2.0. + * + * @see http://backend.userland.com/rss + * @since 1.3 + * @author Kai Blankenhorn <kaib@bitfolge.de> + */ +class RSSCreator20 extends RSSCreator091 { + + function RSSCreator20() { + parent::_setRSSVersion("2.0"); + } + +} + + +/** + * PIECreator01 is a FeedCreator that implements the emerging PIE specification, + * as in http://intertwingly.net/wiki/pie/Syntax. + * + * @deprecated + * @since 1.3 + * @author Scott Reynen <scott@randomchaos.com> and Kai Blankenhorn <kaib@bitfolge.de> + */ +class PIECreator01 extends FeedCreator { + + function PIECreator01() { + $this->encoding = "utf-8"; + } + + function createFeed() { + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; + $feed.= $this->_createStylesheetReferences(); + $feed.= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; + $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</title>\n"; + $this->truncSize = 500; + $feed.= " <subtitle>".$this->getDescription()."</subtitle>\n"; + $feed.= " <link>".$this->link."</link>\n"; + for ($i=0;$i<count($this->items);$i++) { + $feed.= " <entry>\n"; + $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100)."</title>\n"; + $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; + $itemDate = new FeedDate($this->items[$i]->date); + $feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; + $feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; + $feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; + $feed.= " <id>".htmlspecialchars($this->items[$i]->guid)."</id>\n"; + if ($this->items[$i]->author!="") { + $feed.= " <author>\n"; + $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; + if ($this->items[$i]->authorEmail!="") { + $feed.= " <email>".$this->items[$i]->authorEmail."</email>\n"; + } + $feed.=" </author>\n"; + } + $feed.= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; + $feed.= " <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription()."</div>\n"; + $feed.= " </content>\n"; + $feed.= " </entry>\n"; + } + $feed.= "</feed>\n"; + return $feed; + } +} + + +/** + * AtomCreator03 is a FeedCreator that implements the atom specification, + * as in http://www.intertwingly.net/wiki/pie/FrontPage. + * Please note that just by using AtomCreator03 you won't automatically + * produce valid atom files. For example, you have to specify either an editor + * for the feed or an author for every single feed item. + * + * Some elements have not been implemented yet. These are (incomplete list): + * author URL, item author's email and URL, item contents, alternate links, + * other link content types than text/html. Some of them may be created with + * AtomCreator03::additionalElements. + * + * @see FeedCreator#additionalElements + * @since 1.6 + * @author Kai Blankenhorn <kaib@bitfolge.de>, Scott Reynen <scott@randomchaos.com> + */ +class AtomCreator03 extends FeedCreator { + + function AtomCreator03() { + $this->contentType = "application/atom+xml"; + $this->encoding = "utf-8"; + } + + function createFeed() { + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; + $feed.= $this->_createGeneratorComment(); + $feed.= $this->_createStylesheetReferences(); + $feed.= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; + if ($this->language!="") { + $feed.= " xml:lang=\"".$this->language."\""; + } + $feed.= ">\n"; + $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; + $feed.= " <tagline>".htmlspecialchars($this->description)."</tagline>\n"; + $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; + $feed.= " <id>".htmlspecialchars($this->link)."</id>\n"; + $now = new FeedDate(); + $feed.= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n"; + if ($this->editor!="") { + $feed.= " <author>\n"; + $feed.= " <name>".$this->editor."</name>\n"; + if ($this->editorEmail!="") { + $feed.= " <email>".$this->editorEmail."</email>\n"; + } + $feed.= " </author>\n"; + } + $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; + $feed.= $this->_createAdditionalElements($this->additionalElements, " "); + for ($i=0;$i<count($this->items);$i++) { + $feed.= " <entry>\n"; + $feed.= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; + $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; + if ($this->items[$i]->date=="") { + $this->items[$i]->date = time(); + } + $itemDate = new FeedDate($this->items[$i]->date); + $feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; + $feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; + $feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; + $feed.= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; + $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); + if ($this->items[$i]->author!="") { + $feed.= " <author>\n"; + $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; + $feed.= " </author>\n"; + } + if ($this->items[$i]->description!="") { + $feed.= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; + } + $feed.= " </entry>\n"; + } + $feed.= "</feed>\n"; + return $feed; + } +} + + +/** + * MBOXCreator is a FeedCreator that implements the mbox format + * as described in http://www.qmail.org/man/man5/mbox.html + * + * @since 1.3 + * @author Kai Blankenhorn <kaib@bitfolge.de> + */ +class MBOXCreator extends FeedCreator { + + function MBOXCreator() { + $this->contentType = "text/plain"; + $this->encoding = "ISO-8859-15"; + } + + function qp_enc($input = "", $line_max = 76) { + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $lines = preg_split("/(?:\r\n|\r|\n)/", $input); + $eol = "\r\n"; + $escape = "="; + $output = ""; + while( list(, $line) = each($lines) ) { + //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary + $linlen = strlen($line); + $newline = ""; + for($i = 0; $i < $linlen; $i++) { + $c = substr($line, $i, 1); + $dec = ord($c); + if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only + $c = "=20"; + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); $h1 = floor($dec%16); + $c = $escape.$hex["$h2"].$hex["$h1"]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay + $newline = ""; + } + $newline .= $c; + } // end of for + $output .= $newline.$eol; + } + return trim($output); + } + + + /** + * Builds the MBOX contents. + * @return string the feed's complete text + */ + function createFeed() { + for ($i=0;$i<count($this->items);$i++) { + if ($this->items[$i]->author!="") { + $from = $this->items[$i]->author; + } else { + $from = $this->title; + } + $itemDate = new FeedDate($this->items[$i]->date); + $feed.= "From ".strtr(MBOXCreator::qp_enc($from)," ","_")." ".date("D M d H:i:s Y",$itemDate->unix())."\n"; + $feed.= "Content-Type: text/plain;\n"; + $feed.= " charset=\"".$this->encoding."\"\n"; + $feed.= "Content-Transfer-Encoding: quoted-printable\n"; + $feed.= "Content-Type: text/plain\n"; + $feed.= "From: \"".MBOXCreator::qp_enc($from)."\"\n"; + $feed.= "Date: ".$itemDate->rfc822()."\n"; + $feed.= "Subject: ".MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title,100))."\n"; + $feed.= "\n"; + $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description)); + $feed.= preg_replace("~\nFrom ([^\n]*)(\n?)~","\n>From $1$2\n",$body); + $feed.= "\n"; + $feed.= "\n"; + } + return $feed; + } + + /** + * Generate a filename for the feed cache file. Overridden from FeedCreator to prevent XML data types. + * @return string the feed cache filename + * @since 1.4 + * @access private + */ + function _generateFilename() { + $fileInfo = pathinfo($_SERVER["PHP_SELF"]); + return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".mbox"; + } +} + + +/** + * OPMLCreator is a FeedCreator that implements OPML 1.0. + * + * @see http://opml.scripting.com/spec + * @author Dirk Clemens, Kai Blankenhorn + * @since 1.5 + */ +class OPMLCreator extends FeedCreator { + + function OPMLCreator() { + $this->encoding = "utf-8"; + } + + function createFeed() { + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; + $feed.= $this->_createGeneratorComment(); + $feed.= $this->_createStylesheetReferences(); + $feed.= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; + $feed.= " <head>\n"; + $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; + if ($this->pubDate!="") { + $date = new FeedDate($this->pubDate); + $feed.= " <dateCreated>".$date->rfc822()."</dateCreated>\n"; + } + if ($this->lastBuildDate!="") { + $date = new FeedDate($this->lastBuildDate); + $feed.= " <dateModified>".$date->rfc822()."</dateModified>\n"; + } + if ($this->editor!="") { + $feed.= " <ownerName>".$this->editor."</ownerName>\n"; + } + if ($this->editorEmail!="") { + $feed.= " <ownerEmail>".$this->editorEmail."</ownerEmail>\n"; + } + $feed.= " </head>\n"; + $feed.= " <body>\n"; + for ($i=0;$i<count($this->items);$i++) { + $feed.= " <outline type=\"rss\" "; + $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title,"\n\r"," "))); + $feed.= " title=\"".$title."\""; + $feed.= " text=\"".$title."\""; + //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\""; + $feed.= " url=\"".htmlspecialchars($this->items[$i]->link)."\""; + $feed.= "/>\n"; + } + $feed.= " </body>\n"; + $feed.= "</opml>\n"; + return $feed; + } +} + + + +/** + * HTMLCreator is a FeedCreator that writes an HTML feed file to a specific + * location, overriding the createFeed method of the parent FeedCreator. + * The HTML produced can be included over http by scripting languages, or serve + * as the source for an IFrame. + * All output by this class is embedded in <div></div> tags to enable formatting + * using CSS. + * + * @author Pascal Van Hecke + * @since 1.7 + */ +class HTMLCreator extends FeedCreator { + + var $contentType = "text/html"; + + /** + * Contains HTML to be output at the start of the feed's html representation. + */ + var $header; + + /** + * Contains HTML to be output at the end of the feed's html representation. + */ + var $footer ; + + /** + * Contains HTML to be output between entries. A separator is only used in + * case of multiple entries. + */ + var $separator; + + /** + * Used to prefix the stylenames to make sure they are unique + * and do not clash with stylenames on the users' page. + */ + var $stylePrefix; + + /** + * Determines whether the links open in a new window or not. + */ + var $openInNewWindow = true; + + var $imageAlign ="right"; + + /** + * In case of very simple output you may want to get rid of the style tags, + * hence this variable. There's no equivalent on item level, but of course you can + * add strings to it while iterating over the items ($this->stylelessOutput .= ...) + * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored + * in the function createFeed(). + */ + var $stylelessOutput =""; + + /** + * Writes the HTML. + * @return string the scripts's complete text + */ + function createFeed() { + // if there is styleless output, use the content of this variable and ignore the rest + if ($this->stylelessOutput!="") { + return $this->stylelessOutput; + } + + //if no stylePrefix is set, generate it yourself depending on the script name + if ($this->stylePrefix=="") { + $this->stylePrefix = str_replace(".", "_", $this->_generateFilename())."_"; + } + + //set an openInNewWindow_token_to be inserted or not + if ($this->openInNewWindow) { + $targetInsert = " target='_blank'"; + } + + // use this array to put the lines in and implode later with "document.write" javascript + $feedArray = array(); + if ($this->image!=null) { + $imageStr = "<a href='".$this->image->link."'".$targetInsert.">". + "<img src='".$this->image->url."' border='0' alt='". + FeedCreator::iTrunc(htmlspecialchars($this->image->title),100). + "' align='".$this->imageAlign."' "; + if ($this->image->width) { + $imageStr .=" width='".$this->image->width. "' "; + } + if ($this->image->height) { + $imageStr .=" height='".$this->image->height."' "; + } + $imageStr .="/></a>"; + $feedArray[] = $imageStr; + } + + if ($this->title) { + $feedArray[] = "<div class='".$this->stylePrefix."title'><a href='".$this->link."' ".$targetInsert." class='".$this->stylePrefix."title'>". + FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</a></div>"; + } + if ($this->getDescription()) { + $feedArray[] = "<div class='".$this->stylePrefix."description'>". + str_replace("]]>", "", str_replace("<![CDATA[", "", $this->getDescription())). + "</div>"; + } + + if ($this->header) { + $feedArray[] = "<div class='".$this->stylePrefix."header'>".$this->header."</div>"; + } + + for ($i=0;$i<count($this->items);$i++) { + if ($this->separator and $i > 0) { + $feedArray[] = "<div class='".$this->stylePrefix."separator'>".$this->separator."</div>"; + } + + if ($this->items[$i]->title) { + if ($this->items[$i]->link) { + $feedArray[] = + "<div class='".$this->stylePrefix."item_title'><a href='".$this->items[$i]->link."' class='".$this->stylePrefix. + "item_title'".$targetInsert.">".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100). + "</a></div>"; + } else { + $feedArray[] = + "<div class='".$this->stylePrefix."item_title'>". + FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100). + "</div>"; + } + } + if ($this->items[$i]->getDescription()) { + $feedArray[] = + "<div class='".$this->stylePrefix."item_description'>". + str_replace("]]>", "", str_replace("<![CDATA[", "", $this->items[$i]->getDescription())). + "</div>"; + } + } + if ($this->footer) { + $feedArray[] = "<div class='".$this->stylePrefix."footer'>".$this->footer."</div>"; + } + + $feed= "".join($feedArray, "\r\n"); + return $feed; + } + + /** + * Overrrides parent to produce .html extensions + * + * @return string the feed cache filename + * @since 1.4 + * @access private + */ + function _generateFilename() { + $fileInfo = pathinfo($_SERVER["PHP_SELF"]); + return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".html"; + } +} + + +/** + * JSCreator is a class that writes a js file to a specific + * location, overriding the createFeed method of the parent HTMLCreator. + * + * @author Pascal Van Hecke + */ +class JSCreator extends HTMLCreator { + var $contentType = "text/javascript"; + + /** + * writes the javascript + * @return string the scripts's complete text + */ + function createFeed() + { + $feed = parent::createFeed(); + $feedArray = explode("\n",$feed); + + $jsFeed = ""; + foreach ($feedArray as $value) { + $jsFeed .= "document.write('".trim(addslashes($value))."');\n"; + } + return $jsFeed; + } + + /** + * Overrrides parent to produce .js extensions + * + * @return string the feed cache filename + * @since 1.4 + * @access private + */ + function _generateFilename() { + $fileInfo = pathinfo($_SERVER["PHP_SELF"]); + return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".js"; + } + +} + + + +/*** TEST SCRIPT ********************************************************* + +//include("feedcreator.class.php"); + +$rss = new UniversalFeedCreator(); +$rss->useCached(); +$rss->title = "PHP news"; +$rss->description = "daily news from the PHP scripting world"; + +//optional +//$rss->descriptionTruncSize = 500; +//$rss->descriptionHtmlSyndicated = true; +//$rss->xslStyleSheet = "http://feedster.com/rss20.xsl"; + +$rss->link = "http://www.dailyphp.net/news"; +$rss->feedURL = "http://www.dailyphp.net/".$PHP_SELF; + +$image = new FeedImage(); +$image->title = "dailyphp.net logo"; +$image->url = "http://www.dailyphp.net/images/logo.gif"; +$image->link = "http://www.dailyphp.net"; +$image->description = "Feed provided by dailyphp.net. Click to visit."; + +//optional +$image->descriptionTruncSize = 500; +$image->descriptionHtmlSyndicated = true; + +$rss->image = $image; + +// get your news items from somewhere, e.g. your database: +//mysql_select_db($dbHost, $dbUser, $dbPass); +//$res = mysql_query("SELECT * FROM news ORDER BY newsdate DESC"); +//while ($data = mysql_fetch_object($res)) { + $item = new FeedItem(); + $item->title = "This is an the test title of an item"; + $item->link = "http://localhost/item/"; + $item->description = "<b>description in </b><br/>HTML"; + + //optional + //item->descriptionTruncSize = 500; + $item->descriptionHtmlSyndicated = true; + + $item->date = time(); + $item->source = "http://www.dailyphp.net"; + $item->author = "John Doe"; + + $rss->addItem($item); +//} + +// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML, ATOM0.3, HTML, JS +echo $rss->saveFeed("RSS0.91", "feed.xml"); + + + +***************************************************************************/ + +/** + * This class allows to override the hardcoded charset + * + * @author Andreas Gohr + */ +class DokuWikiFeedCreator extends UniversalFeedCreator{ + function createFeed($format = "RSS0.91",$encoding='iso-8859-15') { + $this->_setFormat($format); + $this->_feed->encoding = $encoding; + return $this->_feed->createFeed(); + } +} + + +?> diff --git a/inc/format.php b/inc/format.php new file mode 100644 index 000000000..806ea5010 --- /dev/null +++ b/inc/format.php @@ -0,0 +1,475 @@ +<? +require_once("conf/dokuwiki.php"); +require_once("inc/common.php"); + + +/** + * Assembles all parts defined by the link formater below + * Returns HTML for the link + */ +function format_link_build($link){ + //make sure the url is XHTML compliant + $link['url'] = str_replace('&','&',$link['url']); + $link['url'] = str_replace('&amp;','&',$link['url']); + + $ret = ''; + $ret .= $link['pre']; + $ret .= '<a href="'.$link['url'].'"'; + if($link['class']) $ret .= ' class="'.$link['class'].'"'; + if($link['target']) $ret .= ' target="'.$link['target'].'"'; + if($link['title']) $ret .= ' title="'.$link['title'].'"'; + if($link['style']) $ret .= ' style="'.$link['style'].'"'; + if($link['more']) $ret .= ' '.$link['more']; + $ret .= '>'; + $ret .= $link['name']; + $ret .= '</a>'; + $ret .= $link['suf']; + return $ret; +} + +/** + * Link Formaters + * + * Each of these functions need to set + * + * $link['url'] URL to use in href="" + * $link['name'] HTML to enclose in <a> with proper special char encoding + * $link['class'] CSS class to set on link + * $link['target'] which target to use (blank) for current window + * $link['style'] Additonal style attribute set with style="" + * $link['title'] Title to set with title="" + * $link['pre'] HTML to prepend to link + * $link['suf'] HTML to append to link + * $link['more'] Additonal HTML to include into the anchortag + * + */ + +function format_link_wiki($link){ + global $conf; + global $ID; //we use this to get the current namespace + //obvious setup + $link['target'] = $conf['target']['wiki']; + $link['style'] = ''; + $link['pre'] = ''; + $link['suf'] = ''; + $link['more'] = 'onclick="return svchk()" onkeypress="return svchk()"'; + + //if links starts with . add current namespace if any + if(strpos($link['url'],'.')===0){ + $ns = substr($ID,0,strrpos($ID,':')); #get current ns + $link['url'] = $ns.':'.substr($link['url'],1); + } + + //if link contains no namespace. add current namespace (if any) + if(strpos($ID,':')!==false && strpos($link['url'],':') === false){ + $ns = substr($ID,0,strrpos($ID,':')); #get current ns + $link['url'] = $ns.':'.$link['url']; + } + + //keep hashlink if exists + list($link['url'],$hash) = split('#',$link['url'],2); + $hash = cleanID($hash); + + //use link without namespace as name + if(empty($link['name'])) $link['name'] = preg_replace('/.*:/','',$link['url']); + $link['name'] = htmlspecialchars($link['name']); + + $link['url'] = cleanID($link['url']); + $link['title'] = $link['url']; + + //set class depending on existance + $file = wikiFN($link['url']); + if(@file_exists($file)){ + $link['class']="wikilink1"; + }else{ + if($conf['autoplural']){ + //try plural/nonplural + if(substr($link['url'],-1) == 's'){ + $try = substr($link['url'],0,-1); + }else{ + $try = $link['url'].'s'; + } + $file = wikiFN($try); + //check if the other form exists + if(@file_exists($file)){ + $link['class']="wikilink1"; + $link['url'] = $try; + }else{ + $link['class']="wikilink2"; + } + }else{ + //no autoplural is wanted + $link['class']="wikilink2"; + } + } + + //construct the full link + $link['url'] = wl($link['url']); + + //add hash if exists + if($hash) $link['url'] .= '#'.$hash; + + return $link; +} + +function format_link_externalurl($link){ + global $conf; + //simple setup + $link['class'] = 'urlextern'; + $link['target'] = $conf['target']['extern']; + $link['pre'] = ''; + $link['suf'] = ''; + $link['style'] = ''; + $link['more'] = 'onclick="return svchk()" onkeypress="return svchk()"'; + $link['url'] = $link['url']; //keep it + $link['title'] = htmlspecialchars($link['url']); + if(!$link['name']) $link['name'] = htmlspecialchars($link['url']); + //thats it :-) + return $link; +} + +//this only works in IE :-( +function format_link_windows($link){ + global $conf; + global $lang; + //simple setup + $link['class'] = 'windows'; + $link['target'] = $conf['target']['windows']; + $link['pre'] = ''; + $link['suf'] = ''; + $link['style'] = ''; + //Display error on browsers other than IE + $link['more'] = 'onclick="if(document.all == null){alert(\''.htmlspecialchars($lang['nosmblinks'],ENT_QUOTES).'\');}" onkeypress="if(document.all == null){alert(\''.htmlspecialchars($lang['nosmblinks'],ENT_QUOTES).'\');}"'; + + if(!$link['name']) $link['name'] = htmlspecialchars($link['url']); + $link['title'] = htmlspecialchars($link['url']); + $link['url'] = str_replace('\\','/',$link['url']); + $link['url'] = 'file:///'.$link['url']; + + return $link; +} + +function format_link_email($link){ + global $conf; + //simple setup + $link['class'] = 'mail'; + $link['target'] = ''; + $link['pre'] = ''; + $link['suf'] = ''; + $link['style'] = ''; + $link['more'] = ''; + + $link['name'] = htmlspecialchars($link['name']); + + //shields up + if($conf['mailguard']=='visible'){ + //the mail name gets some visible encoding + $link['url'] = str_replace('@',' [at] ',$link['url']); + $link['url'] = str_replace('.',' [dot] ',$link['url']); + $link['url'] = str_replace('-',' [dash] ',$link['url']); + }elseif($conf['mailguard']=='hex'){ + for ($x=0; $x < strlen($link['url']); $x++) { + $encode .= '&#x' . bin2hex($link['url'][$x]).';'; + } + $link['url'] = $encode; + } + + $link['title'] = $link['url']; + if(!$link['name']) $link['name'] = $link['url']; + $link['url'] = 'mailto:'.$link['url']; + + return $link; +} + +function format_link_interwiki($link){ + global $conf; + + //obvious ones + $link['class'] = 'interwiki'; + $link['target'] = $conf['target']['interwiki']; + $link['pre'] = ''; + $link['suf'] = ''; + $link['more'] = 'onclick="return svchk()" onkeypress="return svchk()"'; + + //get interwiki short name + list($wiki,$link['url']) = split('>',$link['url'],2); + $wiki = strtolower(trim($wiki)); //always use lowercase + $link['url'] = trim($link['url']); + if(!$link['name']) $link['name'] = $link['url']; + + //encode special chars + $link['name'] = htmlspecialchars($link['name']); + + //set default to google + $url = 'http://www.google.com/search?q='; + $ico = 'google'; + + //load interwikilinks + //FIXME: loading this once may enhance speed a little bit + $iwlinks = file('conf/interwiki.conf'); + + //add special case 'this' + $iwlinks[] = 'this '.getBaseURL(true).'{NAME}'; + + //go through iwlinks and find URL for wiki + foreach ($iwlinks as $line){ + $line = preg_replace('/#.*/','',$line); //skip comments + $line = trim($line); + list($iw,$iwurl) = preg_split('/\s+/',$line); + if(!$iw or !$iwurl) continue; //skip broken or empty lines + //check for match + if(strtolower($iw) == $wiki){ + $ico = $wiki; + $url = $iwurl; + break; + } + } + + //if ico exists set additonal style + if(@file_exists('interwiki/'.$ico.'.png')){ + $link['style']='background: transparent url('.getBaseURL().'interwiki/'.$ico.'.png) 0px 1px no-repeat;'; + }elseif(@file_exists('interwiki/'.$ico.'.gif')){ + $link['style']='background: transparent url('.getBaseURL().'interwiki/'.$ico.'.gif) 0px 1px no-repeat;'; + } + + //do we stay at the same server? Use local target + if( strpos($url,getBaseURL(true)) === 0 ){ + $link['target'] = $conf['target']['wiki']; + } + + //replace placeholder + if(strstr($url,'{URL}') !== false){ + $link['url'] = str_replace('{URL}',urlencode($link['url']),$url); + }elseif(strstr($url,'{NAME}') !== false){ + $link['url'] = str_replace('{NAME}',$link['url'],$url); + }else{ + $link['url'] = $url.urlencode($link['url']); + } + + $link['title'] = htmlspecialchars($link['url']); + + //done :-) + return $link; +} + + +function format_link_media($link){ + global $conf; + + $link['class'] = 'media'; + $link['style'] = ''; + $link['pre'] = ''; + $link['suf'] = ''; + $link['more'] = 'onclick="return svchk()" onkeypress="return svchk()"'; + $class = 'media'; + + list($link['name'],$title) = split('\|',$link['name'],2); + $t = htmlspecialchars($title); + + //set alignment from spaces + if(substr($link['name'],0,1)==' ' && substr($link['name'],-1,1)==' '){ + $link['pre'] = "</p>\n<div align=\"center\">"; + $link['suf'] = "</div>\n<p>"; + }elseif(substr($link['name'],0,1)==' '){ + #$a = ' align="right"'; + $class = 'mediaright'; + }elseif(substr($link['name'],-1,1)==' '){ + #$a = ' align="left"'; + $class = 'medialeft'; + }else{ + $a = ' align="middle"'; + } + $link['name'] = trim($link['name']); + + //split into src and parameters + list($src,$param) = split('\?',$link['name'],2); + //parse width and height + if(preg_match('#(\d*)(x(\d*))?#i',$param,$size)){ + if($size[1]) $w = $size[1]; + if($size[3]) $h = $size[3]; + } + + //check for nocache param + $nocache = preg_match('/nocache/i',$param); + //do image caching, resizing and src rewriting + $cache = $src; + $isimg = img_cache($cache,$src,$w,$h,$nocache); + + //set link to src if none given + if(!$link['url']){ + $link['url'] = $src; + $link['target'] = $conf['target']['media']; + } + + //prepare name + if($isimg){ + $link['name'] = '<img src="'.getBaseURL().$cache.'"'; + if($w) $link['name'] .= ' width="'.$w.'"'; + if($h) $link['name'] .= ' height="'.$h.'"'; + if($t) $link['name'] .= ' title="'.$t.'"'; + if($a) $link['name'] .= $a; + $link['name'] .= ' class="'.$class.'" border="0" alt="'.$t.'" />'; + }else{ + if($t){ + $link['name'] = $t; + }else{ + $link['name'] = basename($src); + } + } + + return $link; +} + +/** + * Builds an URL list from a RSS feed + */ +function format_rss($url){ + global $lang; + define('MAGPIE_DIR', 'inc/magpie/'); + require_once(MAGPIE_DIR.'/rss_fetch.inc'); + + //disable warning while fetching + $elvl = error_reporting(E_ERROR); + $rss = fetch_rss($url); + error_reporting($elvl); + + $ret = '<ul class="rss">'; + if($rss){ + foreach ($rss->items as $item ) { + $link = array(); + $link['url'] = $item['link']; + $link['name'] = $item['title']; + $link = format_link_externalurl($link); + $ret .= '<li>'.format_link_build($link).'</li>'; + } + }else{ + $link['url'] = $url; + $link = format_link_externalurl($link); + $ret .= '<li>'; + $ret .= '<em>'.$lang['rssfailed'].'</em>'; + $ret .= format_link_build($link); + $ret .= '</li>'; + } + $ret .= '</ul>'; + return $ret; +} + + +function img_cache(&$csrc,&$src,&$w,&$h,$nocache){ + global $conf; + + //container for various paths + $f['full']['web'] = $src; + $f['resz']['web'] = $src; + $f['full']['fs'] = $src; + $f['resz']['fs'] = $src; + + //generate cachename + $md5 = md5($src); + + //check if it is an image + if(preg_match('#\.(jpe?g|gif|png)$#i',$src,$match)){ + $ext = strtolower($match[1]); + $isimg = true; + } + + //check if it is external or a local mediafile + if(preg_match('#^([a-z0-9]+?)://#i',$src)){ + $isurl = true; + }else{ + $src = str_replace(':','/',$src); + $f['full']['web'] = $conf['mediaweb'].'/'.$src; + $f['resz']['web'] = $conf['mediaweb'].'/'.$src; + $f['full']['fs'] = $conf['mediadir'].'/'.$src; + $f['resz']['fs'] = $conf['mediadir'].'/'.$src; + } + + //download external images if allowed + if($isurl && $isimg && !$nocache){ + $cache = $conf['mediadir']."/.cache/$md5.$ext"; + if (@file_exists($cache) || download($src,$cache)){ + $f['full']['web'] = $conf['mediaweb']."/.cache/$md5.$ext"; + $f['resz']['web'] = $conf['mediaweb']."/.cache/$md5.$ext"; + $f['full']['fs'] = $conf['mediadir']."/.cache/$md5.$ext"; + $f['resz']['fs'] = $conf['mediadir']."/.cache/$md5.$ext"; + $isurl = false; + } + } + + //for local images (cached or media) do resizing + if($isimg && (!$isurl) && $w){ + $info = getImageSize($f['full']['fs']); + //if $h not given calcualte it with correct aspect ratio + if(!$h){ + $h = round(($w * $info[1]) / $info[0]); + } + $cache = $conf['mediadir'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext; + //delete outdated cachefile + if(@file_exists($cache) && (filemtime($cache)<filemtime($f['full']['fs']))){ + unlink($cache); + } + //check if a resized cachecopy exists else create one + if(@file_exists($cache) || img_resize($ext,$f['full']['fs'],$info[0],$info[1],$cache,$w,$h)){ + $f['resz']['web'] = $conf['mediaweb'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext; + $f['resz']['fs'] = $conf['mediadir'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext; + } + }elseif($isimg && (!$isurl)){ + //if no new size was given just return the img size + $info = getImageSize($f['full']['fs']); + $w = $info[0]; + $h = $info[1]; + } + + //set srcs + $src = $f['full']['web']; + $csrc = $f['resz']['web']; + return $isimg; +} + +function img_resize($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ + // create cachedir + io_makeFileDir($to); + + // create an image of the given filetype + if ($ext == 'jpg' || $ext == 'jpeg'){ + if(!function_exists("imagecreatefromjpeg")) return false; + $image = @imagecreateFromjpeg($from); + }elseif($ext == 'png') { + if(!function_exists("imagecreatefrompng")) return false; + $image = @imagecreatefrompng($from); + }elseif($ext == 'gif') { + if(!function_exists("imagecreatefromgif")) return false; + $image = @imagecreatefromgif($from); + } + if(!$image) return false; + + if(function_exists("imagecreatetruecolor")){ + $newimg = @imagecreatetruecolor ($to_w, $to_h); + } + if(!$newimg) $newimg = @imagecreate($to_w, $to_h); + if(!$newimg) return false; + + //try resampling first + if(function_exists("imagecopyresampled")){ + if(!@imagecopyresampled($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h)) { + imagecopyresized($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h); + } + }else{ + imagecopyresized($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h); + } + + if ($ext == 'jpg' || $ext == 'jpeg'){ + if(!function_exists("imagejpeg")) return false; + return imagejpeg($newimg, $to, 70); + }elseif($ext == 'png') { + if(!function_exists("imagepng")) return false; + return imagepng($newimg, $to); + }elseif($ext == 'gif') { + if(!function_exists("imagegif")) return false; + return imagegif($newimg, $to); + } + + return false; +} + +?> diff --git a/inc/geshi.php b/inc/geshi.php new file mode 100644 index 000000000..c1231fb59 --- /dev/null +++ b/inc/geshi.php @@ -0,0 +1,2413 @@ +<?php +/************************************************************************************* + * geshi.php + * --------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie + * Release Version: 1.0.4 + * CVS Revision Version: $Revision: 1.6 $ + * Date Started: 2004/05/20 + * Last Modified: $Date: 2004/11/27 00:57:58 $ + * + * The GeSHi class for Generic Syntax Highlighting. Please refer to the documentation + * at http://qbnz.com/highlighter/documentation.php for more information about how to + * use this class. + * + * For changes, release notes, TODOs etc, see the relevant files in the docs/ directory + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + + +// +// GeSHi Constants +// You should use these constant names in your programs instead of +// their values - you never know when a value may change in a future +// version +// + +// For the future (though this may never be realised) +define('GESHI_OUTPUT_HTML', 0); + +// Shouldn't be used by your program +define('GESHI_COMMENTS', 0); + +// Error detection - use these to analyse faults +define('GESHI_ERROR_NO_INPUT', 1); +define('GESHI_ERROR_NO_SUCH_LANG', 2); +// Human error messages - added in 1.0.2 +$_GESHI_ERRORS = array( + GESHI_ERROR_NO_INPUT => 'No source code inputted', + GESHI_ERROR_NO_SUCH_LANG => 'GeSHi could not find the language {LANGUAGE} (using path {PATH})' +); + +// Line numbers - use with enable_line_numbers() +define('GESHI_NO_LINE_NUMBERS', 0); +define('GESHI_NORMAL_LINE_NUMBERS', 1); +define('GESHI_FANCY_LINE_NUMBERS', 2); + +// Strict mode - shouldn't be used by your scripts +define('GESHI_NEVER', 0); +define('GESHI_MAYBE', 1); +define('GESHI_ALWAYS', 2); + +// Container HTML type - use these (added in 1.0.1) +define('GESHI_HEADER_DIV', 1); +define('GESHI_HEADER_PRE', 2); + +// Capatalisation constants - use these (added in 1.0.1) +define('GESHI_CAPS_NO_CHANGE', 0); +define('GESHI_CAPS_UPPER', 1); +define('GESHI_CAPS_LOWER', 2); + +// Link style constants - use these (added in 1.0.2) +define('GESHI_LINK', 0); +define('GESHI_HOVER', 1); +define('GESHI_ACTIVE', 2); +define('GESHI_VISITED', 3); + +// Important string starter/finisher - use these (added in 1.0.2). +// Note that if you change these, they should be as-is: i.e., don't +// write them as if they had been run through htmlentities() +define('GESHI_START_IMPORTANT', '<BEGIN GeSHi>'); +define('GESHI_END_IMPORTANT', '<END GeSHi>'); + +// Advanced regexp handling - don't use these (added in 1.0.2) +define('GESHI_SEARCH', 0); +define('GESHI_REPLACE', 1); +define('GESHI_MODIFIERS', 2); +define('GESHI_BEFORE', 3); +define('GESHI_AFTER', 4); + +// Begin Class GeSHi +class GeSHi +{ + // + // Data Fields + // + + // Basic fields + var $source = ''; // The source code to highlight + var $language = ''; // The language to use when highlighting + var $language_data = array(); // The data for the language used + var $language_path = 'geshi/'; // The path to the language files + var $error = false; // The error message associated with an error + var $strict_mode = false; // Whether highlighting is strict or not + var $use_classes = false; // Whether to use classes + var $header_type = GESHI_HEADER_PRE; // The type of header to use + var $lexic_permissions = array(); // Array of permissions for which lexics should be highlighted + // Added in 1.0.2 basic fields + var $time = 0; // The time it took to parse the code + var $header_content = ''; // The content of the header block + var $footer_content = ''; // The content of the footer block + var $header_content_style = ''; // The style of the header block + var $footer_content_style = ''; // The style of the footer block + var $link_styles = array(); // The styles for hyperlinks in the code + var $enable_important_blocks = true; // Whether important blocks should be recognised or not + var $important_styles = 'font-weight: bold; color: red;'; // Styles for important parts of the code + var $add_ids = false; // Whether css IDs should be added to the code + var $highlight_extra_lines = array(); // Lines that should be highlighted extra + var $highlight_extra_lines_style = 'color: #cc0; background-color: #ffc;';// Styles of extra-highlighted lines + var $line_numbers_start = 1; // Number at which line numbers should start at + + // Style fields + var $overall_style = ''; // The overall style for this code block + // The style for the actual code + var $code_style = 'font-family: \'Courier New\', Courier, monospace; font-weight: normal;'; + var $overall_class = ''; // The overall class for this code block + var $overall_id = ''; // The overall id for this code block + // Line number styles + var $line_style1 = 'font-family: \'Courier New\', Courier, monospace; color: black; font-weight: normal; font-style: normal;'; + var $line_style2 = 'font-weight: bold;'; + var $line_numbers = GESHI_NO_LINE_NUMBERS; // Flag for how line numbers are displayed + var $line_nth_row = 0; // The "nth" value for fancy line highlighting + + // Misc + var $tab_width = 8; // A value for the size of tab stops. + var $max_tabs = 20; // Maximum number of spaces per tab + var $min_tabs = 0; // Minimum " " " " " + var $link_target = ''; // default target for keyword links + var $encoding = ''; // The encoding to use for htmlentities() calls + + // Deprecated/unused + var $output_format = GESHI_OUTPUT_HTML; + + + /** + * constructor: GeSHi + * ------------------ + * Creates a new GeSHi object, with source and language + */ + function GeSHi ($source, $language, $path = 'geshi/') + { + $this->source = $source; + // Security, just in case :) + $language = preg_replace('#[^a-zA-Z0-9\-\_]#', '', $language); + $this->language = strtolower($language); + $this->language_path = ( substr($path, strlen($path) - 1, 1) == '/' ) ? $path : $path . '/'; + $this->load_language(); + } + + + // + // Error methods + // + + /** + * method: error + * ------------- + * Returns an error message associated with the last GeSHi operation, + * or false if no error has occured + */ + function error() + { + global $_GESHI_ERRORS; + if ( $this->error != 0 ) + { + $msg = $_GESHI_ERRORS[$this->error]; + $debug_tpl_vars = array( + '{LANGUAGE}' => $this->language, + '{PATH}' => $this->language_path + ); + foreach ( $debug_tpl_vars as $tpl => $var ) + { + $msg = str_replace($tpl, $var, $msg); + } + return "<br /><strong>GeSHi Error:</strong> $msg (code $this->error)<br />"; + } + return false; + } + + + // + // Getters + // + + /** + * get_language_name() + * --------------- + * Gets a human-readable language name (thanks to Simon Patterson + * for the idea :)) + */ + function get_language_name() + { + if ( $this->error == GESHI_ERROR_NO_SUCH_LANG ) + { + return $this->language_data['LANG_NAME'] . ' (Unknown Language)'; + } + return $this->language_data['LANG_NAME']; + } + + + // + // Setters + // + + /** + * method: set_source + * ------------------ + * Sets the source code for this object + */ + function set_source ( $source ) + { + $this->source = $source; + } + + + /** + * method: set_language + * -------------------- + * Sets the language for this object + */ + function set_language ( $language ) + { + $language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language); + $this->language = strtolower($language); + // Load the language for parsing + $this->load_language(); + } + + + /** + * method: set_language_path + * ------------------------- + * Sets the path to the directory containing the language files. NOTE + * that this path is relative to the directory of the script that included + * geshi.php, NOT geshi.php itself. + */ + function set_language_path ( $path ) + { + $this->language_path = ( substr($path, strlen($path) - 1, 1) == '/' ) ? $path : $path . '/'; + } + + + /** + * method: set_header_type + * ----------------------- + * Sets the type of header to be used. If GESHI_HEADER_DIV is used, + * the code is surrounded in a <div>. This means more source code but + * more control over tab width and line-wrapping. GESHI_HEADER_PRE + * means that a <pre> is used - less source, but less control. Default + * is GESHI_HEADER_PRE + */ + function set_header_type ( $type ) + { + $this->header_type = $type; + } + + + /** + * method: set_overall_style + * ------------------------- + * Sets the styles for the code that will be outputted + * when this object is parsed. The style should be a + * string of valid stylesheet declarations + */ + function set_overall_style ( $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->overall_style .= $style; + } + else + { + $this->overall_style = $style; + } + } + + + /** + * method: set_overall_class + * ------------------------- + * Sets the overall classname for this block of code. This + * class can then be used in a stylesheet to style this object's + * output + */ + function set_overall_class ( $class ) + { + $this->overall_class = $class; + } + + + /** + * method: set_overall_id + * ---------------------- + * Sets the overall id for this block of code. This id can then + * be used in a stylesheet to style this object's output + */ + function set_overall_id ( $id ) + { + $this->overall_id = $id; + } + + + /** + * method: enable_classes + * ---------------------- + * Sets whether CSS classes should be used to highlight the source. Default + * is off, calling this method with no arguments will turn it on + */ + function enable_classes ( $flag = true ) + { + $this->use_classes = ( $flag ) ? true : false; + } + + + /** + * method: set_code_style + * ---------------------- + * Sets the style for the actual code. This should be a string + * containing valid stylesheet declarations. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + * + * NOTE: Use this method to override any style changes you made to + * the line numbers if you are using line numbers, else the line of + * code will have the same style as the line number! Consult the + * GeSHi documentation for more information about this. + */ + function set_code_style ( $style, $preserve_defaults ) + { + if ( $preserve_defaults ) + { + $this->code_style .= $style; + } + else + { + $this->code_style = $style; + } + } + + + /** + * method: set_line_style + * ---------------------- + * Sets the styles for the line numbers. This should be a string + * containing valid stylesheet declarations. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_line_style ( $style1, $style2 = '', $preserve_defaults = false ) + { + if ( is_bool($style2) ) + { + $preserve_defaults = $style2; + $style2 = ''; + } + if ( $preserve_defaults ) + { + $this->line_style1 .= $style1; + $this->line_style2 .= $style2; + } + else + { + $this->line_style1 = $style1; + $this->line_style2 = $style2; + } + } + + + /** + * method: enable_line_numbers + * --------------------------- + * Sets whether line numbers should be displayed. GESHI_NO_LINE_NUMBERS = not displayed, + * GESHI_NORMAL_LINE_NUMBERS = displayed, GESHI_FANCY_LINE_NUMBERS = every nth line a + * different class. Default is for no line numbers to be used + */ + function enable_line_numbers ( $flag, $nth_row = 5 ) + { + $this->line_numbers = $flag; + $this->line_nth_row = $nth_row; + } + + + /** + * method: set_keyword_group_style + * ------------------------------- + * Sets the style for a keyword group. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_keyword_group_style ( $key, $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['KEYWORDS'][$key] .= $style; + } + else + { + $this->language_data['STYLES']['KEYWORDS'][$key] = $style; + } + } + + + /** + * method: set_keyword_group_highlighting + * -------------------------------------- + * Turns highlighting on/off for a keyword group + */ + function set_keyword_group_highlighting ( $key, $flag = true ) + { + $this->lexic_permissions['KEYWORDS'][$key] = ( $flag ) ? true : false; + } + + + /** + * method: set_comments_style + * -------------------------- + * Sets the styles for comment groups. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_comments_style ( $key, $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['COMMENTS'][$key] .= $style; + } + else + { + $this->language_data['STYLES']['COMMENTS'][$key] = $style; + } + } + + + /** + * method: set_comments_highlighting + * --------------------------------- + * Turns highlighting on/off for comment groups + */ + function set_comments_highlighting ( $key, $flag = true ) + { + $this->lexic_permissions['COMMENTS'][$key] = ( $flag ) ? true : false; + } + + + /** + * method: set_escape_characters_style + * ----------------------------------- + * Sets the styles for escaped characters. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_escape_characters_style ( $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['ESCAPE_CHAR'][0] .= $style; + } + else + { + $this->language_data['STYLES']['ESCAPE_CHAR'][0] = $style; + } + } + + + /** + * method: set_escape_characters_highlighting + * ------------------------------------------ + * Turns highlighting on/off for escaped characters + */ + function set_escape_characters_highlighting ( $flag = true ) + { + $this->lexic_permissions['ESCAPE_CHAR'] = ( $flag ) ? true : false; + } + + + /** + * method: set_brackets_style + * -------------------------- + * Sets the styles for brackets. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + * + * This method is DEPRECATED: use set_symbols_style instead. + * This method will be removed in 1.2.X + */ + function set_brackets_style ( $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['BRACKETS'][0] .= $style; + } + else + { + $this->language_data['STYLES']['BRACKETS'][0] = $style; + } + } + + + /** + * method: set_brackets_highlighting + * --------------------------------- + * Turns highlighting on/off for brackets + * + * This method is DEPRECATED: use set_symbols_highlighting instead. + * This method will be remove in 1.2.X + */ + function set_brackets_highlighting ( $flag ) + { + $this->lexic_permissions['BRACKETS'] = ( $flag ) ? true : false; + } + + + /** + * method: set_symbols_style + * -------------------------- + * Sets the styles for symbols. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_symbols_style ( $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['SYMBOLS'][0] .= $style; + } + else + { + $this->language_data['STYLES']['SYMBOLS'][0] = $style; + } + // For backward compatibility + $this->set_brackets_style ( $style, $preserve_defaults ); + } + + + /** + * method: set_symbols_highlighting + * --------------------------------- + * Turns highlighting on/off for symbols + */ + function set_symbols_highlighting ( $flag ) + { + $this->lexic_permissions['SYMBOLS'] = ( $flag ) ? true : false; + // For backward compatibility + $this->set_brackets_highlighting ( $flag ); + } + + + /** + * method: set_strings_style + * ------------------------- + * Sets the styles for strings. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_strings_style ( $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['STRINGS'][0] .= $style; + } + else + { + $this->language_data['STYLES']['STRINGS'][0] = $style; + } + } + + + /** + * method: set_strings_highlighting + * -------------------------------- + * Turns highlighting on/off for strings + */ + function set_strings_highlighting ( $flag ) + { + $this->lexic_permissions['STRINGS'] = ( $flag ) ? true : false; + } + + + /** + * method: set_numbers_style + * ------------------------- + * Sets the styles for numbers. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_numbers_style ( $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['NUMBERS'][0] .= $style; + } + else + { + $this->language_data['STYLES']['NUMBERS'][0] = $style; + } + } + + + /** + * method: set_numbers_highlighting + * -------------------------------- + * Turns highlighting on/off for numbers + */ + function set_numbers_highlighting ( $flag ) + { + $this->lexic_permissions['NUMBERS'] = ( $flag ) ? true : false; + } + + + /** + * method: set_methods_style + * ------------------------- + * Sets the styles for methods. $key is a number that references the + * appropriate "object splitter" - see the language file for the language + * you are highlighting to get this number. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_methods_style ( $key, $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['METHODS'][$key] .= $style; + } + else + { + $this->language_data['STYLES']['METHODS'][$key] = $style; + } + } + + + /** + * method: set_methods_highlighting + * -------------------------------- + * Turns highlighting on/off for methods + */ + function set_methods_highlighting ( $flag ) + { + $this->lexic_permissions['METHODS'] = ( $flag ) ? true : false; + } + + + /** + * method: set_regexps_style + * ------------------------- + * Sets the styles for regexps. If $preserve_defaults is + * true, then styles are merged with the default styles, with the + * user defined styles having priority + */ + function set_regexps_style ( $key, $style, $preserve_defaults = false ) + { + if ( $preserve_defaults ) + { + $this->language_data['STYLES']['REGEXPS'][$key] .= $style; + } + else + { + $this->language_data['STYLES']['REGEXPS'][$key] = $style; + } + } + + + /** + * method: set_regexps_highlighting + * -------------------------------- + * Turns highlighting on/off for regexps + */ + function set_regexps_highlighting ( $key, $flag ) + { + $this->lexic_permissions['REGEXPS'][$key] = ( $flag ) ? true : false; + } + + + /** + * method: set_case_sensitivity + * ---------------------------- + * Sets whether a set of keywords are checked for in a case sensitive manner + */ + function set_case_sensitivity ( $key, $case ) + { + $this->language_data['CASE_SENSITIVE'][$key] = ( $case ) ? true : false; + } + + + /** + * method: set_case_keywords + * ------------------------- + * Sets the case that keywords should use when found. Use the constants: + * GESHI_CAPS_NO_CHANGE: leave keywords as-is + * GESHI_CAPS_UPPER: convert all keywords to uppercase where found + * GESHI_CAPS_LOWER: convert all keywords to lowercase where found + * Method added in 1.0.1 + */ + function set_case_keywords ( $case ) + { + $this->language_data['CASE_KEYWORDS'] = $case; + } + + + /** + * method: set_tab_width + * --------------------- + * Sets how many spaces a tab is substituted for + * This method will probably be re-engineered later to allow customisability + * in the maximum and minimum number of tabs without mutulating data fields. + */ + function set_tab_width ( $width ) + { + if ( $width > $this->max_tabs ) $width = $this->max_tabs; + if ( $width < $this->min_tabs ) $width = $this->min_tabs; + $this->tab_width = $width; + } + + + /** + * method: enable_strict_mode + * -------------------------- + * Enables/disables strict highlighting. Default is off, calling this + * method without parameters will turn it on. See documentation + * for more details on strict mode and where to use it + */ + function enable_strict_mode ( $mode = true ) + { + $this->strict_mode = ( $mode ) ? true : false; + // Turn on strict mode no matter what if language should always + // be in strict mode + if ( $this->language_data['STRICT_MODE_APPLIES'] == GESHI_ALWAYS ) + { + $this->strict_mode = true; + } + // Turn off strict mode no matter what if language should never + // be in strict mode + elseif ( $this->language_data['STRICT_MODE_APPLIES'] == GESHI_NEVER ) + { + $this->strict_mode = false; + } + } + + + /** + * method: disable_highlighting + * ---------------------------- + * Disables all highlighting + */ + function disable_highlighting () + { + foreach ( $this->language_data['KEYWORDS'] as $key => $words ) + { + $this->lexic_permissions['KEYWORDS'][$key] = false; + } + foreach ( $this->language_data['COMMENT_SINGLE'] as $key => $comment ) + { + $this->lexic_permissions['COMMENTS'][$key] = false; + } + // Multiline comments + $this->lexic_permissions['COMMENTS']['MULTI'] = false; + // Escape characters + $this->lexic_permissions['ESCAPE_CHAR'] = false; + // Brackets + $this->lexic_permissions['BRACKETS'] = false; + // Strings + $this->lexic_permissions['STRINGS'] = false; + // Numbers + $this->lexic_permissions['NUMBERS'] = false; + // Methods + $this->lexic_permissions['METHODS'] = false; + // Symbols + $this->lexic_permissions['SYMBOLS'] = false; + // Script + $this->lexic_permissions['SCRIPT'] = false; + // Regexps + foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) + { + $this->lexic_permissions['REGEXPS'][$key] = false; + } + // Context blocks + $this->enable_important_blocks = false; + } + + + /** + * method: enable_highlighting + * --------------------------- + * Enables all highlighting + */ + function enable_highlighting () + { + foreach ( $this->language_data['KEYWORDS'] as $key => $words ) + { + $this->lexic_permissions['KEYWORDS'][$key] = true; + } + foreach ( $this->language_data['COMMENT_SINGLE'] as $key => $comment ) + { + $this->lexic_permissions['COMMENTS'][$key] = true; + } + // Multiline comments + $this->lexic_permissions['COMMENTS']['MULTI'] = true; + // Escape characters + $this->lexic_permissions['ESCAPE_CHAR'] = true; + // Brackets + $this->lexic_permissions['BRACKETS'] = true; + // Strings + $this->lexic_permissions['STRINGS'] = true; + // Numbers + $this->lexic_permissions['NUMBERS'] = true; + // Methods + $this->lexic_permissions['METHODS'] = true; + // Symbols + $this->lexic_permissions['SYMBOLS'] = true; + // Script + $this->lexic_permissions['SCRIPT'] = true; + // Regexps + foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) + { + $this->lexic_permissions['REGEXPS'][$key] = true; + } + // Context blocks + $this->enable_important_blocks = true; + } + + + /** + * method: add_keyword + * ------------------- + * Adds a keyword to a keyword group for highlighting + */ + function add_keyword( $key, $word ) + { + $this->language_data['KEYWORDS'][$key][] = $word; + } + + + /** + * method: remove_keyword + * ---------------------- + * Removes a keyword from a keyword group + */ + function remove_keyword ( $key, $word ) + { + $this->language_data['KEYWORDS'][$key] = array_diff($this->language_data['KEYWORDS'][$key], array($word)); + } + + + /** + * method: add_keyword_group + * ------------------------- + * Creates a new keyword group + */ + function add_keyword_group ( $key, $styles, $case_sensitive = true, $words = array() ) + { + if ( !is_array($words) ) + { + $words = array($words); + } + $this->language_data['KEYWORDS'][$key] = $words; + $this->lexic_permissions['KEYWORDS'][$key] = true; + $this->language_data['CASE_SENSITIVE'][$key] = $case_sensitive; + $this->language_data['STYLES']['KEYWORDS'][$key] = $styles; + } + + + /** + * method: remove_keyword_group + * ---------------------------- + * Removes a keyword group + */ + function remove_keyword_group ( $key ) + { + unset($this->language_data['KEYWORDS'][$key]); + unset($this->lexic_permissions['KEYWORDS'][$key]); + unset($this->language_data['CASE_SENSITIVE'][$key]); + unset($this->language_data['STYLES']['KEYWORDS'][$key]); + } + + + /** + * method: set_header_content + * -------------------------- + * Sets the content of the header block + */ + function set_header_content ( $content ) + { + $this->header_content = $content; + } + + + /** + * method: set_footer_content + * -------------------------- + * Sets the content of the footer block + */ + function set_footer_content ( $content ) + { + $this->footer_content = $content; + } + + + /** + * method: set_header_content_style + * -------------------------------- + * Sets the style for the header content + */ + function set_header_content_style ( $style ) + { + $this->header_content_style = $style; + } + + + /** + * method: set_footer_content_style + * -------------------------------- + * Sets the style for the footer content + */ + function set_footer_content_style ( $style ) + { + $this->footer_content_style = $style; + } + + + /** + * method: set_url_for_keyword_group + * --------------------------------- + * Sets the base URL to be used for keywords + */ + function set_url_for_keyword_group ( $group, $url ) + { + $this->language_data['URLS'][$group] = $url; + } + + + /** + * method: set_link_styles + * ----------------------- + * Sets styles for links in code + */ + function set_link_styles ( $type, $styles ) + { + $this->link_styles[$type] = $styles; + } + + + /** + * method: set_link_target + * ----------------------- + * Sets the target for links in code + */ + function set_link_target ( $target ) + { + if ( empty( $target ) ) + { + $this->link_target = ''; + } + else + { + $this->link_target = ' target="' . $target . '" '; + } + } + + + /** + * method: set_important_styles + * ---------------------------- + * Sets styles for important parts of the code + */ + function set_important_styles ( $styles ) + { + $this->important_styles = $styles; + } + + + /** + * method: enable_important_blocks + * ------------------------------- + * Sets whether context-important blocks are highlighted + */ + function enable_important_blocks ( $flag ) + { + $this->enable_important_blocks = ( $flag ) ? true : false; + } + + + /** + * method: enable_ids + * ------------------ + * Whether CSS IDs should be added to each line + */ + function enable_ids ( $flag = true ) + { + $this->add_ids = ( $flag ) ? true : false; + } + + + /** + * method: highlight_lines_extra + * ----------------------------- + * Specifies which lines to highlight extra + */ + function highlight_lines_extra ( $lines ) + { + if ( is_array($lines) ) + { + foreach ( $lines as $line ) + { + $this->highlight_extra_lines[intval($line)] = intval($line); + } + } + else + { + $this->highlight_extra_lines[intval($lines)] = intval($lines); + } + } + + + /** + * method: set_highlight_lines_extra_style + * --------------------------------------- + * Sets the style for extra-highlighted lines + */ + function set_highlight_lines_extra_style ( $styles ) + { + $this->highlight_extra_lines_style = $styles; + } + + + /** + * method: start_line_numbers_at + * ----------------------------- + * Sets what number line numbers should start at. Should + * be a positive integer, and will be converted to one. + */ + function start_line_numbers_at ( $number ) + { + $this->line_numbers_start = abs(intval($number)); + } + + + /** + * method: set_encoding + * -------------------- + * Sets the encoding used for htmlentities(), for international + * support. + */ + function set_encoding ( $encoding ) + { + $this->encoding = $encoding; + } + + + /** + * method: parse_code() + * -------------------- + * Returns the code in $this->source, highlighted and surrounded by the + * nessecary HTML. This should only be called ONCE, cos it's SLOW! + * If you want to highlight the same source multiple times, you're better + * off doing a whole lot of str_replaces to replace the <span>s + */ + function parse_code() + { + // Start the timer + $start_time = microtime(); + + // Firstly, if there is an error, we won't highlight + // FUTURE: maybe an option to try to force highlighting anyway? + if ( $this->error ) + { + $result = $this->header(); + if ( $this->header_type != GESHI_HEADER_PRE ) + { + $result .= $this->indent(htmlentities($this->source, ENT_COMPAT, $this->encoding)); + } + else + { + $result .= htmlentities($this->source, ENT_COMPAT, $this->encoding); + } + // Stop Timing + $this->set_time($start_time, microtime()); + return $result . $this->footer(); + } + + // Add spaces for regular expression matching and line numbers + $code = ' ' . $this->source . ' '; + // Replace all newlines to a common form. + $code = str_replace("\r\n", "\n", $code); + $code = str_replace("\r", "\n", $code); + + // Initialise various stuff + $length = strlen($code); + $STRING_OPEN = ''; + $CLOSE_STRING = false; + $ESCAPE_CHAR_OPEN = false; + $COMMENT_MATCHED = false; + // Turn highlighting on if strict mode doesn't apply to this language + $HIGHLIGHTING_ON = ( !$this->strict_mode ) ? true : ''; + // Whether to highlight inside a block of code + $HIGHLIGHT_INSIDE_STRICT = false; + $stuff_to_parse = ''; + $result = ''; + + // "Important" selections are handled like multiline comments + if ( $this->enable_important_blocks ) + { + $this->language_data['COMMENT_MULTI'][GESHI_START_IMPORTANT] = GESHI_END_IMPORTANT; + } + + + if ( $this->strict_mode ) + { + // Break the source into bits. Each bit will be a portion of the code + // within script delimiters - for example, HTML between < and > + $parts = array(0 => array(0 => '')); + $k = 0; + for ( $i = 0; $i < $length; $i++ ) + { + $char = substr($code, $i, 1); + if ( !$HIGHLIGHTING_ON ) + { + foreach ( $this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters ) + { + foreach ( $delimiters as $open => $close ) + { + // Get the next little bit for this opening string + $check = substr($code, $i, strlen($open)); + // If it matches... + if ( $check == $open ) + { + // We start a new block with the highlightable + // code in it + $HIGHLIGHTING_ON = $open; + $i += strlen($open) - 1; + ++$k; + $char = $open; + $parts[$k][0] = $char; + + // No point going around again... + break(2); + } + } + } + } + else + { + foreach ( $this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters ) + { + foreach ( $delimiters as $open => $close ) + { + if ( $open == $HIGHLIGHTING_ON ) + { + // Found the closing tag + break(2); + } + } + } + // We check code from our current position BACKWARDS. This is so + // the ending string for highlighting can be included in the block + $check = substr($code, $i - strlen($close) + 1, strlen($close)); + if ( $check == $close ) + { + $HIGHLIGHTING_ON = ''; + // Add the string to the rest of the string for this part + $parts[$k][1] = ( isset($parts[$k][1]) ) ? $parts[$k][1] . $char : $char; + ++$k; + $parts[$k][0] = ''; + $char = ''; + } + } + $parts[$k][1] = ( isset($parts[$k][1]) ) ? $parts[$k][1] . $char : $char; + } + $HIGHLIGHTING_ON = ''; + } + else + { + // Not strict mode - simply dump the source into + // the array at index 1 (the first highlightable block) + $parts = array( + 1 => array( + 0 => '', + 1 => $code + ) + ); + } + + // Now we go through each part. We know that even-indexed parts are + // code that shouldn't be highlighted, and odd-indexed parts should + // be highlighted + foreach ( $parts as $key => $data ) + { + $part = $data[1]; + // If this block should be highlighted... + if ( $key % 2 ) + { + if ( $this->strict_mode ) + { + // Find the class key for this block of code + foreach ( $this->language_data['SCRIPT_DELIMITERS'] as $script_key => $script_data ) + { + foreach ( $script_data as $open => $close ) + { + if ( $data[0] == $open ) + { + break(2); + } + } + } + + if ( $this->language_data['STYLES']['SCRIPT'][$script_key] != '' && $this->lexic_permissions['SCRIPT'] ) + { + // Add a span element around the source to + // highlight the overall source block + if ( !$this->use_classes && $this->language_data['STYLES']['SCRIPT'][$script_key] != '' ) + { + $attributes = ' style="' . $this->language_data['STYLES']['SCRIPT'][$script_key] . '"'; + } + else + { + $attributes = ' class="sc' . $script_key . '"'; + } + $result .= "<span$attributes>"; + } + } + + if ( !$this->strict_mode || $this->language_data['HIGHLIGHT_STRICT_BLOCK'][$script_key] ) + { + // Now, highlight the code in this block. This code + // is really the engine of GeSHi (along with the method + // parse_non_string_part). + $length = strlen($part); + for ( $i = 0; $i < $length; $i++ ) + { + // Get the next char + $char = substr($part, $i, 1); + // Is this char the newline and line numbers being used? + if ( ($this->line_numbers != GESHI_NO_LINE_NUMBERS || count($this->highlight_extra_lines) > 0) && $char == "\n" ) + { + // If so, is there a string open? If there is, we should end it before + // the newline and begin it again (so when <li>s are put in the source + // remains XHTML compliant) + // NOTE TO SELF: This opens up possibility of config files specifying + // that languages can/cannot have multiline strings??? + if ( $STRING_OPEN ) + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['STRINGS'][0] . '"'; + } + else + { + $attributes = ' class="st0"'; + } + $char = '</span>' . $char . "<span$attributes>"; + } + } + // Is this a match of a string delimiter? + elseif ( $char == $STRING_OPEN ) + { + if ( ($this->lexic_permissions['ESCAPE_CHAR'] && $ESCAPE_CHAR_OPEN) || ($this->lexic_permissions['STRINGS'] && !$ESCAPE_CHAR_OPEN) ) + { + $char .= '</span>'; + } + if ( !$ESCAPE_CHAR_OPEN ) + { + $STRING_OPEN = ''; + $CLOSE_STRING = true; + } + $ESCAPE_CHAR_OPEN = false; + } + // Is this the start of a new string? + elseif ( in_array( $char, $this->language_data['QUOTEMARKS'] ) && ($STRING_OPEN == '') && $this->lexic_permissions['STRINGS'] ) + { + $STRING_OPEN = $char; + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['STRINGS'][0] . '"'; + } + else + { + $attributes = ' class="st0"'; + } + $char = "<span$attributes>" . $char; + + $result .= $this->parse_non_string_part( $stuff_to_parse ); + $stuff_to_parse = ''; + } + // Is this an escape char? + elseif ( ($char == $this->language_data['ESCAPE_CHAR']) && ($STRING_OPEN != '') ) + { + if ( !$ESCAPE_CHAR_OPEN ) + { + $ESCAPE_CHAR_OPEN = true; + if ( $this->lexic_permissions['ESCAPE_CHAR'] ) + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['ESCAPE_CHAR'][0] . '"'; + } + else + { + $attributes = ' class="es0"'; + } + $char = "<span$attributes>" . $char; + } + } + else + { + $ESCAPE_CHAR_OPEN = false; + if ( $this->lexic_permissions['ESCAPE_CHAR'] ) + { + $char .= '</span>'; + } + } + } + elseif ( $ESCAPE_CHAR_OPEN ) + { + if ( $this->lexic_permissions['ESCAPE_CHAR'] ) + { + $char .= '</span>'; + } + $ESCAPE_CHAR_OPEN = false; + $test_str = $char; + } + elseif ( $STRING_OPEN == '' ) + { + // Is this a multiline comment? + foreach ( $this->language_data['COMMENT_MULTI'] as $open => $close ) + { + $com_len = strlen($open); + $test_str = substr( $part, $i, $com_len ); + $test_str_match = $test_str; + if ( $open == $test_str ) + { + $COMMENT_MATCHED = true; + if ( $this->lexic_permissions['COMMENTS']['MULTI'] || $test_str == GESHI_START_IMPORTANT ) + { + if ( $test_str != GESHI_START_IMPORTANT ) + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['COMMENTS']['MULTI'] . '"'; + } + else + { + $attributes = ' class="coMULTI"'; + } + $test_str = "<span$attributes>" . htmlentities($test_str, ENT_COMPAT, $this->encoding); + } + else + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->important_styles . '"'; + } + else + { + $attributes = ' class="imp"'; + } + // We don't include the start of the comment if it's an + // "important" part + $test_str = "<span$attributes>"; + } + } + else + { + $test_str = htmlentities($test_str, ENT_COMPAT, $this->encoding); + } + + $close_pos = strpos( $part, $close, $i + strlen($close) ); + + if ( $close_pos === false ) + { + $close_pos = strlen($part); + } + + // Short-cut through all the multiline code + $rest_of_comment = htmlentities(substr($part, $i + $com_len, $close_pos - $i), ENT_COMPAT, $this->encoding); + if ( ($this->lexic_permissions['COMMENTS']['MULTI'] || $test_str_match == GESHI_START_IMPORTANT) && ($this->line_numbers != GESHI_NO_LINE_NUMBERS || count($this->highlight_extra_lines) > 0) ) + { + // strreplace to put close span and open span around multiline newlines + $test_str .= str_replace("\n", "</span>\n<span$attributes>", $rest_of_comment); + } + else + { + $test_str .= $rest_of_comment; + } + + if ( $this->lexic_permissions['COMMENTS']['MULTI'] || $test_str_match == GESHI_START_IMPORTANT ) + { + $test_str .= '</span>'; + } + $i = $close_pos + $com_len - 1; + // parse the rest + $result .= $this->parse_non_string_part( $stuff_to_parse ); + $stuff_to_parse = ''; + break; + } + } + // If we haven't matched a multiline comment, try single-line comments + if ( !$COMMENT_MATCHED ) + { + foreach ( $this->language_data['COMMENT_SINGLE'] as $comment_key => $comment_mark ) + { + $com_len = strlen($comment_mark); + $test_str = substr( $part, $i, $com_len ); + if ( $this->language_data['CASE_SENSITIVE'][GESHI_COMMENTS] ) + { + $match = ( $comment_mark == $test_str ); + } + else + { + $match = ( strtolower($comment_mark) == strtolower($test_str) ); + } + if ( $match ) + { + $COMMENT_MATCHED = true; + if ( $this->lexic_permissions['COMMENTS'][$comment_key] ) + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['COMMENTS'][$comment_key] . '"'; + } + else + { + $attributes = ' class="co' . $comment_key . '"'; + } + $test_str = "<span$attributes>" . htmlentities($this->change_case($test_str), ENT_COMPAT, $this->encoding); + } + else + { + $test_str = htmlentities($test_str, ENT_COMPAT, $this->encoding); + } + $close_pos = strpos( $part, "\n", $i ); + if ( $close_pos === false ) + { + $close_pos = strlen($part); + } + $test_str .= htmlentities(substr($part, $i + $com_len, $close_pos - $i - $com_len), ENT_COMPAT, $this->encoding); + if ( $this->lexic_permissions['COMMENTS'][$comment_key] ) + { + $test_str .= "</span>"; + } + $test_str .= "\n"; + $i = $close_pos; + // parse the rest + $result .= $this->parse_non_string_part( $stuff_to_parse ); + $stuff_to_parse = ''; + break; + } + } + } + } + // Otherwise, convert it to HTML form + elseif ( $STRING_OPEN != '' ) + { + $char = htmlentities($char, ENT_COMPAT, $this->encoding); + } + // Where are we adding this char? + if ( !$COMMENT_MATCHED ) + { + if ( ($STRING_OPEN == '') && !$CLOSE_STRING ) + { + $stuff_to_parse .= $char; + } + else + { + $result .= $char; + $CLOSE_STRING = false; + } + } + else + { + $result .= $test_str; + $COMMENT_MATCHED = false; + } + } + // Parse the last bit + $result .= $this->parse_non_string_part( $stuff_to_parse ); + $stuff_to_parse = ''; + } + else + { + $result .= htmlentities($part, ENT_COMPAT, $this->encoding); + } + // Close the <span> that surrounds the block + if ( $this->strict_mode && $this->lexic_permissions['SCRIPT'] ) + { + $result .= '</span>'; + } + } + // Else not a block to highlight + else + { + $result .= htmlentities($part, ENT_COMPAT, $this->encoding); + } + } + + // Parse the last stuff (redundant?) + $result .= $this->parse_non_string_part( $stuff_to_parse ); + + // Lop off the very first and last spaces + $result = substr($result, 1, strlen($result) - 1); + + // Are we still in a string? + if ( $STRING_OPEN ) + { + $result .= '</span>'; + } + + // We're finished: stop timing + $this->set_time($start_time, microtime()); + + return $this->finalise($result); + } + + /** + * method: indent + * -------------- + * Swaps out spaces and tabs for HTML indentation. Not needed if + * the code is in a pre block... + */ + function indent ( $result ) + { + $result = str_replace(' ', ' ', $result); + $result = str_replace(' ', ' ', $result); + $result = str_replace("\n ", "\n ", $result); + $result = str_replace("\t", $this->get_tab_replacement(), $result); + if ( $this->line_numbers == GESHI_NO_LINE_NUMBERS ) + { + $result = nl2br($result); + } + return $result; + } + + /** + * method: change_case + * ------------------- + * Changes the case of a keyword for those languages where a change is asked for + */ + function change_case ( $instr ) + { + if ( $this->language_data['CASE_KEYWORDS'] == GESHI_CAPS_UPPER ) + { + return strtoupper($instr); + } + elseif ( $this->language_data['CASE_KEYWORDS'] == GESHI_CAPS_LOWER ) + { + return strtolower($instr); + } + return $instr; + } + + + /** + * method: add_url_to_keyword + * -------------------------- + * Adds a url to a keyword where needed. + * Added in 1.0.2 + */ + function add_url_to_keyword ( $keyword, $group, $start_or_end ) + { + if ( isset($this->language_data['URLS'][$group]) && $this->language_data['URLS'][$group] != '' && substr($keyword, 0, 5) != '</' ) + { + // There is a base group for this keyword + + if ( $start_or_end == 'BEGIN' ) + { + // HTML workaround... not good form (tm) but should work for 1.0.X + $keyword = ( substr($keyword, 0, 4) == '<' ) ? substr($keyword, 4) : $keyword; + $keyword = ( substr($keyword, -4) == '>' ) ? substr($keyword, 0, strlen($keyword) - 4) : $keyword; + if ( $keyword != '' ) + { + $keyword = ( $this->language_data['CASE_SENSITIVE'][$group] ) ? $keyword : strtolower($keyword); + return '<|UR1|"' . str_replace(array('{FNAME}', '.'), array(htmlentities($keyword, ENT_COMPAT, $this->encoding), '<DOT>'), $this->language_data['URLS'][$group]) . '">'; + } + return ''; + } + else + { + return '</a>'; + } + } + } + + + /** + * method: parse_non_string_part + * ----------------------------- + * Takes a string that has no strings or comments in it, and highlights + * stuff like keywords, numbers and methods. + */ + function parse_non_string_part ( &$stuff_to_parse ) + { + $stuff_to_parse = ' ' . quotemeta(htmlentities($stuff_to_parse, ENT_COMPAT, $this->encoding)); + // These vars will disappear in the future + $func = '$this->change_case'; + $func2 = '$this->add_url_to_keyword'; + + + // + // Regular expressions + // + foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) + { + if ( $this->lexic_permissions['REGEXPS'][$key] ) + { + if ( is_array($regexp) ) + { + $stuff_to_parse = preg_replace( "#" . $regexp[GESHI_SEARCH] . "#{$regexp[GESHI_MODIFIERS]}", "{$regexp[GESHI_BEFORE]}<|!REG3XP$key!>{$regexp[GESHI_REPLACE]}|>{$regexp[GESHI_AFTER]}", $stuff_to_parse); + } + else + { + $stuff_to_parse = preg_replace( "#(" . $regexp . ")#", "<|!REG3XP$key!>\\1|>", $stuff_to_parse); + } + } + } + + // + // Highlight numbers. This regexp sucks... anyone with a regexp that WORKS + // here wins a cookie if they send it to me. At the moment there's two doing + // almost exactly the same thing, except the second one prevents a number + // being highlighted twice (eg <span...><span...>5</span></span>) + // Put /NUM!/ in for the styles, which gets replaced at the end. + // + if ( $this->lexic_permissions['NUMBERS'] && preg_match('#[0-9]#', $stuff_to_parse ) ) + { + $stuff_to_parse = preg_replace('#([^a-zA-Z0-9\#])([0-9]+)([^a-zA-Z0-9])#', "\\1<|/NUM!/>\\2|>\\3", $stuff_to_parse); + $stuff_to_parse = preg_replace('#([^a-zA-Z0-9\#>])([0-9]+)([^a-zA-Z0-9])#', "\\1<|/NUM!/>\\2|>\\3", $stuff_to_parse); + } + + // Highlight keywords + // if there is a couple of alpha symbols there *might* be a keyword + if ( preg_match('#[a-zA-Z]{2,}#', $stuff_to_parse) ) + { + foreach ( $this->language_data['KEYWORDS'] as $k => $keywordset ) + { + if ( $this->lexic_permissions['KEYWORDS'][$k] ) + { + foreach ( $keywordset as $keyword ) + { + $keyword = quotemeta($keyword); + // + // This replacement checks the word is on it's own (except if brackets etc + // are next to it), then highlights it. We don't put the color=" for the span + // in just yet - otherwise languages with the keywords "color" or "or" have + // a fit. + // + if ( false !== stristr($stuff_to_parse, $keyword ) ) + { + $stuff_to_parse .= ' '; + // Might make a more unique string for putting the number in soon + // Basically, we don't put the styles in yet because then the styles themselves will + // get highlighted if the language has a CSS keyword in it (like CSS, for example ;)) + $styles = "/$k/"; + $keyword = quotemeta($keyword); + if ( $this->language_data['CASE_SENSITIVE'][$k] ) + { + $stuff_to_parse = preg_replace("#([^a-zA-Z0-9\$_\|\.\#;>])($keyword)([^a-zA-Z0-9_<\|%\-&])#e", "'\\1' . $func2('\\2', '$k', 'BEGIN') . '<|$styles>' . $func('\\2') . '|>' . $func2('\\2', '$k', 'END') . '\\3'", $stuff_to_parse); + } + else + { + // Change the case of the word. + $stuff_to_parse = preg_replace("#([^a-zA-Z0-9\$_\|\.\#;>])($keyword)([^a-zA-Z0-9_<\|%\-&])#ie", "'\\1' . $func2('\\2', '$k', 'BEGIN') . '<|$styles>' . $func('\\2') . '|>' . $func2('\\2', '$k', 'END') . '\\3'", $stuff_to_parse); + } + $stuff_to_parse = substr($stuff_to_parse, 0, strlen($stuff_to_parse) - 1); + } + } + } + } + } + + // + // Now that's all done, replace /[number]/ with the correct styles + // + foreach ( $this->language_data['KEYWORDS'] as $k => $kws ) + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['KEYWORDS'][$k] . '"'; + } + else + { + $attributes = ' class="kw' . $k . '"'; + } + $stuff_to_parse = str_replace("/$k/", $attributes, $stuff_to_parse); + } + + // Put number styles in + if ( !$this->use_classes && $this->lexic_permissions['NUMBERS'] ) + { + $attributes = ' style="' . $this->language_data['STYLES']['NUMBERS'][0] . '"'; + } + else + { + $attributes = ' class="nu0"'; + } + $stuff_to_parse = str_replace('/NUM!/', $attributes, $stuff_to_parse); + + // + // Highlight methods and fields in objects + // + if ( $this->lexic_permissions['METHODS'] && $this->language_data['OOLANG'] ) + { + foreach ( $this->language_data['OBJECT_SPLITTERS'] as $key => $splitter ) + { + if ( false !== stristr($stuff_to_parse, $this->language_data['OBJECT_SPLITTERS'][$key]) ) + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['METHODS'][$key] . '"'; + } + else + { + $attributes = ' class="me' . $key . '"'; + } + $stuff_to_parse = preg_replace("#(" . quotemeta($this->language_data['OBJECT_SPLITTERS'][$key]) . "[\s]*)([a-zA-Z\*\(][a-zA-Z0-9_\*]*)#", "\\1<|$attributes>\\2|>", $stuff_to_parse); + } + } + } + + // + // Highlight brackets. Yes, I've tried adding a semi-colon to this list. + // You try it, and see what happens ;) + // TODO: Fix lexic permissions not converting entities if shouldn't + // be highlighting regardless + // + if ( $this->lexic_permissions['BRACKETS'] ) + { + $code_entities_match = array('[', ']', '(', ')', '{', '}'); + if ( !$this->use_classes ) + { + $code_entities_replace = array( + '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">[|>', + '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">]|>', + '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">(|>', + '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">)|>', + '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">{|>', + '<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">}|>', + ); + } + else + { + $code_entities_replace = array( + '<| class="br0">[|>', + '<| class="br0">]|>', + '<| class="br0">(|>', + '<| class="br0">)|>', + '<| class="br0">{|>', + '<| class="br0">}|>', + ); + } + $stuff_to_parse = str_replace( $code_entities_match, $code_entities_replace, $stuff_to_parse ); + } + + // + // Add class/style for regexps + // + foreach ( $this->language_data['REGEXPS'] as $key => $regexp ) + { + if ( $this->lexic_permissions['REGEXPS'][$key] ) + { + if ( !$this->use_classes ) + { + $attributes = ' style="' . $this->language_data['STYLES']['REGEXPS'][$key] . '"'; + } + else + { + $attributes = ' class="re' . $key . '"'; + } + $stuff_to_parse = str_replace("!REG3XP$key!", "$attributes", $stuff_to_parse); + } + } + + // Replace <DOT> with . for urls + $stuff_to_parse = str_replace('<DOT>', '.', $stuff_to_parse); + // Replace <|UR1| with <a href= for urls also + if ( isset($this->link_styles[GESHI_LINK]) ) + { + if ( $this->use_classes ) + { + $stuff_to_parse = str_replace('<|UR1|', '<a' . $this->link_target . ' href=', $stuff_to_parse); + } + else + { + $stuff_to_parse = str_replace('<|UR1|', '<a' . $this->link_target . ' style="' . $this->link_styles[GESHI_LINK] . '" href=', $stuff_to_parse); + } + } + else + { + $stuff_to_parse = str_replace('<|UR1|', '<a' . $this->link_target . ' href=', $stuff_to_parse); + } + + // + // NOW we add the span thingy ;) + // + + $stuff_to_parse = str_replace('<|', '<span', $stuff_to_parse); + $stuff_to_parse = str_replace ( '|>', '</span>', $stuff_to_parse ); + + return substr(stripslashes($stuff_to_parse), 1); + } + + /** + * method: set_time + * ---------------- + * Sets the time taken to parse the code + */ + function set_time ( $start_time, $end_time ) + { + $start = explode(' ', $start_time); + $end = explode(' ', $end_time); + $this->time = $end[0] + $end[1] - $start[0] - $start[1]; + } + + /** + * method: get_time + * ---------------- + * Gets the time taken to parse the code + */ + function get_time () + { + return $this->time; + } + + /** + * method: load_language + * --------------------- + * Gets language information and stores it for later use + */ + function load_language () + { + $file_name = $this->language_path . $this->language . '.php'; + if ( !is_readable($file_name)) + { + $this->error = GESHI_ERROR_NO_SUCH_LANG; + return; + } + require($file_name); + // Perhaps some checking might be added here later to check that + // $language data is a valid thing but maybe not + $this->language_data = $language_data; + // Set strict mode if should be set + if ( $this->language_data['STRICT_MODE_APPLIES'] == GESHI_ALWAYS ) + { + $this->strict_mode = true; + } + // Set permissions for all lexics to true + // so they'll be highlighted by default + $this->enable_highlighting(); + // Set default class for CSS + $this->overall_class = $this->language; + } + + /** + * method: get_tab_replacement + * --------------------------- + * Gets the replacement string for tabs in the source code. Useful for + * HTML highlighting, where tabs don't mean anything to a browser. + */ + function get_tab_replacement () + { + $i = 0; + $result = ''; + while ( $i < $this->tab_width ) + { + $i++; + if ( $i % 2 == 0 ) + { + $result .= ' '; + } + else + { + $result .= ' '; + } + } + return $result; + } + + /** + * method: finalise + * ---------------- + * Takes the parsed code and various options, and creates the HTML + * surrounding it to make it look nice. + */ + function finalise ( $parsed_code ) + { + // Remove end parts of important declarations + // This is BUGGY!! My fault for bad code: fix coming in 1.2 + if ( $this->enable_important_blocks && (strstr($parsed_code, htmlentities(GESHI_START_IMPORTANT, ENT_COMPAT, $this->encoding)) === false) ) + { + $parsed_code = str_replace(htmlentities(GESHI_END_IMPORTANT, ENT_COMPAT, $this->encoding), '', $parsed_code); + } + + // Add HTML whitespace stuff if we're using the <div> header + if ( $this->header_type == GESHI_HEADER_DIV ) + { + $parsed_code = $this->indent($parsed_code); + } + + // If we're using line numbers, we insert <li>s and appropriate + // markup to style them (otherwise we don't need to do anything) + if ( $this->line_numbers != GESHI_NO_LINE_NUMBERS ) + { + // If we're using the <pre> header, we shouldn't add newlines because + // the <pre> will line-break them (and the <li>s already do this for us) + $ls = ( $this->header_type != GESHI_HEADER_PRE ) ? "\n" : ''; + // Get code into lines + $code = explode("\n", $parsed_code); + // Set vars to defaults for following loop + $parsed_code = ''; + $i = 0; + // Foreach line... + foreach ( $code as $line ) + { + $line = ( $line ) ? $line : ' '; + // If this is a "special line"... + if ( $this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1) ) + { + // Set the attributes to style the line + if ( $this->use_classes ) + { + $attr = ' class="li2"'; + $def_attr = ' class="de2"'; + } + else + { + $attr = ' style="' . $this->line_style2 . '"'; + // This style "covers up" the special styles set for special lines + // so that styles applied to special lines don't apply to the actual + // code on that line + $def_attr = ' style="' . $this->code_style . '"'; + } + // Span or div? + $start = "<div$def_attr>"; + $end = '</div>'; + } + else + { + if ( $this->use_classes ) + { + $def_attr = ' class="de1"'; + } + else + { + $def_attr = ' style="' . $this->code_style . '"'; + } + // Reset everything + $attr = ''; + // Span or div? + $start = "<div$def_attr>"; + $end = '</div>'; + } + + ++$i; + // Are we supposed to use ids? If so, add them + if ( $this->add_ids ) + { + $attr .= " id=\"{$this->overall_id}-{$i}\""; + } + if ( $this->use_classes && in_array($i, $this->highlight_extra_lines) ) + { + $attr .= " class=\"ln-xtra\""; + } + if ( !$this->use_classes && in_array($i, $this->highlight_extra_lines) ) + { + $attr .= " style=\"{$this->highlight_extra_lines_style}\""; + } + + // Add in the line surrounded by appropriate list HTML + $parsed_code .= "<li$attr>$start$line$end</li>$ls"; + } + } + else + { + // No line numbers, but still need to handle highlighting lines extra. + // Have to use divs so the full width of the code is highlighted + $code = explode("\n", $parsed_code); + $parsed_code = ''; + $i = 0; + foreach ( $code as $line ) + { + // Make lines have at least one space in them if they're empty + $line = ( $line ) ? $line : ' '; + if ( in_array(++$i, $this->highlight_extra_lines) ) + { + if ( $this->use_classes ) + { + //$id = ( $this->overall_id != '' ) ? $this->overall_id . "-$i" : $this->overall_class . "-$i"; + $parsed_code .= '<div class="ln-xtra">'; + } + else + { + $parsed_code .= "<div style=\"{$this->highlight_extra_lines_style}\">"; + } + $parsed_code .= $line . "</div>\n"; + } + else + { + $parsed_code .= $line . "\n"; + } + } + } + + return $this->header() . chop($parsed_code) . $this->footer(); + } + + + /** + * method: header + * -------------- + * Creates the header for the code block (with correct attributes) + */ + function header () + { + // Get attributes needed + $attributes = $this->get_attributes(); + + if ( $this->use_classes ) + { + $ol_attributes = ''; + } + else + { + $ol_attributes = ' style="margin: 0;"'; + } + + if ( $this->line_numbers_start != 1 ) + { + $ol_attributes .= ' start="' . $this->line_numbers_start . '"'; + } + + // Get the header HTML + $header = $this->format_header_content(); + + // Work out what to return and do it + if ( $this->line_numbers != GESHI_NO_LINE_NUMBERS ) + { + if ( $this->header_type == GESHI_HEADER_PRE ) + { + return "<pre$attributes>$header<ol$ol_attributes>"; + } + elseif ( $this->header_type == GESHI_HEADER_DIV ) + { + return "<div$attributes>$header<ol$ol_attributes>"; + } + } + else + { + if ( $this->header_type == GESHI_HEADER_PRE ) + { + return "<pre$attributes>$header"; + } + elseif ( $this->header_type == GESHI_HEADER_DIV ) + { + return "<div$attributes>$header"; + } + } + } + + + /** + * method: format_header_content + * ----------------------------- + * Returns the header content, formatted for output + */ + function format_header_content () + { + $header = $this->header_content; + if ( $header ) + { + if ( $this->header_type == GESHI_HEADER_PRE ) + { + $header = str_replace("\n", '', $header); + } + $header = $this->replace_keywords($header); + + if ( $this->use_classes ) + { + $attr = ' class="head"'; + } + else + { + $attr = " style=\"{$this->header_content_style}\""; + } + return "<div$attr>$header</div>"; + } + } + + + /** + * method: footer + * -------------- + * Returns the footer for the code block. Ending newline removed in 1.0.2 + */ + function footer () + { + $footer_content = $this->format_footer_content(); + + if ( $this->header_type == GESHI_HEADER_DIV ) + { + if ( $this->line_numbers != GESHI_NO_LINE_NUMBERS ) + { + return "</ol>$footer_content</div>"; + } + return "$footer_content</div>"; + } + else + { + if ( $this->line_numbers != GESHI_NO_LINE_NUMBERS ) + { + return "</ol>$footer_content</pre>"; + } + return "$footer_content</pre>"; + } + } + + + /** + * method: format_footer_content + * ----------------------------- + * Returns the footer content, formatted for output + */ + function format_footer_content () + { + $footer = $this->footer_content; + if ( $footer ) + { + if ( $this->header_type == GESHI_HEADER_PRE ) + { + $footer = str_replace("\n", '', $footer);; + } + $footer = $this->replace_keywords($footer); + + if ( $this->use_classes ) + { + $attr = ' class="foot"'; + } + else + { + $attr = " style=\"{$this->footer_content_style}\">"; + } + return "<div$attr>$footer</div>"; + } + } + + + /** + * method: replace_keywords + * ---------------------- + * Replaces certain keywords in the header and footer with + * certain configuration values + */ + function replace_keywords ( $instr ) + { + $keywords = $replacements = array(); + + $keywords[] = '<TIME>'; + $replacements[] = number_format($this->get_time(), 3); + + $keywords[] = '<LANGUAGE>'; + $replacements[] = $this->language; + + $keywords[] = '<VERSION>'; + $replacements[] = '1.0.4'; + + return str_replace($keywords, $replacements, $instr); + } + + /** + * method: get_attributes + * ---------------------- + * Gets the CSS attributes for this code + */ + function get_attributes () + { + $attributes = ''; + + if ( $this->overall_class != '' && $this->use_classes ) + { + $attributes .= " class=\"{$this->overall_class}\""; + } + if ( $this->overall_id != '' ) + { + $attributes .= " id=\"{$this->overall_id}\""; + } + if ( $this->overall_style != '' && !$this->use_classes ) + { + $attributes .= ' style="' . $this->overall_style . '"'; + } + return $attributes; + } + + + /** + * method: get_stylesheet + * ---------------------- + * Returns a stylesheet for the highlighted code. If $economy mode + * is true, we only return the stylesheet declarations that matter for + * this code block instead of the whole thing + */ + function get_stylesheet ( $economy_mode = true ) + { + // If there's an error, chances are that the language file + // won't have populated the language data file, so we can't + // risk getting a stylesheet... + if ( $this->error ) + { + return ''; + } + // First, work out what the selector should be. If there's an ID, + // that should be used, the same for a class. Otherwise, a selector + // of '' means that these styles will be applied anywhere + $selector = ( $this->overall_id != '' ) ? "#{$this->overall_id} " : ''; + $selector = ( $selector == '' && $this->overall_class != '' ) ? ".{$this->overall_class} " : $selector; + + // Header of the stylesheet + if ( !$economy_mode ) + { + $stylesheet = "/**\n * GeSHi Dynamically Generated Stylesheet\n * --------------------------------------\n * Dynamically generated stylesheet for {$this->language}\n * CSS class: {$this->overall_class}, CSS id: {$this->overall_id}\n * GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter)\n */\n"; + } + else + { + $stylesheet = '/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */' . "\n"; + } + + // Set the <ol> to have no effect at all if there are line numbers + // (<ol>s have margins that should be destroyed so all layout is + // controlled by the set_overall_style method, which works on the + // <pre> or <div> container). Additionally, set default styles for lines + if ( !$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS ) + { + $stylesheet .= "$selector, {$selector}ol, {$selector}ol li {margin: 0;}\n"; + $stylesheet .= "$selector.de1, $selector.de2 {{$this->code_style}}\n"; + } + + // Add overall styles + if ( !$economy_mode || $this->overall_style != '' ) + { + $stylesheet .= "$selector {{$this->overall_style}}\n"; + } + + // Add styles for links + foreach ( $this->link_styles as $key => $style ) + { + if ( !$economy_mode || $key == GESHI_LINK && $style != '' ) + { + $stylesheet .= "{$selector}a:link {{$style}}\n"; + } + if ( !$economy_mode || $key == GESHI_HOVER && $style != '' ) + { + $stylesheet .= "{$selector}a:hover {{$style}}\n"; + } + if ( !$economy_mode || $key == GESHI_ACTIVE && $style != '' ) + { + $stylesheet .= "{$selector}a:active {{$style}}\n"; + } + if ( !$economy_mode || $key == GESHI_VISITED && $style != '' ) + { + $stylesheet .= "{$selector}a:visited {{$style}}\n"; + } + } + + // Header and footer + if ( !$economy_mode || $this->header_content_style != '' ) + { + $stylesheet .= "$selector.head {{$this->header_content_style}}\n"; + } + if ( !$economy_mode || $this->footer_content_style != '' ) + { + $stylesheet .= "$selector.foot {{$this->footer_content_style}}\n"; + } + + // Styles for important stuff + if ( !$economy_mode || $this->important_styles != '' ) + { + $stylesheet .= "$selector.imp {{$this->important_styles}}\n"; + } + + + // Styles for lines being highlighted extra + if ( !$economy_mode || count($this->highlight_extra_lines) ) + { + /*foreach ( $this->highlight_extra_lines as $line ) + { + $id = ( $this->overall_id != '' ) ? $this->overall_id . "-$line" : $this->overall_class . "-$line"; + $stylesheet .= "$selector#$id,"; + }*/ + $stylesheet .= "$selector.ln-xtra {{$this->highlight_extra_lines_style}}\n"; + } + + + // Simple line number styles + if ( !$economy_mode || ($this->line_numbers != GESHI_NO_LINE_NUMBERS && $this->line_style1 != '') ) + { + $stylesheet .= "{$selector}li {{$this->line_style1}}\n"; + } + + // If there is a style set for fancy line numbers, echo it out + if ( !$economy_mode || ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $this->line_style2 != '') ) + { + $stylesheet .= "{$selector}li.li2 {{$this->line_style2}}\n"; + } + + + foreach ( $this->language_data['STYLES']['KEYWORDS'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && (!$this->lexic_permissions['KEYWORDS'][$group] || $styles == '')) ) + { + $stylesheet .= "$selector.kw$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['COMMENTS'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['COMMENTS'][$group]) ) + { + $stylesheet .= "$selector.co$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['ESCAPE_CHAR'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['ESCAPE_CHAR']) ) + { + $stylesheet .= "$selector.es$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['SYMBOLS'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['BRACKETS']) ) + { + $stylesheet .= "$selector.br$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['STRINGS'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['STRINGS']) ) + { + $stylesheet .= "$selector.st$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['NUMBERS'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['NUMBERS']) ) + { + $stylesheet .= "$selector.nu$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['METHODS'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['METHODS']) ) + { + $stylesheet .= "$selector.me$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['SCRIPT'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') /*&& !($economy_mode && !$this->lexic_permissions['SCRIPT'])*/ ) + { + $stylesheet .= "$selector.sc$group {{$styles}}\n"; + } + } + foreach ( $this->language_data['STYLES']['REGEXPS'] as $group => $styles ) + { + if ( !$economy_mode || !($economy_mode && $styles == '') && !($economy_mode && !$this->lexic_permissions['REGEXPS'][$group]) ) + { + $stylesheet .= "$selector.re$group {{$styles}}\n"; + } + } + + return $stylesheet; + } + +} // End Class GeSHi + + +if ( !function_exists('geshi_highlight') ) +{ + /** + * function: geshi_highlight + * ------------------------- + * Easy way to highlight stuff. Behaves just like highlight_string + */ + function geshi_highlight ( $string, $language, $path, $return = false ) + { + $geshi = new GeSHi($string, $language, $path); + $geshi->set_header_type(GESHI_HEADER_DIV); + if ( $return ) + { + return str_replace('<div>', '<code>', str_replace('</div>', '</code>', $geshi->parse_code())); + } + echo str_replace('<div>', '<code>', str_replace('</div>', '</code>', $geshi->parse_code())); + if ( $geshi->error() ) + { + return false; + } + return true; + } +} + +?> diff --git a/inc/geshi/actionscript.php b/inc/geshi/actionscript.php new file mode 100644 index 000000000..26b299f94 --- /dev/null +++ b/inc/geshi/actionscript.php @@ -0,0 +1,199 @@ +<?php +/************************************************************************************* + * actionscript.php + * ---------------- + * Author: Steffen Krause (Steffen.krause@muse.de) + * Copyright: (c) 2004 Steffen Krause, Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/20 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Actionscript language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Actionscript', + 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + '#include', 'for', 'foreach', 'if', 'elseif', 'else', 'while', 'do', 'dowhile', + 'endwhile', 'endif', 'switch', 'case', 'endswitch', 'return', 'break', 'continue', 'in' + ), + 2 => array( + 'null', 'false', 'true', 'var', + 'default', 'function', 'class', + 'new', '_global' + ), + 3 => array( + '#endinitclip', '#initclip', '__proto__', '_accProps', '_alpha', '_currentframe', + '_droptarget', '_focusrect', '_framesloaded', '_height', '_highquality', '_lockroot', + '_name', '_parent', '_quality', '_root', '_rotation', '_soundbuftime', '_target', '_totalframes', + '_url', '_visible', '_width', '_x', '_xmouse', '_xscale', '_y', '_ymouse', '_yscale', 'abs', + 'Accessibility', 'acos', 'activityLevel', 'add', 'addListener', 'addPage', 'addProperty', + 'addRequestHeader', 'align', 'allowDomain', 'allowInsecureDomain', 'and', 'appendChild', + 'apply', 'Arguments', 'Array', 'asfunction', 'asin', 'atan', 'atan2', 'attachAudio', 'attachMovie', + 'attachSound', 'attachVideo', 'attributes', 'autosize', 'avHardwareDisable', 'background', + 'backgroundColor', 'BACKSPACE', 'bandwidth', 'beginFill', 'beginGradientFill', 'blockIndent', + 'bold', 'Boolean', 'border', 'borderColor', 'bottomScroll', 'bufferLength', 'bufferTime', + 'builtInItems', 'bullet', 'Button', 'bytesLoaded', 'bytesTotal', 'call', 'callee', 'caller', + 'Camera', 'capabilities', 'CAPSLOCK', 'caption', 'catch', 'ceil', 'charAt', 'charCodeAt', + 'childNodes', 'chr', 'clear', 'clearInterval', 'cloneNode', 'close', 'Color', 'concat', + 'connect', 'condenseWhite', 'constructor', 'contentType', 'ContextMenu', 'ContextMenuItem', + 'CONTROL', 'copy', 'cos', 'createElement', 'createEmptyMovieClip', 'createTextField', + 'createTextNode', 'currentFps', 'curveTo', 'CustomActions', 'customItems', 'data', 'Date', + 'deblocking', 'delete', 'DELETEKEY', 'docTypeDecl', 'domain', 'DOWN', + 'duplicateMovieClip', 'duration', 'dynamic', 'E', 'embedFonts', 'enabled', + 'END', 'endFill', 'ENTER', 'eq', 'Error', 'ESCAPE(Konstante)', 'escape(Funktion)', 'eval', + 'exactSettings', 'exp', 'extends', 'finally', 'findText', 'firstChild', 'floor', + 'flush', 'focusEnabled', 'font', 'fps', 'fromCharCode', 'fscommand', + 'gain', 'ge', 'get', 'getAscii', 'getBeginIndex', 'getBounds', 'getBytesLoaded', 'getBytesTotal', + 'getCaretIndex', 'getCode', 'getCount', 'getDate', 'getDay', 'getDepth', 'getEndIndex', 'getFocus', + 'getFontList', 'getFullYear', 'getHours', 'getInstanceAtDepth', 'getLocal', 'getMilliseconds', + 'getMinutes', 'getMonth', 'getNewTextFormat', 'getNextHighestDepth', 'getPan', 'getProgress', + 'getProperty', 'getRGB', 'getSeconds', 'getSelected', 'getSelectedText', 'getSize', 'getStyle', + 'getStyleNames', 'getSWFVersion', 'getText', 'getTextExtent', 'getTextFormat', 'getTextSnapshot', + 'getTime', 'getTimer', 'getTimezoneOffset', 'getTransform', 'getURL', 'getUTCDate', 'getUTCDay', + 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', + 'getVersion', 'getVolume', 'getYear', 'globalToLocal', 'goto', 'gotoAndPlay', 'gotoAndStop', + 'hasAccessibility', 'hasAudio', 'hasAudioEncoder', 'hasChildNodes', 'hasEmbeddedVideo', 'hasMP3', + 'hasPrinting', 'hasScreenBroadcast', 'hasScreenPlayback', 'hasStreamingAudio', 'hasStreamingVideo', + 'hasVideoEncoder', 'height', 'hide', 'hideBuiltInItems', 'hitArea', 'hitTest', 'hitTestTextNearPos', + 'HOME', 'hscroll', 'html', 'htmlText', 'ID3', 'ifFrameLoaded', 'ignoreWhite', 'implements', + 'import', 'indent', 'index', 'indexOf', 'Infinity', '-Infinity', 'INSERT', 'insertBefore', 'install', + 'instanceof', 'int', 'interface', 'isActive', 'isDebugger', 'isDown', 'isFinite', 'isNaN', 'isToggled', + 'italic', 'join', 'Key', 'language', 'lastChild', 'lastIndexOf', 'le', 'leading', 'LEFT', 'leftMargin', + 'length', 'level', 'lineStyle', 'lineTo', 'list', 'LN10', 'LN2', 'load', 'loadClip', 'loaded', 'loadMovie', + 'loadMovieNum', 'loadSound', 'loadVariables', 'loadVariablesNum', 'LoadVars', 'LocalConnection', + 'localFileReadDisable', 'localToGlobal', 'log', 'LOG10E', 'LOG2E', 'manufacturer', 'Math', 'max', + 'MAX_VALUE', 'maxChars', 'maxhscroll', 'maxscroll', 'mbchr', 'mblength', 'mbord', 'mbsubstring', 'menu', + 'message', 'Microphone', 'min', 'MIN_VALUE', 'MMExecute', 'motionLevel', 'motionTimeOut', 'Mouse', + 'mouseWheelEnabled', 'moveTo', 'Movieclip', 'MovieClipLoader', 'multiline', 'muted', 'name', 'names', 'NaN', + 'ne', 'NEGATIVE_INFINITY', 'NetConnection', 'NetStream', 'newline', 'nextFrame', + 'nextScene', 'nextSibling', 'nodeName', 'nodeType', 'nodeValue', 'not', 'Number', 'Object', + 'on', 'onActivity', 'onChanged', 'onClipEvent', 'onClose', 'onConnect', 'onData', 'onDragOut', + 'onDragOver', 'onEnterFrame', 'onID3', 'onKeyDown', 'onKeyUp', 'onKillFocus', 'onLoad', 'onLoadComplete', + 'onLoadError', 'onLoadInit', 'onLoadProgress', 'onLoadStart', 'onMouseDown', 'onMouseMove', 'onMouseUp', + 'onMouseWheel', 'onPress', 'onRelease', 'onReleaseOutside', 'onResize', 'onRollOut', 'onRollOver', + 'onScroller', 'onSelect', 'onSetFocus', 'onSoundComplete', 'onStatus', 'onUnload', 'onUpdate', 'onXML', + 'or(logischesOR)', 'ord', 'os', 'parentNode', 'parseCSS', 'parseFloat', 'parseInt', 'parseXML', 'password', + 'pause', 'PGDN', 'PGUP', 'PI', 'pixelAspectRatio', 'play', 'playerType', 'pop', 'position', + 'POSITIVE_INFINITY', 'pow', 'prevFrame', 'previousSibling', 'prevScene', 'print', 'printAsBitmap', + 'printAsBitmapNum', 'PrintJob', 'printNum', 'private', 'prototype', 'public', 'push', 'quality', + 'random', 'rate', 'registerClass', 'removeListener', 'removeMovieClip', 'removeNode', 'removeTextField', + 'replaceSel', 'replaceText', 'resolutionX', 'resolutionY', 'restrict', 'reverse', 'RIGHT', + 'rightMargin', 'round', 'scaleMode', 'screenColor', 'screenDPI', 'screenResolutionX', 'screenResolutionY', + 'scroll', 'seek', 'selectable', 'Selection', 'send', 'sendAndLoad', 'separatorBefore', 'serverString', + 'set', 'setvariable', 'setBufferTime', 'setClipboard', 'setDate', 'setFocus', 'setFullYear', 'setGain', + 'setHours', 'setInterval', 'setMask', 'setMilliseconds', 'setMinutes', 'setMode', 'setMonth', + 'setMotionLevel', 'setNewTextFormat', 'setPan', 'setProperty', 'setQuality', 'setRate', 'setRGB', + 'setSeconds', 'setSelectColor', 'setSelected', 'setSelection', 'setSilenceLevel', 'setStyle', + 'setTextFormat', 'setTime', 'setTransform', 'setUseEchoSuppression', 'setUTCDate', 'setUTCFullYear', + 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setVolume', + 'setYear', 'SharedObject', 'SHIFT(Konstante)', 'shift(Methode)', 'show', 'showMenu', 'showSettings', + 'silenceLevel', 'silenceTimeout', 'sin', 'size', 'slice', 'smoothing', 'sort', 'sortOn', 'Sound', 'SPACE', + 'splice', 'split', 'sqrt', 'SQRT1_2', 'SQRT2', 'Stage', 'start', 'startDrag', 'static', 'status', 'stop', + 'stopAllSounds', 'stopDrag', 'String', 'StyleSheet(Klasse)', 'styleSheet(Eigenschaft)', 'substr', + 'substring', 'super', 'swapDepths', 'System', 'TAB', 'tabChildren', 'tabEnabled', 'tabIndex', + 'tabStops', 'tan', 'target', 'targetPath', 'tellTarget', 'text', 'textColor', 'TextField', 'TextFormat', + 'textHeight', 'TextSnapshot', 'textWidth', 'this', 'throw', 'time', 'toggleHighQuality', 'toLowerCase', + 'toString', 'toUpperCase', 'trace', 'trackAsMenu', 'try', 'type', 'typeof', 'undefined', + 'underline', 'unescape', 'uninstall', 'unloadClip', 'unloadMovie', 'unLoadMovieNum', 'unshift', 'unwatch', + 'UP', 'updateAfterEvent', 'updateProperties', 'url', 'useCodePage', 'useEchoSuppression', 'useHandCursor', + 'UTC', 'valueOf', 'variable', 'version', 'Video', 'visible', 'void', 'watch', 'width', + 'with', 'wordwrap', 'XML', 'xmlDecl', 'XMLNode', 'XMLSocket' + ) + ), + 'SYMBOLS' => array( + '(', ')', '[', ']', '{', '}', '!', '@', '%', '&', '*', '|', '/', '<', '>' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false, + 2 => false, + 3 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #0066CC;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 2 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #006600;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array(), + 'HIGHLIGHT_STRICT_BLOCK' => array() +); + +?>
\ No newline at end of file diff --git a/inc/geshi/ada.php b/inc/geshi/ada.php new file mode 100644 index 000000000..23ba14704 --- /dev/null +++ b/inc/geshi/ada.php @@ -0,0 +1,136 @@ +<?php +/************************************************************************************* + * ada.php + * ------- + * Author: Tux (tux@inmail.cz) + * Copyright: (c) 2004 Tux (http://tux.a4.cz/), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.2 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/07/29 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Ada language file for GeSHi. + * Words are from SciTe configuration file + * + * CHANGES + * ------- + * 2004/11/27 (1.0.2) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.1) + * - Removed apostrophe as string delimiter + * - Added URL support + * 2004/08/05 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Ada', + 'COMMENT_SINGLE' => array(1 => '--'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'begin', 'declare', 'do', 'else', 'elsif', 'exception', 'for', 'if', + 'is', 'loop', 'while', 'then', 'is', 'end', 'select', 'case', 'while', 'until', + 'goto', 'return' + ), + 2 => array( + 'abs', 'and', 'mod', 'not', 'or', 'rem', 'xor' + ), + 3 => array( + 'abort', 'abstract', 'accept', 'access', 'aliased', 'all', 'array', 'at', 'body', + 'constant', 'delay', 'delta', 'digits', 'entry', 'exit', + 'function', 'generic', 'in', 'limited', 'new', 'null', 'of', 'others', 'out', 'package', 'pragma', + 'private', 'procedure', 'protected', 'raise', 'range', 'record', 'renames', 'requeue', 'reverse', + 'separate', 'subtype', 'tagged', 'task', 'terminate', 'type', 'use', 'when', 'with' + ) + ), + 'SYMBOLS' => array( + '(', ')' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #00007f;', + 2 => 'color: #0000ff;', + 3 => 'color: #46aa03; font-weight:bold;', + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'COMMENTS' => array( + 1 => 'color: #adadad; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #7f007f;' + ), + 'NUMBERS' => array( + 0 => 'color: #ff0000;' + ), + 'METHODS' => array( + 1 => 'color: #202020;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> + diff --git a/inc/geshi/apache.php b/inc/geshi/apache.php new file mode 100644 index 000000000..d7447a1ac --- /dev/null +++ b/inc/geshi/apache.php @@ -0,0 +1,174 @@ +<?php +/************************************************************************************* + * apache.php + * ---------- + * Author: Tux (tux@inmail.cz) + * Copyright: (c) 2004 Tux (http://tux.a4.cz/), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.2 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/29/07 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Apache language file for GeSHi. + * Words are from SciTe configuration file + * + * CHANGES + * ------- + * 2004/11/27 (1.0.2) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.1) + * - Added support for URLs + * 2004/08/05 (1.0.0) + * - First Release + * + * TODO (updated 2004/07/29) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Apache', + 'COMMENT_SINGLE' => array(1 => '#'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + /*keywords*/ + 1 => array( + 'accessconfig','accessfilename','action','addalt', + 'addaltbyencoding','addaltbytype','addcharset', + 'adddefaultcharset','adddescription', + 'addencoding','addhandler','addicon','addiconbyencoding', + 'addiconbytype','addlanguage','addmodule','addmoduleinfo', + 'addtype','agentlog','alias','aliasmatch', + 'allow','allowconnect','allowoverride','anonymous', + 'anonymous_authoritative','anonymous_logemail','anonymous_mustgiveemail', + 'anonymous_nouserid','anonymous_verifyemail','authauthoritative', + 'authdbauthoritative','authdbgroupfile','authdbmauthoritative', + 'authdbmgroupfile','authdbmgroupfile','authdbuserfile','authdbmuserfile', + 'authdigestfile','authgroupfile','authname','authtype', + 'authuserfile','bindaddress','browsermatch','browsermatchnocase', + 'bs2000account','cachedefaultexpire','cachedirlength','cachedirlevels', + 'cacheforcecompletion','cachegcinterval','cachelastmodifiedfactor','cachemaxexpire', + 'cachenegotiateddocs','cacheroot','cachesize','checkspelling', + 'clearmodulelist','contentdigest','cookieexpires','cookielog', + 'cookielog','cookietracking','coredumpdirectory','customlog', + 'defaulticon','defaultlanguage','defaulttype','define', + 'deny','directory','directorymatch','directoryindex', + 'documentroot','errordocument','errorlog','example', + 'expiresactive','expiresbytype','expiresdefault','extendedstatus', + 'fancyindexing','files','filesmatch','forcetype', + 'group','header','headername','hostnamelookups', + 'identitycheck','ifdefine','ifmodule','imapbase', + 'imapdefault','imapmenu','include','indexignore', + 'indexoptions','keepalive','keepalivetimeout','languagepriority', + 'limit','limitexcept','limitrequestbody','limitrequestfields', + 'limitrequestfieldsize','limitrequestline','listen','listenbacklog', + 'loadfile','loadmodule','location','locationmatch', + 'lockfile','logformat','loglevel','maxclients', + 'maxkeepaliverequests','maxrequestsperchild','maxspareservers','metadir', + 'metafiles','metasuffix','mimemagicfile','minspareservers', + 'mmapfile','namevirtualhost','nocache','options','order', + 'passenv','pidfile','port','proxyblock','proxydomain', + 'proxypass','proxypassreverse','proxyreceivebuffersize','proxyremote', + 'proxyrequests','proxyvia','qsc','readmename', + 'redirect','redirectmatch','redirectpermanent','redirecttemp', + 'refererignore','refererlog','removehandler','require', + 'resourceconfig','rewritebase','rewritecond','rewriteengine', + 'rewritelock','rewritelog','rewriteloglevel','rewritemap', + 'rewriteoptions','rewriterule','rlimitcpu','rlimitmem', + 'rlimitnproc','satisfy','scoreboardfile','script', + 'scriptalias','scriptaliasmatch','scriptinterpretersource','scriptlog', + 'scriptlogbuffer','scriptloglength','sendbuffersize', + 'serveradmin','serveralias','servername','serverpath', + 'serverroot','serversignature','servertokens','servertype', + 'setenv','setenvif','setenvifnocase','sethandler', + 'singlelisten','startservers','threadsperchild','timeout', + 'transferlog','typesconfig','unsetenv','usecanonicalname', + 'user','userdir','virtualhost','virtualdocumentroot', + 'virtualdocumentrootip','virtualscriptalias','virtualscriptaliasip', + 'xbithack','from','all' + ), + /*keyords 2*/ + 2 => array( + 'on','off','standalone','inetd', + 'force-response-1.0','downgrade-1.0','nokeepalive', + 'ndexes','includes','followsymlinks','none', + 'x-compress','x-gzip' + ) + ), + 'SYMBOLS' => array( + '(', ')' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #00007f;', + 2 => 'color: #0000ff;', + ), + 'COMMENTS' => array( + 1 => 'color: #adadad; font-style: italic;', + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #7f007f;' + ), + 'NUMBERS' => array( + 0 => 'color: #ff0000;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> + diff --git a/inc/geshi/asm.php b/inc/geshi/asm.php new file mode 100644 index 000000000..ea8d2c1d2 --- /dev/null +++ b/inc/geshi/asm.php @@ -0,0 +1,200 @@ +<?php +/************************************************************************************* + * asm.php + * ------- + * Author: Tux (tux@inmail.cz) + * Copyright: (c) 2004 Tux (http://tux.a4.cz/), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.2 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/07/27 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * x86 Assembler language file for GeSHi. + * Words are from SciTe configuration file (based on NASM syntax) + * + * CHANGES + * ------- + * 2004/11/27 (1.0.2) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.1) + * - Added support for URLs + * - Added binary and hexadecimal regexps + * 2004/08/05 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'assembler', + 'COMMENT_SINGLE' => array(1 => ';'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '', + 'KEYWORDS' => array( + /*CPU*/ + 1 => array( + 'aaa','aad','aam','aas','adc','add','and','call','cbw','clc','cld','cli','cmc','cmp', + 'cmps','cmpsb','cmpsw','cwd','daa','das','dec','div','esc','hlt','idiv','imul','in','inc', + 'int','into','iret','ja','jae','jb','jbe','jc','jcxz','je','jg','jge','jl','jle','jmp', + 'jna','jnae','jnb','jnbe','jnc','jne','jng','jnge','jnl','jnle','jno','jnp','jns','jnz', + 'jo','jp','jpe','jpo','js','jz','lahf','lds','lea','les','lods','lodsb','lodsw','loop', + 'loope','loopew','loopne','loopnew','loopnz','loopnzw','loopw','loopz','loopzw','mov', + 'movs','movsb','movsw','mul','neg','nop','not','or','out','pop','popf','push','pushf', + 'rcl','rcr','ret','retf','retn','rol','ror','sahf','sal','sar','sbb','scas','scasb','scasw', + 'shl','shr','stc','std','sti','stos','stosb','stosw','sub','test','wait','xchg','xlat', + 'xlatb','xor','bound','enter','ins','insb','insw','leave','outs','outsb','outsw','popa','pusha','pushw', + 'arpl','lar','lsl','sgdt','sidt','sldt','smsw','str','verr','verw','clts','lgdt','lidt','lldt','lmsw','ltr', + 'bsf','bsr','bt','btc','btr','bts','cdq','cmpsd','cwde','insd','iretd','iretdf','iretf', + 'jecxz','lfs','lgs','lodsd','loopd','looped','loopned','loopnzd','loopzd','lss','movsd', + 'movsx','movzx','outsd','popad','popfd','pushad','pushd','pushfd','scasd','seta','setae', + 'setb','setbe','setc','sete','setg','setge','setl','setle','setna','setnae','setnb','setnbe', + 'setnc','setne','setng','setnge','setnl','setnle','setno','setnp','setns','setnz','seto','setp', + 'setpe','setpo','sets','setz','shld','shrd','stosd','bswap','cmpxchg','invd','invlpg','wbinvd','xadd','lock', + 'rep','repe','repne','repnz','repz' + ), + /*FPU*/ + 2 => array( + 'f2xm1','fabs','fadd','faddp','fbld','fbstp','fchs','fclex','fcom','fcomp','fcompp','fdecstp', + 'fdisi','fdiv','fdivp','fdivr','fdivrp','feni','ffree','fiadd','ficom','ficomp','fidiv', + 'fidivr','fild','fimul','fincstp','finit','fist','fistp','fisub','fisubr','fld','fld1', + 'fldcw','fldenv','fldenvw','fldl2e','fldl2t','fldlg2','fldln2','fldpi','fldz','fmul', + 'fmulp','fnclex','fndisi','fneni','fninit','fnop','fnsave','fnsavew','fnstcw','fnstenv', + 'fnstenvw','fnstsw','fpatan','fprem','fptan','frndint','frstor','frstorw','fsave', + 'fsavew','fscale','fsqrt','fst','fstcw','fstenv','fstenvw','fstp','fstsw','fsub','fsubp', + 'fsubr','fsubrp','ftst','fwait','fxam','fxch','fxtract','fyl2x','fyl2xp1', + 'fsetpm','fcos','fldenvd','fnsaved','fnstenvd','fprem1','frstord','fsaved','fsin','fsincos', + 'fstenvd','fucom','fucomp','fucompp' + ), + /*registers*/ + 3 => array( + 'ah','al','ax','bh','bl','bp','bx','ch','cl','cr0','cr2','cr3','cs','cx','dh','di','dl', + 'dr0','dr1','dr2','dr3','dr6','dr7','ds','dx','eax','ebp','ebx','ecx','edi','edx', + 'es','esi','esp','fs','gs','si','sp','ss','st','tr3','tr4','tr5','tr6','tr7' + ), + /*Directive*/ + 4 => array( + '186','286','286c','286p','287','386','386c','386p','387','486','486p', + '8086','8087','alpha','break','code','const','continue','cref','data','data?', + 'dosseg','else','elseif','endif','endw','err','err1','err2','errb', + 'errdef','errdif','errdifi','erre','erridn','erridni','errnb','errndef', + 'errnz','exit','fardata','fardata?','if','lall','lfcond','list','listall', + 'listif','listmacro','listmacroall',' model','no87','nocref','nolist', + 'nolistif','nolistmacro','radix','repeat','sall','seq','sfcond','stack', + 'startup','tfcond','type','until','untilcxz','while','xall','xcref', + 'xlist','alias','align','assume','catstr','comm','comment','db','dd','df','dosseg','dq', + 'dt','dup','dw','echo','else','elseif','elseif1','elseif2','elseifb','elseifdef','elseifdif', + 'elseifdifi','elseife','elseifidn','elseifidni','elseifnb','elseifndef','end', + 'endif','endm','endp','ends','eq',' equ','even','exitm','extern','externdef','extrn','for', + 'forc','ge','goto','group','high','highword','if','if1','if2','ifb','ifdef','ifdif', + 'ifdifi','ife',' ifidn','ifidni','ifnb','ifndef','include','includelib','instr','invoke', + 'irp','irpc','label','le','length','lengthof','local','low','lowword','lroffset', + 'macro','mask','mod','msfloat','name','ne','offset','opattr','option','org','%out', + 'page','popcontext','proc','proto','ptr','public','purge','pushcontext','record', + 'repeat','rept','seg','segment','short','size','sizeof','sizestr','struc','struct', + 'substr','subtitle','subttl','textequ','this','title','type','typedef','union','while','width', + '.model', '.stack', '.code', '.data' + + ), + + /*Operands*/ + 5 => array( + '@b','@f','addr','basic','byte','c','carry?','dword', + 'far','far16','fortran','fword','near','near16','overflow?','parity?','pascal','qword', + 'real4',' real8','real10','sbyte','sdword','sign?','stdcall','sword','syscall','tbyte', + 'vararg','word','zero?','flat','near32','far32', + 'abs','all','assumes','at','casemap','common','compact', + 'cpu','dotname','emulator','epilogue','error','export','expr16','expr32','farstack','flat', + 'forceframe','huge','language','large','listing','ljmp','loadds','m510','medium','memory', + 'nearstack','nodotname','noemulator','nokeyword','noljmp','nom510','none','nonunique', + 'nooldmacros','nooldstructs','noreadonly','noscoped','nosignextend','nothing', + 'notpublic','oldmacros','oldstructs','os_dos','para','private','prologue','radix', + 'readonly','req','scoped','setif2','smallstack','tiny','use16','use32','uses' + ) + ), + 'SYMBOLS' => array( + '[', ']', '(', ')' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #00007f;', + 2 => 'color: #0000ff;', + 3 => 'color: #46aa03; font-weight:bold;', + 4 => 'color: #0000ff;', + 5 => 'color: #0000ff;' + ), + 'COMMENTS' => array( + 1 => 'color: #adadad; font-style: italic;', + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #7f007f;' + ), + 'NUMBERS' => array( + 0 => 'color: #ff0000;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + 0 => 'color: #ff0000;', + 1 => 'color: #ff0000;' + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + 0 => '[0-9a-fA-F][0-9a-fA-F]*[hH]', + 1 => '[01][01]*[bB]' + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/asp.php b/inc/geshi/asp.php new file mode 100644 index 000000000..5728a1bbd --- /dev/null +++ b/inc/geshi/asp.php @@ -0,0 +1,153 @@ +<?php
+/*************************************************************************************
+ * asp.php
+ * --------
+ * Author: Amit Gupta (http://blog.igeek.info/)
+ * Copyright: (c) 2004 Amit Gupta (http://blog.igeek.info/), Nigel McNie (http://qbnz.com/highlighter)
+ * Release Version: 1.0.2
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2004/08/13
+ * Last Modified: $Date: 2004/11/29 08:46:24 $
+ *
+ * ASP language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/11/27 (1.0.2)
+ * - Added support for multiple object splitters
+ * 2004/10/27 (1.0.1)
+ * - Added support for URLs
+ * 2004/08/13 (1.0.0)
+ * - First Release
+ *
+ * TODO (updated 2004/11/27)
+ * -------------------------
+ * * Include all the functions, keywords etc that I have missed
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+$language_data = array (
+ 'LANG_NAME' => 'ASP',
+ 'COMMENT_SINGLE' => array(1 => "'", 2 => '//'),
+ 'COMMENT_MULTI' => array('/*' => '*/'),
+ 'CASE_KEYWORDS' => 0,
+ 'QUOTEMARKS' => array("'", '"'),
+ 'ESCAPE_CHAR' => '\\',
+ 'KEYWORDS' => array(
+ 1 => array(
+ 'include', 'file', 'Dim', 'Option', 'Explicit', 'Implicit', 'Set', 'Select', 'ReDim', 'Preserve',
+ 'ByVal', 'ByRef', 'End', 'Private', 'Public', 'If', 'Then', 'Else', 'ElseIf', 'Case', 'With', 'NOT',
+ 'While', 'Wend', 'For', 'Loop', 'Do', 'Request', 'Response', 'Server', 'ADODB', 'Session', 'Application',
+ 'Each', 'In', 'Get', 'Next', 'INT', 'CINT', 'CBOOL', 'CDATE', 'CBYTE', 'CCUR', 'CDBL', 'CLNG', 'CSNG',
+ 'CSTR', 'Fix', 'Is', 'Sgn', 'String', 'Boolean', 'Currency', 'Me', 'Single', 'Long', 'Integer', 'Byte',
+ 'Variant', 'Double', 'To', 'Let', 'Xor', 'Resume', 'On', 'Error', 'Imp', 'GoTo', 'Call', 'Global'
+ ),
+ 2 => array(
+ 'Null', 'Nothing', 'And',
+ 'False', '<%', '%>',
+ '<script language=', '</script>',
+ 'True', 'var', 'Or', 'BOF', 'EOF',
+ 'Function', 'Class', 'New', 'Sub'
+ ),
+ 3 => array(
+ 'CreateObject', 'Write', 'Redirect', 'Cookies', 'BinaryRead', 'ClientCertificate', 'Form', 'QueryString',
+ 'ServerVariables', 'TotalBytes', 'AddHeader', 'AppendToLog', 'BinaryWrite', 'Buffer', 'CacheControl',
+ 'Charset', 'Clear', 'ContentType', 'End()', 'Expires', 'ExpiresAbsolute', 'Flush()', 'IsClientConnected',
+ 'PICS', 'Status', 'Connection', 'Recordset', 'Execute', 'Abandon', 'Lock', 'UnLock', 'Command', 'Fields',
+ 'Properties', 'Property', 'Send', 'Replace', 'InStr', 'TRIM', 'NOW', 'Day', 'Month', 'Hour', 'Minute', 'Second',
+ 'Year', 'MonthName', 'LCase', 'UCase', 'Abs', 'Array', 'As', 'LEN', 'MoveFirst', 'MoveLast', 'MovePrevious',
+ 'MoveNext', 'LBound', 'UBound', 'Transfer', 'Open', 'Close', 'MapPath', 'FileExists', 'OpenTextFile', 'ReadAll'
+ )
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => false,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #990099; font-weight: bold;',
+ 2 => 'color: #0000ff; font-weight: bold;',
+ 3 => 'color: #330066;'
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #008000;',
+ 2 => 'color: #ff6600;',
+ 'MULTI' => 'color: #008000;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #000099; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #006600; font-weight:bold'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #cc0000;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #800000;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #9900cc;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #006600; font-weight: bold'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'SCRIPT' => array(
+ 0 => '',
+ 1 => '',
+ 2 => '',
+ )
+ ),
+ 'URLS' => array(
+ 1 => '',
+ 2 => '',
+ 3 => ''
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_MAYBE,
+ 'SCRIPT_DELIMITERS' => array(
+ 0 => array(
+ '<%' => '%>'
+ ),
+ 1 => array(
+ '<script language="vbscript" runat="server">' => '</script>'
+ ),
+ 2 => array(
+ '<script language="javascript" runat="server">' => '</script>'
+ )
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ 0 => true,
+ 1 => true,
+ 2 => true,
+ )
+);
+
+?>
\ No newline at end of file diff --git a/inc/geshi/bash.php b/inc/geshi/bash.php new file mode 100644 index 000000000..976ecd676 --- /dev/null +++ b/inc/geshi/bash.php @@ -0,0 +1,130 @@ +<?php +/************************************************************************************* + * bash.php + * -------- + * Author: Andreas Gohr (andi@splitbrain.org) + * Copyright: (c) 2004 Andreas Gohr, Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.2 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/20 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * BASH language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.2) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.1) + * - Added support for URLs + * 2004/08/20 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * Get symbols working + * * Highlight builtin vars + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Bash', + 'COMMENT_SINGLE' => array(1 => '#'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'case', 'do', 'done', 'elif', 'else', 'esac', 'fi', 'for', 'function', + 'if', 'in', 'select', 'then', 'until', 'while', 'time' + ), + 3 => array( + 'source', 'alias', 'bg', 'bind', 'break', 'builtin', 'cd', 'command', + 'compgen', 'complete', 'continue', 'declare', 'typeset', 'dirs', + 'disown', 'echo', 'enable', 'eval', 'exec', 'exit', 'export', 'fc', + 'fg', 'getopts', 'hash', 'help', 'history', 'jobs', 'kill', 'let', + 'local', 'logout', 'popd', 'printf', 'pushd', 'pwd', 'read', 'readonly', + 'return', 'set', 'shift', 'shopt', 'suspend', 'test', 'times', 'trap', + 'type', 'ulimit', 'umask', 'unalias', 'unset', 'wait' + ) + ), + 'SYMBOLS' => array( + '(', ')', '[', ']', '!', '@', '%', '&', '*', '|', '/', '<', '>' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => true, + 3 => true, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 3 => 'color: #000066;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + 0 => 'color: #0000ff;', + 1 => 'color: #0000ff;', + 2 => 'color: #0000ff;' + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 3 => '' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + 0 => "\\$\\{[a-zA-Z_][a-zA-Z0-9_]*?\\}", + 1 => "\\$[a-zA-Z_][a-zA-Z0-9_]*", + 2 => "([a-zA-Z_][a-zA-Z0-9_]*)=" + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/c.php b/inc/geshi/c.php new file mode 100644 index 000000000..79a3295e1 --- /dev/null +++ b/inc/geshi/c.php @@ -0,0 +1,144 @@ +<?php +/************************************************************************************* + * c.php + * ----- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Contributors: + * - Jack Lloyd (lloyd@randombit.net) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.4 + * CVS Revision Version: $Revision: 1.2 $ + * Date Started: 2004/06/04 + * Last Modified: $Date: 2004/12/01 08:44:47 $ + * + * C language file for GeSHi. + * + * CHANGES + * ------- + * 2004/XX/XX (1.0.4) + * - Added a couple of new keywords (Jack Lloyd) + * 2004/11/27 (1.0.3) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.2) + * - Added support for URLs + * 2004/08/05 (1.0.1) + * - Added support for symbols + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * - Get a list of inbuilt functions to add (and explore C more + * to complete this rather bare language file + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'C', + 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'if', 'return', 'while', 'case', 'continue', 'default', + 'do', 'else', 'for', 'switch', 'goto' + ), + 2 => array( + 'null', 'false', 'break', 'true', 'function', 'enum', 'extern', 'inline' + ), + 3 => array( + 'printf', 'cout' + ), + 4 => array( + 'auto', 'char', 'const', 'double', 'float', 'int', 'long', + 'register', 'short', 'signed', 'sizeof', 'static', 'string', 'struct', + 'typedef', 'union', 'unsigned', 'void', 'volatile', 'wchar_t' + ), + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', '[', ']', '=', '+', '-', '*', '/', '!', '%', '^', '&', ':' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #000066;', + 4 => 'color: #993333;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 2 => 'color: #339933;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #202020;', + 2 => 'color: #202020;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => 'http://www.opengroup.org/onlinepubs/009695399/functions/{FNAME}.html', + 4 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.', + 2 => '::' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/c_mac.php b/inc/geshi/c_mac.php new file mode 100644 index 000000000..94a8fd25a --- /dev/null +++ b/inc/geshi/c_mac.php @@ -0,0 +1,176 @@ +<?php +/************************************************************************************* + * c_mac.php + * --------- + * Author: M. Uli Kusterer (witness.of.teachtext@gmx.net) + * Copyright: (c) 2004 M. Uli Kusterer, Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.0 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/04 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * C for Macs language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'C', + 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'if', 'return', 'while', 'case', 'continue', 'default', + 'do', 'else', 'for', 'switch', 'goto' + ), + 2 => array( + 'NULL', 'false', 'break', 'true', 'enum', 'errno', 'EDOM', + 'ERANGE', 'FLT_RADIX', 'FLT_ROUNDS', 'FLT_DIG', 'DBL_DIG', 'LDBL_DIG', + 'FLT_EPSILON', 'DBL_EPSILON', 'LDBL_EPSILON', 'FLT_MANT_DIG', 'DBL_MANT_DIG', + 'LDBL_MANT_DIG', 'FLT_MAX', 'DBL_MAX', 'LDBL_MAX', 'FLT_MAX_EXP', 'DBL_MAX_EXP', + 'LDBL_MAX_EXP', 'FLT_MIN', 'DBL_MIN', 'LDBL_MIN', 'FLT_MIN_EXP', 'DBL_MIN_EXP', + 'LDBL_MIN_EXP', 'CHAR_BIT', 'CHAR_MAX', 'CHAR_MIN', 'SCHAR_MAX', 'SCHAR_MIN', + 'UCHAR_MAX', 'SHRT_MAX', 'SHRT_MIN', 'USHRT_MAX', 'INT_MAX', 'INT_MIN', + 'UINT_MAX', 'LONG_MAX', 'LONG_MIN', 'ULONG_MAX', 'HUGE_VAL', 'SIGABRT', + 'SIGFPE', 'SIGILL', 'SIGINT', 'SIGSEGV', 'SIGTERM', 'SIG_DFL', 'SIG_ERR', + 'SIG_IGN', 'BUFSIZ', 'EOF', 'FILENAME_MAX', 'FOPEN_MAX', 'L_tmpnam', 'NULL', + 'SEEK_CUR', 'SEEK_END', 'SEEK_SET', 'TMP_MAX', 'stdin', 'stdout', 'stderr', + 'EXIT_FAILURE', 'EXIT_SUCCESS', 'RAND_MAX', 'CLOCKS_PER_SEC', + // Mac-specific constants: + 'kCFAllocatorDefault' + ), + 3 => array( + 'printf', 'fprintf', 'snprintf', 'sprintf', 'assert', + 'isalnum', 'isalpha', 'isdigit', 'iscntrl', 'isgraph', 'islower', 'isprint', + 'ispunct', 'isspace', 'ispunct', 'isupper', 'isxdigit', 'tolower', 'toupper', + 'exp', 'log', 'log10', 'pow', 'sqrt', 'ceil', 'floor', 'fabs', 'ldexp', + 'frexp', 'modf', 'fmod', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'atan2', + 'sinh', 'cosh', 'tanh', 'setjmp', 'longjmp', 'asin', 'acos', 'atan', 'atan2', + 'va_start', 'va_arg', 'va_end', 'offsetof', 'sizeof', 'fopen', 'freopen', + 'fflush', 'fclose', 'remove', 'rename', 'tmpfile', 'tmpname', 'setvbuf', + 'setbuf', 'vfprintf', 'vprintf', 'vsprintf', 'fscanf', 'scanf', 'sscanf', + 'fgetc', 'fgets', 'fputc', 'fputs', 'getc', 'getchar', 'gets', 'putc', + 'putchar', 'puts', 'ungetc', 'fread', 'fwrite', 'fseek', 'ftell', 'rewind', + 'fgetpos', 'fsetpos', 'clearerr', 'feof', 'ferror', 'perror', 'abs', 'labs', + 'div', 'ldiv', 'atof', 'atoi', 'atol', 'strtod', 'strtol', 'strtoul', 'calloc', + 'malloc', 'realloc', 'free', 'abort', 'exit', 'atexit', 'system', 'getenv', + 'bsearch', 'qsort', 'rand', 'srand', 'strcpy', 'strncpy', 'strcat', 'strncat', + 'strcmp', 'strncmp', 'strcoll', 'strchr', 'strrchr', 'strspn', 'strcspn', + 'strpbrk', 'strstr', 'strlen', 'strerror', 'strtok', 'strxfrm', 'memcpy', + 'memmove', 'memcmp', 'memchr', 'memset', 'clock', 'time', 'difftime', 'mktime', + 'asctime', 'ctime', 'gmtime', 'localtime', 'strftime' + ), + 4 => array( + 'auto', 'char', 'const', 'double', 'float', 'int', 'long', + 'register', 'short', 'signed', 'sizeof', 'static', 'string', 'struct', + 'typedef', 'union', 'unsigned', 'void', 'volatile', 'extern', 'jmp_buf', + 'signal', 'raise', 'va_list', 'ptrdiff_t', 'size_t', 'FILE', 'fpos_t', + 'div_t', 'ldiv_t', 'clock_t', 'time_t', 'tm', + // Mac-specific types: + 'CFArrayRef', 'CFDictionaryRef', 'CFMutableDictionaryRef', 'CFBundleRef', 'CFSetRef', 'CFStringRef', + 'CFURLRef', 'CFLocaleRef', 'CFDateFormatterRef', 'CFNumberFormatterRef', 'CFPropertyListRef', + 'CFTreeRef', 'CFWriteStreamRef', 'CFCharacterSetRef', 'CFMutableStringRef', 'CFNotificationRef', + 'CFNotificationRef', 'CFReadStreamRef', 'CFNull', 'CFAllocatorRef', 'CFBagRef', 'CFBinaryHeapRef', + 'CFBitVectorRef', 'CFBooleanRef', 'CFDataRef', 'CFDateRef', 'CFMachPortRef', 'CFMessagePortRef', + 'CFMutableArrayRef', 'CFMutableBagRef', 'CFMutableBitVectorRef', 'CFMutableCharacterSetRef', + 'CFMutableDataRef', 'CFMutableSetRef', 'CFNumberRef', 'CFPlugInRef', 'CFPlugInInstanceRef', + 'CFRunLoopRef', 'CFRunLoopObserverRef', 'CFRunLoopSourceRef', 'CFRunLoopTimerRef', 'CFSocketRef', + 'CFTimeZoneRef', 'CFTypeRef', 'CFUserNotificationRef', 'CFUUIDRef', 'CFXMLNodeRef', 'CFXMLParserRef', + 'CFXMLTreeRef' + ), + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', '[', ']', '=', '+', '-', '*', '/', '!', '%', '^', '&', ':' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #0000ff;', + 2 => 'color: #0000ff;', + 3 => 'color: #0000dd;', + 4 => 'color: #0000ff;' + ), + 'COMMENTS' => array( + 1 => 'color: #ff0000;', + 2 => 'color: #339900;', + 'MULTI' => 'color: #ff0000; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #666666; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #000000;' + ), + 'STRINGS' => array( + 0 => 'color: #666666;' + ), + 'NUMBERS' => array( + 0 => 'color: #0000dd;' + ), + 'METHODS' => array( + 1 => 'color: #00eeff;', + 2 => 'color: #00eeff;' + ), + 'SYMBOLS' => array( + 0 => 'color: #000000;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => 'http://www.opengroup.org/onlinepubs/009695399/functions/{FNAME}.html', + 4 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.', + 2 => '::' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/caddcl.php b/inc/geshi/caddcl.php new file mode 100644 index 000000000..04c3c117f --- /dev/null +++ b/inc/geshi/caddcl.php @@ -0,0 +1,127 @@ +<?php +/************************************************************************************* + * caddcl.php + * ---------- + * Author: Roberto Rossi (rsoftware@altervista.org) + * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/30 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * CAD DCL (Dialog Control Language) file for GeSHi. + * + * DCL for AutoCAD 12 or later and IntelliCAD all versions. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/1!/27 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'CADDCL', + 'COMMENT_SINGLE' => array(1 => '//'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'boxed_column','boxed_radio_column','boxed_radio_row','boxed_row', + 'column','concatenation','button','dialog','edit_box','image','image_button', + 'errtile','list_box','ok_cancel','ok_cancel_help','ok_cancel_help_errtile', + 'ok_cancel_help_info','ok_only','paragraph','popup_list','radio_button', + 'radio_column','radio_row','row','slider','spacer','spacer_0','spacer_1','text', + 'text_part','toggle', + 'action','alignment','allow_accept','aspect_ratio','big_increment', + 'children_alignment','children_fixed_height', + 'children_fixed_width','color', + 'edit_limit','edit_width','fixed_height','fixed_width', + 'height','initial_focus','is_cancel','is_default', + 'is_enabled','is_tab_stop','is-bold','key','label','layout','list', + 'max_value','min_value','mnemonic','multiple_select','password_char', + 'small_increment','tabs','tab_truncate','value','width', + 'false','true','left','right','centered','top','bottom', + 'dialog_line','dialog_foreground','dialog_background', + 'graphics_background','black','red','yellow','green','cyan', + 'blue','magenta','whitegraphics_foreground', + 'horizontal','vertical' + ) + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', '[', ']', '=', '+', '-', '*', '/', '!', '%', '^', '&', ':' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/cadlisp.php b/inc/geshi/cadlisp.php new file mode 100644 index 000000000..23991d576 --- /dev/null +++ b/inc/geshi/cadlisp.php @@ -0,0 +1,187 @@ +<?php +/************************************************************************************* + * cadlisp.php + * ----------- + * Author: Roberto Rossi (rsoftware@altervista.org) + * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/blog) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/30 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * AutoCAD/IntelliCAD Lisp language file for GeSHi. + * + * For AutoCAD V.12..2005 and IntelliCAD all versions. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'CADLISP', + 'COMMENT_SINGLE' => array(1 => ";"), + 'COMMENT_MULTI' => array(";|" => "|;"), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'abs','acad_colordlg','acad_helpdlg','acad_strlsort','action_tile', + 'add_list','alert','alloc','and','angle','angtof','angtos','append','apply', + 'arx','arxload','arxunload','ascii','assoc','atan','atof','atoi','atom', + 'atoms-family','autoarxload','autoload','Boole','boundp','caddr', + 'cadr','car','cdr','chr','client_data_tile','close','command','cond', + 'cons','cos','cvunit','defun','defun-q','defun-q-list-ref', + 'defun-q-list-set','dictadd','dictnext','dictremove','dictrename', + 'dictsearch','dimx_tile','dimy_tile','distance','distof','done_dialog', + 'end_image','end_list','entdel','entget','entlast','entmake', + 'entmakex','entmod','entnext','entsel','entupd','eq','equal','eval','exit', + 'exp','expand','expt','fill_image','findfile','fix','float','foreach','function', + 'gc','gcd','get_attr','get_tile','getangle','getcfg','getcname','getcorner', + 'getdist','getenv','getfiled','getint','getkword','getorient','getpoint', + 'getreal','getstring','getvar','graphscr','grclear','grdraw','grread','grtext', + 'grvecs','handent','help','if','initdia','initget','inters','itoa','lambda','last', + 'layoutlist','length','list','listp','load','load_dialog','log','logand','logior', + 'lsh','mapcar','max','mem','member','menucmd','menugroup','min','minusp','mode_tile', + 'namedobjdict','nentsel','nentselp','new_dialog','nil','not','nth','null', + 'numberp','open','or','osnap','polar','prin1','princ','print','progn','prompt', + 'quit','quote','read','read-char','read-line','redraw','regapp','rem','repeat', + 'reverse','rtos','set','set_tile','setcfg','setenv','setfunhelp','setq','setvar', + 'setview','sin','slide_image','snvalid','sqrt','ssadd','ssdel','ssget','ssgetfirst', + 'sslength','ssmemb','ssname','ssnamex','sssetfirst','start_dialog','start_image', + 'start_list','startapp','strcase','strcat','strlen','subst','substr','t','tablet', + 'tblnext','tblobjname','tblsearch','term_dialog','terpri','textbox','textpage', + 'textscr','trace','trans','type','unload_dialog','untrace','vector_image','ver', + 'vports','wcmatch','while','write-char','write-line','xdroom','xdsize','zerop', + 'vl-acad-defun','vl-acad-undefun','vl-arx-import','vlax-3D-point', + 'vlax-add-cmd','vlax-create-object','vlax-curve-getArea', + 'vlax-curve-getClosestPointTo','vlax-curve-getClosestPointToProjection', + 'vlax-curve-getDistAtParam','vlax-curve-getDistAtPoint', + 'vlax-curve-getEndParam','vlax-curve-getEndPoint', + 'vlax-curve-getFirstDeriv','vlax-curve-getParamAtDist', + 'vlax-curve-getParamAtPoint','vlax-curve-getPointAtDist', + 'vlax-curve-getPointAtParam','vlax-curve-getSecondDeriv', + 'vlax-curve-getStartParam','vlax-curve-getStartPoint', + 'vlax-curve-isClosed','vlax-curve-isPeriodic','vlax-curve-isPlanar', + 'vlax-dump-object','vlax-erased-p','vlax-for','vlax-get-acad-object', + 'vlax-get-object','vlax-get-or-create-object','vlax-get-property', + 'vlax-import-type-library','vlax-invoke-method','vlax-ldata-delete', + 'vlax-ldata-get','vlax-ldata-list','vlax-ldata-put','vlax-ldata-test', + 'vlax-make-safearray','vlax-make-variant','vlax-map-collection', + 'vlax-method-applicable-p','vlax-object-released-p','vlax-product-key', + 'vlax-property-available-p','vlax-put-property','vlax-read-enabled-p', + 'vlax-release-object','vlax-remove-cmd','vlax-safearray-fill', + 'vlax-safearray-get-dim','vlax-safearray-get-element', + 'vlax-safearray-get-l-bound','vlax-safearray-get-u-bound', + 'vlax-safearray-put-element','vlax-safearray-type','vlax-tmatrix', + 'vlax-typeinfo-available-p','vlax-variant-change-type', + 'vlax-variant-type','vlax-variant-value','vlax-write-enabled-p', + 'vl-bb-ref','vl-bb-set','vl-catch-all-apply','vl-catch-all-error-message', + 'vl-catch-all-error-p','vl-cmdf','vl-consp','vl-directory-files','vl-doc-export', + 'vl-doc-import','vl-doc-ref','vl-doc-set','vl-every','vl-exit-with-error', + 'vl-exit-with-value','vl-file-copy','vl-file-delete','vl-file-directory-p', + 'vl-filename-base','vl-filename-directory','vl-filename-extension', + 'vl-filename-mktemp','vl-file-rename','vl-file-size','vl-file-systime', + 'vl-get-resource','vlisp-compile','vl-list-exported-functions', + 'vl-list-length','vl-list-loaded-vlx','vl-load-all','vl-load-com', + 'vl-load-reactors','vl-member-if','vl-member-if-not','vl-position', + 'vl-prin1-to-string','vl-princ-to-string','vl-propagate','vlr-acdb-reactor', + 'vlr-add','vlr-added-p','vlr-beep-reaction','vlr-command-reactor', + 'vlr-current-reaction-name','vlr-data','vlr-data-set', + 'vlr-deepclone-reactor','vlr-docmanager-reactor','vlr-dwg-reactor', + 'vlr-dxf-reactor','vlr-editor-reactor','vl-registry-delete', + 'vl-registry-descendents','vl-registry-read','vl-registry-write', + 'vl-remove','vl-remove-if','vl-remove-if-not','vlr-insert-reactor', + 'vlr-linker-reactor','vlr-lisp-reactor','vlr-miscellaneous-reactor', + 'vlr-mouse-reactor','vlr-notification','vlr-object-reactor', + 'vlr-owner-add','vlr-owner-remove','vlr-owners','vlr-pers','vlr-pers-list', + 'vlr-pers-p','vlr-pers-release','vlr-reaction-names','vlr-reactions', + 'vlr-reaction-set','vlr-reactors','vlr-remove','vlr-remove-all', + 'vlr-set-notification','vlr-sysvar-reactor','vlr-toolbar-reactor', + 'vlr-trace-reaction','vlr-type','vlr-types','vlr-undo-reactor', + 'vlr-wblock-reactor','vlr-window-reactor','vlr-xref-reactor', + 'vl-some','vl-sort','vl-sort-i','vl-string-elt','vl-string-left-trim', + 'vl-string-mismatch','vl-string-position','vl-string-right-trim', + 'vl-string-search','vl-string-subst','vl-string-translate','vl-string-trim', + 'vl-symbol-name','vl-symbolp','vl-symbol-value','vl-unload-vlx','vl-vbaload', + 'vl-vbarun','vl-vlx-loaded-p' + ) + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', '[', ']', '!', '%', '^', '&', '/','+','-','*','=','<','>' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/cpp.php b/inc/geshi/cpp.php new file mode 100644 index 000000000..b7cd988c1 --- /dev/null +++ b/inc/geshi/cpp.php @@ -0,0 +1,174 @@ +<?php
+/*************************************************************************************
+ * cpp.php
+ * -------
+ * Author: Dennis Bayer (Dennis.Bayer@mnifh-giessen.de)
+ * Contributors:
+ * - M. Uli Kusterer (witness.of.teachtext@gmx.net)
+ * - Jack Lloyd (lloyd@randombit.net)
+ * Copyright: (c) 2004 Dennis Bayer, Nigel McNie (http://qbnz.com/highlighter)
+ * Release Version: 1.0.2
+ * CVS Revision Version: $Revision: 1.2 $
+ * Date Started: 2004/09/27
+ * Last Modified: $Date: 2004/12/01 08:44:47 $
+ *
+ * C++ language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/XX/XX (1.0.2)
+ * - Added several new keywords (Jack Lloyd)
+ * 2004/11/27 (1.0.1)
+ * - Added StdCLib function and constant names, changed color scheme to
+ * a cleaner one. (M. Uli Kusterer)
+ * - Added support for multiple object splitters
+ * 2004/10/27 (1.0.0)
+ * - First Release
+ *
+ * TODO (updated 2004/11/27)
+ * -------------------------
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+$language_data = array (
+ 'LANG_NAME' => 'C++',
+ 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'),
+ 'COMMENT_MULTI' => array('/*' => '*/'),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array("'", '"'),
+ 'ESCAPE_CHAR' => '\\',
+ 'KEYWORDS' => array(
+ 1 => array(
+ 'case', 'continue', 'default', 'do', 'else', 'for', 'goto', 'if', 'return',
+ 'switch', 'while'
+ ),
+ 2 => array(
+ 'NULL', 'false', 'break', 'true', 'enum', 'errno', 'EDOM',
+ 'ERANGE', 'FLT_RADIX', 'FLT_ROUNDS', 'FLT_DIG', 'DBL_DIG', 'LDBL_DIG',
+ 'FLT_EPSILON', 'DBL_EPSILON', 'LDBL_EPSILON', 'FLT_MANT_DIG', 'DBL_MANT_DIG',
+ 'LDBL_MANT_DIG', 'FLT_MAX', 'DBL_MAX', 'LDBL_MAX', 'FLT_MAX_EXP', 'DBL_MAX_EXP',
+ 'LDBL_MAX_EXP', 'FLT_MIN', 'DBL_MIN', 'LDBL_MIN', 'FLT_MIN_EXP', 'DBL_MIN_EXP',
+ 'LDBL_MIN_EXP', 'CHAR_BIT', 'CHAR_MAX', 'CHAR_MIN', 'SCHAR_MAX', 'SCHAR_MIN',
+ 'UCHAR_MAX', 'SHRT_MAX', 'SHRT_MIN', 'USHRT_MAX', 'INT_MAX', 'INT_MIN',
+ 'UINT_MAX', 'LONG_MAX', 'LONG_MIN', 'ULONG_MAX', 'HUGE_VAL', 'SIGABRT',
+ 'SIGFPE', 'SIGILL', 'SIGINT', 'SIGSEGV', 'SIGTERM', 'SIG_DFL', 'SIG_ERR',
+ 'SIG_IGN', 'BUFSIZ', 'EOF', 'FILENAME_MAX', 'FOPEN_MAX', 'L_tmpnam', 'NULL',
+ 'SEEK_CUR', 'SEEK_END', 'SEEK_SET', 'TMP_MAX', 'stdin', 'stdout', 'stderr',
+ 'EXIT_FAILURE', 'EXIT_SUCCESS', 'RAND_MAX', 'CLOCKS_PER_SEC',
+ 'virtual', 'public', 'private', 'protected', 'template', 'using', 'namespace',
+ 'try', 'catch', 'inline', 'dynamic_cast', 'const_cast', 'reinterpret_cast',
+ 'static_cast', 'explicit', 'friend', 'wchar_t', 'typename', 'typeid'
+ ),
+ 3 => array(
+ 'cin', 'cerr', 'clog', 'cout', 'delete', 'new', 'this',
+ 'printf', 'fprintf', 'snprintf', 'sprintf', 'assert',
+ 'isalnum', 'isalpha', 'isdigit', 'iscntrl', 'isgraph', 'islower', 'isprint',
+ 'ispunct', 'isspace', 'ispunct', 'isupper', 'isxdigit', 'tolower', 'toupper',
+ 'exp', 'log', 'log10', 'pow', 'sqrt', 'ceil', 'floor', 'fabs', 'ldexp',
+ 'frexp', 'modf', 'fmod', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'atan2',
+ 'sinh', 'cosh', 'tanh', 'setjmp', 'longjmp', 'asin', 'acos', 'atan', 'atan2',
+ 'va_start', 'va_arg', 'va_end', 'offsetof', 'sizeof', 'fopen', 'freopen',
+ 'fflush', 'fclose', 'remove', 'rename', 'tmpfile', 'tmpname', 'setvbuf',
+ 'setbuf', 'vfprintf', 'vprintf', 'vsprintf', 'fscanf', 'scanf', 'sscanf',
+ 'fgetc', 'fgets', 'fputc', 'fputs', 'getc', 'getchar', 'gets', 'putc',
+ 'putchar', 'puts', 'ungetc', 'fread', 'fwrite', 'fseek', 'ftell', 'rewind',
+ 'fgetpos', 'fsetpos', 'clearerr', 'feof', 'ferror', 'perror', 'abs', 'labs',
+ 'div', 'ldiv', 'atof', 'atoi', 'atol', 'strtod', 'strtol', 'strtoul', 'calloc',
+ 'malloc', 'realloc', 'free', 'abort', 'exit', 'atexit', 'system', 'getenv',
+ 'bsearch', 'qsort', 'rand', 'srand', 'strcpy', 'strncpy', 'strcat', 'strncat',
+ 'strcmp', 'strncmp', 'strcoll', 'strchr', 'strrchr', 'strspn', 'strcspn',
+ 'strpbrk', 'strstr', 'strlen', 'strerror', 'strtok', 'strxfrm', 'memcpy',
+ 'memmove', 'memcmp', 'memchr', 'memset', 'clock', 'time', 'difftime', 'mktime',
+ 'asctime', 'ctime', 'gmtime', 'localtime', 'strftime'
+ ),
+ 4 => array(
+ 'auto', 'bool', 'char', 'const', 'double', 'float', 'int', 'long', 'longint',
+ 'register', 'short', 'shortint', 'signed', 'static', 'struct',
+ 'typedef', 'union', 'unsigned', 'void', 'volatile', 'extern', 'jmp_buf',
+ 'signal', 'raise', 'va_list', 'ptrdiff_t', 'size_t', 'FILE', 'fpos_t',
+ 'div_t', 'ldiv_t', 'clock_t', 'time_t', 'tm',
+ ),
+ ),
+ 'SYMBOLS' => array(
+ '(', ')', '{', '}', '[', ']', '=', '+', '-', '*', '/', '!', '%', '^', '&', ':'
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => true,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ 4 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #0000ff;',
+ 2 => 'color: #0000ff;',
+ 3 => 'color: #0000dd;',
+ 4 => 'color: #0000ff;'
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #ff0000;',
+ 2 => 'color: #339900;',
+ 'MULTI' => 'color: #ff0000; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #666666; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #000000;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #666666;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #0000dd;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #00eeff;',
+ 2 => 'color: #00eeff;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #000000;'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'SCRIPT' => array(
+ )
+ ),
+ 'URLS' => array(
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.',
+ 2 => '::'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_NEVER,
+ 'SCRIPT_DELIMITERS' => array(
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ )
+);
+
+?>
+
+
diff --git a/inc/geshi/csharp.php b/inc/geshi/csharp.php new file mode 100644 index 000000000..d602d53fc --- /dev/null +++ b/inc/geshi/csharp.php @@ -0,0 +1,229 @@ +<?php
+/*************************************************************************************
+ * csharp.php
+ * ----------
+ * Author: Alan Juden (alan@judenware.org)
+ * Copyright: (c) 2004 Alan Juden, Nigel McNie (http://qbnz.com/highlighter/)
+ * Release Version: 1.0.0
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2004/06/04
+ * Last Modified: $Date: 2004/11/29 08:46:24 $
+ *
+ * C# language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/11/27 (1.0.0)
+ * - Initial release
+ *
+ * TODO (updated 2004/11/27)
+ * -------------------------
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+ $language_data = array (
+ 'LANG_NAME' => 'CSharp',
+ 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'),
+ 'COMMENT_MULTI' => array('/*' => '*/'),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array("'", '"'),
+ 'ESCAPE_CHAR' => '\\',
+ 'KEYWORDS' => array(
+ 1 => array(
+ 'as', 'auto', 'base', 'break', 'case', 'catch', 'const', 'continue',
+ 'default', 'do', 'else', 'event', 'explicit', 'extern', 'false',
+ 'finally', 'fixed', 'for', 'foreach', 'goto', 'if', 'implicit',
+ 'in', 'internal', 'lock', 'namespace', 'null', 'operator', 'out',
+ 'override', 'params', 'private', 'protected', 'public', 'readonly',
+ 'ref', 'return', 'sealed', 'stackalloc', 'static', 'switch', 'this',
+ 'throw', 'true', 'try', 'unsafe', 'using', 'virtual', 'void', 'while'
+ ),
+ 2 => array(
+ '#elif', '#endif', '#endregion', '#else', '#error', '#define', '#if',
+ '#line', '#region', '#undef', '#warning'
+ ),
+ 3 => array(
+ 'checked', 'is', 'new', 'sizeof', 'typeof', 'unchecked'
+ ),
+ 4 => array(
+ 'bool', 'byte', 'char', 'class', 'decimal', 'delegate', 'double',
+ 'enum', 'float', 'int', 'interface', 'long', 'object', 'sbyte',
+ 'short', 'string', 'struct', 'uint', 'ulong', 'ushort'
+ ),
+ 5 => array(
+ 'Microsoft.Win32',
+ 'System',
+ 'System.CodeDOM',
+ 'System.CodeDOM.Compiler',
+ 'System.Collections',
+ 'System.Collections.Bases',
+ 'System.ComponentModel',
+ 'System.ComponentModel.Design',
+ 'System.ComponentModel.Design.CodeModel',
+ 'System.Configuration',
+ 'System.Configuration.Assemblies',
+ 'System.Configuration.Core',
+ 'System.Configuration.Install',
+ 'System.Configuration.Interceptors',
+ 'System.Configuration.Schema',
+ 'System.Configuration.Web',
+ 'System.Core',
+ 'System.Data',
+ 'System.Data.ADO',
+ 'System.Data.Design',
+ 'System.Data.Internal',
+ 'System.Data.SQL',
+ 'System.Data.SQLTypes',
+ 'System.Data.XML',
+ 'System.Data.XML.DOM',
+ 'System.Data.XML.XPath',
+ 'System.Data.XML.XSLT',
+ 'System.Diagnostics',
+ 'System.Diagnostics.SymbolStore',
+ 'System.DirectoryServices',
+ 'System.Drawing',
+ 'System.Drawing.Design',
+ 'System.Drawing.Drawing2D',
+ 'System.Drawing.Imaging',
+ 'System.Drawing.Printing',
+ 'System.Drawing.Text',
+ 'System.Globalization',
+ 'System.IO',
+ 'System.IO.IsolatedStorage',
+ 'System.Messaging',
+ 'System.Net',
+ 'System.Net.Sockets',
+ 'System.NewXml',
+ 'System.NewXml.XPath',
+ 'System.NewXml.Xsl',
+ 'System.Reflection',
+ 'System.Reflection.Emit',
+ 'System.Resources',
+ 'System.Runtime.InteropServices',
+ 'System.Runtime.InteropServices.Expando',
+ 'System.Runtime.Remoting',
+ 'System.Runtime.Serialization',
+ 'System.Runtime.Serialization.Formatters',
+ 'System.Runtime.Serialization.Formatters.Binary',
+ 'System.Security',
+ 'System.Security.Cryptography',
+ 'System.Security.Cryptography.X509Certificates',
+ 'System.Security.Permissions',
+ 'System.Security.Policy',
+ 'System.Security.Principal',
+ 'System.ServiceProcess',
+ 'System.Text',
+ 'System.Text.RegularExpressions',
+ 'System.Threading',
+ 'System.Timers',
+ 'System.Web',
+ 'System.Web.Caching',
+ 'System.Web.Configuration',
+ 'System.Web.Security',
+ 'System.Web.Services',
+ 'System.Web.Services.Description',
+ 'System.Web.Services.Discovery',
+ 'System.Web.Services.Protocols',
+ 'System.Web.UI',
+ 'System.Web.UI.Design',
+ 'System.Web.UI.Design.WebControls',
+ 'System.Web.UI.Design.WebControls.ListControls',
+ 'System.Web.UI.HtmlControls',
+ 'System.Web.UI.WebControls',
+ 'System.WinForms',
+ 'System.WinForms.ComponentModel',
+ 'System.WinForms.Design',
+ 'System.Xml',
+ 'System.Xml.Serialization',
+ 'System.Xml.Serialization.Code',
+ 'System.Xml.Serialization.Schema'
+ ),
+ ),
+ 'SYMBOLS' => array(
+ '+', '-', '*', '?', '=', '/', '%', '&', '>', '<', '^', '!', '|', ':',
+ '(', ')', '{', '}', '[', ']'
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => true,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ 4 => false,
+ 5 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #0600FF;',
+ 2 => 'color: #FF8000; font-weight: bold;',
+ 3 => 'color: #008000;',
+ 4 => 'color: #FF0000;',
+ 5 => 'color: #000000;'
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #008080; font-style: italic;',
+ 2 => 'color: #008080;',
+ 'MULTI' => 'color: #008080; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #008080; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #000000;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #808080;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #FF0000;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #0000FF;',
+ 2 => 'color: #0000FF;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #008000;'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'SCRIPT' => array(
+ )
+ ),
+ 'URLS' => array(
+ 1 => '',
+ 2 => '',
+ 3 => 'http://www.google.com/search?q={FNAME}+msdn.microsoft.com',
+ 4 => ''
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.',
+ 2 => '::'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_NEVER,
+ 'SCRIPT_DELIMITERS' => array(
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ )
+);
+
+?>
\ No newline at end of file diff --git a/inc/geshi/css-gen.cfg b/inc/geshi/css-gen.cfg new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/inc/geshi/css-gen.cfg diff --git a/inc/geshi/css.php b/inc/geshi/css.php new file mode 100644 index 000000000..b82aa555a --- /dev/null +++ b/inc/geshi/css.php @@ -0,0 +1,177 @@ +<?php +/************************************************************************************* + * css.php + * ------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.3 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/18 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * CSS language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.3) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.2) + * - Changed regexps to catch "-" symbols + * - Added support for URLs + * 2004/08/05 (1.0.1) + * - Added support for symbols + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * Improve or drop regexps for class/id/psuedoclass highlighting + * * Re-look at keywords - possibly to make several CSS language + * files, all with different versions of CSS in them + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + + +$language_data = array ( + 'LANG_NAME' => 'CSS', + 'COMMENT_SINGLE' => array(1 => '@'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"', "'"), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'aqua', 'azimuth', 'background-attachment', 'background-color', + 'background-image', 'background-position', 'background-repeat', + 'background', 'black', 'blue', 'border-bottom-color', 'border-bottom-style', + 'border-bottom-width', 'border-left-color', 'border-left-style', + 'border-left-width', 'border-right', 'border-right-color', + 'border-right-style', 'border-right-width', 'border-top-color', + 'border-top-style', 'border-top-width','border-bottom', 'border-collapse', + 'border-left', 'border-width', 'border-color', 'border-spacing', + 'border-style', 'border-top', 'border', 'bottom', 'caption-side', + 'clear', 'clip', 'color', 'content', 'counter-increment', 'counter-reset', + 'cue-after', 'cue-before', 'cue', 'cursor', 'direction', 'display', + 'elevation', 'empty-cells', 'float', 'font-family', 'font-size', + 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', + 'font-weight', 'font', 'height', 'left', 'letter-spacing', 'line-height', + 'list-style', 'list-style-image', 'list-style-position', 'list-style-type', + 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'margin', + 'marker-offset', 'marks', 'max-height', 'max-width', 'min-height', + 'min-width', 'orphans', 'outline', 'outline-color', 'outline-style', + 'outline-width', 'overflow', 'padding-bottom', 'padding-left', + 'padding-right', 'padding-top', 'padding', 'page', 'page-break-after', + 'page-break-before', 'page-break-inside', 'pause-after', 'pause-before', + 'pause', 'pitch', 'pitch-range', 'play-during', 'position', 'quotes', + 'richness', 'right', 'size', 'speak-header', 'speak-numeral', 'speak-punctuation', + 'speak', 'speech-rate', 'stress', 'table-layout', 'text-align', 'text-decoration', + 'text-indent', 'text-shadow', 'text-transform', 'top', 'unicode-bidi', + 'vertical-align', 'visibility', 'voice-family', 'volume', 'white-space', 'widows', + 'width', 'word-spacing', 'z-index' + ), + 2 => array( + 'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', + 'baseline', 'behind', 'below', 'bidi-override', 'blink', 'block', 'bold', 'bolder', 'both', + 'capitalize', 'center-left', 'center-right', 'center', 'circle', 'cjk-ideographic', 'close-quote', 'collapse', 'condensed', 'continuous', 'crop', 'crosshair', 'cross', 'cursive', + 'dashed', 'decimal-leading-zero', 'decimal', 'default', 'digits', 'disc', 'dotted', 'double', + 'e-resize', 'embed', 'extra-condensed', 'extra-expanded', 'expanded', + 'fantasy', 'far-left', 'far-right', 'faster', 'fast', 'fixed', 'fuchsia', + 'georgian', 'gray', 'green', 'groove', 'hebrew', 'help', 'hidden', 'hide', 'higher', + 'high', 'hiragana-iroha', 'hiragana', 'icon', 'inherit', 'inline-table', 'inline', + 'inset', 'inside', 'invert', 'italic', 'justify', 'katakana-iroha', 'katakana', + 'landscape', 'larger', 'large', 'left-side', 'leftwards', 'level', 'lighter', 'lime', 'line-through', 'list-item', 'loud', 'lower-alpha', 'lower-greek', 'lower-roman', 'lowercase', 'ltr', 'lower', 'low', + 'maroon', 'medium', 'message-box', 'middle', 'mix', 'monospace', + 'n-resize', 'narrower', 'navy', 'ne-resize', 'no-close-quote', 'no-open-quote', 'no-repeat', 'none', 'normal', 'nowrap', 'nw-resize', + 'oblique', 'olive', 'once', 'open-quote', 'outset', 'outside', 'overline', + 'pointer', 'portrait', 'purple', 'px', + 'red', 'relative', 'repeat-x', 'repeat-y', 'repeat', 'rgb', 'ridge', 'right-side', 'rightwards', + 's-resize', 'sans-serif', 'scroll', 'se-resize', 'semi-condensed', 'semi-expanded', 'separate', 'serif', 'show', 'silent', 'silver', 'slow', 'slower', 'small-caps', 'small-caption', 'smaller', 'soft', 'solid', 'spell-out', 'square', + 'static', 'status-bar', 'super', 'sw-resize', + 'table-caption', 'table-cell', 'table-column', 'table-column-group', 'table-footer-group', 'table-header-group', 'table-row', 'table-row-group', 'teal', 'text', 'text-bottom', 'text-top', 'thick', 'thin', 'transparent', + 'ultra-condensed', 'ultra-expanded', 'underline', 'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url', + 'visible', + 'w-resize', 'wait', 'white', 'wider', + 'x-fast', 'x-high', 'x-large', 'x-loud', 'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', + 'yellow', 'yes' + ) + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', ':', ';' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => true, + 2 => true + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #000000; font-weight: bold;', + 2 => 'color: #993333;' + ), + 'COMMENTS' => array( + 1 => 'color: #a1a100;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + 0 => 'color: #cc00cc;', + 1 => 'color: #6666ff;', + 2 => 'color: #3333ff;', + ) + ), + 'URLS' => array( + 1 => '', + 2 => '' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + 0 => '\#[a-zA-Z0-9\-]+\s+\{', + 1 => '\.[a-zA-Z0-9\-]+\s', + 2 => ':[a-zA-Z0-9\-]+\s' + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/delphi.php b/inc/geshi/delphi.php new file mode 100644 index 000000000..b27ec698d --- /dev/null +++ b/inc/geshi/delphi.php @@ -0,0 +1,159 @@ +<?php
+/*************************************************************************************
+ * delphi.php
+ * ----------
+ * Author: Járja Norbert (jnorbi@vipmail.hu)
+ * Copyright: (c) 2004 Járja Norbert, Nigel McNie (http://qbnz.com/highlighter)
+ * Release Version: 1.0.1
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2004/07/26
+ * Last Modified: $Date: 2004/11/29 08:46:24 $
+ *
+ * Delphi (Object Pascal) language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/11/27 (1.0.1)
+ * - Added support for multiple object splitters
+ * 2004/10/27 (1.0.0)
+ * - First Release
+ *
+ * TODO (updated 2004/11/27)
+ * -------------------------
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+$language_data = array (
+ 'LANG_NAME' => 'Delphi',
+ 'COMMENT_SINGLE' => array(1 => '//'),
+ 'COMMENT_MULTI' => array('(*' => '*)', '{' => '}'),
+ 'CASE_KEYWORDS' => 0,
+ 'QUOTEMARKS' => array("'", '"'),
+ 'ESCAPE_CHAR' => '',
+ 'KEYWORDS' => array(
+ 1 => array(
+ 'And', 'Array', 'As', 'Begin', 'Case', 'Class', 'Constructor', 'Destructor', 'Div', 'Do', 'DownTo', 'Else',
+ 'End', 'Except', 'File', 'Finally', 'For', 'Function', 'Goto', 'If', 'Implementation', 'In', 'Inherited', 'Interface',
+ 'Is', 'Mod', 'Not', 'Object', 'Of', 'On', 'Or', 'Packed', 'Procedure', 'Program', 'Property', 'Raise', 'Record',
+ 'Repeat', 'Set', 'Shl', 'Shr', 'Then', 'ThreadVar', 'To', 'Try', 'Unit', 'Until', 'Uses', 'While', 'With', 'Xor'
+ ),
+ 2 => array(
+ 'nil', 'false', 'true', 'var', 'type', 'const'
+ ),
+ 3 => array(
+ 'Abs', 'Addr', 'AnsiCompareStr', 'AnsiCompareText', 'AnsiContainsStr', 'AnsiEndsStr', 'AnsiIndexStr', 'AnsiLeftStr',
+ 'AnsiLowerCase', 'AnsiMatchStr', 'AnsiMidStr', 'AnsiPos', 'AnsiReplaceStr', 'AnsiReverseString', 'AnsiRightStr',
+ 'AnsiStartsStr', 'AnsiUpperCase', 'ArcCos', 'ArcSin', 'ArcTan', 'Assigned', 'BeginThread', 'Bounds', 'CelsiusToFahrenheit',
+ 'ChangeFileExt', 'Chr', 'CompareStr', 'CompareText', 'Concat', 'Convert', 'Copy', 'Cos', 'CreateDir', 'CurrToStr',
+ 'CurrToStrF', 'Date', 'DateTimeToFileDate', 'DateTimeToStr', 'DateToStr', 'DayOfTheMonth', 'DayOfTheWeek', 'DayOfTheYear',
+ 'DayOfWeek', 'DaysBetween', 'DaysInAMonth', 'DaysInAYear', 'DaySpan', 'DegToRad', 'DeleteFile', 'DiskFree', 'DiskSize',
+ 'DupeString', 'EncodeDate', 'EncodeDateTime', 'EncodeTime', 'EndOfADay', 'EndOfAMonth', 'Eof', 'Eoln', 'Exp', 'ExtractFileDir',
+ 'ExtractFileDrive', 'ExtractFileExt', 'ExtractFileName', 'ExtractFilePath', 'FahrenheitToCelsius', 'FileAge',
+ 'FileDateToDateTime', 'FileExists', 'FilePos', 'FileSearch', 'FileSetDate', 'FileSize', 'FindClose', 'FindCmdLineSwitch',
+ 'FindFirst', 'FindNext', 'FloatToStr', 'FloatToStrF', 'Format', 'FormatCurr', 'FormatDateTime', 'FormatFloat', 'Frac',
+ 'GetCurrentDir', 'GetLastError', 'GetMem', 'High', 'IncDay', 'IncMinute', 'IncMonth', 'IncYear', 'InputBox',
+ 'InputQuery', 'Int', 'IntToHex', 'IntToStr', 'IOResult', 'IsInfinite', 'IsLeapYear', 'IsMultiThread', 'IsNaN',
+ 'LastDelimiter', 'Length', 'Ln', 'Lo', 'Log10', 'Low', 'LowerCase', 'Max', 'Mean', 'MessageDlg', 'MessageDlgPos',
+ 'MonthOfTheYear', 'Now', 'Odd', 'Ord', 'ParamCount', 'ParamStr', 'Pi', 'Point', 'PointsEqual', 'Pos', 'Pred',
+ 'Printer', 'PromptForFileName', 'PtInRect', 'RadToDeg', 'Random', 'RandomRange', 'RecodeDate', 'RecodeTime', 'Rect',
+ 'RemoveDir', 'RenameFile', 'Round', 'SeekEof', 'SeekEoln', 'SelectDirectory', 'SetCurrentDir', 'Sin', 'SizeOf',
+ 'Slice', 'Sqr', 'Sqrt', 'StringOfChar', 'StringReplace', 'StringToWideChar', 'StrToCurr', 'StrToDate', 'StrToDateTime',
+ 'StrToFloat', 'StrToInt', 'StrToInt64', 'StrToInt64Def', 'StrToIntDef', 'StrToTime', 'StuffString', 'Succ', 'Sum', 'Tan',
+ 'Time', 'TimeToStr', 'Tomorrow', 'Trunc', 'UpCase', 'UpperCase', 'VarType', 'WideCharToString', 'WrapText', 'Yesterday',
+
+ 'Append', 'AppendStr', 'Assign', 'AssignFile', 'AssignPrn', 'Beep', 'BlockRead', 'BlockWrite', 'Break',
+ 'ChDir', 'Close', 'CloseFile', 'Continue', 'DateTimeToString', 'Dec', 'DecodeDate', 'DecodeDateTime',
+ 'DecodeTime', 'Delete', 'Dispose', 'EndThread', 'Erase', 'Exclude', 'Exit', 'FillChar', 'Flush', 'FreeAndNil',
+ 'FreeMem', 'GetDir', 'GetLocaleFormatSettings', 'Halt', 'Inc', 'Include', 'Insert', 'MkDir', 'Move', 'New',
+ 'ProcessPath', 'Randomize', 'Read', 'ReadLn', 'ReallocMem', 'Rename', 'ReplaceDate', 'ReplaceTime',
+ 'Reset', 'ReWrite', 'RmDir', 'RunError', 'Seek', 'SetLength', 'SetString', 'ShowMessage', 'ShowMessageFmt',
+ 'ShowMessagePos', 'Str', 'Truncate', 'Val', 'Write', 'WriteLn'
+ ),
+ 4 => array(
+ 'AnsiChar', 'AnsiString', 'Boolean', 'Byte', 'Cardinal', 'Char', 'Comp', 'Currency', 'Double', 'Extended',
+ 'Int64', 'Integer', 'LongInt', 'LongWord', 'PAnsiChar', 'PAnsiString', 'PChar', 'PCurrency', 'PDateTime',
+ 'PExtended', 'PInt64', 'Pointer', 'PShortString', 'PString', 'PVariant', 'PWideChar', 'PWideString',
+ 'Real', 'Real48', 'ShortInt', 'ShortString', 'Single', 'SmallInt', 'String', 'TBits', 'TConvType', 'TDateTime',
+ 'Text', 'TextFile', 'TFloatFormat', 'TFormatSettings', 'TList', 'TObject', 'TOpenDialog', 'TPoint',
+ 'TPrintDialog', 'TRect', 'TReplaceFlags', 'TSaveDialog', 'TSearchRec', 'TStringList', 'TSysCharSet',
+ 'TThreadFunc', 'Variant', 'WideChar', 'WideString', 'Word'
+ ),
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => true,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ 4 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #000000; font-weight: bold;',
+ 2 => 'color: #000000; font-weight: bold;',
+ 3 => 'color: #000066;',
+ 4 => 'color: #993333;'
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #808080; font-style: italic;',
+ 'MULTI' => 'color: #808080; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #66cc66;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #ff0000;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #cc66cc;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #006600;'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #66cc66;'
+ ),
+ 'SCRIPT' => array(
+ )
+ ),
+ 'URLS' => array(
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => ''
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_NEVER,
+ 'SCRIPT_DELIMITERS' => array(
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ )
+);
+
+?>
\ No newline at end of file diff --git a/inc/geshi/html4strict.php b/inc/geshi/html4strict.php new file mode 100644 index 000000000..22c0c33eb --- /dev/null +++ b/inc/geshi/html4strict.php @@ -0,0 +1,254 @@ +<?php +/************************************************************************************* + * html4strict.php + * --------------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.3 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/07/10 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * HTML 4.01 strict language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.3) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.2) + * - Added support for URLs + * 2004/08/05 (1.0.1) + * - Added INS and DEL + * - Removed the background colour from tags' styles + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * Check that only HTML4 strict attributes are highlighted + * * Eliminate empty tags that aren't allowed in HTML4 strict + * * Split to several files - html4trans, xhtml1 etc + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'HTML', + 'COMMENT_SINGLE' => array(), + 'COMMENT_MULTI' => array('<!--' => '-->'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + ), + 2 => array( + '<a>', '<abbr>', '<acronym>', '<address>', '<applet>', + '<a', '<abbr', '<acronym', '<address', '<applet', + '</a>', '</abbr>', '</acronym>', '</address>', '</applet>', + '</a', '</abbr', '</acronym', '</address', '</applet', + + '<base>', '<basefont>', '<bdo>', '<big>', '<blockquote>', '<body>', '<br>', '<button>', '<b>', + '<base', '<basefont', '<bdo', '<big', '<blockquote', '<body', '<br', '<button', '<b', + '</base>', '</basefont>', '</bdo>', '</big>', '</blockquote>', '</body>', '</br>', '</button>', '</b>', + '</base', '</basefont', '</bdo', '</big', '</blockquote', '</body', '</br', '</button', '</b', + + '<caption>', '<center>', '<cite>', '<code>', '<colgroup>', '<col>', + '<caption', '<center', '<cite', '<code', '<colgroup', '<col', + '</caption>', '</center>', '</cite>', '</code>', '</colgroup>', '</col>', + '</caption', '</center', '</cite', '</code', '</colgroup', '</col', + + '<dd>', '<del>', '<dfn>', '<dir>', '<div>', '<dl>', '<dt>', + '<dd', '<del', '<dfn', '<dir', '<div', '<dl', '<dt', + '</dd>', '</del>', '</dfn>', '</dir>', '</div>', '</dl>', '</dt>', + '</dd', '</del', '</dfn', '</dir', '</div', '</dl', '</dt', + + '<em>', + '<em', + '</em>', + '</em', + + '<fieldset>', '<font>', '<form>', '<frame>', '<frameset>', + '<fieldset', '<font', '<form', '<frame', '<frameset', + '</fieldset>', '</font>', '</form>', '</frame>', '</frameset>', + '</fieldset', '</font', '</form', '</frame', '</frameset', + + '<h1>', '<h2>', '<h3>', '<h4>', '<h5>', '<h6>', '<head>', '<hr>', '<html>', + '<h1', '<h2', '<h3', '<h4', '<h5', '<h6', '<head', '<hr', '<html', + '</h1>', '</h2>', '</h3>', '</h4>', '</h5>', '</h6>', '</head>', '</hr>', '</html>', + '</h1', '</h2', '</h3', '</h4', '</h5', '</h6', '</head', '</hr', '</html', + + '<iframe>', '<ilayer>', '<img>', '<input>', '<ins>', '<isindex>', '<i>', + '<iframe', '<ilayer', '<img', '<input', '<ins', '<isindex', '<i', + '</iframe>', '</ilayer>', '</img>', '</input>', '</ins>', '</isindex>', '</i>', + '</iframe', '</ilayer', '</img', '</input', '</ins', '</isindex', '</i', + + '<kbd>', + '<kbd', + '&t;/kbd>', + '</kbd', + + '<label>', '<legend>', '<link>', '<li>', + '<label', '<legend', '<link', '<li', + '</label>', '</legend>', '</link>', '</li>', + '</label', '</legend', '</link', '</li', + + '<map>', '<meta>', + '<map', '<meta', + '</map>', '</meta>', + '</map', '</meta', + + '<noframes>', '<noscript>', + '<noframes', '<noscript', + '</noframes>', '</noscript>', + '</noframes', '</noscript', + + '<object>', '<ol>', '<optgroup>', '<option>', + '<object', '<ol', '<optgroup', '<option', + '</object>', '</ol>', '</optgroup>', '</option>', + '</object', '</ol', '</optgroup', '</option', + + '<param>', '<pre>', '<p>', + '<param', '<pre', '<p', + '</param>', '</pre>', '</p>', + '</param', '</pre', '</p', + + '<q>', + '<q', + '</q>', + '</q', + + '<samp>', '<script>', '<select>', '<small>', '<span>', '<strike>', '<strong>', '<style>', '<sub>', '<sup>', '<s>', + '<samp', '<script', '<select', '<small', '<span', '<strike', '<strong', '<style', '<sub', '<sup', '<s', + '</samp>', '</script>', '</select>', '</small>', '</span>', '</strike>', '</strong>', '</style>', '</sub>', '</sup>', '</s>', + '</samp', '</script', '</select', '</small', '</span', '</strike', '</strong', '</style', '</sub', '</sup', '</s', + + '<table>', '<tbody>', '<td>', '<textarea>', '<text>', '<tfoot>', '<thead>', '<th>', '<title>', '<tr>', '<tt>', + '<table', '<tbody', '<td', '<textarea', '<text', '<tfoot', '<tfoot', '<thead', '<th', '<title', '<tr', '<tt', + '</table>', '</tbody>', '</td>', '</textarea>', '</text>', '</tfoot>', '</thead', '</tfoot', '</th>', '</title>', '</tr>', '</tt>', + '</table', '</tbody', '</td', '</textarea', '</text', '</tfoot', '</tfoot', '</thead', '</th', '</title', '</tr', '</tt', + + '<ul>', '<u>', + '<ul', '<u', + '</ul>', '</ul>', + '</ul', '</u', + + '<var>', + '<var', + '</var>', + '</var', + + '>', '<' + ), + 3 => array( + 'abbr', 'accept-charset', 'accept', 'accesskey', 'action', 'align', 'alink', 'alt', 'archive', 'axis', + 'background', 'bgcolor', 'border', + 'cellpadding', 'cellspacing', 'char', 'char', 'charoff', 'charset', 'checked', 'cite', 'class', 'classid', 'clear', 'code', 'codebase', 'codetype', 'color', 'cols', 'colspan', 'compact', 'content', 'coords', + 'data', 'datetime', 'declare', 'defer', 'dir', 'disabled', + 'enctype', + 'face', 'for', 'frame', 'frameborder', + 'headers', 'height', 'href', 'hreflang', 'hspace', 'http-equiv', + 'id', 'ismap', + 'label', 'lang', 'language', 'link', 'longdesc', + 'marginheight', 'marginwidth', 'maxlength', 'media', 'method', 'multiple', + 'name', 'nohref', 'noresize', 'noshade', 'nowrap', + 'object', 'onblur', 'onchange', 'onclick', 'ondblclick', 'onfocus', 'onkeydown', 'onkeypress', 'onkeyup', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onreset', 'onselect', 'onsubmit', 'onunload', + 'profile', 'prompt', + 'readonly', 'rel', 'rev', 'rowspan', 'rows', 'rules', + 'scheme', 'scope', 'scrolling', 'selected', 'shape', 'size', 'span', 'src', 'standby', 'start', 'style', 'summary', + 'tabindex', 'target', 'text', 'title', 'type', + 'usemap', + 'valign', 'value', 'valuetype', 'version', 'vlink', 'vspace', + 'width' + ) + ), + 'SYMBOLS' => array( + '/', '=' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false, + 2 => false, + 3 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #000066;' + ), + 'COMMENTS' => array( + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'SCRIPT' => array( + 0 => 'color: #00bbdd;', + 1 => 'color: #ddbb00;', + 2 => 'color: #009900;' + ), + 'REGEXPS' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => 'http://december.com/html/4/element/{FNAME}.html', + 3 => '' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_ALWAYS, + 'SCRIPT_DELIMITERS' => array( + 0 => array( + '<!DOCTYPE' => '>' + ), + 1 => array( + '&' => ';' + ), + 2 => array( + '<' => '>' + ) + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + 0 => false, + 1 => false, + 2 => true + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/java.php b/inc/geshi/java.php new file mode 100644 index 000000000..3033b3738 --- /dev/null +++ b/inc/geshi/java.php @@ -0,0 +1,1402 @@ +<?php +/************************************************************************************* + * java.php + * -------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.3 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/07/10 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Java language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.3) + * - Added support for multiple object splitters + * 2004/08/05 (1.0.2) + * - Added URL support + * - Added keyword "this", as bugs in GeSHi class ironed out + * 2004/08/05 (1.0.1) + * - Added support for symbols + * - Added extra missed keywords + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * Compact the class names like the first few have been + * and eliminate repeats + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Java', + 'COMMENT_SINGLE' => array(1 => '//', 2 => 'import'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'for', 'foreach', 'if', 'elseif', 'else', 'while', 'do', + 'switch', 'case' + ), + 2 => array( + 'null', 'return', 'false', 'final', 'true', 'public', + 'private', 'protected', 'extends', 'break', 'class', + 'new', 'try', 'catch', 'throws', 'finally', 'implements', + 'interface', 'throw', 'native', 'synchronized', 'this' + ), + 3 => array( + 'AbstractAction', 'AbstractBorder', 'AbstractButton', 'AbstractCellEditor', + 'AbstractCollection', 'AbstractColorChooserPanel', 'AbstractDocument', + 'AbstractDocument.AttributeContext', 'AbstractDocument.Content', + 'AbstractDocument.ElementEdit', 'AbstractLayoutCache', + 'AbstractLayoutCache.NodeDimensions', 'AbstractList', 'AbstractListModel', + 'AbstractMap', 'AbstractMethodError', 'AbstractSequentialList', + 'AbstractSet', 'AbstractTableModel', 'AbstractUndoableEdit', 'AbstractWriter', + 'AccessControlContext', 'AccessControlException', 'AccessController', + 'AccessException', 'Accessible', 'AccessibleAction', 'AccessibleBundle', + 'AccessibleComponent', 'AccessibleContext', 'AccessibleHyperlink', + 'AccessibleHypertext', 'AccessibleIcon', 'AccessibleObject', + 'AccessibleRelation', 'AccessibleRelationSet', 'AccessibleResourceBundle', + 'AccessibleRole', 'AccessibleSelection', 'AccessibleState', + 'AccessibleStateSet', 'AccessibleTable', 'AccessibleTableModelChange', + 'AccessibleText', 'AccessibleValue', 'Acl', 'AclEntry', 'AclNotFoundException', + 'Action', 'ActionEvent', 'ActionListener', 'ActionMap', 'ActionMapUIResource', + 'Activatable', 'ActivateFailedException', 'ActivationDesc', + 'ActivationException', 'ActivationGroup', 'ActivationGroupDesc', + 'ActivationGroupDesc.CommandEnvironment', 'ActivationGroupID', 'ActivationID', + 'ActivationInstantiator', 'ActivationMonitor', 'ActivationSystem', + 'Activator', 'ActiveEvent', 'Adjustable', 'AdjustmentEvent', 'AdjustmentListener', + 'Adler32', 'AffineTransform', 'AffineTransformOp', 'AlgorithmParameterGenerator', + 'AlgorithmParameterGeneratorSpi', 'AlgorithmParameters', 'AlgorithmParameterSpec', + 'AlgorithmParametersSpi', 'AllPermission', 'AlphaComposite', 'AlreadyBound', + 'AlreadyBoundException', 'AlreadyBoundHelper', 'AlreadyBoundHolder', + 'AncestorEvent', 'AncestorListener', 'Annotation', 'Any', 'AnyHolder', + 'AnySeqHelper', 'AnySeqHolder', 'Applet', 'AppletContext', 'AppletInitializer', + 'AppletStub', 'ApplicationException', 'Arc2D', 'Arc2D.Double', 'Arc2D.Float', + 'Area', 'AreaAveragingScaleFilter', 'ARG_IN', 'ARG_INOUT', 'ARG_OUT', + 'ArithmeticException', 'Array', 'ArrayIndexOutOfBoundsException', + 'ArrayList', 'Arrays', 'ArrayStoreException', 'AsyncBoxView', + 'Attribute', 'AttributedCharacterIterator', 'AttributedCharacterIterator.Attribute', + 'AttributedString', 'AttributeInUseException', 'AttributeList', + 'AttributeModificationException', 'Attributes', 'Attributes.Name', + 'AttributeSet', 'AttributeSet.CharacterAttribute', 'AttributeSet.ColorAttribute', + 'AttributeSet.FontAttribute', 'AttributeSet.ParagraphAttribute', + 'AudioClip', 'AudioFileFormat', 'AudioFileFormat.Type', 'AudioFileReader', + 'AudioFileWriter', 'AudioFormat', 'AudioFormat.Encoding', 'AudioInputStream', + 'AudioPermission', 'AudioSystem', 'AuthenticationException', + 'AuthenticationNotSupportedException', 'Authenticator', 'Autoscroll', + 'AWTError', 'AWTEvent', 'AWTEventListener', 'AWTEventMulticaster', + 'AWTException', 'AWTPermission', 'BAD_CONTEXT', 'BAD_INV_ORDER', 'BAD_OPERATION', + 'BAD_PARAM', 'BAD_POLICY', 'BAD_POLICY_TYPE', 'BAD_POLICY_VALUE', 'BAD_TYPECODE', + 'BadKind', 'BadLocationException', 'BandCombineOp', 'BandedSampleModel','BasicArrowButton', + 'BasicAttribute', 'BasicAttributes', 'BasicBorders', 'BasicBorders.ButtonBorder', + 'BasicBorders.FieldBorder', 'BasicBorders.MarginBorder', 'BasicBorders.MenuBarBorder', + 'BasicBorders.RadioButtonBorder', 'BasicBorders.SplitPaneBorder', + 'BasicBorders.ToggleButtonBorder', 'BasicButtonListener', 'BasicButtonUI', + 'BasicCheckBoxMenuItemUI', 'BasicCheckBoxUI', 'BasicColorChooserUI', 'BasicComboBoxEditor', + 'BasicComboBoxEditor.UIResource', 'BasicComboBoxRenderer', 'BasicComboBoxRenderer.UIResource', + 'BasicComboBoxUI', 'BasicComboPopup', 'BasicDesktopIconUI', 'BasicDesktopPaneUI', + 'BasicDirectoryModel', 'BasicEditorPaneUI', 'BasicFileChooserUI', + 'BasicGraphicsUtils', 'BasicHTML', 'BasicIconFactory', 'BasicInternalFrameTitlePane', + 'BasicInternalFrameUI', 'BasicLabelUI', 'BasicListUI', 'BasicLookAndFeel', + 'BasicMenuBarUI', 'BasicMenuItemUI', 'BasicMenuUI', 'BasicOptionPaneUI', + 'BasicOptionPaneUI.ButtonAreaLayout', 'BasicPanelUI', 'BasicPasswordFieldUI', + 'BasicPermission', 'BasicPopupMenuSeparatorUI', 'BasicPopupMenuUI', + 'BasicProgressBarUI', 'BasicRadioButtonMenuItemUI', 'BasicRadioButtonUI', + 'BasicRootPaneUI', 'BasicScrollBarUI', 'BasicScrollPaneUI', 'BasicSeparatorUI', + 'BasicSliderUI', 'BasicSplitPaneDivider', 'BasicSplitPaneUI', 'BasicStroke', + 'BasicTabbedPaneUI', 'BasicTableHeaderUI', 'BasicTableUI', 'BasicTextAreaUI', + 'BasicTextFieldUI', 'BasicTextPaneUI', 'BasicTextUI', 'BasicTextUI.BasicCaret', + 'BasicTextUI.BasicHighlighter', 'BasicToggleButtonUI', 'BasicToolBarSeparatorUI', + 'BasicToolBarUI', 'BasicToolTipUI', 'BasicTreeUI', 'BasicViewportUI', + 'BatchUpdateException', 'BeanContext', 'BeanContextChild', + 'BeanContextChildComponentProxy', 'BeanContextChildSupport', 'BeanContextContainerProxy', + 'BeanContextEvent', 'BeanContextMembershipEvent', 'BeanContextMembershipListener', + 'BeanContextProxy', 'BeanContextServiceAvailableEvent', 'BeanContextServiceProvider', + 'BeanContextServiceProviderBeanInfo', 'BeanContextServiceRevokedEvent', + 'BeanContextServiceRevokedListener', 'BeanContextServices', + 'BeanContextServicesListener', 'BeanContextServicesSupport', + 'BeanContextServicesSupport.BCSSServiceProvider', 'BeanContextSupport', + 'BeanContextSupport.BCSIterator', 'BeanDescriptor', 'BeanInfo', 'Beans', + 'BevelBorder', 'BigDecimal', 'BigInteger', 'BinaryRefAddr', 'BindException', + 'Binding', 'BindingHelper', 'BindingHolder', 'BindingIterator', + 'BindingIteratorHelper', 'BindingIteratorHolder', 'BindingIteratorOperations', + 'BindingListHelper', 'BindingListHolder', 'BindingType', 'BindingTypeHelper', + 'BindingTypeHolder', 'BitSet', 'Blob', 'BlockView', 'Book', 'Boolean', + 'BooleanControl', 'BooleanControl.Type', 'BooleanHolder', 'BooleanSeqHelper', + 'BooleanSeqHolder', 'Border', 'BorderFactory', 'BorderLayout', 'BorderUIResource', + 'BorderUIResource.BevelBorderUIResource', 'BorderUIResource.CompoundBorderUIResource', + 'BorderUIResource.EmptyBorderUIResource', 'BorderUIResource.EtchedBorderUIResource', + 'BorderUIResource.LineBorderUIResource', 'BorderUIResource.MatteBorderUIResource', + 'BorderUIResource.TitledBorderUIResource', 'BoundedRangeModel', 'Bounds', + 'Box', 'Box.Filler', 'BoxedValueHelper', 'BoxLayout', 'BoxView', + 'BreakIterator', 'BufferedImage', 'BufferedImageFilter', 'BufferedImageOp', + 'BufferedInputStream', 'BufferedOutputStream', 'BufferedReader', 'BufferedWriter', + 'Button', 'ButtonGroup', 'ButtonModel', 'ButtonUI', 'Byte', 'ByteArrayInputStream', + 'ByteArrayOutputStream', 'ByteHolder', 'ByteLookupTable', 'Calendar', + 'CallableStatement', 'CannotProceed', 'CannotProceedException', 'CannotProceedHelper', + 'CannotProceedHolder', 'CannotRedoException', 'CannotUndoException', + 'Canvas', 'CardLayout', 'Caret', 'CaretEvent', 'CaretListener', 'CellEditor', + 'CellEditorListener', 'CellRendererPane', 'Certificate', 'Certificate.CertificateRep', + 'CertificateEncodingException', 'CertificateException', 'CertificateExpiredException', + 'CertificateFactory', 'CertificateFactorySpi', 'CertificateNotYetValidException', + 'CertificateParsingException', 'ChangedCharSetException', 'ChangeEvent', + 'ChangeListener', 'Character', 'Character.Subset', 'Character.UnicodeBlock', + 'CharacterIterator', 'CharArrayReader', 'CharArrayWriter', 'CharConversionException', + 'CharHolder', 'CharSeqHelper', 'CharSeqHolder', 'Checkbox', 'CheckboxGroup', + 'CheckboxMenuItem', 'CheckedInputStream', 'CheckedOutputStream', 'Checksum', + 'Choice', 'ChoiceFormat', 'Class', 'ClassCastException', 'ClassCircularityError', + 'ClassDesc', 'ClassFormatError', 'ClassLoader', 'ClassNotFoundException', + 'Clip', 'Clipboard', 'ClipboardOwner', 'Clob', 'Cloneable', 'CloneNotSupportedException', + 'CMMException', 'CodeSource', 'CollationElementIterator', 'CollationKey', + 'Collator', 'Collection', 'Collections', 'Color', 'ColorChooserComponentFactory', + 'ColorChooserUI', 'ColorConvertOp', 'ColorModel', 'ColorSelectionModel', + 'ColorSpace', 'ColorUIResource', 'ComboBoxEditor', 'ComboBoxModel', 'ComboBoxUI', + 'ComboPopup', 'COMM_FAILURE', 'CommunicationException', 'Comparable', + 'Comparator', 'Compiler', 'CompletionStatus', 'CompletionStatusHelper', + 'Component', 'ComponentAdapter', 'ComponentColorModel', 'ComponentEvent', + 'ComponentInputMap', 'ComponentInputMapUIResource', 'ComponentListener', + 'ComponentOrientation', 'ComponentSampleModel', 'ComponentUI', 'ComponentView', + 'Composite', 'CompositeContext', 'CompositeName','CompositeView', 'CompoundBorder', + 'CompoundControl', 'CompoundControl.Type', 'CompoundEdit', 'CompoundName', + 'ConcurrentModificationException', 'ConfigurationException', 'ConnectException', + 'ConnectException', 'ConnectIOException', 'Connection', 'Constructor', + 'Container', 'ContainerAdapter', 'ContainerEvent', 'ContainerListener', + 'ContentHandler', 'ContentHandlerFactory', 'ContentModel', 'Context', 'ContextList', + 'ContextNotEmptyException', 'ContextualRenderedImageFactory', 'Control', + 'Control.Type', 'ControlFactory', 'ControllerEventListener', 'ConvolveOp', + 'CRC32', 'CRL', 'CRLException', 'CropImageFilter', 'CSS', 'CSS.Attribute', + 'CTX_RESTRICT_SCOPE', 'CubicCurve2D', 'CubicCurve2D.Double', 'CubicCurve2D.Float', + 'Current', 'CurrentHelper', 'CurrentHolder', 'CurrentOperations', 'Cursor', + 'Customizer', 'CustomMarshal', 'CustomValue', 'DATA_CONVERSION', 'DatabaseMetaData', + 'DataBuffer', 'DataBufferByte', 'DataBufferInt', 'DataBufferShort', 'DataBufferUShort', + 'DataFlavor', 'DataFormatException', 'DatagramPacket', 'DatagramSocket', + 'DatagramSocketImpl', 'DatagramSocketImplFactory', 'DataInput', 'DataInputStream', + 'DataLine', 'DataLine.Info', 'DataOutput', 'DataOutputStream', 'DataOutputStream', + 'DataTruncation', 'Date', 'DateFormat', 'DateFormatSymbols', 'DebugGraphics', + 'DecimalFormat', 'DecimalFormatSymbols', 'DefaultBoundedRangeModel', + 'DefaultButtonModel', 'DefaultCaret', 'DefaultCellEditor', 'DefaultColorSelectionModel', + 'DefaultComboBoxModel', 'DefaultDesktopManager', 'DefaultEditorKit', + 'DefaultEditorKit.BeepAction', 'DefaultEditorKit.CopyAction', + 'DefaultEditorKit.CutAction', 'DefaultEditorKit.DefaultKeyTypedAction', + 'DefaultEditorKit.InsertBreakAction', 'DefaultEditorKit.InsertContentAction', + 'DefaultEditorKit.InsertTabAction', 'DefaultEditorKit.PasteAction,', + 'DefaultFocusManager', 'DefaultHighlighter', 'DefaultHighlighter.DefaultHighlightPainter', + 'DefaultListCellRenderer', 'DefaultListCellRenderer.UIResource', 'DefaultListModel', + 'DefaultListSelectionModel', 'DefaultMenuLayout', 'DefaultMetalTheme', + 'DefaultMutableTreeNode', 'DefaultSingleSelectionModel', 'DefaultStyledDocument', + 'DefaultStyledDocument.AttributeUndoableEdit', 'DefaultStyledDocument.ElementSpec', + 'DefaultTableCellRenderer', 'DefaultTableCellRenderer.UIResource', 'DefaultTableColumnModel', + 'DefaultTableModel', 'DefaultTextUI', 'DefaultTreeCellEditor', 'DefaultTreeCellRenderer', + 'DefaultTreeModel', 'DefaultTreeSelectionModel', 'DefinitionKind', 'DefinitionKindHelper', + 'Deflater', 'DeflaterOutputStream', 'Delegate', 'DesignMode', 'DesktopIconUI', + 'DesktopManager', 'DesktopPaneUI', 'DGC', 'Dialog', 'Dictionary', 'DigestException', + 'DigestInputStream', 'DigestOutputStream', 'Dimension', 'Dimension2D', + 'DimensionUIResource', 'DirContext', 'DirectColorModel', 'DirectoryManager', + 'DirObjectFactory', 'DirStateFactory', 'DirStateFactory.Result', 'DnDConstants', + 'Document', 'DocumentEvent', 'DocumentEvent.ElementChange', 'DocumentEvent.EventType', + 'DocumentListener', 'DocumentParser', 'DomainCombiner', 'DomainManager', + 'DomainManagerOperations', 'Double', 'DoubleHolder', 'DoubleSeqHelper', + 'DoubleSeqHolder', 'DragGestureEvent', 'DragGestureListener', 'DragGestureRecognizer', + 'DragSource', 'DragSourceContext', 'DragSourceDragEvent', 'DragSourceDropEvent', + 'DragSourceEvent', 'DragSourceListener', 'Driver', 'DriverManager', + 'DriverPropertyInfo', 'DropTarget', 'DropTarget.DropTargetAutoScroller', + 'DropTargetContext', 'DropTargetDragEvent', 'DropTargetDropEvent', + 'DropTargetEvent', 'DropTargetListener', 'DSAKey', 'DSAKeyPairGenerator', + 'DSAParameterSpec', 'DSAParams', 'DSAPrivateKey', 'DSAPrivateKeySpec', + 'DSAPublicKey', 'DSAPublicKeySpec', 'DTD', 'DTDConstants', 'DynamicImplementation', + 'DynAny', 'DynArray', 'DynEnum', 'DynFixed', 'DynSequence', 'DynStruct', + 'DynUnion', 'DynValue', 'EditorKit', 'Element', 'ElementIterator', 'Ellipse2D', + 'Ellipse2D.Double', 'Ellipse2D.Float', 'EmptyBorder', 'EmptyStackException', + 'EncodedKeySpec', 'Entity', 'EnumControl', 'EnumControl.Type','Enumeration', + 'Environment', 'EOFException', 'Error', 'EtchedBorder', 'Event', 'EventContext', + 'EventDirContext', 'EventListener', 'EventListenerList', 'EventObject', 'EventQueue', + 'EventSetDescriptor', 'Exception', 'ExceptionInInitializerError', 'ExceptionList', + 'ExpandVetoException', 'ExportException', 'ExtendedRequest', 'ExtendedResponse', + 'Externalizable', 'FeatureDescriptor', 'Field', 'FieldNameHelper', + 'FieldPosition', 'FieldView', 'File', 'FileChooserUI', 'FileDescriptor', + 'FileDialog', 'FileFilter', 'FileFilter', 'FileInputStream', 'FilenameFilter', + 'FileNameMap', 'FileNotFoundException', 'FileOutputStream', 'FilePermission', + 'FileReader', 'FileSystemView', 'FileView', 'FileWriter', 'FilteredImageSource', + 'FilterInputStream', 'FilterOutputStream', 'FilterReader', 'FilterWriter', + 'FixedHeightLayoutCache', 'FixedHolder', 'FlatteningPathIterator', 'FlavorMap', + 'Float', 'FloatControl', 'FloatControl.Type', 'FloatHolder', 'FloatSeqHelper', + 'FloatSeqHolder', 'FlowLayout', 'FlowView', 'FlowView.FlowStrategy', 'FocusAdapter', + 'FocusEvent', 'FocusListener', 'FocusManager', 'Font', 'FontFormatException', + 'FontMetrics', 'FontRenderContext', 'FontUIResource', 'Format', 'FormatConversionProvider', + 'FormView', 'Frame', 'FREE_MEM', 'GapContent', 'GeneralPath', 'GeneralSecurityException', + 'GlyphJustificationInfo', 'GlyphMetrics', 'GlyphVector', + 'GlyphView', + 'GlyphView.GlyphPainter', + 'GradientPaint', + 'GraphicAttribute', + 'Graphics', + 'Graphics2D', + 'GraphicsConfigTemplate', + 'GraphicsConfiguration', + 'GraphicsDevice', + 'GraphicsEnvironment', + 'GrayFilter', + 'GregorianCalendar', + 'GridBagConstraints', + 'GridBagLayout', + 'GridLayout', + 'Group', + 'Guard', + 'GuardedObject', + 'GZIPInputStream', + 'GZIPOutputStream', + 'HasControls', + 'HashMap', + 'HashSet', + 'Hashtable', + 'HierarchyBoundsAdapter', + 'HierarchyBoundsListener', + 'HierarchyEvent', + 'HierarchyListener', + 'Highlighter', + 'Highlighter.Highlight', + 'Highlighter.HighlightPainter', + 'HTML', + 'HTML.Attribute', + 'HTML.Tag', + 'HTML.UnknownTag', + 'HTMLDocument', + 'HTMLDocument.Iterator', + 'HTMLEditorKit', + 'HTMLEditorKit.HTMLFactory', + 'HTMLEditorKit.HTMLTextAction', + 'HTMLEditorKit.InsertHTMLTextAction', + 'HTMLEditorKit.LinkController', + 'HTMLEditorKit.Parser', + 'HTMLEditorKit.ParserCallback', + 'HTMLFrameHyperlinkEvent', + 'HTMLWriter', + 'HttpURLConnection', + 'HyperlinkEvent', + 'HyperlinkEvent.EventType', + 'HyperlinkListener', + 'ICC_ColorSpace', + 'ICC_Profile', + 'ICC_ProfileGray', + 'ICC_ProfileRGB', + 'Icon', + 'IconUIResource', + 'IconView', + 'IdentifierHelper', + 'Identity', + 'IdentityScope', + 'IDLEntity', + 'IDLType', + 'IDLTypeHelper', 'IDLTypeOperations', + 'IllegalAccessError', + 'IllegalAccessException', + 'IllegalArgumentException', + 'IllegalComponentStateException', + 'IllegalMonitorStateException', + 'IllegalPathStateException', + 'IllegalStateException', + 'IllegalThreadStateException', + 'Image', + 'ImageConsumer', + 'ImageFilter', + 'ImageGraphicAttribute', + 'ImageIcon', + 'ImageObserver', + 'ImageProducer', + 'ImagingOpException', + 'IMP_LIMIT', + 'IncompatibleClassChangeError', + 'InconsistentTypeCode', + 'IndexColorModel', + 'IndexedPropertyDescriptor', + 'IndexOutOfBoundsException', + 'IndirectionException', + 'InetAddress', + 'Inflater', + 'InflaterInputStream', + 'InheritableThreadLocal', + 'InitialContext', + 'InitialContextFactory', + 'InitialContextFactoryBuilder', + 'InitialDirContext', + 'INITIALIZE', + 'Initializer', + 'InitialLdapContext', + 'InlineView', + 'InputContext', + 'InputEvent', + 'InputMap', + 'InputMapUIResource', + 'InputMethod', + 'InputMethodContext', + 'InputMethodDescriptor', + 'InputMethodEvent', + 'InputMethodHighlight', + 'InputMethodListener', + 'InputMethodRequests', + 'InputStream', + 'InputStream', + 'InputStream', + 'InputStreamReader', + 'InputSubset', + 'InputVerifier', + 'Insets', + 'InsetsUIResource', + 'InstantiationError', + 'InstantiationException', + 'Instrument', + 'InsufficientResourcesException', + 'Integer', + 'INTERNAL', + 'InternalError', 'InternalFrameAdapter', + 'InternalFrameEvent', + 'InternalFrameListener', + 'InternalFrameUI', + 'InterruptedException', + 'InterruptedIOException', + 'InterruptedNamingException', + 'INTF_REPOS', + 'IntHolder', + 'IntrospectionException', + 'Introspector', + 'INV_FLAG', + 'INV_IDENT', + 'INV_OBJREF', + 'INV_POLICY', + 'Invalid', + 'INVALID_TRANSACTION', + 'InvalidAlgorithmParameterException', + 'InvalidAttributeIdentifierException', + 'InvalidAttributesException', + 'InvalidAttributeValueException', + 'InvalidClassException', + 'InvalidDnDOperationException', + 'InvalidKeyException', + 'InvalidKeySpecException', + 'InvalidMidiDataException', + 'InvalidName', + 'InvalidName', + 'InvalidNameException', + 'InvalidNameHelper', + 'InvalidNameHolder', + 'InvalidObjectException', + 'InvalidParameterException', + 'InvalidParameterSpecException', + 'InvalidSearchControlsException', + 'InvalidSearchFilterException', + 'InvalidSeq', + 'InvalidTransactionException', + 'InvalidValue', + 'InvocationEvent', + 'InvocationHandler', + 'InvocationTargetException', + 'InvokeHandler', + 'IOException', + 'IRObject', + 'IRObjectOperations', 'IstringHelper', 'ItemEvent', 'ItemListener', + 'ItemSelectable', 'Iterator', 'JApplet', 'JarEntry', 'JarException', + 'JarFile', 'JarInputStream', 'JarOutputStream', 'JarURLConnection', + 'JButton', 'JCheckBox', 'JCheckBoxMenuItem', 'JColorChooser', + 'JComboBox', + 'JComboBox.KeySelectionManager', + 'JComponent', + 'JDesktopPane', + 'JDialog', + 'JEditorPane', + 'JFileChooser', + 'JFrame', + 'JInternalFrame', + 'JInternalFrame.JDesktopIcon', + 'JLabel', + 'JLayeredPane', + 'JList', + 'JMenu', + 'JMenuBar', + 'JMenuItem', + 'JobAttributes', + 'JobAttributes.DefaultSelectionType', + 'JobAttributes.DestinationType', + 'JobAttributes.DialogType', + 'JobAttributes.MultipleDocumentHandlingType', + 'JobAttributes.SidesType', + 'JOptionPane', + 'JPanel', + 'JPasswordField', + 'JPopupMenu', + 'JPopupMenu.Separator', + 'JProgressBar', + 'JRadioButton', + 'JRadioButtonMenuItem', + 'JRootPane', + 'JScrollBar', + 'JScrollPane', + 'JSeparator', + 'JSlider', + 'JSplitPane', + 'JTabbedPane', + 'JTable', + 'JTableHeader', + 'JTextArea', + 'JTextComponent', + 'JTextComponent.KeyBinding', 'JTextField', + 'JTextPane', + 'JToggleButton', + 'JToggleButton.ToggleButtonModel', + 'JToolBar', + 'JToolBar.Separator', + 'JToolTip', + 'JTree', + 'JTree.DynamicUtilTreeNode', + 'JTree.EmptySelectionModel', + 'JViewport', + 'JWindow', + 'Kernel', + 'Key', + 'KeyAdapter', + 'KeyEvent', + 'KeyException', + 'KeyFactory', + 'KeyFactorySpi', + 'KeyListener', + 'KeyManagementException', + 'Keymap', + 'KeyPair', + 'KeyPairGenerator', + 'KeyPairGeneratorSpi', + 'KeySpec', + 'KeyStore', + 'KeyStoreException', + 'KeyStoreSpi', + 'KeyStroke', + 'Label', + 'LabelUI', + 'LabelView', + 'LastOwnerException', + 'LayeredHighlighter', + 'LayeredHighlighter.LayerPainter', + 'LayoutManager', + 'LayoutManager2', + 'LayoutQueue', + 'LdapContext', + 'LdapReferralException', + 'Lease', + 'LimitExceededException', + 'Line', + 'Line.Info', + 'Line2D', + 'Line2D.Double', + 'Line2D.Float', + 'LineBorder', + 'LineBreakMeasurer', + 'LineEvent', + 'LineEvent.Type', + 'LineListener', + 'LineMetrics', + 'LineNumberInputStream', + 'LineNumberReader', + 'LineUnavailableException', + 'LinkageError', + 'LinkedList', + 'LinkException', + 'LinkLoopException', + 'LinkRef', + 'List', + 'List', + 'ListCellRenderer', + 'ListDataEvent', + 'ListDataListener', + 'ListIterator', + 'ListModel', + 'ListResourceBundle', + 'ListSelectionEvent', + 'ListSelectionListener', + 'ListSelectionModel', + 'ListUI', + 'ListView', + 'LoaderHandler', + 'Locale', + 'LocateRegistry', + 'LogStream', + 'Long', + 'LongHolder', + 'LongLongSeqHelper', + 'LongLongSeqHolder', + 'LongSeqHelper', + 'LongSeqHolder', + 'LookAndFeel', + 'LookupOp', + 'LookupTable', + 'MalformedLinkException', + 'MalformedURLException', + 'Manifest', 'Map', + 'Map.Entry', + 'MARSHAL', + 'MarshalException', + 'MarshalledObject', + 'Math', + 'MatteBorder', + 'MediaTracker', + 'Member', + 'MemoryImageSource', + 'Menu', + 'MenuBar', + 'MenuBarUI', + 'MenuComponent', + 'MenuContainer', + 'MenuDragMouseEvent', + 'MenuDragMouseListener', + 'MenuElement', + 'MenuEvent', + 'MenuItem', + 'MenuItemUI', + 'MenuKeyEvent', + 'MenuKeyListener', + 'MenuListener', + 'MenuSelectionManager', + 'MenuShortcut', + 'MessageDigest', + 'MessageDigestSpi', + 'MessageFormat', + 'MetaEventListener', + 'MetalBorders', + 'MetalBorders.ButtonBorder', + 'MetalBorders.Flush3DBorder', + 'MetalBorders.InternalFrameBorder', + 'MetalBorders.MenuBarBorder', + 'MetalBorders.MenuItemBorder', + 'MetalBorders.OptionDialogBorder', + 'MetalBorders.PaletteBorder', + 'MetalBorders.PopupMenuBorder', + 'MetalBorders.RolloverButtonBorder', + 'MetalBorders.ScrollPaneBorder', + 'MetalBorders.TableHeaderBorder', + 'MetalBorders.TextFieldBorder', + 'MetalBorders.ToggleButtonBorder', + 'MetalBorders.ToolBarBorder', + 'MetalButtonUI', + 'MetalCheckBoxIcon', + 'MetalCheckBoxUI', + 'MetalComboBoxButton', + 'MetalComboBoxEditor', + 'MetalComboBoxEditor.UIResource', + 'MetalComboBoxIcon', + 'MetalComboBoxUI', + 'MetalDesktopIconUI', + 'MetalFileChooserUI', + 'MetalIconFactory', + 'MetalIconFactory.FileIcon16', + 'MetalIconFactory.FolderIcon16', + 'MetalIconFactory.PaletteCloseIcon', + 'MetalIconFactory.TreeControlIcon', + 'MetalIconFactory.TreeFolderIcon', + 'MetalIconFactory.TreeLeafIcon', + 'MetalInternalFrameTitlePane', + 'MetalInternalFrameUI', + 'MetalLabelUI', + 'MetalLookAndFeel', + 'MetalPopupMenuSeparatorUI', + 'MetalProgressBarUI', + 'MetalRadioButtonUI', + 'MetalScrollBarUI', + 'MetalScrollButton', + 'MetalScrollPaneUI', + 'MetalSeparatorUI', + 'MetalSliderUI', + 'MetalSplitPaneUI', + 'MetalTabbedPaneUI', + 'MetalTextFieldUI', + 'MetalTheme', + 'MetalToggleButtonUI', + 'MetalToolBarUI', + 'MetalToolTipUI', + 'MetalTreeUI', + 'MetaMessage', + 'Method', + 'MethodDescriptor', + 'MidiChannel', + 'MidiDevice', + 'MidiDevice.Info', + 'MidiDeviceProvider', + 'MidiEvent', + 'MidiFileFormat', + 'MidiFileReader', + 'MidiFileWriter', + 'MidiMessage', + 'MidiSystem', + 'MidiUnavailableException', + 'MimeTypeParseException', + 'MinimalHTMLWriter', + 'MissingResourceException', + 'Mixer', + 'Mixer.Info', + 'MixerProvider', + 'ModificationItem', + 'Modifier', + 'MouseAdapter', + 'MouseDragGestureRecognizer', + 'MouseEvent', + 'MouseInputAdapter', + 'MouseInputListener', + 'MouseListener', + 'MouseMotionAdapter', + 'MouseMotionListener', + 'MultiButtonUI', + 'MulticastSocket', + 'MultiColorChooserUI', + 'MultiComboBoxUI', + 'MultiDesktopIconUI', + 'MultiDesktopPaneUI', + 'MultiFileChooserUI', + 'MultiInternalFrameUI', + 'MultiLabelUI', 'MultiListUI', + 'MultiLookAndFeel', + 'MultiMenuBarUI', + 'MultiMenuItemUI', + 'MultiOptionPaneUI', + 'MultiPanelUI', + 'MultiPixelPackedSampleModel', + 'MultipleMaster', + 'MultiPopupMenuUI', + 'MultiProgressBarUI', + 'MultiScrollBarUI', + 'MultiScrollPaneUI', + 'MultiSeparatorUI', + 'MultiSliderUI', + 'MultiSplitPaneUI', + 'MultiTabbedPaneUI', + 'MultiTableHeaderUI', + 'MultiTableUI', + 'MultiTextUI', + 'MultiToolBarUI', + 'MultiToolTipUI', + 'MultiTreeUI', + 'MultiViewportUI', + 'MutableAttributeSet', + 'MutableComboBoxModel', + 'MutableTreeNode', + 'Name', + 'NameAlreadyBoundException', + 'NameClassPair', + 'NameComponent', + 'NameComponentHelper', + 'NameComponentHolder', + 'NamedValue', + 'NameHelper', + 'NameHolder', + 'NameNotFoundException', + 'NameParser', + 'NamespaceChangeListener', + 'NameValuePair', + 'NameValuePairHelper', + 'Naming', + 'NamingContext', + 'NamingContextHelper', + 'NamingContextHolder', + 'NamingContextOperations', + 'NamingEnumeration', + 'NamingEvent', + 'NamingException', + 'NamingExceptionEvent', + 'NamingListener', + 'NamingManager', + 'NamingSecurityException', + 'NegativeArraySizeException', + 'NetPermission', + 'NO_IMPLEMENT', + 'NO_MEMORY', + 'NO_PERMISSION', + 'NO_RESOURCES', + 'NO_RESPONSE', + 'NoClassDefFoundError', + 'NoInitialContextException', 'NoninvertibleTransformException', + 'NoPermissionException', + 'NoRouteToHostException', + 'NoSuchAlgorithmException', + 'NoSuchAttributeException', + 'NoSuchElementException', + 'NoSuchFieldError', + 'NoSuchFieldException', + 'NoSuchMethodError', + 'NoSuchMethodException', + 'NoSuchObjectException', + 'NoSuchProviderException', + 'NotActiveException', + 'NotBoundException', + 'NotContextException', + 'NotEmpty', + 'NotEmptyHelper', + 'NotEmptyHolder', + 'NotFound', + 'NotFoundHelper', + 'NotFoundHolder', + 'NotFoundReason', + 'NotFoundReasonHelper', + 'NotFoundReasonHolder', + 'NotOwnerException', + 'NotSerializableException', + 'NullPointerException', + 'Number', + 'NumberFormat', 'NumberFormatException', 'NVList', + 'OBJ_ADAPTER', 'Object', 'OBJECT_NOT_EXIST', 'ObjectChangeListener', + 'ObjectFactory', + 'ObjectFactoryBuilder', + 'ObjectHelper', + 'ObjectHolder', + 'ObjectImpl', 'ObjectImpl', + 'ObjectInput', + 'ObjectInputStream', + 'ObjectInputStream.GetField', + 'ObjectInputValidation', + 'ObjectOutput', + 'ObjectOutputStream', + 'ObjectOutputStream.PutField', + 'ObjectStreamClass', + 'ObjectStreamConstants', + 'ObjectStreamException', + 'ObjectStreamField', + 'ObjectView', + 'ObjID', + 'Observable', + 'Observer', + 'OctetSeqHelper', + 'OctetSeqHolder', + 'OMGVMCID', + 'OpenType', + 'Operation', + 'OperationNotSupportedException', + 'Option', + 'OptionalDataException', + 'OptionPaneUI', + 'ORB', + 'OutOfMemoryError', + 'OutputStream', + 'OutputStreamWriter', + 'OverlayLayout', + 'Owner', + 'Package', + 'PackedColorModel', + 'Pageable', + 'PageAttributes', + 'PageAttributes.ColorType', + 'PageAttributes.MediaType', + 'PageAttributes.OrientationRequestedType', + 'PageAttributes.OriginType', + 'PageAttributes.PrintQualityType', + 'PageFormat', + 'Paint', + 'PaintContext', + 'PaintEvent', + 'Panel', + 'PanelUI', + 'Paper', + 'ParagraphView', + 'ParagraphView', + 'ParameterBlock', + 'ParameterDescriptor', + 'ParseException', + 'ParsePosition', + 'Parser', + 'ParserDelegator', + 'PartialResultException', + 'PasswordAuthentication', + 'PasswordView', + 'Patch', + 'PathIterator', + 'Permission', + 'Permission', + 'PermissionCollection', + 'Permissions', + 'PERSIST_STORE', + 'PhantomReference', + 'PipedInputStream', + 'PipedOutputStream', + 'PipedReader', + 'PipedWriter', + 'PixelGrabber', + 'PixelInterleavedSampleModel', + 'PKCS8EncodedKeySpec', + 'PlainDocument', + 'PlainView', + 'Point', + 'Point2D', + 'Point2D.Double', + 'Point2D.Float', + 'Policy', + 'Policy', + 'PolicyError', + 'PolicyHelper', + 'PolicyHolder', + 'PolicyListHelper', + 'PolicyListHolder', + 'PolicyOperations', 'PolicyTypeHelper', + 'Polygon', + 'PopupMenu', + 'PopupMenuEvent', + 'PopupMenuListener', + 'PopupMenuUI', + 'Port', + 'Port.Info', + 'PortableRemoteObject', + 'PortableRemoteObjectDelegate', + 'Position', + 'Position.Bias', + 'PreparedStatement', + 'Principal', + 'Principal', + 'PrincipalHolder', + 'Printable', + 'PrinterAbortException', + 'PrinterException', + 'PrinterGraphics', + 'PrinterIOException', + 'PrinterJob', + 'PrintGraphics', + 'PrintJob', + 'PrintStream', + 'PrintWriter', + 'PRIVATE_MEMBER', + 'PrivateKey', + 'PrivilegedAction', + 'PrivilegedActionException', + 'PrivilegedExceptionAction', + 'Process', + 'ProfileDataException', + 'ProgressBarUI', + 'ProgressMonitor', + 'ProgressMonitorInputStream', + 'Properties', + 'PropertyChangeEvent', + 'PropertyChangeListener', + 'PropertyChangeSupport', + 'PropertyDescriptor', + 'PropertyEditor', + 'PropertyEditorManager', + 'PropertyEditorSupport', + 'PropertyPermission', + 'PropertyResourceBundle', + 'PropertyVetoException', + 'ProtectionDomain', + 'ProtocolException', + 'Provider', + 'ProviderException', + 'Proxy', + 'PUBLIC_MEMBER', + 'PublicKey', + 'PushbackInputStream', + 'PushbackReader', + 'QuadCurve2D', + 'QuadCurve2D.Double', + 'QuadCurve2D.Float', + 'Random', + 'RandomAccessFile', 'Raster', 'RasterFormatException', 'RasterOp', + 'Reader', 'Receiver', 'Rectangle', 'Rectangle2D', 'Rectangle2D.Double', + 'Rectangle2D.Float', 'RectangularShape', 'Ref', 'RefAddr', 'Reference', + 'Referenceable', 'ReferenceQueue', 'ReferralException', + 'ReflectPermission', 'Registry', 'RegistryHandler', 'RemarshalException', + 'Remote', 'RemoteCall', 'RemoteException', 'RemoteObject', 'RemoteRef', + 'RemoteServer', + 'RemoteStub', + 'RenderableImage', + 'RenderableImageOp', + 'RenderableImageProducer', + 'RenderContext', + 'RenderedImage', + 'RenderedImageFactory', + 'Renderer', + 'RenderingHints', + 'RenderingHints.Key', + 'RepaintManager', + 'ReplicateScaleFilter', + 'Repository', + 'RepositoryIdHelper', + 'Request', + 'RescaleOp', + 'Resolver', + 'ResolveResult', + 'ResourceBundle', + 'ResponseHandler', + 'ResultSet', + 'ResultSetMetaData', + 'ReverbType', + 'RGBImageFilter', + 'RMIClassLoader', + 'RMIClientSocketFactory', + 'RMIFailureHandler', + 'RMISecurityException', + 'RMISecurityManager', + 'RMIServerSocketFactory', + 'RMISocketFactory', + 'Robot', + 'RootPaneContainer', + 'RootPaneUI', + 'RoundRectangle2D', + 'RoundRectangle2D.Double', + 'RoundRectangle2D.Float', + 'RowMapper', + 'RSAKey', + 'RSAKeyGenParameterSpec', + 'RSAPrivateCrtKey', + 'RSAPrivateCrtKeySpec', + 'RSAPrivateKey', + 'RSAPrivateKeySpec', + 'RSAPublicKey', + 'RSAPublicKeySpec', + 'RTFEditorKit', + 'RuleBasedCollator', + 'Runnable', + 'Runtime', + 'RunTime', + 'RuntimeException', + 'RunTimeOperations', + 'RuntimePermission', + 'SampleModel', + 'SchemaViolationException', + 'Scrollable', + 'Scrollbar', + 'ScrollBarUI', + 'ScrollPane', + 'ScrollPaneConstants', + 'ScrollPaneLayout', + 'ScrollPaneLayout.UIResource', + 'ScrollPaneUI', + 'SearchControls', + 'SearchResult', + 'SecureClassLoader', + 'SecureRandom', + 'SecureRandomSpi', + 'Security', + 'SecurityException', + 'SecurityManager', + 'SecurityPermission', + 'Segment', + 'SeparatorUI', + 'Sequence', + 'SequenceInputStream', + 'Sequencer', + 'Sequencer.SyncMode', + 'Serializable', + 'SerializablePermission', + 'ServantObject', + 'ServerCloneException', + 'ServerError', 'ServerException', + 'ServerNotActiveException', + 'ServerRef', + 'ServerRequest', + 'ServerRuntimeException', + 'ServerSocket', + 'ServiceDetail', + 'ServiceDetailHelper', + 'ServiceInformation', + 'ServiceInformationHelper', + 'ServiceInformationHolder', + 'ServiceUnavailableException', + 'Set', + 'SetOverrideType', + 'SetOverrideTypeHelper', + 'Shape', + 'ShapeGraphicAttribute', + 'Short', + 'ShortHolder', + 'ShortLookupTable', + 'ShortMessage', + 'ShortSeqHelper', + 'ShortSeqHolder', + 'Signature', + 'SignatureException', + 'SignatureSpi', + 'SignedObject', + 'Signer', + 'SimpleAttributeSet', + 'SimpleBeanInfo', + 'SimpleDateFormat', + 'SimpleTimeZone', + 'SinglePixelPackedSampleModel', + 'SingleSelectionModel', + 'SizeLimitExceededException', + 'SizeRequirements', + 'SizeSequence', + 'Skeleton', + 'SkeletonMismatchException', + 'SkeletonNotFoundException', + 'SliderUI', + 'Socket', + 'SocketException', + 'SocketImpl', + 'SocketImplFactory', + 'SocketOptions', + 'SocketPermission', + 'SocketSecurityException', + 'SoftBevelBorder', + 'SoftReference', + 'SortedMap', + 'SortedSet', + 'Soundbank', + 'SoundbankReader', + 'SoundbankResource', + 'SourceDataLine', + 'SplitPaneUI', + 'SQLData', + 'SQLException', + 'SQLInput', + 'SQLOutput', 'SQLPermission', + 'SQLWarning', + 'Stack', + 'StackOverflowError', + 'StateEdit', + 'StateEditable', + 'StateFactory', + 'Statement', + 'Streamable', + 'StreamableValue', + 'StreamCorruptedException', + 'StreamTokenizer', + 'StrictMath', + 'String', + 'StringBuffer', + 'StringBufferInputStream', + 'StringCharacterIterator', + 'StringContent', + 'StringHolder', + 'StringIndexOutOfBoundsException', + 'StringReader', + 'StringRefAddr', + 'StringSelection', + 'StringTokenizer', + 'StringValueHelper', + 'StringWriter', + 'Stroke', + 'Struct', + 'StructMember', + 'StructMemberHelper', + 'Stub', + 'StubDelegate', + 'StubNotFoundException', + 'Style', + 'StyleConstants', + 'StyleConstants.CharacterConstants', + 'StyleConstants.ColorConstants', + 'StyleConstants.FontConstants', + 'StyleConstants.ParagraphConstants', + 'StyleContext', + 'StyledDocument', + 'StyledEditorKit', + 'StyledEditorKit.AlignmentAction', + 'StyledEditorKit.BoldAction', + 'StyledEditorKit.FontFamilyAction', + 'StyledEditorKit.FontSizeAction', + 'StyledEditorKit.ForegroundAction', + 'StyledEditorKit.ItalicAction', + 'StyledEditorKit.StyledTextAction', + 'StyledEditorKit.UnderlineAction', + 'StyleSheet', + 'StyleSheet.BoxPainter', + 'StyleSheet.ListPainter', + 'SwingConstants', + 'SwingPropertyChangeSupport', + 'SwingUtilities', + 'SyncFailedException', + 'Synthesizer', + 'SysexMessage', + 'System', + 'SystemColor', 'SystemException', + 'SystemFlavorMap', + 'TabableView', + 'TabbedPaneUI', + 'TabExpander', + 'TableCellEditor', + 'TableCellRenderer', + 'TableColumn', + 'TableColumnModel', + 'TableColumnModelEvent', + 'TableColumnModelListener', + 'TableHeaderUI', + 'TableModel', + 'TableModelEvent', + 'TableModelListener', + 'TableUI', + 'TableView', + 'TabSet', + 'TabStop', + 'TagElement', + 'TargetDataLine', + 'TCKind', + 'TextAction', + 'TextArea', + 'TextAttribute', + 'TextComponent', + 'TextEvent', + 'TextField', + 'TextHitInfo', + 'TextLayout', + 'TextLayout.CaretPolicy', + 'TextListener', + 'TextMeasurer', + 'TextUI', + 'TexturePaint', + 'Thread', + 'ThreadDeath', + 'ThreadGroup', + 'ThreadLocal', + 'Throwable', + 'Tie', + 'TileObserver', + 'Time', + 'TimeLimitExceededException', + 'Timer', + 'Timer', + 'TimerTask', + 'Timestamp', + 'TimeZone', + 'TitledBorder', + 'ToolBarUI', + 'Toolkit', + 'ToolTipManager', + 'ToolTipUI', + 'TooManyListenersException', + 'Track', + 'TRANSACTION_REQUIRED', + 'TRANSACTION_ROLLEDBACK', + 'TransactionRequiredException', + 'TransactionRolledbackException', + 'Transferable', + 'TransformAttribute', + 'TRANSIENT', + 'Transmitter', + 'Transparency', + 'TreeCellEditor', + 'TreeCellRenderer', + 'TreeExpansionEvent', + 'TreeExpansionListener', + 'TreeMap', + 'TreeModel', + 'TreeModelEvent', + 'TreeModelListener', + 'TreeNode', + 'TreePath', + 'TreeSelectionEvent', + 'TreeSelectionListener', + 'TreeSelectionModel', + 'TreeSet', + 'TreeUI', + 'TreeWillExpandListener', + 'TypeCode', + 'TypeCodeHolder', + 'TypeMismatch', + 'Types', + 'UID', + 'UIDefaults', + 'UIDefaults.ActiveValue', + 'UIDefaults.LazyInputMap', + 'UIDefaults.LazyValue', + 'UIDefaults.ProxyLazyValue', 'UIManager', + 'UIManager.LookAndFeelInfo', + 'UIResource', + 'ULongLongSeqHelper', + 'ULongLongSeqHolder', + 'ULongSeqHelper', + 'ULongSeqHolder', + 'UndeclaredThrowableException', + 'UndoableEdit', + 'UndoableEditEvent', + 'UndoableEditListener', + 'UndoableEditSupport', + 'UndoManager', + 'UnexpectedException', + 'UnicastRemoteObject', + 'UnionMember', + 'UnionMemberHelper', + 'UNKNOWN', + 'UnknownError', + 'UnknownException', + 'UnknownGroupException', + 'UnknownHostException', + 'UnknownHostException', + 'UnknownObjectException', + 'UnknownServiceException', + 'UnknownUserException', + 'UnmarshalException', + 'UnrecoverableKeyException', + 'Unreferenced', + 'UnresolvedPermission', + 'UnsatisfiedLinkError', + 'UnsolicitedNotification', + 'UnsolicitedNotificationEvent', + 'UnsolicitedNotificationListener', + 'UNSUPPORTED_POLICY', + 'UNSUPPORTED_POLICY_VALUE', + 'UnsupportedAudioFileException', + 'UnsupportedClassVersionError', + 'UnsupportedEncodingException', + 'UnsupportedFlavorException', + 'UnsupportedLookAndFeelException', + 'UnsupportedOperationException', + 'URL', + 'URLClassLoader', + 'URLConnection', + 'URLDecoder', + 'URLEncoder', + 'URLStreamHandler', + 'URLStreamHandlerFactory', + 'UserException', + 'UShortSeqHelper', + 'UShortSeqHolder', + 'UTFDataFormatException', + 'Util', + 'UtilDelegate', + 'Utilities', + 'ValueBase', + 'ValueBaseHelper', + 'ValueBaseHolder', + 'ValueFactory', + 'ValueHandler', + 'ValueMember', + 'ValueMemberHelper', + 'VariableHeightLayoutCache', + 'Vector', + 'VerifyError', + 'VersionSpecHelper', + 'VetoableChangeListener', + 'VetoableChangeSupport', + 'View', + 'ViewFactory', + 'ViewportLayout', + 'ViewportUI', + 'VirtualMachineError', + 'Visibility', + 'VisibilityHelper', + 'VM_ABSTRACT', + 'VM_CUSTOM', + 'VM_NONE', + 'VM_TRUNCATABLE', + 'VMID', + 'VoiceStatus', + 'Void', + 'WCharSeqHelper', + 'WCharSeqHolder', + 'WeakHashMap', + 'WeakReference', + 'Window', + 'WindowAdapter', + 'WindowConstants', + 'WindowEvent', 'WindowListener', + 'WrappedPlainView', + 'WritableRaster', + 'WritableRenderedImage', + 'WriteAbortedException', + 'Writer', + 'WrongTransaction', + 'WStringValueHelper', + 'X509Certificate', + 'X509CRL', + 'X509CRLEntry', + 'X509EncodedKeySpec', + 'X509Extension', + 'ZipEntry', + 'ZipException', + 'ZipFile', + 'ZipInputStream', + 'ZipOutputStream', + 'ZoneView', + '_BindingIteratorImplBase', + '_BindingIteratorStub', + '_IDLTypeStub', + '_NamingContextImplBase', + '_NamingContextStub', + '_PolicyStub', + '_Remote_Stub ' + ), + 4 => array( + 'static', 'void', 'double', 'int', 'real', 'boolean', 'byte' + ) + ), + 'SYMBOLS' => array( + '(', ')', '[', ']', '{', '}', '*', '&', '%', '!', ';', '<', '>', '?' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => true, + 4 => true + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #aaaadd; font-weight: bold;', + 4 => 'color: #993333;' + ), + 'COMMENTS' => array( + 1=> 'color: #808080; font-style: italic;', + 2=> 'color: #a1a100;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #006600;', + 2 => 'color: #006600;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => 'http://www.google.com/search?q=allinurl%3A{FNAME}+java.sun.com&bntl=1', + 4 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.', + 2 => '::' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/javascript.php b/inc/geshi/javascript.php new file mode 100644 index 000000000..95f41ee05 --- /dev/null +++ b/inc/geshi/javascript.php @@ -0,0 +1,146 @@ +<?php
+/*************************************************************************************
+ * javascript.php
+ * --------------
+ * Author: Ben Keen (ben.keen@gmail.com)
+ * Copyright: (c) 2004 Ben Keen (ben.keen@gmail.com), Nigel McNie (http://qbnz.com/highlighter)
+ * Release Version: 1.0.1
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2004/06/20
+ * Last Modified: $Date: 2004/11/29 08:46:24 $
+ *
+ * JavaScript language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/11/27 (1.0.1)
+ * - Added support for multiple object splitters
+ * 2004/10/27 (1.0.0)
+ * - First Release
+ *
+ * TODO (updated 2004/11/27)
+ * -------------------------
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+$language_data = array (
+ 'LANG_NAME' => 'JAVASCRIPT',
+ 'COMMENT_SINGLE' => array(1 => '//'),
+ 'COMMENT_MULTI' => array('/*' => '*/'),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array("'", '"'),
+ 'ESCAPE_CHAR' => '\\',
+ 'KEYWORDS' => array(
+ 1 => array(
+ 'as', 'break', 'case', 'catch', 'continue', 'decodeURI', 'delete', 'do',
+ 'else', 'encodeURI', 'eval', 'finally', 'for', 'if', 'in', 'is', 'item',
+ 'instanceof', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'void',
+ 'while', 'write', 'with'
+ ),
+ 2 => array(
+ 'class', 'const', 'default', 'debugger', 'export', 'extends', 'false',
+ 'function', 'import', 'namespace', 'new', 'null', 'package', 'private',
+ 'protected', 'public', 'super', 'true', 'use', 'var'
+ ),
+ 3 => array(
+
+ // common functions for Window object
+ 'alert', 'back', 'blur', 'close', 'confirm', 'focus', 'forward', 'home',
+ 'name', 'navigate', 'onblur', 'onerror', 'onfocus', 'onload', 'onmove',
+ 'onresize', 'onunload', 'open', 'print', 'prompt', 'scroll', 'status',
+ 'stop',
+ )
+ ),
+ 'SYMBOLS' => array(
+ '(', ')', '[', ']', '{', '}', '!', '@', '%', '&', '*', '|', '/', '<', '>'
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => false,
+ 1 => false,
+ 2 => false,
+ 3 => false
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #000066; font-weight: bold;',
+ 2 => 'color: #003366; font-weight: bold;',
+ 3 => 'color: #000066;'
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #009900; font-style: italic;',
+ 'MULTI' => 'color: #009900; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #000099; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #66cc66;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #3366CC;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #CC0000;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #006600;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #66cc66;'
+ ),
+ 'REGEXPS' => array(
+ 0 => 'color: #0066FF;'
+ ),
+ 'SCRIPT' => array(
+ 0 => '',
+ 1 => '',
+ 2 => '',
+ 3 => ''
+ )
+ ),
+ 'URLS' => array(
+ 1 => '',
+ 2 => '',
+ 3 => ''
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.'
+ ),
+ 'REGEXPS' => array(
+ 0 => "/.*/([igm]*)?" // matches js reg exps
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_MAYBE,
+ 'SCRIPT_DELIMITERS' => array(
+ 0 => array(
+ '<script type="text/javascript">' => '</script>'
+ ),
+ 1 => array(
+ '<script language="javascript">' => '</script>'
+ )
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ 0 => true,
+ 1 => true
+ )
+);
+
+?>
\ No newline at end of file diff --git a/inc/geshi/lisp.php b/inc/geshi/lisp.php new file mode 100644 index 000000000..38ce47274 --- /dev/null +++ b/inc/geshi/lisp.php @@ -0,0 +1,131 @@ +<?php +/************************************************************************************* + * lisp.php + * -------- + * Author: Roberto Rossi (rsoftware@altervista.org) + * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/30 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Generic Lisp language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/08/30 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'LISP', + 'COMMENT_SINGLE' => array(1 => ';'), + 'COMMENT_MULTI' => array(';|' => '|;'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'not','defun','princ', + 'eval','apply','funcall','quote','identity','function', + 'complement','backquote','lambda','set','setq','setf', + 'defun','defmacro','gensym','make','symbol','intern', + 'symbol','name','symbol','value','symbol','plist','get', + 'getf','putprop','remprop','hash','make','array','aref', + 'car','cdr','caar','cadr','cdar','cddr','caaar','caadr','cadar', + 'caddr','cdaar','cdadr','cddar','cdddr','caaaar','caaadr', + 'caadar','caaddr','cadaar','cadadr','caddar','cadddr', + 'cdaaar','cdaadr','cdadar','cdaddr','cddaar','cddadr', + 'cdddar','cddddr','cons','list','append','reverse','last','nth', + 'nthcdr','member','assoc','subst','sublis','nsubst', + 'nsublis','remove','length','list','length', + 'mapc','mapcar','mapl','maplist','mapcan','mapcon','rplaca', + 'rplacd','nconc','delete','atom','symbolp','numberp', + 'boundp','null','listp','consp','minusp','zerop','plusp', + 'evenp','oddp','eq','eql','equal','cond','case','and','or', + 'let','l','if','prog','prog1','prog2','progn','go','return', + 'do','dolist','dotimes','catch','throw','error','cerror','break', + 'continue','errset','baktrace','evalhook','truncate','float', + 'rem','min','max','abs','sin','cos','tan','expt','exp','sqrt', + 'random','logand','logior','logxor','lognot','bignums','logeqv', + 'lognand','lognor','logorc2','logtest','logbitp','logcount', + 'integer','length','nil' + ) + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', '[', ']', '!', '%', '^', '&', '/','+','-','*','=','<','>',';','|' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 0 => 'color: #202020;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/lua.php b/inc/geshi/lua.php new file mode 100644 index 000000000..939fa1644 --- /dev/null +++ b/inc/geshi/lua.php @@ -0,0 +1,132 @@ +<?php +/************************************************************************************* + * lua.php + * ------- + * Author: Roberto Rossi (rsoftware@altervista.org) + * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/blog) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/07/10 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * LUA language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'LUA', + 'COMMENT_SINGLE' => array(1 => "--"), + 'COMMENT_MULTI' => array('--[[' => ']]'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'and','break','do','else','elseif','end','false','for','function','if', + 'in','local','nil','not','or','repeat','return','then','true','until','while', + '_VERSION','assert','collectgarbage','dofile','error','gcinfo','loadfile','loadstring', + 'print','tonumber','tostring','type','unpack', + '_ALERT','_ERRORMESSAGE','_INPUT','_PROMPT','_OUTPUT', + '_STDERR','_STDIN','_STDOUT','call','dostring','foreach','foreachi','getn','globals','newtype', + 'rawget','rawset','require','sort','tinsert','tremove', + 'abs','acos','asin','atan','atan2','ceil','cos','deg','exp', + 'floor','format','frexp','gsub','ldexp','log','log10','max','min','mod','rad','random','randomseed', + 'sin','sqrt','strbyte','strchar','strfind','strlen','strlower','strrep','strsub','strupper','tan', + 'openfile','closefile','readfrom','writeto','appendto', + 'remove','rename','flush','seek','tmpfile','tmpname','read','write', + 'clock','date','difftime','execute','exit','getenv','setlocale','time', + '_G','getfenv','getmetatable','ipairs','loadlib','next','pairs','pcall', + 'rawegal','rawget','rawset','require','setfenv','setmetatable','xpcall', + 'string','table','math','coroutine','io','os','debug', + 'string.byte','string.char','string.dump','string.find','string.len', + 'string.lower','string.rep','string.sub','string.upper','string.format','string.gfind','string.gsub', + 'table.concat','table.foreach','table.foreachi','table.getn','table.sort','table.insert','table.remove','table.setn', + 'math.abs','math.acos','math.asin','math.atan','math.atan2','math.ceil','math.cos','math.deg','math.exp', + 'math.floor','math.frexp','math.ldexp','math.log','math.log10','math.max','math.min','math.mod', + 'math.pi','math.rad','math.random','math.randomseed','math.sin','math.sqrt','math.tan', + 'coroutine.create','coroutine.resume','coroutine.status', + 'coroutine.wrap','coroutine.yield', + 'io.close','io.flush','io.input','io.lines','io.open','io.output','io.read','io.tmpfile','io.type','io.write', + 'io.stdin','io.stdout','io.stderr', + 'os.clock','os.date','os.difftime','os.execute','os.exit','os.getenv','os.remove','os.rename', + 'os.setlocale','os.time','os.tmpname' + ) + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', '!', '@', '%', '&', '*', '|', '/', '<', '>', '=', ';' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => true + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/nsis.php b/inc/geshi/nsis.php new file mode 100644 index 000000000..1d249c524 --- /dev/null +++ b/inc/geshi/nsis.php @@ -0,0 +1,164 @@ +<?php +/************************************************************************************* + * nsis.php + * -------- + * Author: Tux (tux@inmail.cz) + * Copyright: (c) 2004 Tux (http://tux.a4.cz/), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.2 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/29/07 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * NullSoft Installer System language file for GeSHi. + * Words are from SciTe configuration file + * + * CHANGES + * ------- + * 2004/11/27 (1.0.2) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.1) + * - Added support for URLs + * 2004/08/05 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'nsis', + 'COMMENT_SINGLE' => array(1 => ';'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'",'"'), + 'ESCAPE_CHAR' => '', + 'KEYWORDS' => array( + 1 => array( + 'What','Abort','AddSize','AllowRootDirInstall','AutoCloseWindow', + 'BGGradient','BrandingText','BringToFront','CRCCheck','Call','CallInstDLL','Caption','ClearErrors', + 'CompletedText','ComponentText','CopyFiles','CreateDirectory','CreateShortCut','Delete', + 'DeleteINISec','DeleteINIStr','DeleteRegKey','DeleteRegValue','DetailPrint','DetailsButtonText', + 'DirShow','DirText','DisabledBitmap','EnabledBitmap','EnumRegKey','EnumRegValue','Exch','Exec', + 'ExecShell','ExecWait','ExpandEnvStrings','File','FileClose','FileErrorText','FileOpen','FileRead', + 'FileReadByte','FileSeek','FileWrite','FileWriteByte','FindClose','FindFirst','FindNext','FindWindow', + 'Function','FunctionEnd','GetCurrentAddress','GetDLLVersionLocal','GetDllVersion','GetFileTime', + 'GetFileTimeLocal','GetFullPathName','GetFunctionAddress','GetLabelAddress','GetTempFileName', + 'Goto','HideWindow','Icon','IfErrors','IfFileExists','IfRebootFlag','InstProgressFlags','InstType', + 'InstallButtonText','InstallColors','InstallDir','InstallDirRegKey','IntCmp','IntCmpU','IntFmt','IntOp', + 'IsWindow','LicenseData','LicenseText','MessageBox','MiscButtonText','Name','OutFile','Pop','Push', + 'Quit','RMDir','ReadEnvStr','ReadINIStr','ReadRegDword','ReadRegStr','Reboot','RegDLL','Rename', + 'Return','SearchPath','Section','SectionDivider','SectionEnd','SectionIn','SendMessage','SetAutoClose', + 'SetCompress','SetCompressor','SetDatablockOptimize','SetDateSave','SetDetailsPrint','SetDetailsView','SetErrors', + 'SetFileAttributes','SetOutPath','SetOverwrite','SetRebootFlag','ShowInstDetails','ShowUninstDetails', + 'SilentInstall','SilentUnInstall','Sleep','SpaceTexts','StrCmp','StrCpy','StrLen','SubCaption','UnRegDLL', + 'UninstallButtonText','UninstallCaption','UninstallEXEName','UninstallIcon','UninstallSubCaption', + 'UninstallText','WindowIcon','WriteINIStr','WriteRegBin','WriteRegDword','WriteRegDWORD','WriteRegExpandStr', + 'WriteRegStr','WriteUninstaller','SectionGetFlags','SectionSetFlags','SectionSetText','SectionGetText', + 'LogText','LogSet','CreateFont','SetShellVarContext','SetStaticBkColor','SetBrandingImage','PluginDir', + 'SubSectionEnd','SubSection','CheckBitmap','ChangeUI','SetFont','AddBrandingImage','XPStyle','Var', + 'LangString','!define','!undef','!ifdef','!ifndef','!endif','!else','!macro','!echo','!warning','!error','!verbose', + '!macroend','!insertmacro','!system','!include','!cd','!packhdr','!addplugindir' + ), + 2 => array( + '$0','$1','$2','$3','$4','$5','$6','$7','$8','$9', + '$R0','$R1','$R2','$R3','$R4','$R5','$R6','$R7','$R8','$R9','$CMDLINE','$DESKTOP', + '$EXEDIR','$HWNDPARENT','$INSTDIR','$OUTDIR','$PROGRAMFILES','${NSISDIR}', + '$QUICKLAUNCH','$SMPROGRAMS','$SMSTARTUP','$STARTMENU','$SYSDIR','$TEMP','$WINDIR' + ), + 3 => array( + 'ARCHIVE','FILE_ATTRIBUTE_ARCHIVE','FILE_ATTRIBUTE_HIDDEN', + 'FILE_ATTRIBUTE_NORMAL','FILE_ATTRIBUTE_OFFLINE','FILE_ATTRIBUTE_READONLY', + 'FILE_ATTRIBUTE_SYSTEM','FILE_ATTRIBUTE_TEMPORARY','HIDDEN','HKCC','HKCR','HKCU', + 'HKDD','HKEY_CLASSES_ROOT','HKEY_CURRENT_CONFIG','HKEY_CURRENT_USER','HKEY_DYN_DATA', + 'HKEY_LOCAL_MACHINE','HKEY_PERFORMANCE_DATA','HKEY_USERS','HKLM','HKPD','HKU','IDABORT', + 'IDCANCEL','IDIGNORE','IDNO','IDOK','IDRETRY','IDYES','MB_ABORTRETRYIGNORE','MB_DEFBUTTON1', + 'MB_DEFBUTTON2','MB_DEFBUTTON3','MB_DEFBUTTON4','MB_ICONEXCLAMATION', + 'MB_ICONINFORMATION','MB_ICONQUESTION','MB_ICONSTOP','MB_OK','MB_OKCANCEL', + 'MB_RETRYCANCEL','MB_RIGHT','MB_SETFOREGROUND','MB_TOPMOST','MB_YESNO','MB_YESNOCANCEL', + 'NORMAL','OFFLINE','READONLY','SW_SHOWMAXIMIZED','SW_SHOWMINIMIZED','SW_SHOWNORMAL', + 'SYSTEM','TEMPORARY','auto','colored','false','force','hide','ifnewer','nevershow','normal', + 'off','on','show','silent','silentlog','smooth','true','try' + ), + 4 => array( + 'MyFunction','MySomethingElse' + ) + ), + 'SYMBOLS' => array( + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #00007f;', + 2 => 'color: #0000ff;', + 3 => 'color: #46aa03; font-weight:bold;', + 4 => 'color: #0000ff;', + ), + 'COMMENTS' => array( + 1 => 'color: #adadad; font-style: italic;', + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #7f007f;' + ), + 'NUMBERS' => array( + 0 => 'color: #ff0000;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => '', + 4 => '' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/objc.php b/inc/geshi/objc.php new file mode 100644 index 000000000..d9fc56adf --- /dev/null +++ b/inc/geshi/objc.php @@ -0,0 +1,241 @@ +<?php +/************************************************************************************* + * objc.php + * -------- + * Author: M. Uli Kusterer (witness.of.teachtext@gmx.net) + * Copyright: (c) 2004 M. Uli Kusterer, Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.0 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/04 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Objective C language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Objective C', + 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'if', 'return', 'while', 'case', 'continue', 'default', + 'do', 'else', 'for', 'switch', 'goto' + ), + 2 => array( + 'NULL', 'false', 'break', 'true', 'enum', 'nil', 'Nil', 'errno', 'EDOM', + 'ERANGE', 'FLT_RADIX', 'FLT_ROUNDS', 'FLT_DIG', 'DBL_DIG', 'LDBL_DIG', + 'FLT_EPSILON', 'DBL_EPSILON', 'LDBL_EPSILON', 'FLT_MANT_DIG', 'DBL_MANT_DIG', + 'LDBL_MANT_DIG', 'FLT_MAX', 'DBL_MAX', 'LDBL_MAX', 'FLT_MAX_EXP', 'DBL_MAX_EXP', + 'LDBL_MAX_EXP', 'FLT_MIN', 'DBL_MIN', 'LDBL_MIN', 'FLT_MIN_EXP', 'DBL_MIN_EXP', + 'LDBL_MIN_EXP', 'CHAR_BIT', 'CHAR_MAX', 'CHAR_MIN', 'SCHAR_MAX', 'SCHAR_MIN', + 'UCHAR_MAX', 'SHRT_MAX', 'SHRT_MIN', 'USHRT_MAX', 'INT_MAX', 'INT_MIN', + 'UINT_MAX', 'LONG_MAX', 'LONG_MIN', 'ULONG_MAX', 'HUGE_VAL', 'SIGABRT', + 'SIGFPE', 'SIGILL', 'SIGINT', 'SIGSEGV', 'SIGTERM', 'SIG_DFL', 'SIG_ERR', + 'SIG_IGN', 'BUFSIZ', 'EOF', 'FILENAME_MAX', 'FOPEN_MAX', 'L_tmpnam', 'NULL', + 'SEEK_CUR', 'SEEK_END', 'SEEK_SET', 'TMP_MAX', 'stdin', 'stdout', 'stderr', + 'EXIT_FAILURE', 'EXIT_SUCCESS', 'RAND_MAX', 'CLOCKS_PER_SEC' + ), + 3 => array( + 'printf', 'fprintf', 'snprintf', 'sprintf', 'assert', + 'isalnum', 'isalpha', 'isdigit', 'iscntrl', 'isgraph', 'islower', 'isprint', + 'ispunct', 'isspace', 'ispunct', 'isupper', 'isxdigit', 'tolower', 'toupper', + 'exp', 'log', 'log10', 'pow', 'sqrt', 'ceil', 'floor', 'fabs', 'ldexp', + 'frexp', 'modf', 'fmod', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'atan2', + 'sinh', 'cosh', 'tanh', 'setjmp', 'longjmp', 'asin', 'acos', 'atan', 'atan2', + 'va_start', 'va_arg', 'va_end', 'offsetof', 'sizeof', 'fopen', 'freopen', + 'fflush', 'fclose', 'remove', 'rename', 'tmpfile', 'tmpname', 'setvbuf', + 'setbuf', 'vfprintf', 'vprintf', 'vsprintf', 'fscanf', 'scanf', 'sscanf', + 'fgetc', 'fgets', 'fputc', 'fputs', 'getc', 'getchar', 'gets', 'putc', + 'putchar', 'puts', 'ungetc', 'fread', 'fwrite', 'fseek', 'ftell', 'rewind', + 'fgetpos', 'fsetpos', 'clearerr', 'feof', 'ferror', 'perror', 'abs', 'labs', + 'div', 'ldiv', 'atof', 'atoi', 'atol', 'strtod', 'strtol', 'strtoul', 'calloc', + 'malloc', 'realloc', 'free', 'abort', 'exit', 'atexit', 'system', 'getenv', + 'bsearch', 'qsort', 'rand', 'srand', 'strcpy', 'strncpy', 'strcat', 'strncat', + 'strcmp', 'strncmp', 'strcoll', 'strchr', 'strrchr', 'strspn', 'strcspn', + 'strpbrk', 'strstr', 'strlen', 'strerror', 'strtok', 'strxfrm', 'memcpy', + 'memmove', 'memcmp', 'memchr', 'memset', 'clock', 'time', 'difftime', 'mktime', + 'asctime', 'ctime', 'gmtime', 'localtime', 'strftime' + ), + 4 => array( // Data types: + 'auto', 'char', 'const', 'double', 'float', 'int', 'long', + 'register', 'short', 'signed', 'sizeof', 'static', 'string', 'struct', + 'typedef', 'union', 'unsigned', 'void', 'volatile', 'extern', 'jmp_buf', + 'signal', 'raise', 'va_list', 'ptrdiff_t', 'size_t', 'FILE', 'fpos_t', + 'div_t', 'ldiv_t', 'clock_t', 'time_t', 'tm', + // OpenStep/GNUstep/Cocoa: + 'SEL', 'id', 'NSRect', 'NSRange', 'NSPoint', 'NSZone', 'Class', 'IMP', 'BOOL', + // OpenStep/GNUstep/Cocoa @identifiers + '@selector', '@class', '@protocol', '@interface', '@implementation', '@end', + '@private', '@protected', '@public', '@try', '@throw', '@catch', '@finally', + '@encode', '@defs', '@synchronized' + ), + 5 => array( // OpenStep/GNUstep/Cocoa Foundation + 'NSAppleEventDescriptor', 'NSNetService', 'NSAppleEventManager', + 'NSNetServiceBrowser', 'NSAppleScript', 'NSNotification', 'NSArchiver', + 'NSNotificationCenter', 'NSArray', 'NSNotificationQueue', 'NSAssertionHandler', + 'NSNull', 'NSAttributedString', 'NSNumber', 'NSAutoreleasePool', + 'NSNumberFormatter', 'NSBundle', 'NSObject', 'NSCachedURLResponse', + 'NSOutputStream', 'NSCalendarDate', 'NSPipe', 'NSCharacterSet', 'NSPort', + 'NSClassDescription', 'NSPortCoder', 'NSCloneCommand', 'NSPortMessage', + 'NSCloseCommand', 'NSPortNameServer', 'NSCoder', 'NSPositionalSpecifier', + 'NSConditionLock', 'NSProcessInfo', 'NSConnection', 'NSPropertyListSerialization', + 'NSCountCommand', 'NSPropertySpecifier', 'NSCountedSet', 'NSProtocolChecker', + 'NSCreateCommand', 'NSProxy', 'NSData', 'NSQuitCommand', 'NSDate', + 'NSRandomSpecifier', 'NSDateFormatter', 'NSRangeSpecifier', 'NSDecimalNumber', + 'NSRecursiveLock', 'NSDecimalNumberHandler', 'NSRelativeSpecifier', + 'NSDeleteCommand', 'NSRunLoop', 'NSDeserializer', 'NSScanner', 'NSDictionary', + 'NSScriptClassDescription', 'NSDirectoryEnumerator', 'NSScriptCoercionHandler', + 'NSDistantObject', 'NSScriptCommand', 'NSDistantObjectRequest', + 'NSScriptCommandDescription', 'NSDistributedLock', 'NSScriptExecutionContext', + 'NSDistributedNotificationCenter', 'NSScriptObjectSpecifier', 'NSEnumerator', + 'NSScriptSuiteRegistry', 'NSError', 'NSScriptWhoseTest', 'NSException', + 'NSSerializer', 'NSExistsCommand', 'NSSet', 'NSFileHandle', 'NSSetCommand', + 'NSFileManager', 'NSSocketPort', 'NSFormatter', 'NSSocketPortNameServer', + 'NSGetCommand', 'NSSortDescriptor', 'NSHost', 'NSSpecifierTest', 'NSHTTPCookie', + 'NSSpellServer', 'NSHTTPCookieStorage', 'NSStream', 'NSHTTPURLResponse', + 'NSString', 'NSIndexSet', 'NSTask', 'NSIndexSpecifier', 'NSThread', + 'NSInputStream', 'NSTimer', 'NSInvocation', 'NSTimeZone', 'NSKeyedArchiver', + 'NSUnarchiver', 'NSKeyedUnarchiver', 'NSUndoManager', 'NSLock', + 'NSUniqueIDSpecifier', 'NSLogicalTest', 'NSURL', 'NSMachBootstrapServer', + 'NSURLAuthenticationChallenge', 'NSMachPort', 'NSURLCache', 'NSMessagePort', + 'NSURLConnection', 'NSMessagePortNameServer', 'NSURLCredential', + 'NSMethodSignature', 'NSURLCredentialStorage', 'NSMiddleSpecifier', + 'NSURLDownload', 'NSMoveCommand', 'NSURLHandle', 'NSMutableArray', + 'NSURLProtectionSpace', 'NSMutableAttributedString', 'NSURLProtocol', + 'NSMutableCharacterSet', 'NSURLRequest', 'NSMutableData', 'NSURLResponse', + 'NSMutableDictionary', 'NSUserDefaults', 'NSMutableIndexSet', 'NSValue', + 'NSMutableSet', 'NSValueTransformer', 'NSMutableString', 'NSWhoseSpecifier', + 'NSMutableURLRequest', 'NSXMLParser', 'NSNameSpecifier' + ), + 6 => array( // OpenStep/GNUstep/Cocoa AppKit + 'NSActionCell', 'NSOpenGLPixelFormat', 'NSAffineTransform', 'NSOpenGLView', + 'NSAlert', 'NSOpenPanel', 'NSAppleScript Additions', 'NSOutlineView', + 'NSApplication', 'NSPageLayout', 'NSArrayController', 'NSPanel', + 'NSATSTypesetter', 'NSParagraphStyle', 'NSPasteboard', 'NSBezierPath', + 'NSPDFImageRep', 'NSBitmapImageRep', 'NSPICTImageRep', 'NSBox', 'NSPopUpButton', + 'NSBrowser', 'NSPopUpButtonCell', 'NSBrowserCell', 'NSPrinter', 'NSPrintInfo', + 'NSButton', 'NSPrintOperation', 'NSButtonCell', 'NSPrintPanel', 'NSCachedImageRep', + 'NSProgressIndicator', 'NSCell', 'NSQuickDrawView', 'NSClipView', 'NSResponder', + 'NSRulerMarker', 'NSColor', 'NSRulerView', 'NSColorList', 'NSSavePanel', + 'NSColorPanel', 'NSScreen', 'NSColorPicker', 'NSScroller', 'NSColorWell', + 'NSScrollView', 'NSComboBox', 'NSSearchField', 'NSComboBoxCell', + 'NSSearchFieldCell', 'NSControl', 'NSSecureTextField', 'NSController', + 'NSSecureTextFieldCell', 'NSCursor', 'NSSegmentedCell', 'NSCustomImageRep', + 'NSSegmentedControl', 'NSDocument', 'NSShadow', 'NSDocumentController', + 'NSSimpleHorizontalTypesetter', 'NSDrawer', 'NSSlider', 'NSEPSImageRep', + 'NSSliderCell', 'NSEvent', 'NSSound', 'NSFileWrapper', 'NSSpeechRecognizer', + 'NSFont', 'NSSpeechSynthesizer', 'NSFontDescriptor', 'NSSpellChecker', + 'NSFontManager', 'NSSplitView', 'NSFontPanel', 'NSStatusBar', 'NSForm', + 'NSStatusItem', 'NSFormCell', 'NSStepper', 'NSGlyphGenerator', 'NSStepperCell', + 'NSGlyphInfo', 'NSGraphicsContext', 'NSTableColumn', 'NSHelpManager', + 'NSTableHeaderCell', 'NSImage', 'NSTableHeaderView', 'NSImageCell', 'NSTableView', + 'NSImageRep', 'NSTabView', 'NSImageView', 'NSTabViewItem', 'NSInputManager', + 'NSText', 'NSInputServer', 'NSTextAttachment', 'NSLayoutManager', + 'NSTextAttachmentCell', 'NSMatrix', 'NSTextContainer', 'NSMenu', 'NSTextField', + 'NSMenuItem', 'NSTextFieldCell', 'NSMenuItemCell', 'NSTextStorage', 'NSMenuView', + 'NSTextTab', 'NSMovie', 'NSTextView', 'NSMovieView', 'NSToolbar', 'NSToolbarItem', + 'NSMutableParagraphStyle', 'NSTypesetter', 'NSNib', 'NSNibConnector', + 'NSUserDefaultsController', 'NSNibControlConnector', 'NSView', + 'NSNibOutletConnector', 'NSWindow', 'NSObjectController', 'NSWindowController', + 'NSOpenGLContext', 'NSWorkspace', 'NSOpenGLPixelBuffer' + ) + ), + 'SYMBOLS' => array( + '(', ')', '{', '}', '[', ']', '=', '+', '-', '*', '/', '!', '%', '^', '&', ':' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #0000ff;', + 2 => 'color: #0000ff;', + 3 => 'color: #0000dd;', + 4 => 'color: #0000ff;', + 5 => 'color: #0000ff;', + 6 => 'color: #0000ff;' + ), + 'COMMENTS' => array( + 1 => 'color: #ff0000;', + 2 => 'color: #339900;', + 'MULTI' => 'color: #ff0000; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #666666; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #002200;' + ), + 'STRINGS' => array( + 0 => 'color: #666666;' + ), + 'NUMBERS' => array( + 0 => 'color: #0000dd;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #002200;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => 'http://www.opengroup.org/onlinepubs/009695399/functions/{FNAME}.html', + 4 => '', + 5 => 'http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/{FNAME}.html', + 6 => 'http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/{FNAME}.html' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/oobas.php b/inc/geshi/oobas.php new file mode 100644 index 000000000..f771d1239 --- /dev/null +++ b/inc/geshi/oobas.php @@ -0,0 +1,132 @@ +<?php +/************************************************************************************* + * oobas.php + * --------- + * Author: Roberto Rossi (rsoftware@altervista.org) + * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/30 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * OpenOffice.org Basic language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'OpenOffice.org Basic', + 'COMMENT_SINGLE' => array(1 => "'"), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '', + 'KEYWORDS' => array( + 1 => array( + 'dim','private','public','global','as','if','redim','true','set', + 'byval', + 'false','bool','double','integer','long','object','single','variant', + 'msgbox','print','inputbox','green','blue','red','qbcolor', + 'rgb','open','close','reset','freefile','get','input','line', + 'put','write','loc','seek','eof','lof','chdir','chdrive', + 'curdir','dir','fileattr','filecopy','filedatetime','fileexists', + 'filelen','getattr','kill','mkdir','name','rmdir','setattr', + 'dateserial','datevalue','day','month','weekday','year','cdatetoiso', + 'cdatefromiso','hour','minute','second','timeserial','timevalue', + 'date','now','time','timer','erl','err','error','on','error','goto','resume', + 'and','eqv','imp','not','or','xor','mod','','atn','cos','sin','tan','log', + 'exp','rnd','randomize','sqr','fix','int','abs','sgn','hex','oct', + 'it','then','else','select','case','iif','do','loop','for','next', + 'while','wend','gosub','return','goto','on','goto','call','choose','declare', + 'end','exit','freelibrary','function','rem','stop','sub','switch','with', + 'cbool','cdate','cdbl','cint','clng','const','csng','cstr','defbool', + 'defdate','defdbl','defint','deflng','asc','chr','str','val','cbyte', + 'space','string','format','lcase','left','lset','ltrim','mid','right', + 'rset','rtrim','trim','ucase','split','join','converttourl','convertfromurl', + 'instr','len','strcomp','beep','shell','wait','getsystemticks','environ', + 'getsolarversion','getguitype','twipsperpixelx','twipsperpixely', + 'createunostruct','createunoservice','getprocessservicemanager', + 'createunodialog','createunolistener','createunovalue','thiscomponent', + 'globalscope' + ) + ), + 'SYMBOLS' => array( + '(', ')', '=' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #006600;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099;' + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + ) + ), + 'URLS' => array( + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/pascal.php b/inc/geshi/pascal.php new file mode 100644 index 000000000..ac44eebd5 --- /dev/null +++ b/inc/geshi/pascal.php @@ -0,0 +1,145 @@ +<?php +/************************************************************************************* + * pascal.php + * ---------- + * Author: Tux (tux@inamil.cz) + * Copyright: (c) 2004 Tux (http://tux.a4.cz/), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.2 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/07/26 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Pascal language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.2) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.1) + * - Added support for URLs + * 2004/08/05 (1.0.0) + * - Added support for symbols + * 2004/07/27 (0.9.1) + * - Pascal is OO language. Some new words. + * 2004/07/26 (0.9.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Pascal', + 'COMMENT_SINGLE' => array(1 => '//'), + 'COMMENT_MULTI' => array('{' => '}','(*' => '*)'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'if', 'while', 'until', 'repeat', 'default', + 'do', 'else', 'for', 'switch', 'goto','label','asm','begin','end', + 'assembler','case', 'downto', 'to','div','mod','far','forward','in','inherited', + 'inline','interrupt','label','library','not','var','of','then','stdcall', + 'cdecl','end.','raise','try','except','name','finally','resourcestring','override','overload', + 'default','public','protected','private','property','published','stored','catch' + ), + 2 => array( + 'nil', 'false', 'break', 'true', 'function', 'procedure','implementation','interface', + 'unit','program','initialization','finalization','uses' + ), + 3 => array( + 'abs', 'absolute','and','arc','arctan','chr','constructor','destructor', + 'dispose','cos','eof','eoln','exp','get','index','ln','new','xor','write','writeln', + 'shr','sin','sqrt','succ','pred','odd','read','readln','ord','ordinal','blockread','blockwrite' + ), + 4 => array( + 'array', 'char', 'const', 'boolean', 'real', 'integer', 'longint', + 'word', 'shortint', 'record','byte','bytebool','string', + 'type','object','export','exports','external','file','longbool','pointer','set', + 'packed','ansistring','union' + ), + ), + 'SYMBOLS' => array( + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => '', + 4 => 'color: #993333;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 2 => 'color: #339933;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #202020;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => '', + 4 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/perl.php b/inc/geshi/perl.php new file mode 100644 index 000000000..196dd8689 --- /dev/null +++ b/inc/geshi/perl.php @@ -0,0 +1,162 @@ +<?php +/************************************************************************************* + * perl.php + * -------- + * Author: Andreas Gohr (andi@splitbrain.org), Ben Keen (ben.keen@gmail.com) + * Copyright: (c) 2004 Andreas Gohr, Ben Keen (http://www.benjaminkeen.org/), Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/20 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * Perl language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/08/20 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * LABEL: + * * string comparison operators + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Perl', + 'COMMENT_SINGLE' => array(1 => '#'), + 'COMMENT_MULTI' => array( '=pod' => '=cut'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'case', 'do', 'else', 'elsif', 'for', 'if', 'then', 'until', 'while', 'foreach', 'my', + 'or', 'and', 'unless', 'next', 'last', 'redo', 'not', 'our', + 'reset', 'continue','and', 'cmp', 'ne' + ), + 2 => array( + 'use', 'sub', 'new', '__END__', '__DATA__', '__DIE__', '__WARN__', 'BEGIN', + 'STDIN', 'STDOUT', 'STDERR' + ), + 3 => array( + 'abs', 'accept', 'alarm', 'atan2', 'bind', 'binmode', 'bless', + 'caller', 'chdir', 'chmod', 'chomp', 'chop', 'chown', 'chr', + 'chroot', 'close', 'closedir', 'connect', 'continue', 'cos', + 'crypt', 'dbmclose', 'dbmopen', 'defined', 'delete', 'die', + 'dump', 'each', 'endgrent', 'endhostent', 'endnetent', 'endprotoent', + 'endpwent', 'endservent', 'eof', 'eval', 'exec', 'exists', 'exit', + 'exp', 'fcntl', 'fileno', 'flock', 'fork', 'format', 'formline', + 'getc', 'getgrent', 'getgrgid', 'getgrnam', 'gethostbyaddr', + 'gethostbyname', 'gethostent', 'getlogin', 'getnetbyaddr', 'getnetbyname', + 'getnetent', 'getpeername', 'getpgrp', 'getppid', 'getpriority', + 'getprotobyname', 'getprotobynumber', 'getprotoent', 'getpwent', + 'getpwnam', 'getpwuid', 'getservbyname', 'getservbyport', 'getservent', + 'getsockname', 'getsockopt', 'glob', 'gmtime', 'goto', 'grep', + 'hex', 'import', 'index', 'int', 'ioctl', 'join', 'keys', 'kill', + 'last', 'lc', 'lcfirst', 'length', 'link', 'listen', 'local', + 'localtime', 'log', 'lstat', 'm', 'map', 'mkdir', 'msgctl', 'msgget', + 'msgrcv', 'msgsnd', 'my', 'next', 'no', 'oct', 'open', 'opendir', + 'ord', 'our', 'pack', 'package', 'pipe', 'pop', 'pos', 'print', + 'printf', 'prototype', 'push', 'qq', 'qr', 'quotemeta', 'qw', + 'qx', 'q', 'rand', 'read', 'readdir', 'readline', 'readlink', 'readpipe', + 'recv', 'redo', 'ref', 'rename', 'require', 'return', + 'reverse', 'rewinddir', 'rindex', 'rmdir', 's', 'scalar', 'seek', + 'seekdir', 'select', 'semctl', 'semget', 'semop', 'send', 'setgrent', + 'sethostent', 'setnetent', 'setpgrp', 'setpriority', 'setprotoent', + 'setpwent', 'setservent', 'setsockopt', 'shift', 'shmctl', 'shmget', + 'shmread', 'shmwrite', 'shutdown', 'sin', 'sleep', 'socket', 'socketpair', + 'sort', 'splice', 'split', 'sprintf', 'sqrt', 'srand', 'stat', + 'study', 'substr', 'symlink', 'syscall', 'sysopen', 'sysread', + 'sysseek', 'system', 'syswrite', 'tell', 'telldir', 'tie', 'tied', + 'time', 'times', 'tr', 'truncate', 'uc', 'ucfirst', 'umask', 'undef', + 'unlink', 'unpack', 'unshift', 'untie', 'utime', 'values', + 'vec', 'wait', 'waitpid', 'wantarray', 'warn', 'write', 'y' + ) + ), + 'SYMBOLS' => array( + '(', ')', '[', ']', '!', '@', '%', '&', '*', '|', '/', '<', '>' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => true, + 2 => true, + 3 => true, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #000066;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #006600;', + 2 => 'color: #006600;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + 0 => 'color: #0000ff;', + 4 => 'color: #009999;', + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + 3 => 'http://www.perldoc.com/perl5.6/pod/func/{FNAME}.html' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '->', + 2 => '::' + ), + 'REGEXPS' => array( + 0 => '[\\$%@]+[a-zA-Z_][a-zA-Z0-9_]*', + 4 => '<[a-zA-Z_][a-zA-Z0-9_]*>', + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?> diff --git a/inc/geshi/php-brief.php b/inc/geshi/php-brief.php new file mode 100644 index 000000000..54729318e --- /dev/null +++ b/inc/geshi/php-brief.php @@ -0,0 +1,162 @@ +<?php +/************************************************************************************* + * php-brief.php + * ------------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.3 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/02 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * PHP language file for GeSHi (brief version). + * + * CHANGES + * ------- + * 2004/11/27 (1.0.3) + * - Added support for multiple object splitters + * - Fixed &new problem + * 2004/10/27 (1.0.2) + * - Added support for URLs + * 2004/08/05 (1.0.1) + * - Added support for symbols + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/07/14) + * ------------------------- + * * Remove more functions that are hardly used + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'PHP', + 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'include', 'require', 'include_once', 'require_once', + 'for', 'as', 'foreach', 'if', 'elseif', 'else', 'while', 'do', 'endwhile', 'endif', 'switch', 'case', 'endswitch', + 'return', 'break' + ), + 2 => array( + 'null', '__LINE__', '__FILE__', + 'false', '<?php', '?>', + 'true', 'var', 'default', + 'function', 'class', 'new', '&new' + ), + 3 => array( + 'func_num_args', 'func_get_arg', 'func_get_args', 'strlen', 'strcmp', 'strncmp', 'strcasecmp', 'strncasecmp', 'each', 'error_reporting', 'define', 'defined', + 'trigger_error', 'user_error', 'set_error_handler', 'restore_error_handler', 'get_declared_classes', 'get_loaded_extensions', + 'extension_loaded', 'get_extension_funcs', 'debug_backtrace', + 'constant', 'bin2hex', 'sleep', 'usleep', 'time', 'mktime', 'gmmktime', 'strftime', 'gmstrftime', 'strtotime', 'date', 'gmdate', 'getdate', 'localtime', 'checkdate', 'flush', 'wordwrap', 'htmlspecialchars', 'htmlentities', 'html_entity_decode', 'md5', 'md5_file', 'crc32', 'getimagesize', 'image_type_to_mime_type', 'phpinfo', 'phpversion', 'phpcredits', 'strnatcmp', 'strnatcasecmp', 'substr_count', 'strspn', 'strcspn', 'strtok', 'strtoupper', 'strtolower', 'strpos', 'strrpos', 'strrev', 'hebrev', 'hebrevc', 'nl2br', 'basename', 'dirname', 'pathinfo', 'stripslashes', 'stripcslashes', 'strstr', 'stristr', 'strrchr', 'str_shuffle', 'str_word_count', 'strcoll', 'substr', 'substr_replace', 'quotemeta', 'ucfirst', 'ucwords', 'strtr', 'addslashes', 'addcslashes', 'rtrim', 'str_replace', 'str_repeat', 'count_chars', 'chunk_split', 'trim', 'ltrim', 'strip_tags', 'similar_text', 'explode', 'implode', 'setlocale', 'localeconv', + 'parse_str', 'str_pad', 'chop', 'strchr', 'sprintf', 'printf', 'vprintf', 'vsprintf', 'sscanf', 'fscanf', 'parse_url', 'urlencode', 'urldecode', 'rawurlencode', 'rawurldecode', 'readlink', 'linkinfo', 'link', 'unlink', 'exec', 'system', 'escapeshellcmd', 'escapeshellarg', 'passthru', 'shell_exec', 'proc_open', 'proc_close', 'rand', 'srand', 'getrandmax', 'mt_rand', 'mt_srand', 'mt_getrandmax', 'base64_decode', 'base64_encode', 'abs', 'ceil', 'floor', 'round', 'is_finite', 'is_nan', 'is_infinite', 'bindec', 'hexdec', 'octdec', 'decbin', 'decoct', 'dechex', 'base_convert', 'number_format', 'fmod', 'ip2long', 'long2ip', 'getenv', 'putenv', 'getopt', 'microtime', 'gettimeofday', 'getrusage', 'uniqid', 'quoted_printable_decode', 'set_time_limit', 'get_cfg_var', 'magic_quotes_runtime', 'set_magic_quotes_runtime', 'get_magic_quotes_gpc', 'get_magic_quotes_runtime', + 'import_request_variables', 'error_log', 'serialize', 'unserialize', 'memory_get_usage', 'var_dump', 'var_export', 'debug_zval_dump', 'print_r','highlight_file', 'show_source', 'highlight_string', 'ini_get', 'ini_get_all', 'ini_set', 'ini_alter', 'ini_restore', 'get_include_path', 'set_include_path', 'restore_include_path', 'setcookie', 'header', 'headers_sent', 'connection_aborted', 'connection_status', 'ignore_user_abort', 'parse_ini_file', 'is_uploaded_file', 'move_uploaded_file', 'intval', 'floatval', 'doubleval', 'strval', 'gettype', 'settype', 'is_null', 'is_resource', 'is_bool', 'is_long', 'is_float', 'is_int', 'is_integer', 'is_double', 'is_real', 'is_numeric', 'is_string', 'is_array', 'is_object', 'is_scalar', + 'ereg', 'ereg_replace', 'eregi', 'eregi_replace', 'split', 'spliti', 'join', 'sql_regcase', 'dl', 'pclose', 'popen', 'readfile', 'rewind', 'rmdir', 'umask', 'fclose', 'feof', 'fgetc', 'fgets', 'fgetss', 'fread', 'fopen', 'fpassthru', 'ftruncate', 'fstat', 'fseek', 'ftell', 'fflush', 'fwrite', 'fputs', 'mkdir', 'rename', 'copy', 'tempnam', 'tmpfile', 'file', 'file_get_contents', 'stream_select', 'stream_context_create', 'stream_context_set_params', 'stream_context_set_option', 'stream_context_get_options', 'stream_filter_prepend', 'stream_filter_append', 'fgetcsv', 'flock', 'get_meta_tags', 'stream_set_write_buffer', 'set_file_buffer', 'set_socket_blocking', 'stream_set_blocking', 'socket_set_blocking', 'stream_get_meta_data', 'stream_register_wrapper', 'stream_wrapper_register', 'stream_set_timeout', 'socket_set_timeout', 'socket_get_status', 'realpath', 'fnmatch', 'fsockopen', 'pfsockopen', 'pack', 'unpack', 'get_browser', 'crypt', 'opendir', 'closedir', 'chdir', 'getcwd', 'rewinddir', 'readdir', 'dir', 'glob', 'fileatime', 'filectime', 'filegroup', 'fileinode', 'filemtime', 'fileowner', 'fileperms', 'filesize', 'filetype', 'file_exists', 'is_writable', 'is_writeable', 'is_readable', 'is_executable', 'is_file', 'is_dir', 'is_link', 'stat', 'lstat', 'chown', + 'touch', 'clearstatcache', 'mail', 'ob_start', 'ob_flush', 'ob_clean', 'ob_end_flush', 'ob_end_clean', 'ob_get_flush', 'ob_get_clean', 'ob_get_length', 'ob_get_level', 'ob_get_status', 'ob_get_contents', 'ob_implicit_flush', 'ob_list_handlers', 'ksort', 'krsort', 'natsort', 'natcasesort', 'asort', 'arsort', 'sort', 'rsort', 'usort', 'uasort', 'uksort', 'shuffle', 'array_walk', 'count', 'end', 'prev', 'next', 'reset', 'current', 'key', 'min', 'max', 'in_array', 'array_search', 'extract', 'compact', 'array_fill', 'range', 'array_multisort', 'array_push', 'array_pop', 'array_shift', 'array_unshift', 'array_splice', 'array_slice', 'array_merge', 'array_merge_recursive', 'array_keys', 'array_values', 'array_count_values', 'array_reverse', 'array_reduce', 'array_pad', 'array_flip', 'array_change_key_case', 'array_rand', 'array_unique', 'array_intersect', 'array_intersect_assoc', 'array_diff', 'array_diff_assoc', 'array_sum', 'array_filter', 'array_map', 'array_chunk', 'array_key_exists', 'pos', 'sizeof', 'key_exists', 'assert', 'assert_options', 'version_compare', 'ftok', 'str_rot13', 'aggregate', + 'session_name', 'session_module_name', 'session_save_path', 'session_id', 'session_regenerate_id', 'session_decode', 'session_register', 'session_unregister', 'session_is_registered', 'session_encode', + 'session_start', 'session_destroy', 'session_unset', 'session_set_save_handler', 'session_cache_limiter', 'session_cache_expire', 'session_set_cookie_params', 'session_get_cookie_params', 'session_write_close', 'preg_match', 'preg_match_all', 'preg_replace', 'preg_replace_callback', 'preg_split', 'preg_quote', 'preg_grep', 'overload', 'ctype_alnum', 'ctype_alpha', 'ctype_cntrl', 'ctype_digit', 'ctype_lower', 'ctype_graph', 'ctype_print', 'ctype_punct', 'ctype_space', 'ctype_upper', 'ctype_xdigit', 'virtual', 'apache_request_headers', 'apache_note', 'apache_lookup_uri', 'apache_child_terminate', 'apache_setenv', 'apache_response_headers', 'apache_get_version', 'getallheaders', 'mysql_connect', 'mysql_pconnect', 'mysql_close', 'mysql_select_db', 'mysql_create_db', 'mysql_drop_db', 'mysql_query', 'mysql_unbuffered_query', 'mysql_db_query', 'mysql_list_dbs', 'mysql_list_tables', 'mysql_list_fields', 'mysql_list_processes', 'mysql_error', 'mysql_errno', 'mysql_affected_rows', 'mysql_insert_id', 'mysql_result', 'mysql_num_rows', 'mysql_num_fields', 'mysql_fetch_row', 'mysql_fetch_array', 'mysql_fetch_assoc', 'mysql_fetch_object', 'mysql_data_seek', 'mysql_fetch_lengths', 'mysql_fetch_field', 'mysql_field_seek', 'mysql_free_result', 'mysql_field_name', 'mysql_field_table', 'mysql_field_len', 'mysql_field_type', 'mysql_field_flags', 'mysql_escape_string', 'mysql_real_escape_string', 'mysql_stat', + 'mysql_thread_id', 'mysql_client_encoding', 'mysql_get_client_info', 'mysql_get_host_info', 'mysql_get_proto_info', 'mysql_get_server_info', 'mysql_info', 'mysql', 'mysql_fieldname', 'mysql_fieldtable', 'mysql_fieldlen', 'mysql_fieldtype', 'mysql_fieldflags', 'mysql_selectdb', 'mysql_createdb', 'mysql_dropdb', 'mysql_freeresult', 'mysql_numfields', 'mysql_numrows', 'mysql_listdbs', 'mysql_listtables', 'mysql_listfields', 'mysql_db_name', 'mysql_dbname', 'mysql_tablename', 'mysql_table_name', 'pg_connect', 'pg_pconnect', 'pg_close', 'pg_connection_status', 'pg_connection_busy', 'pg_connection_reset', 'pg_host', 'pg_dbname', 'pg_port', 'pg_tty', 'pg_options', 'pg_ping', 'pg_query', 'pg_send_query', 'pg_cancel_query', 'pg_fetch_result', 'pg_fetch_row', 'pg_fetch_assoc', 'pg_fetch_array', 'pg_fetch_object', 'pg_fetch_all', 'pg_affected_rows', 'pg_get_result', 'pg_result_seek', 'pg_result_status', 'pg_free_result', 'pg_last_oid', 'pg_num_rows', 'pg_num_fields', 'pg_field_name', 'pg_field_num', 'pg_field_size', 'pg_field_type', 'pg_field_prtlen', 'pg_field_is_null', 'pg_get_notify', 'pg_get_pid', 'pg_result_error', 'pg_last_error', 'pg_last_notice', 'pg_put_line', 'pg_end_copy', 'pg_copy_to', 'pg_copy_from', + 'pg_trace', 'pg_untrace', 'pg_lo_create', 'pg_lo_unlink', 'pg_lo_open', 'pg_lo_close', 'pg_lo_read', 'pg_lo_write', 'pg_lo_read_all', 'pg_lo_import', 'pg_lo_export', 'pg_lo_seek', 'pg_lo_tell', 'pg_escape_string', 'pg_escape_bytea', 'pg_unescape_bytea', 'pg_client_encoding', 'pg_set_client_encoding', 'pg_meta_data', 'pg_convert', 'pg_insert', 'pg_update', 'pg_delete', 'pg_select', 'pg_exec', 'pg_getlastoid', 'pg_cmdtuples', 'pg_errormessage', 'pg_numrows', 'pg_numfields', 'pg_fieldname', 'pg_fieldsize', 'pg_fieldtype', 'pg_fieldnum', 'pg_fieldprtlen', 'pg_fieldisnull', 'pg_freeresult', 'pg_result', 'pg_loreadall', 'pg_locreate', 'pg_lounlink', 'pg_loopen', 'pg_loclose', 'pg_loread', 'pg_lowrite', 'pg_loimport', 'pg_loexport', + 'echo', 'print', 'global', 'static', 'exit', 'array', 'empty', 'eval', 'isset', 'unset', 'die' + ) + ), + 'SYMBOLS' => array( + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false, + 2 => false, + 3 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #000066;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 2 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #006600;', + 2 => 'color: #006600;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + 0 => 'color: #0000ff;' + ), + 'SCRIPT' => array( + 0 => '', + 1 => '', + 2 => '', + 3 => '' + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => 'http://www.php.net/{FNAME}', + 4 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '->', + 2 => '::' + ), + 'REGEXPS' => array( + 0 => "[\\$]{1,2}[a-zA-Z_][a-zA-Z0-9_]*" + ), + 'STRICT_MODE_APPLIES' => GESHI_MAYBE, + 'SCRIPT_DELIMITERS' => array( + '<?php' => '?>', + '<?' => '?>', + '<%' => '%>', + '<script language="php">' => '</script>' + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + 0 => true, + 1 => true, + 2 => true, + 3 => true + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/php.php b/inc/geshi/php.php new file mode 100644 index 000000000..447e85fb2 --- /dev/null +++ b/inc/geshi/php.php @@ -0,0 +1,346 @@ +<?php +/************************************************************************************* + * php.php + * -------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.3 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/20 + * Last Modified: $Date: 2004/11/29 08:46:24 $ + * + * PHP language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/25 (1.0.3) + * - Added support for multiple object splitters + * - Fixed &new problem + * 2004/10/27 (1.0.2) + * - Added URL support + * - Added extra constants + * 2004/08/05 (1.0.1) + * - Added support for symbols + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/07/14) + * ------------------------- + * * Make sure the last few function I may have missed + * (like eval()) are included for highlighting + * * Split to several files - php4, php5 etc + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'PHP', + 'COMMENT_SINGLE' => array(1 => '//', 2 => '#'), + 'COMMENT_MULTI' => array('/*' => '*/'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'include', 'require', 'include_once', 'require_once', + 'for', 'foreach', 'as', 'if', 'elseif', 'else', 'while', 'do', 'endwhile', 'endif', 'switch', 'case', 'endswitch', + 'return', 'break' + ), + 2 => array( + 'null', '__LINE__', '__FILE__', + 'false', '<?php', '?>', '<?', + '<script language', '</script>', + 'true', 'var', 'default', + 'function', 'class', 'new', '&new', + '__FUNCTION__', '__CLASS__', '__METHOD__', 'PHP_VERSION', + 'PHP_OS', 'DEFAULT_INCLUDE_PATH', 'PEAR_INSTALL_DIR', 'PEAR_EXTENSION_DIR', + 'PHP_EXTENSION_DIR', 'PHP_BINDIR', 'PHP_LIBDIR', 'PHP_DATADIR', 'PHP_SYSCONFDIR', + 'PHP_LOCALSTATEDIR', 'PHP_CONFIG_FILE_PATH', 'PHP_OUTPUT_HANDLER_START', 'PHP_OUTPUT_HANDLER_CONT', + 'PHP_OUTPUT_HANDLER_END', 'E_ERROR', 'E_WARNING', 'E_PARSE', 'E_NOTICE', + 'E_CORE_ERROR', 'E_CORE_WARNING', 'E_COMPILE_ERROR', 'E_COMPILE_WARNING', 'E_USER_ERROR', + 'E_USER_WARNING', 'E_USER_NOTICE', 'E_ALL' + ), + 3 => array( + 'zlib_get_coding_type','zend_version','zend_logo_guid','yp_order','yp_next', + 'yp_match','yp_master','yp_get_default_domain','yp_first','yp_errno','yp_err_string', + 'yp_cat','yp_all','xml_set_unparsed_entity_decl_handler','xml_set_start_namespace_decl_handler','xml_set_processing_instruction_handler','xml_set_object', + 'xml_set_notation_decl_handler','xml_set_external_entity_ref_handler','xml_set_end_namespace_decl_handler','xml_set_element_handler','xml_set_default_handler','xml_set_character_data_handler', + 'xml_parser_set_option','xml_parser_get_option','xml_parser_free','xml_parser_create_ns','xml_parser_create','xml_parse_into_struct', + 'xml_parse','xml_get_error_code','xml_get_current_line_number','xml_get_current_column_number','xml_get_current_byte_index','xml_error_string', + 'wordwrap','wddx_serialize_vars','wddx_serialize_value','wddx_packet_start','wddx_packet_end','wddx_deserialize', + 'wddx_add_vars','vsprintf','vprintf','virtual','version_compare','var_export', + 'var_dump','utf8_encode','utf8_decode','usort','usleep','user_error', + 'urlencode','urldecode','unserialize','unregister_tick_function','unpack','unlink', + 'unixtojd','uniqid','umask','uksort','ucwords','ucfirst', + 'uasort','trim','trigger_error','touch','token_name','token_get_all', + 'tmpfile','time','textdomain','tempnam','tanh','tan', + 'system','syslog','symlink','substr_replace','substr_count','substr', + 'strval','strtr','strtoupper','strtotime','strtolower','strtok', + 'strstr','strspn','strrpos','strrev','strrchr','strpos', + 'strncmp','strncasecmp','strnatcmp','strnatcasecmp','strlen','stristr', + 'stripslashes','stripcslashes','strip_tags','strftime','stream_wrapper_register','stream_set_write_buffer', + 'stream_set_timeout','stream_set_blocking','stream_select','stream_register_wrapper','stream_get_meta_data','stream_filter_prepend', + 'stream_filter_append','stream_context_set_params','stream_context_set_option','stream_context_get_options','stream_context_create','strcspn', + 'strcoll','strcmp','strchr','strcasecmp','str_word_count','str_shuffle', + 'str_rot13','str_replace','str_repeat','str_pad','stat','sscanf', + 'srand','sqrt','sql_regcase','sprintf','spliti','split', + 'soundex','sort','socket_writev','socket_write','socket_strerror','socket_shutdown', + 'socket_setopt','socket_set_timeout','socket_set_option','socket_set_nonblock','socket_set_blocking','socket_set_block', + 'socket_sendto','socket_sendmsg','socket_send','socket_select','socket_recvmsg','socket_recvfrom', + 'socket_recv','socket_readv','socket_read','socket_listen','socket_last_error','socket_iovec_set', + 'socket_iovec_free','socket_iovec_fetch','socket_iovec_delete','socket_iovec_alloc','socket_iovec_add','socket_getsockname', + 'socket_getpeername','socket_getopt','socket_get_status','socket_get_option','socket_create_pair','socket_create_listen', + 'socket_create','socket_connect','socket_close','socket_clear_error','socket_bind','socket_accept', + 'sleep','sizeof','sinh','sin','similar_text','shuffle', + 'show_source','shmop_write','shmop_size','shmop_read','shmop_open','shmop_delete', + 'shmop_close','shm_remove_var','shm_remove','shm_put_var','shm_get_var','shm_detach', + 'shm_attach','shell_exec','sha1_file','sha1','settype','setlocale', + 'setcookie','set_time_limit','set_socket_blocking','set_magic_quotes_runtime','set_include_path','set_file_buffer', + 'set_error_handler','session_write_close','session_unset','session_unregister','session_start','session_set_save_handler', + 'session_set_cookie_params','session_save_path','session_register','session_regenerate_id','session_name','session_module_name', + 'session_is_registered','session_id','session_get_cookie_params','session_encode','session_destroy','session_decode', + 'session_cache_limiter','session_cache_expire','serialize','sem_remove','sem_release','sem_get', + 'sem_acquire','rtrim','rsort','round','rmdir','rewinddir', + 'rewind','restore_include_path','restore_error_handler','reset','rename','register_tick_function', + 'register_shutdown_function','realpath','readlink','readgzfile','readfile','readdir', + 'read_exif_data','rawurlencode','rawurldecode','range','rand','rad2deg', + 'quotemeta','quoted_printable_decode','putenv','proc_open','proc_close','printf', + 'print_r','prev','preg_split','preg_replace_callback','preg_replace','preg_quote', + 'preg_match_all','preg_match','preg_grep','pow','posix_uname','posix_ttyname', + 'posix_times','posix_strerror','posix_setuid','posix_setsid','posix_setpgid','posix_setgid', + 'posix_seteuid','posix_setegid','posix_mkfifo','posix_kill','posix_isatty','posix_getuid', + 'posix_getsid','posix_getrlimit','posix_getpwuid','posix_getpwnam','posix_getppid','posix_getpid', + 'posix_getpgrp','posix_getpgid','posix_getlogin','posix_getgroups','posix_getgrnam','posix_getgrgid', + 'posix_getgid','posix_geteuid','posix_getegid','posix_getcwd','posix_get_last_error','posix_errno', + 'posix_ctermid','pos','popen','pi','phpversion','phpinfo', + 'phpcredits','php_uname','php_sapi_name','php_logo_guid','php_ini_scanned_files','pg_update', + 'pg_untrace','pg_unescape_bytea','pg_tty','pg_trace','pg_setclientencoding','pg_set_client_encoding', + 'pg_send_query','pg_select','pg_result_status','pg_result_seek','pg_result_error','pg_result', + 'pg_query','pg_put_line','pg_port','pg_ping','pg_pconnect','pg_options', + 'pg_numrows','pg_numfields','pg_num_rows','pg_num_fields','pg_meta_data','pg_lowrite', + 'pg_lounlink','pg_loreadall','pg_loread','pg_loopen','pg_loimport','pg_loexport', + 'pg_locreate','pg_loclose','pg_lo_write','pg_lo_unlink','pg_lo_tell','pg_lo_seek', + 'pg_lo_read_all','pg_lo_read','pg_lo_open','pg_lo_import','pg_lo_export','pg_lo_create', + 'pg_lo_close','pg_last_oid','pg_last_notice','pg_last_error','pg_insert','pg_host', + 'pg_getlastoid','pg_get_result','pg_get_pid','pg_get_notify','pg_freeresult','pg_free_result', + 'pg_fieldtype','pg_fieldsize','pg_fieldprtlen','pg_fieldnum','pg_fieldname','pg_fieldisnull', + 'pg_field_type','pg_field_size','pg_field_prtlen','pg_field_num','pg_field_name','pg_field_is_null', + 'pg_fetch_row','pg_fetch_result','pg_fetch_object','pg_fetch_assoc','pg_fetch_array','pg_fetch_all', + 'pg_exec','pg_escape_string','pg_escape_bytea','pg_errormessage','pg_end_copy','pg_delete', + 'pg_dbname','pg_copy_to','pg_copy_from','pg_convert','pg_connection_status','pg_connection_reset', + 'pg_connection_busy','pg_connect','pg_cmdtuples','pg_close','pg_clientencoding','pg_client_encoding', + 'pg_cancel_query','pg_affected_rows','pfsockopen','pclose','pathinfo','passthru', + 'parse_url','parse_str','parse_ini_file','pack','overload','output_reset_rewrite_vars', + 'output_add_rewrite_var','ord','openssl_x509_read','openssl_x509_parse','openssl_x509_free','openssl_x509_export_to_file', + 'openssl_x509_export','openssl_x509_checkpurpose','openssl_x509_check_private_key','openssl_verify','openssl_sign','openssl_seal', + 'openssl_public_encrypt','openssl_public_decrypt','openssl_private_encrypt','openssl_private_decrypt','openssl_pkey_new','openssl_pkey_get_public', + 'openssl_pkey_get_private','openssl_pkey_free','openssl_pkey_export_to_file','openssl_pkey_export','openssl_pkcs7_verify','openssl_pkcs7_sign', + 'openssl_pkcs7_encrypt','openssl_pkcs7_decrypt','openssl_open','openssl_get_publickey','openssl_get_privatekey','openssl_free_key', + 'openssl_error_string','openssl_csr_sign','openssl_csr_new','openssl_csr_export_to_file','openssl_csr_export','openlog', + 'opendir','octdec','ob_start','ob_list_handlers','ob_implicit_flush','ob_iconv_handler', + 'ob_gzhandler','ob_get_status','ob_get_level','ob_get_length','ob_get_flush','ob_get_contents', + 'ob_get_clean','ob_flush','ob_end_flush','ob_end_clean','ob_clean','number_format', + 'nl_langinfo','nl2br','ngettext','next','natsort','natcasesort', + 'mysql_unbuffered_query','mysql_thread_id','mysql_tablename','mysql_table_name','mysql_stat','mysql_selectdb', + 'mysql_select_db','mysql_result','mysql_real_escape_string','mysql_query','mysql_ping','mysql_pconnect', + 'mysql_numrows','mysql_numfields','mysql_num_rows','mysql_num_fields','mysql_listtables','mysql_listfields', + 'mysql_listdbs','mysql_list_tables','mysql_list_processes','mysql_list_fields','mysql_list_dbs','mysql_insert_id', + 'mysql_info','mysql_get_server_info','mysql_get_proto_info','mysql_get_host_info','mysql_get_client_info','mysql_freeresult', + 'mysql_free_result','mysql_fieldtype','mysql_fieldtable','mysql_fieldname','mysql_fieldlen','mysql_fieldflags', + 'mysql_field_type','mysql_field_table','mysql_field_seek','mysql_field_name','mysql_field_len','mysql_field_flags', + 'mysql_fetch_row','mysql_fetch_object','mysql_fetch_lengths','mysql_fetch_field','mysql_fetch_assoc','mysql_fetch_array', + 'mysql_escape_string','mysql_error','mysql_errno','mysql_dropdb','mysql_drop_db','mysql_dbname', + 'mysql_db_query','mysql_db_name','mysql_data_seek','mysql_createdb','mysql_create_db','mysql_connect', + 'mysql_close','mysql_client_encoding','mysql_affected_rows','mysql','mt_srand','mt_rand', + 'mt_getrandmax','move_uploaded_file','money_format','mktime','mkdir','min', + 'microtime','method_exists','metaphone','memory_get_usage','md5_file','md5', + 'mbsubstr','mbstrrpos','mbstrpos','mbstrlen','mbstrcut','mbsplit', + 'mbregex_encoding','mberegi_replace','mberegi','mbereg_search_setpos','mbereg_search_regs','mbereg_search_pos', + 'mbereg_search_init','mbereg_search_getregs','mbereg_search_getpos','mbereg_search','mbereg_replace','mbereg_match', + 'mbereg','mb_substr_count','mb_substr','mb_substitute_character','mb_strwidth','mb_strtoupper', + 'mb_strtolower','mb_strrpos','mb_strpos','mb_strlen','mb_strimwidth','mb_strcut', + 'mb_split','mb_send_mail','mb_regex_set_options','mb_regex_encoding','mb_preferred_mime_name','mb_parse_str', + 'mb_output_handler','mb_language','mb_internal_encoding','mb_http_output','mb_http_input','mb_get_info', + 'mb_eregi_replace','mb_eregi','mb_ereg_search_setpos','mb_ereg_search_regs','mb_ereg_search_pos','mb_ereg_search_init', + 'mb_ereg_search_getregs','mb_ereg_search_getpos','mb_ereg_search','mb_ereg_replace','mb_ereg_match','mb_ereg', + 'mb_encode_numericentity','mb_encode_mimeheader','mb_detect_order','mb_detect_encoding','mb_decode_numericentity','mb_decode_mimeheader', + 'mb_convert_variables','mb_convert_kana','mb_convert_encoding','mb_convert_case','max','mail', + 'magic_quotes_runtime','ltrim','lstat','long2ip','log1p','log10', + 'log','localtime','localeconv','linkinfo','link','levenshtein', + 'lcg_value','ksort','krsort','key_exists','key','juliantojd', + 'join','jewishtojd','jdtounix','jdtojulian','jdtojewish','jdtogregorian', + 'jdtofrench','jdmonthname','jddayofweek','is_writeable','is_writable','is_uploaded_file', + 'is_subclass_of','is_string','is_scalar','is_resource','is_real','is_readable', + 'is_object','is_numeric','is_null','is_nan','is_long','is_link', + 'is_integer','is_int','is_infinite','is_float','is_finite','is_file', + 'is_executable','is_double','is_dir','is_callable','is_bool','is_array', + 'is_a','iptcparse','iptcembed','ip2long','intval','ini_set', + 'ini_restore','ini_get_all','ini_get','ini_alter','in_array','import_request_variables', + 'implode','image_type_to_mime_type','ignore_user_abort','iconv_set_encoding','iconv_get_encoding','iconv', + 'i18n_mime_header_encode','i18n_mime_header_decode','i18n_ja_jp_hantozen','i18n_internal_encoding','i18n_http_output','i18n_http_input', + 'i18n_discover_encoding','i18n_convert','hypot','htmlspecialchars','htmlentities','html_entity_decode', + 'highlight_string','highlight_file','hexdec','hebrevc','hebrev','headers_sent', + 'header','gzwrite','gzuncompress','gztell','gzseek','gzrewind', + 'gzread','gzputs','gzpassthru','gzopen','gzinflate','gzgetss', + 'gzgets','gzgetc','gzfile','gzeof','gzencode','gzdeflate', + 'gzcompress','gzclose','gregoriantojd','gmstrftime','gmmktime','gmdate', + 'glob','gettype','gettimeofday','gettext','getservbyport','getservbyname', + 'getrusage','getrandmax','getprotobynumber','getprotobyname','getopt','getmyuid', + 'getmypid','getmyinode','getmygid','getmxrr','getlastmod','getimagesize', + 'gethostbynamel','gethostbyname','gethostbyaddr','getenv','getdate','getcwd', + 'getallheaders','get_resource_type','get_required_files','get_parent_class','get_object_vars','get_meta_tags', + 'get_magic_quotes_runtime','get_magic_quotes_gpc','get_loaded_extensions','get_included_files','get_include_path','get_html_translation_table', + 'get_extension_funcs','get_defined_vars','get_defined_functions','get_defined_constants','get_declared_classes','get_current_user', + 'get_class_vars','get_class_methods','get_class','get_cfg_var','get_browser','fwrite', + 'function_exists','func_num_args','func_get_args','func_get_arg','ftruncate','ftp_systype', + 'ftp_ssl_connect','ftp_size','ftp_site','ftp_set_option','ftp_rmdir','ftp_rename', + 'ftp_rawlist','ftp_quit','ftp_pwd','ftp_put','ftp_pasv','ftp_nlist', + 'ftp_nb_put','ftp_nb_get','ftp_nb_fput','ftp_nb_fget','ftp_nb_continue','ftp_mkdir', + 'ftp_mdtm','ftp_login','ftp_get_option','ftp_get','ftp_fput','ftp_fget', + 'ftp_exec','ftp_delete','ftp_connect','ftp_close','ftp_chdir','ftp_cdup', + 'ftok','ftell','fstat','fsockopen','fseek','fscanf', + 'frenchtojd','fread','fputs','fpassthru','fopen','fnmatch', + 'fmod','flush','floor','flock','floatval','filetype', + 'filesize','filepro_rowcount','filepro_retrieve','filepro_fieldwidth','filepro_fieldtype','filepro_fieldname', + 'filepro_fieldcount','filepro','fileperms','fileowner','filemtime','fileinode', + 'filegroup','filectime','fileatime','file_get_contents','file_exists','file', + 'fgetss','fgets','fgetcsv','fgetc','fflush','feof', + 'fclose','ezmlm_hash','extract','extension_loaded','expm1','explode', + 'exp','exif_thumbnail','exif_tagname','exif_read_data','exif_imagetype','exec', + 'escapeshellcmd','escapeshellarg','error_reporting','error_log','eregi_replace','eregi', + 'ereg_replace','ereg','end','easter_days','easter_date','each', + 'doubleval','dngettext','dl','diskfreespace','disk_total_space','disk_free_space', + 'dirname','dir','dgettext','deg2rad','defined','define_syslog_variables', + 'define','decoct','dechex','decbin','debug_zval_dump','debug_backtrace', + 'deaggregate','dcngettext','dcgettext','dba_sync','dba_replace','dba_popen', + 'dba_optimize','dba_open','dba_nextkey','dba_list','dba_insert','dba_handlers', + 'dba_firstkey','dba_fetch','dba_exists','dba_delete','dba_close','date', + 'current','ctype_xdigit','ctype_upper','ctype_space','ctype_punct','ctype_print', + 'ctype_lower','ctype_graph','ctype_digit','ctype_cntrl','ctype_alpha','ctype_alnum', + 'crypt','create_function','crc32','count_chars','count','cosh', + 'cos','copy','convert_cyr_string','constant','connection_status','connection_aborted', + 'compact','closelog','closedir','clearstatcache','class_exists','chunk_split', + 'chr','chown','chop','chmod','chgrp','checkdnsrr', + 'checkdate','chdir','ceil','call_user_method_array','call_user_method','call_user_func_array', + 'call_user_func','cal_to_jd','cal_info','cal_from_jd','cal_days_in_month','bzwrite', + 'bzread','bzopen','bzflush','bzerrstr','bzerror','bzerrno', + 'bzdecompress','bzcompress','bzclose','bindtextdomain','bindec','bind_textdomain_codeset', + 'bin2hex','bcsub','bcsqrt','bcscale','bcpow','bcmul', + 'bcmod','bcdiv','bccomp','bcadd','basename','base_convert', + 'base64_encode','base64_decode','atanh','atan2','atan','assert_options', + 'assert','asort','asinh','asin','arsort','array_walk', + 'array_values','array_unshift','array_unique','array_sum','array_splice','array_slice', + 'array_shift','array_search','array_reverse','array_reduce','array_rand','array_push', + 'array_pop','array_pad','array_multisort','array_merge_recursive','array_merge','array_map', + 'array_keys','array_key_exists','array_intersect_assoc','array_intersect','array_flip','array_filter', + 'array_fill','array_diff_assoc','array_diff','array_count_values','array_chunk','array_change_key_case', + 'apache_setenv','apache_response_headers','apache_request_headers','apache_note','apache_lookup_uri','apache_get_version', + 'apache_child_terminate','aggregation_info','aggregate_properties_by_regexp','aggregate_properties_by_list','aggregate_properties','aggregate_methods_by_regexp', + 'aggregate_methods_by_list','aggregate_methods','aggregate','addslashes','addcslashes','acosh', + 'acos','abs','_','echo', 'print', 'global', 'static', 'exit', 'array', 'empty', 'eval', 'isset', 'unset', 'die' + ) + ), + 'SYMBOLS' => array( + '(', ')', '[', ']', '{', '}', '!', '@', '%', '&', '*', '|', '/', '<', '>' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false, + 2 => false, + 3 => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;', + 2 => 'color: #000000; font-weight: bold;', + 3 => 'color: #000066;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 2 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #006600;', + 2 => 'color: #006600;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + 0 => 'color: #0000ff;' + ), + 'SCRIPT' => array( + 0 => '', + 1 => '', + 2 => '', + 3 => '' + ) + ), + 'URLS' => array( + 1 => '', + 2 => '', + 3 => 'http://www.php.net/{FNAME}', + 4 => '' + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '->', + 2 => '::' + ), + 'REGEXPS' => array( + 0 => "[\\$]{1,2}[a-zA-Z_][a-zA-Z0-9_]*", + ), + 'STRICT_MODE_APPLIES' => GESHI_MAYBE, + 'SCRIPT_DELIMITERS' => array( + 0 => array( + '<?php' => '?>' + ), + 1 => array( + '<?' => '?>' + ), + 2 => array( + '<%' => '%>' + ), + 3 => array( + '<script language="php">' => '</script>' + ) + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + 0 => true, + 1 => true, + 2 => true, + 3 => true + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/python.php b/inc/geshi/python.php new file mode 100644 index 000000000..86a8f22f1 --- /dev/null +++ b/inc/geshi/python.php @@ -0,0 +1,143 @@ +<?php +/************************************************************************************* + * python.php + * ---------- + * Author: Roberto Rossi (rsoftware@altervista.org) + * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/30 + * Last Modified: $Date: 2004/11/29 08:46:25 $ + * + * Python language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/08/30 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'Python', + 'COMMENT_SINGLE' => array(1 => '#'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '', + 'KEYWORDS' => array( + 1 => array( + 'and','assert','break','class','continue','def','del','elif','else','except','exec','finally','for','from', + 'global','if','import','in','is','lambda','map','not','None','or','pass','print','raise','range','return', + 'try','while','abs','apply','callable','chr','cmp','coerce','compile','complex','delattr','dir','divmod', + 'eval','execfile','filter','float','getattr','globals','group','hasattr','hash','hex','', + 'id','input','int','intern','isinstance','issubclass','joinfields','len','list','local','long', + 'max','min','match','oct','open','ord','pow','raw_input','reduce','reload','repr','round', + 'search','setattr','setdefault','slice','str','splitfields','unichr','unicode','tuple','type', + 'vars','xrange','zip','__abs__','__add__','__and__','__call__','__cmp__','__coerce__', + '__del__','__delattr__','__delitem__','__delslice__','__div__','__divmod__', + '__float__','__getattr__','__getitem__','__getslice__','__hash__','__hex__', + '__iadd__','__isub__','__imod__','__idiv__','__ipow__','__iand__','__ior__','__ixor__', + '__ilshift__','__irshift__','__invert__','__int__','__init__','__len__','__long__','__lshift__', + '__mod__','__mul__','__neg__','__nonzero__','__oct__','__or__','__pos__','__pow__', + '__radd__','__rdiv__','__rdivmod__','__rmod__','__rpow__','__rlshift__','__rrshift__', + '__rshift__','__rsub__','__rmul__','__repr__','__rand__','__rxor__','__ror__', + '__setattr__','__setitem__','__setslice__','__str__','__sub__','__xor__', + '__bases__','__class__','__dict__','__methods__','__members__','__name__', + '__version__','ArithmeticError','AssertionError','AttributeError','EOFError','Exception', + 'FloatingPointError','IOError','ImportError','IndentationError','IndexError', + 'KeyError','KeyboardInterrupt','LookupError','MemoryError','NameError','OverflowError', + 'RuntimeError','StandardError','SyntaxError','SystemError','SystemExit','TabError','TypeError', + 'ValueError','ZeroDivisionError','AST','','atexit','BaseHTTPServer','Bastion', + 'cmd','codecs','commands','compileall','copy','CGIHTTPServer','Complex','dbhash', + 'dircmp','dis','dospath','dumbdbm','emacs','find','fmt','fnmatch','ftplib', + 'getopt','glob','gopherlib','grep','htmllib','httplib','ihooks','imghdr','imputil', + 'linecache','lockfile','macpath','macurl2path','mailbox','mailcap', + 'mimetools','mimify','mutex','math','Mimewriter','newdir','ni','nntplib','ntpath','nturl2path', + 'os','ospath','pdb','pickle','pipes','poly','popen2','posixfile','posixpath','profile','pstats','pyclbr', + 'pyexpat','Para','quopri','Queue','rand','random','regex','regsub','rfc822', + 'sched','sgmllib','shelve','site','sndhdr','string','sys','snmp', + 'SimpleHTTPServer','StringIO','SocketServer', + 'tb','tempfile','toaiff','token','tokenize','traceback','tty','types','tzparse', + 'Tkinter','unicodedata','urllib','urlparse','util','uu','UserDict','UserList', + 'wave','webbrowser','whatsound','whichdb','whrandom','xdrlib','xml','xmlpackage', + 'zmod','array','struct','self', + ) + ), + 'SYMBOLS' => array( + '(', ')', '[', ']', '{', '}', '*', '&', '%', '!', ';', '<', '>', '?' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => true, + 1 => true + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 1 => 'color: #202020;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'REGEXPS' => array( + ), + 'SCRIPT' => array( + ) + ), + 'URLS' => array( + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/qbasic.php b/inc/geshi/qbasic.php new file mode 100644 index 000000000..c1aa44abd --- /dev/null +++ b/inc/geshi/qbasic.php @@ -0,0 +1,146 @@ +<?php +/************************************************************************************* + * qbasic.php + * ---------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.3 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/20 + * Last Modified: $Date: 2004/11/29 08:46:25 $ + * + * QBasic/QuickBASIC language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.3) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.2) + * - Added support for URLs + * 2004/08/05 (1.0.1) + * - Added support for symbols + * - Removed unnessecary slashes from some keywords + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * Make sure all possible combinations of keywords with + * a space in them (EXIT FOR, END SELECT) are added + * to the first keyword group + * * Update colours, especially for the first keyword group + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ +$language_data = array ( + 'LANG_NAME' => 'QBasic/QuickBASIC', + 'COMMENT_SINGLE' => array(1 => "'", 2 => 'REM'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_UPPER, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '', + 'KEYWORDS' => array( + 1 => array( + 'DO', 'LOOP', 'WHILE', 'WEND', 'THEN', 'ELSE', 'ELSEIF', 'IF', + 'FOR', 'TO', 'NEXT', 'STEP', 'GOTO', 'GOSUB', 'RETURN', 'RESUME', 'SELECT', + 'CASE', 'UNTIL' + ), + 3 => array( + 'ABS', 'ABSOLUTE', 'ACCESS', 'ALIAS', 'AND', 'ANY', 'APPEND', 'AS', 'ASC', 'ATN', + 'BASE', 'BEEP', 'BINARY', 'BLOAD', 'BSAVE', 'BYVAL', 'CALL', 'CALLS', 'CASE', + 'CDBL', 'CDECL', 'CHAIN', 'CHDIR', 'CHDIR', 'CHR$', 'CINT', 'CIRCLE', 'CLEAR', + 'CLNG', 'CLOSE', 'CLS', 'COM', 'COMMAND$', 'COMMON', 'CONST', 'COS', 'CSNG', + 'CSRLIN', 'CVD', 'CVDMBF', 'CVI', 'CVL', 'CVS', 'CVSMDF', 'DATA', 'DATE$', + 'DECLARE', 'DEF', 'FN', 'SEG', 'DEFDBL', 'DEFINT', 'DEFLNG', 'DEFSNG', 'DEFSTR', + 'DIM', 'DOUBLE', 'DRAW', 'END', 'ENVIRON', 'ENVIRON$', 'EOF', 'EQV', 'ERASE', + 'ERDEV', 'ERDEV$', 'ERL', 'ERR', 'ERROR', 'EXIT', 'EXP', 'FIELD', 'FILEATTR', + 'FILES', 'FIX', 'FRE', 'FREEFILE', 'FUNCTION', 'GET', 'HEX$', 'IMP', 'INKEY$', + 'INP', 'INPUT', 'INPUT$', 'INSTR', 'INT', 'INTEGER', 'IOCTL', 'IOCTL$', 'IS', + 'KEY', 'KILL', 'LBOUND', 'LCASE$', 'LEFT$', 'LEN', 'LET', 'LINE', 'LIST', 'LOC', + 'LOCAL', 'LOCATE', 'LOCK', 'LOF', 'LOG', 'UNLOCK', 'LONG', 'LPOS', 'LPRINT', + 'LSET', 'LTRIM$', 'MID$', 'MKD$', 'MKDIR', 'MKDMBF$', 'MKI$', 'MKL$', + 'MKS$', 'MKSMBF$', 'MOD', 'NAME', 'NOT', 'OCT$', 'OFF', 'ON', 'PEN', 'PLAY', + 'STRIG', 'TIMER', 'UEVENT', 'OPEN', 'OPTION', 'BASE', 'OR', 'OUT', 'OUTPUT', + 'PAINT', 'PALETTE', 'PCOPY', 'PEEK', 'PMAP', 'POINT', 'POKE', 'POS', 'PRESET', + 'PRINT', 'USING', 'PSET', 'PUT', 'RANDOM', 'RANDOMIZE', 'READ', 'REDIM', 'RESET', + 'RESTORE', 'RIGHT$', 'RMDIR', 'RND', 'RSET', 'RTRIM$', 'RUN', 'SADD', 'SCREEN', + 'SEEK', 'SETMEM', 'SGN', 'SHARED', 'SHELL', 'SIGNAL', 'SIN', 'SINGLE', 'SLEEP', + 'SOUND', 'SPACE$', 'SPC', 'SQR', 'STATIC', 'STICK', 'STOP', 'STR$', 'STRIG', + 'STRING', 'STRING$', 'SUB', 'SWAP', 'SYSTEM', 'TAB', 'TAN', 'TIME$', 'TIMER', + 'TROFF', 'TRON', 'TYPE', 'UBOUND', 'UCASE$', 'UEVENT', 'UNLOCK', 'USING', 'VAL', + 'VARPTR', 'VARPTR$', 'VARSEG', 'VIEW', 'WAIT', 'WIDTH', 'WINDOW', 'WRITE', 'XOR' + ) + ), + 'SYMBOLS' => array( + '(', ')' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false, + 3 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #a1a100;', + 3 => 'color: #000066;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080;', + 2 => 'color: #808080;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099;' + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + ) + ), + 'URLS' => array( + 1 => '', + 3 => 'http://www.qbasicnews.com/qboho/qck{FNAME}.shtml' + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/smarty.php b/inc/geshi/smarty.php new file mode 100644 index 000000000..7a6b4e5f5 --- /dev/null +++ b/inc/geshi/smarty.php @@ -0,0 +1,167 @@ +<?php
+/*************************************************************************************
+ * smarty.php
+ * ----------
+ * Author: Alan Juden (alan@judenware.org)
+ * Copyright: (c) 2004 Alan Juden, Nigel McNie (http://qbnz.com/highlighter/)
+ * Release Version: 1.0.0
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2004/07/10
+ * Last Modified: $Date: 2004/11/29 08:46:25 $
+ *
+ * Smarty template language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/11/27 (1.0.0)
+ * - Initial Release
+ *
+ * TODO
+ * ----
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+$language_data = array (
+ 'LANG_NAME' => 'Smarty',
+ 'COMMENT_SINGLE' => array(),
+ 'COMMENT_MULTI' => array('{*' => '*}'),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array("'", '"'),
+ 'ESCAPE_CHAR' => '\\',
+ 'KEYWORDS' => array(
+ 1 => array(
+ '$smarty', 'now', 'const', 'capture', 'config', 'section', 'foreach', 'template', 'version', 'ldelim', 'rdelim',
+ 'config_load', 'foreach', 'foreachelse', 'include', 'include_php', 'insert', 'if', 'elseif', 'else', 'php',
+ 'sectionelse', 'clear_all_cache', 'clear_cache', 'is_cached', 'from', 'item'
+ ),
+ 2 => array(
+ 'capitalize', 'count_characters', 'cat', 'count_paragraphs', 'count_sentences', 'count_words', 'date_format',
+ 'default', 'escape', 'indent', 'lower', 'nl2br', 'regex_replace', 'replace', 'spacify', 'string_format',
+ 'strip', 'strip_tags', 'truncate', 'upper', 'wordwrap'
+ ),
+ 3 => array(
+ 'assign', 'counter', 'cycle', 'debug', 'eval', 'fetch', 'html_checkboxes', 'html_image', 'html_options',
+ 'html_radios', 'html_select_date', 'html_select_time', 'html_table', 'math', 'mailto', 'popup_init',
+ 'popup', 'textformat'
+ ),
+ 4 => array(
+ '$template_dir', '$compile_dir', '$config_dir', '$plugins_dir', '$debugging', '$debug_tpl',
+ '$debugging_ctrl', '$autoload_filters', '$compile_check', '$force_compile', '$caching', '$cache_dir',
+ '$cache_lifetime', '$cache_handler_func', '$cache_modified_check', '$config_overwrite',
+ '$config_booleanize', '$config_read_hidden', '$config_fix_newlines', '$default_template_handler_func',
+ '$php_handling', '$security', '$secure_dir', '$security_settings', '$trusted_dir', '$left_delimiter',
+ '$right_delimiter', '$compiler_class', '$request_vars_order', '$request_use_auto_globals',
+ '$error_reporting', '$compile_id', '$use_sub_dirs', '$default_modifiers', '$default_resource_type'
+ ),
+ 5 => array(
+ 'append', 'append_by_ref', 'assign', 'assign_by_ref', 'clear_all_assign', 'clear_all_cache',
+ 'clear_assign', 'clear_cache', 'clear_compiled_tpl', 'clear_config', 'config_load', 'display',
+ 'fetch', 'get_config_vars', 'get_registered_object', 'get_template_vars', 'is_cached',
+ 'load_filter', 'register_block', 'register_compiler_function', 'register_function',
+ 'register_modifier', 'register_object', 'register_outputfilter', 'register_postfilter',
+ 'register_prefilter', 'register_resource', 'trigger_error', 'template_exists', 'unregister_block',
+ 'unregister_compiler_function', 'unregister_function', 'unregister_modifier', 'unregister_object',
+ 'unregister_outputfilter', 'unregister_postfilter', 'unregister_prefilter', 'unregister_resource'
+ ),
+ 6 => array(
+ 'name', 'assign', 'file', 'scope', 'global', 'key', 'once', 'script',
+ 'loop', 'start', 'step', 'max', 'show', 'values', 'value'
+ ),
+ 7 => array(
+ 'eq', 'neq', 'ne', 'lte', 'gte', 'ge', 'le', 'not', 'mod'
+ ),
+ ),
+ 'SYMBOLS' => array(
+ '/', '=', '==', '!=', '>', '<', '>=', '<=', '!', '%'
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => false,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ 4 => false,
+ 5 => false,
+ 6 => false,
+ 7 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #0600FF;', //Functions
+ 2 => 'color: #008000;', //Modifiers
+ 3 => 'color: #0600FF;', //Custom Functions
+ 4 => 'color: #804040;', //Variables
+ 5 => 'color: #008000;', //Methods
+ 6 => 'color: #6A0A0A;', //Attributes
+ 7 => 'color: #D36900;' //Text-based symbols
+ ),
+ 'COMMENTS' => array(
+ 'MULTI' => 'color: #008080; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #000099; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #D36900;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #ff0000;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #cc66cc;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #006600;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #D36900;'
+ ),
+ 'SCRIPT' => array(
+ ),
+ 'REGEXPS' => array(
+ )
+ ),
+ 'URLS' => array(
+ 1 => 'http://smarty.php.net/{FNAME}',
+ 2 => 'http://smarty.php.net/{FNAME}',
+ 3 => 'http://smarty.php.net/{FNAME}',
+ 4 => 'http://smarty.php.net/{FNAME}',
+ 5 => 'http://smarty.php.net/{FNAME}',
+ 6 => '',
+ 7 => 'http://smarty.php.net/{FNAME}'
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_ALWAYS,
+ 'SCRIPT_DELIMITERS' => array(
+ 0 => array(
+ '{' => '}'
+ )
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ 0 => true
+ )
+);
+
+?>
\ No newline at end of file diff --git a/inc/geshi/sql.php b/inc/geshi/sql.php new file mode 100644 index 000000000..e0bac2671 --- /dev/null +++ b/inc/geshi/sql.php @@ -0,0 +1,136 @@ +<?php +/************************************************************************************* + * sql.php + * ------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.3 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/06/04 + * Last Modified: $Date: 2004/11/29 08:46:25 $ + * + * SQL language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.3) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.2) + * - Added "`" string delimiter + * - Added "#" single comment starter + * 2004/08/05 (1.0.1) + * - Added support for symbols + * - Added many more keywords (mostly MYSQL keywords) + * 2004/07/14 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * Add all keywords + * * Split this to several sql files - mysql-sql, ansi-sql etc + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'SQL', + 'COMMENT_SINGLE' => array(1 =>'--', 2 => '#'), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => 1, + 'QUOTEMARKS' => array("'", '"', '`'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + 1 => array( + 'ALL', 'ASC', 'AS', 'ALTER', 'AND', 'ADD', 'AUTO_INCREMENT', + 'BETWEEN', 'BINARY', 'BOTH', 'BY', 'BOOLEAN', + 'CHANGE', 'CHECK', 'COLUMNS', 'COLUMN', 'CROSS','CREATE', + 'DATABASES', 'DATABASE', 'DATA', 'DELAYED', 'DESCRIBE', 'DESC', 'DISTINCT', 'DELETE', 'DROP', 'DEFAULT', + 'ENCLOSED', 'ESCAPED', 'EXISTS', 'EXPLAIN', + 'FIELDS', 'FIELD', 'FLUSH', 'FOR', 'FOREIGN', 'FUNCTION', 'FROM', + 'GROUP', 'GRANT', + 'HAVING', + 'IGNORE', 'INDEX', 'INFILE', 'INSERT', 'INNER', 'INTO', 'IDENTIFIED', 'IN', 'IS', 'IF', + 'JOIN', + 'KEYS', 'KILL','KEY', + 'LEADING', 'LIKE', 'LIMIT', 'LINES', 'LOAD', 'LOCAL', 'LOCK', 'LOW_PRIORITY', 'LEFT', 'LANGUAGE', + 'MODIFY', + 'NATURAL', 'NOT', 'NULL', 'NEXTVAL', + 'OPTIMIZE', 'OPTION', 'OPTIONALLY', 'ORDER', 'OUTFILE', 'OR', 'OUTER', 'ON', + 'PROCEEDURE','PROCEDURAL', 'PRIMARY', + 'READ', 'REFERENCES', 'REGEXP', 'RENAME', 'REPLACE', 'RETURN', 'REVOKE', 'RLIKE', 'RIGHT', + 'SHOW', 'SONAME', 'STATUS', 'STRAIGHT_JOIN', 'SELECT', 'SETVAL', 'SET', + 'TABLES', 'TEMINATED', 'TO', 'TRAILING','TRUNCATE', 'TABLE', 'TEMPORARY', 'TRIGGER', 'TRUSTED', + 'UNIQUE', 'UNLOCK', 'USE', 'USING', 'UPDATE', 'UNSIGNED', + 'VALUES', 'VARIABLES', 'VIEW', + 'WITH', 'WRITE', 'WHERE', + 'ZEROFILL', + 'XOR', + ) + ), + 'SYMBOLS' => array( + '(', ')', '=', '<', '>', '|' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #993333; font-weight: bold;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080; font-style: italic;', + 2 => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + ) + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/vb.php b/inc/geshi/vb.php new file mode 100644 index 000000000..c46883bdf --- /dev/null +++ b/inc/geshi/vb.php @@ -0,0 +1,150 @@ +<?php +/************************************************************************************* + * vb.php + * ------ + * Author: Roberto Rossi (rsoftware@altervista.org) + * Copyright: (c) 2004 Roberto Rossi (http://rsoftware.altervista.org), Nigel McNie (http://qbnz.com/highlighter) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/08/30 + * Last Modified: $Date: 2004/11/29 08:46:25 $ + * + * Visual Basic language file for GeSHi. + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/08/30 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + $language_data = array ( + 'LANG_NAME' => 'Visual Basic', + 'COMMENT_SINGLE' => array(1 => "'"), + 'COMMENT_MULTI' => array(), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array('"'), + 'ESCAPE_CHAR' => '', + 'KEYWORDS' => array( + 1 => array( + 'as', 'err', 'boolean', 'and', 'or', 'recordset', 'unload', 'to', + 'integer','long','single','new','database','nothing','set','close', + 'open','print','split','line','field','querydef','instrrev', + 'abs','array','asc','ascb','ascw','atn','avg','me', + 'cbool','cbyte','ccur','cdate','cdbl','cdec','choose','chr','chrb','chrw','cint','clng', + 'command','cos','count','createobject','csng','cstr','curdir','cvar','cvdate','cverr', + 'date','dateadd','datediff','datepart','dateserial','datevalue','day','ddb','dir','doevents', + 'environ','eof','error','exp', + 'fileattr','filedatetime','filelen','fix','format','freefile','fv', + 'getallstrings','getattr','getautoserversettings','getobject','getsetting', + 'hex','hour','iif','imestatus','input','inputb','inputbox','instr','instb','int','ipmt', + 'isarray','isdate','isempty','iserror','ismissing','isnull','isnumeric','isobject', + 'lbound','lcase','left','leftb','len','lenb','loadpicture','loc','lof','log','ltrim', + 'max','mid','midb','min','minute','mirr','month','msgbox', + 'now','nper','npv','oct','partition','pmt','ppmt','pv','qbcolor', + 'rate','rgb','right','rightb','rnd','rtrim', + 'second','seek','sgn','shell','sin','sln','space','spc','sqr','stdev','stdevp','str', + 'strcomp','strconv','string','switch','sum','syd', + 'tab','tan','time','timer','timeserial','timevalue','trim','typename', + 'ubound','ucase','val','var','varp','vartype','weekday','year', + 'appactivate','base','beep','call','case','chdir','chdrive','const', + 'declare','defbool','defbyte','defcur','defdate','defdbl','defdec','defint', + 'deflng','defobj','defsng','defstr','deftype','defvar','deletesetting','dim','do', + 'else','elseif','end','enum','erase','event','exit','explicit', + 'false','filecopy','for','foreach','friend','function','get','gosub','goto', + 'if','implements','kill','let','lineinput','lock','loop','lset','mkdir','name','next','not', + 'onerror','on','option','private','property','public','put','raiseevent','randomize', + 'redim','rem','reset','resume','return','rmdir','rset', + 'savepicture','savesetting','sendkeys','setattr','static','sub', + 'then','true','type','unlock','wend','while','width','with','write', + 'vbabort','vbabortretryignore','vbapplicationmodal','vbarray', + 'vbbinarycompare','vbblack','vbblue','vbboolean','vbbyte','vbcancel', + 'vbcr','vbcritical','vbcrlf','vbcurrency','vbcyan','vbdataobject', + 'vbdate','vbdecimal','vbdefaultbutton1','vbdefaultbutton2', + 'vbdefaultbutton3','vbdefaultbutton4','vbdouble','vbempty', + 'vberror','vbexclamation','vbfirstfourdays','vbfirstfullweek', + 'vbfirstjan1','vbformfeed','vbfriday','vbgeneraldate','vbgreen', + 'vbignore','vbinformation','vbinteger','vblf','vblong','vblongdate', + 'vblongtime','vbmagenta','vbmonday','vbnewline','vbno','vbnull', + 'vbnullchar','vbnullstring','vbobject','vbobjecterror','vbok','vbokcancel', + 'vbokonly','vbquestion','vbred','vbretry','vbretrycancel','vbsaturday', + 'vbshortdate','vbshorttime','vbsingle','vbstring','vbsunday', + 'vbsystemmodal','vbtab','vbtextcompare','vbthursday','vbtuesday', + 'vbusesystem','vbusesystemdayofweek','vbvariant','vbverticaltab', + 'vbwednesday','vbwhite','vbyellow','vbyes','vbyesno','vbyesnocancel', + 'vbnormal','vbdirectory' + ) + ), + 'SYMBOLS' => array( + '(', ')' + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + 1 => false + ), + 'STYLES' => array( + 'KEYWORDS' => array( + 1 => 'color: #b1b100;' + ), + 'COMMENTS' => array( + 1 => 'color: #808080;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + 0 => 'color: #66cc66;' + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099;' + ), + 'SCRIPT' => array( + ), + 'REGEXPS' => array( + ) + ), + 'OOLANG' => true, + 'OBJECT_SPLITTERS' => array( + 1 => '.' + ), + 'REGEXPS' => array( + ), + 'STRICT_MODE_APPLIES' => GESHI_NEVER, + 'SCRIPT_DELIMITERS' => array( + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + ) +); + +?>
\ No newline at end of file diff --git a/inc/geshi/vbnet.php b/inc/geshi/vbnet.php new file mode 100644 index 000000000..37f11133e --- /dev/null +++ b/inc/geshi/vbnet.php @@ -0,0 +1,200 @@ +<?php
+/*************************************************************************************
+ * vbnet.php
+ * ---------
+ * Author: Alan Juden (alan@judenware.org)
+ * Copyright: (c) 2004 Alan Juden, Nigel McNie (http://qbnz.com/highlighter)
+ * Release Version: 1.0.0
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2004/06/04
+ * Last Modified: $Date: 2004/11/29 08:46:25 $
+ *
+ * VB.NET language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/11/27 (1.0.0)
+ * - Initial release
+ *
+ * TODO (updated 2004/11/27)
+ * -------------------------
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+ $language_data = array (
+ 'LANG_NAME' => 'vb.net',
+ 'COMMENT_SINGLE' => array(1 => "'"),
+ 'COMMENT_MULTI' => array(),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array('"'),
+ 'ESCAPE_CHAR' => '',
+ 'KEYWORDS' => array(
+ 1 => array(
+ '3DDKSHADOW', '3DHIGHLIGHT', '3DLIGHT', 'ABORT', 'ABORTRETRYIGNORE', 'ACTIVEBORDER',
+ 'ACTIVETITLEBAR', 'ALIAS', 'APPLICATIONMODAL', 'APPLICATIONWORKSPACE', 'ARCHIVE',
+ 'BACK', 'BINARYCOMPARE', 'BLACK', 'BLUE', 'BUTTONFACE', 'BUTTONSHADOW', 'BUTTONTEXT',
+ 'CANCEL', 'CDROM', 'CR', 'CRITICAL', 'CRLF', 'CYAN', 'DEFAULT', 'DEFAULTBUTTON1',
+ 'DEFAULTBUTTON2', 'DEFAULTBUTTON3', 'DESKTOP', 'DIRECTORY', 'EXCLAMATION', 'FALSE',
+ 'FIXED', 'FORAPPENDING', 'FORMFEED', 'FORREADING', 'FORWRITING', 'FROMUNICODE',
+ 'GRAYTEXT', 'GREEN', 'HIDDEN', 'HIDE', 'HIGHLIGHT', 'HIGHLIGHTTEXT', 'HIRAGANA',
+ 'IGNORE', 'INACTIVEBORDER', 'INACTIVECAPTIONTEXT', 'INACTIVETITLEBAR', 'INFOBACKGROUND',
+ 'INFORMATION', 'INFOTEXT', 'KATAKANALF', 'LOWERCASE', 'MAGENTA', 'MAXIMIZEDFOCUS',
+ 'MENUBAR', 'MENUTEXT', 'METHOD', 'MINIMIZEDFOCUS', 'MINIMIZEDNOFOCUS', 'MSGBOXRIGHT',
+ 'MSGBOXRTLREADING', 'MSGBOXSETFOREGROUND', 'NARROW', 'NEWLINE', 'NO', 'NORMAL',
+ 'NORMALFOCUS', 'NORMALNOFOCUS', 'NULLSTRING', 'OBJECTERROR', 'OK', 'OKCANCEL', 'OKONLY',
+ 'PROPERCASE', 'QUESTION', 'RAMDISK', 'READONLY', 'RED', 'REMOTE', 'REMOVABLE', 'RETRY',
+ 'RETRYCANCEL', 'SCROLLBARS', 'SYSTEMFOLDER', 'SYSTEMMODAL', 'TAB', 'TEMPORARYFOLDER',
+ 'TEXTCOMPARE', 'TITLEBARTEXT', 'TRUE', 'UNICODE', 'UNKNOWN', 'UPPERCASE', 'VERTICALTAB',
+ 'VOLUME', 'WHITE', 'WIDE', 'WIN16', 'WIN32', 'WINDOWBACKGROUND', 'WINDOWFRAME',
+ 'WINDOWSFOLDER', 'WINDOWTEXT', 'YELLOW', 'YES', 'YESNO', 'YESNOCANCEL'
+ ),
+ 2 => array(
+ 'As', 'ADDHANDLER', 'ASSEMBLY', 'AUTO', 'Binary', 'ByRef', 'ByVal', 'BEGINEPILOGUE',
+ 'Else', 'Empty', 'Error', 'ENDPROLOGUE', 'EXTERNALSOURCE', 'ENVIRON', 'For',
+ 'Friend', 'GET', 'HANDLES', 'Input', 'Is', 'Len', 'Lock', 'Me', 'Mid', 'MUSTINHERIT',
+ 'MYBASE', 'MYCLASS', 'New', 'Next', 'Nothing', 'Null', 'NOTINHERITABLE',
+ 'NOTOVERRIDABLE', 'OFF', 'On', 'Option', 'Optional', 'OVERRIDABLE', 'ParamArray',
+ 'Print', 'Private', 'Property', 'Public', 'Resume', 'Seek', 'Static', 'Step',
+ 'String', 'SHELL', 'SENDKEYS', 'SET', 'Then', 'Time', 'To', 'THROW', 'WithEvents'
+ ),
+ 3 => array(
+ 'COLLECTION', 'DEBUG', 'DICTIONARY', 'DRIVE', 'DRIVES', 'ERR', 'FILE', 'FILES',
+ 'FILESYSTEMOBJECT', 'FOLDER', 'FOLDERS', 'TEXTSTREAM'
+ ),
+ 4 => array(
+ 'BOOLEAN', 'BYTE', 'DATE', 'DECIMIAL', 'DOUBLE', 'INTEGER', 'LONG', 'OBJECT',
+ 'SINGLE STRING'
+ ),
+ 5 => array(
+ 'ADDRESSOF', 'AND', 'BITAND', 'BITNOT', 'BITOR', 'BITXOR',
+ 'GETTYPE', 'LIKE', 'MOD', 'NOT', 'ORXOR'
+ ),
+ 6 => array(
+ 'APPACTIVATE', 'BEEP', 'CALL', 'CHDIR', 'CHDRIVE', 'CLASS', 'CASE', 'CATCH',
+ 'DECLARE', 'DELEGATE', 'DELETESETTING', 'DIM', 'DO', 'DOEVENTS', 'END', 'ENUM',
+ 'EVENT', 'EXIT', 'EACH', 'FUNCTION', 'FINALLY', 'IF', 'IMPORTS', 'INHERITS',
+ 'INTERFACE', 'IMPLEMENTS', 'KILL', 'LOOP', 'MIDB', 'NAMESPACE', 'OPEN', 'PUT',
+ 'RAISEEVENT', 'RANDOMIZE', 'REDIM', 'REM', 'RESET', 'SAVESETTING', 'SELECT',
+ 'SETATTR', 'STOP', 'SUB', 'SYNCLOCK', 'STRUCTURE', 'SHADOWS', 'SWITCH',
+ 'TIMEOFDAY', 'TODAY', 'TRY', 'WIDTH', 'WITH', 'WRITE', 'WHILE'
+ ),
+ 7 => array(
+ 'ABS', 'ARRAY', 'ASC', 'ASCB', 'ASCW', 'CALLBYNAME', 'CBOOL', 'CBYTE', 'CCHAR',
+ 'CCHR', 'CDATE', 'CDBL', 'CDEC', 'CHOOSE', 'CHR', 'CHR$', 'CHRB', 'CHRB$', 'CHRW',
+ 'CINT', 'CLNG', 'CLNG8', 'CLOSE', 'COBJ', 'COMMAND', 'COMMAND$', 'CONVERSION',
+ 'COS', 'CREATEOBJECT', 'CSHORT', 'CSTR', 'CURDIR', 'CTYPE', 'CVDATE', 'DATEADD',
+ 'DATEDIFF', 'DATEPART', 'DATESERIAL', 'DATEVALUE', 'DAY', 'DDB', 'DIR', 'DIR$',
+ 'EOF', 'ERROR$', 'EXP', 'FILEATTR', 'FILECOPY', 'FILEDATATIME', 'FILELEN', 'FILTER',
+ 'FIX', 'FORMAT', 'FORMAT$', 'FORMATCURRENCY', 'FORMATDATETIME', 'FORMATNUMBER',
+ 'FORMATPERCENT', 'FREEFILE', 'FV', 'GETALLSETTINGS', 'GETATTRGETOBJECT', 'GETSETTING',
+ 'HEX', 'HEX$', 'HOUR', 'IIF', 'IMESTATUS', 'INPUT$', 'INPUTB', 'INPUTB$', 'INPUTBOX',
+ 'INSTR', 'INSTRB', 'INSTRREV', 'INT', 'IPMT', 'IRR', 'ISARRAY', 'ISDATE', 'ISEMPTY',
+ 'ISERROR', 'ISNULL', 'ISNUMERIC', 'ISOBJECT', 'JOIN', 'LBOUND', 'LCASE', 'LCASE$',
+ 'LEFT', 'LEFT$', 'LEFTB', 'LEFTB$', 'LENB', 'LINEINPUT', 'LOC', 'LOF', 'LOG', 'LTRIM',
+ 'LTRIM$', 'MID$', 'MIDB', 'MIDB$', 'MINUTE', 'MIRR', 'MKDIR', 'MONTH', 'MONTHNAME',
+ 'MSGBOX', 'NOW', 'NPER', 'NPV', 'OCT', 'OCT$', 'PARTITION', 'PMT', 'PPMT', 'PV',
+ 'RATE', 'REPLACE', 'RIGHT', 'RIGHT$', 'RIGHTB', 'RIGHTB$', 'RMDIR', 'RND', 'RTRIM',
+ 'RTRIM$', 'SECOND', 'SIN', 'SLN', 'SPACE', 'SPACE$', 'SPC', 'SPLIT', 'STR', 'STR$',
+ 'STRCOMP', 'STRCONV', 'STRING$', 'STRREVERSE', 'SYD', 'TAB', 'TAN', 'TIMEOFDAY',
+ 'TIMER', 'TIMESERIAL', 'TIMEVALUE', 'TODAY', 'TRIM', 'TRIM$', 'TYPENAME', 'UBOUND',
+ 'UCASE', 'UCASE$', 'VAL', 'WEEKDAY', 'WEEKDAYNAME', 'YEAR'
+ ),
+ 8 => array(
+ 'ANY', 'ATN', 'CALENDAR', 'CIRCLE', 'CURRENCY', 'DEFBOOL', 'DEFBYTE', 'DEFCUR',
+ 'DEFDATE', 'DEFDBL', 'DEFDEC', 'DEFINT', 'DEFLNG', 'DEFOBJ', 'DEFSNG', 'DEFSTR',
+ 'DEFVAR', 'EQV', 'GOSUB', 'IMP', 'INITIALIZE', 'ISMISSING', 'LET', 'LINE', 'LSET',
+ 'RSET', 'SGN', 'SQR', 'TERMINATE', 'VARIANT', 'VARTYPE', 'WEND'
+ ),
+ ),
+ 'SYMBOLS' => array(
+ '&', '&=', '*', '*=', '+', '+=', '-', '-=', '//', '/', '/=', '=', '\\', '\\=',
+ '^', '^='
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => true,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ 4 => false,
+ 5 => false,
+ 6 => false,
+ 7 => false,
+ 8 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #0600FF;', //Constants
+ 2 => 'color: #FF8000;', //Keywords
+ 3 => 'color: #008000;', //Data Types
+ 4 => 'color: #FF0000;', //Objects
+ 5 => 'color: #804040;', //Operators
+ 6 => 'color: #0600FF;', //Statements
+ 7 => 'color: #0600FF;', //Functions
+ 8 => 'color: #0600FF;' //Deprecated
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #008080; font-style: italic;',
+ 2 => 'color: #008080;',
+ 'MULTI' => 'color: #008080; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #008080; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #000000;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #808080;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #FF0000;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #0000FF;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #008000;'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'SCRIPT' => array(
+ )
+ ),
+ 'URLS' => array(
+ 1 => '',
+ 2 => '',
+ 3 => 'http://www.google.com/search?q={FNAME}+msdn.microsoft.com',
+ 4 => ''
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 =>'.'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_NEVER,
+ 'SCRIPT_DELIMITERS' => array(
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ )
+);
+
+?>
\ No newline at end of file diff --git a/inc/geshi/visualfoxpro.php b/inc/geshi/visualfoxpro.php new file mode 100644 index 000000000..0203d116e --- /dev/null +++ b/inc/geshi/visualfoxpro.php @@ -0,0 +1,444 @@ +<?php
+/*************************************************************************************
+ * visualfoxpro.php
+ * ----------------
+ * Author: Roberto Armellin (r.armellin@tin.it)
+ * Copyright: (c) 2004 Roberto Armellin, Nigel McNie (http://qbnz.com/highlighter/)
+ * Release Version: 1.0.1
+ * CVS Revision Version: $Revision: 1.1 $
+ * Date Started: 2004/09/17
+ * Last Modified: 2004/09/18
+ *
+ * Visual FoxPro language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2004/11/27 (1.0.1)
+ * - Added support for multiple object splitters
+ * 2004/10/27 (1.0.0)
+ * - First Release
+ *
+ * TODO (updated 2004/10/27)
+ * -------------------------
+ *
+ *************************************************************************************
+ *
+ * This file is part of GeSHi.
+ *
+ * GeSHi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GeSHi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GeSHi; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ ************************************************************************************/
+
+$language_data = array (
+ 'LANG_NAME' => 'VFP',
+ 'COMMENT_SINGLE' => array(1 => "//", 2 => "\n*"),
+ 'COMMENT_MULTI' => array(),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array('"'),
+ 'ESCAPE_CHAR' => '\\',
+ 'KEYWORDS' => array(
+ 1 => array('Case', 'Else', '#Else', 'Then',
+ 'Endcase', 'Enddefine', 'Enddo', 'Endfor', 'Endfunc', 'Endif', 'Endprintjob',
+ 'Endproc', 'Endscan', 'Endtext', 'Endwith', '#Endif',
+ '#Elif','#Else','#Endif','#Define','#If','#Include',
+ '#Itsexpression','#Readclauses','#Region','#Section','#Undef','#Wname',
+ 'Case','Define','Do','Else','Endcase','Enddefine',
+ 'Enddo','Endfor','Endfunc','Endif','Endprintjob','Endproc',
+ 'Endscan','Endtext','Endwith','For','Function','Hidden',
+ 'If','Local','Lparameter','Lparameters','Next','Otherwise',
+ 'Parameters','Printjob','Procedure','Protected','Public','Scan',
+ 'Text','Then','While','With','?','??',
+ '???','Abs','Accept','Access','Aclass','Acopy',
+ 'Acos','Adatabases','Adbobjects','Addbs','Addrelationtoenv','Addtabletoenv',
+ 'Adel','Adir','Aelement','Aerror','Afields','Afont',
+ 'Agetclass','Agetfileversion','Ains','Ainstance','Alen','Align',
+ 'Alines','Alltrim','Alter','Amembers','Amouseobj','Anetresources',
+ 'Ansitooem','Append','Aprinters','Ascan','Aselobj','Asin',
+ 'Asort','Assert','Asserts','Assist','Asubscript','Asynchronous',
+ 'At_c','Atan','Atc','Atcc','Atcline','Atline',
+ 'Atn2','Aused','Autoform','Autoreport','Avcxclasses','Average',
+ 'BarCount','BarPrompt','BatchMode','BatchUpdateCount','Begin','BellSound',
+ 'BinToC','Bintoc','Bitand','Bitclear','Bitlshift','Bitnot',
+ 'Bitor','Bitrshift','Bitset','Bittest','Bitxor','Bof',
+ 'Browse','BrowseRefresh','Buffering','BuilderLock','COMArray','COMReturnError',
+ 'CToBin','Calculate','Call','Capslock','Cd','Cdow',
+ 'Ceiling','Central','Change','Char','Chdir','Chr',
+ 'Chrsaw','Chrtran','Chrtranc','Close','Cmonth','Cntbar',
+ 'Cntpad','Col','Comclassinfo','CommandTargetQuery','Compile','Completed',
+ 'Compobj','Compute','Concat','ConnectBusy','ConnectHandle','ConnectName',
+ 'ConnectString','ConnectTimeOut','ContainerReleaseType','Continue','Copy','Cos',
+ 'Cot','Count','Coverage','Cpconvert','Cpcurrent','Cpdbf',
+ 'Cpnotrans','Create','CreateBinary','Createobject','Createobjectex','Createoffline',
+ 'CrsBuffering','CrsFetchMemo','CrsFetchSize','CrsMaxRows','CrsMethodUsed','CrsNumBatch',
+ 'CrsShareConnection','CrsUseMemoSize','CrsWhereClause','Ctobin','Ctod','Ctot',
+ 'Curdate','Curdir','CurrLeft','CurrSymbol','CursorGetProp','CursorSetProp',
+ 'Curtime','Curval','DBGetProp','DBSetProp','DB_BufLockRow','DB_BufLockTable',
+ 'DB_BufOff','DB_BufOptRow','DB_BufOptTable','DB_Complette','DB_DeleteInsert','DB_KeyAndModified',
+ 'DB_KeyAndTimestamp','DB_KeyAndUpdatable','DB_LocalSQL','DB_NoPrompt','DB_Prompt','DB_RemoteSQL',
+ 'DB_TransAuto','DB_TransManual','DB_TransNone','DB_Update','Datetime','Day',
+ 'Dayname','Dayofmonth','Dayofweek','Dayofyear','Dbalias','Dbused',
+ 'Ddeaborttrans','Ddeadvise','Ddeenabled','Ddeexecute','Ddeinitiate','Ddelasterror',
+ 'Ddepoke','Dderequest','Ddesetoption','Ddesetservice','Ddesettopic','Ddeterminate',
+ 'Debugout','Declare','DefOLELCid','DefaultValue','Defaultext','Degrees',
+ 'DeleteTrigger','Desc','Description','Difference','Dimension','Dir',
+ 'Directory','Diskspace','DispLogin','DispWarnings','Display','Dll',
+ 'Dmy','DoDefault','DoEvents','Doc','Doevents','Dow',
+ 'Drivetype','Drop','Dropoffline','Dtoc','Dtor','Dtos',
+ 'Dtot','DynamicInputMask','Each','Edit','Eject','Elif',
+ 'End','Eof','Erase','Evaluate','Event','Eventtracking',
+ 'Exclude','Exclusive','Exit','Exp','Export','External',
+ 'FDate','FTime','Fchsize','Fclose','Fcount','Fcreate',
+ 'Feof','Ferror','FetchMemo','FetchSize','Fflush','Fgets',
+ 'Filer','Filetostr','Find','Fklabel','Fkmax','Fldlist',
+ 'Flock','Floor','Flush','Fontmetric','Fopen','Forceext',
+ 'Forcepath','FormSetClass','FormSetLib','FormsClass','FormsLib','Found',
+ 'FoxPro','Foxcode','Foxdoc','Foxgen','Foxgraph','Foxview',
+ 'Fputs','Fread','French','Fseek','Fsize','Fv',
+ 'Fwrite','Gather','German','GetPem','Getbar','Getcolor',
+ 'Getcp','Getdir','Getenv','Getexpr','Getfile','Getfldstate',
+ 'Getfont','Gethost','Getnextmodified','Getobject','Getpad','Getpict',
+ 'Getprinter','Go','Gomonth','Goto','Graph','GridHorz',
+ 'GridShow','GridShowPos','GridSnap','GridVert','Help','HelpOn',
+ 'HelpTo','HighLightRow','Home','Hour','IMEStatus','IdleTimeOut',
+ 'Idxcollate','Ifdef','Ifndef','Iif','Import','Include',
+ 'Indbc','Index','Indexseek','Inkey','Inlist','Input',
+ 'Insert','InsertTrigger','Insmode','IsBlank','IsFLocked','IsLeadByte',
+ 'IsMouse','IsNull','IsRLocked','Isalpha','Iscolor','Isdigit',
+ 'Isexclusive','Isflocked','Ishosted','Islower','Isreadonly','Isrlocked',
+ 'Isupper','Italian','Japan','Join','Justdrive','Justext',
+ 'Justfname','Justpath','Juststem','KeyField','KeyFieldList','Keyboard'
+ ),
+ 2 => array('Keymatch','LastProject','Lastkey','Lcase','Leftc','Len',
+ 'Lenc','Length','Likec','Lineno','LoadPicture','Loadpicture',
+ 'Locate','Locfile','Log','Log10','Logout','Lookup',
+ 'Loop','Lower','Ltrim','Lupdate','Mail','MaxRecords',
+ 'Mcol','Md','Mdown','Mdx','Mdy','Memlines',
+ 'Menu','Messagebox','Minute','Mkdir','Mline','Modify',
+ 'Month','Monthname','Mouse','Mrkbar','Mrkpad','Mrow',
+ 'Mtdll','Mton','Mwindow','Native','Ndx','Network',
+ 'NoFilter','Nodefault','Normalize','Note','Now','Ntom',
+ 'NullString','Numlock','Nvl','ODBChdbc','ODBChstmt','OLEDropTextInsertion',
+ 'OLELCid','Objnum','Objref','Objtoclient','Objvar','Occurs',
+ 'Oemtoansi','Oldval','OlePublic','Olereturnerror','On','Open',
+ 'Oracle','Order','Os','Outer','PCount','Pack',
+ 'PacketSize','Padc','Padl','Padr','Payment','Pcol',
+ 'PemStatus','Pi','Pivot','Play','Pop','Popup',
+ 'Power','PrimaryKey','Printstatus','Private','Prmbar','Prmpad',
+ 'ProjectClick','Proper','Prow','Prtinfo','Push','Putfile',
+ 'Pv','Qpr','Quater','QueryTimeOut','Quit','Radians',
+ 'Rand','Rat','Ratc','Ratline','Rd','Rdlevel',
+ 'Read','Readkey','Recall','Reccount','RecentlyUsedFiles','Recno',
+ 'Recsize','Regional','Reindex','RelatedChild','RelatedTable','RelatedTag',
+ 'Remove','Rename','Repeat','Replace','Replicate','Report',
+ 'ResHeight','ResWidth','ResourceOn','ResourceTo','Resources','Restore',
+ 'Resume','Retry','Return','Revertoffline','Rgbscheme','Rightc',
+ 'Rlock','Rmdir','Rollback','Round','Rtod','Rtrim',
+ 'RuleExpression','RuleText','Run','Runscript','Rview','SQLAsynchronous',
+ 'SQLBatchMode','SQLCancel','SQLColumns','SQLConnect','SQLConnectTimeOut','SQLDisconnect',
+ 'SQLDispLogin','SQLDispWarnings','SQLExec','SQLGetProp','SQLIdleTimeOut','SQLMoreResults',
+ 'SQLPrepare','SQLQueryTimeOut','SQLSetProp','SQLTables','SQLTransactions','SQLWaitTime',
+ 'Save','SavePicture','Savepicture','ScaleUnits','Scatter','Scols',
+ 'Scroll','Sec','Second','Seek','Select','SendUpdates',
+ 'Set','SetDefault','Setfldstate','Setup','ShareConnection','ShowOLEControls',
+ 'ShowOLEInsertable','ShowVCXs','Sign','Sin','Size','SizeBox',
+ 'Skpbar','Skppad','Sort','Soundex','SourceName','Sqlcommit',
+ 'Sqll','Sqlrollback','Sqlstringconnect','Sqrt','Srows','StatusBar',
+ 'Store','Str','Strconv','Strtofile','Strtran','Stuff',
+ 'Stuffc','Substr','Substrc','Substring','Sum','Suspend',
+ 'Sys','Sysmetric','TabOrdering','Table','TableRefresh','Tablerevert',
+ 'Tableupdate','TagCount','TagNo','Tan','Target','This',
+ 'Thisform','Thisformset','Timestamp','Timestampdiff','Total','Transactions',
+ 'Transform','Trim','Truncate','Ttoc','Ttod','Txnlevel',
+ 'Txtwidth','Type','Ucase','Undefine','Unlock','Unpack',
+ 'Updatable','UpdatableFieldList','Update','UpdateName','UpdateNameList','UpdateTrigger',
+ 'UpdateType','Updated','Upper','Upsizing','Usa','Use',
+ 'UseMemoSize','Used','Val','Validate','Varread','Vartype',
+ 'Version','VersionLanguage','Wait','WaitTime','Wborder','Wchild',
+ 'Wcols','Week','Wexist','Wfont','WhereType','Windcmd',
+ 'Windhelp','Windmemo','Windmenu','Windmodify','Windquery','Windscreen',
+ 'Windsnip','Windstproc','WizardPrompt','Wlast','Wlcol','Wlrow',
+ 'Wmaximum','Wminimum','Wontop','Woutput','Wparent','Wread',
+ 'Wrows','Wtitle','Wvisible','Year','Zap','_Alignment',
+ '_Asciicols','_Asciirows','_Assist','_Beautify','_Box','_Browser',
+ '_Builder','_Calcmem','_Calcvalue','_Cliptext','_Converter','_Coverage',
+ '_Curobj','_Dblclick','_Diarydate','_Dos','_Foxdoc','_Foxgraph',
+ '_Gallery','_Gengraph','_Genhtml','_Genmenu','_Genpd','_Genscrn',
+ '_Genxtab','_Getexpr','_Include','_Indent','_Lmargin','_Mac',
+ '_Mbr_appnd','_Mbr_cpart','_Mbr_delet','_Mbr_font','_Mbr_goto','_Mbr_grid',
+ '_Mbr_link','_Mbr_mode','_Mbr_mvfld','_Mbr_mvprt','_Mbr_seek','_Mbr_sp100',
+ '_Mbr_sp200','_Mbr_szfld','_Mbrowse','_Mda_appnd','_Mda_avg','_Mda_brow',
+ '_Mda_calc','_Mda_copy','_Mda_count','_Mda_label','_Mda_pack','_Mda_reprt',
+ '_Mda_rindx','_Mda_setup','_Mda_sort','_Mda_sp100','_Mda_sp200','_Mda_sp300',
+ '_Mda_sum','_Mda_total','_Mdata','_Mdiary','_Med_clear','_Med_copy',
+ '_Med_cut','_Med_cvtst','_Med_find','_Med_finda','_Med_goto','_Med_insob',
+ '_Med_link','_Med_obj','_Med_paste','_Med_pref','_Med_pstlk','_Med_redo',
+ '_Med_repl','_Med_repla','_Med_slcta','_Med_sp100','_Med_sp200','_Med_sp300',
+ '_Med_sp400','_Med_sp500','_Med_undo','_Medit','_Mfi_clall','_Mfi_close',
+ '_Mfi_export','_Mfi_import','_Mfi_new','_Mfi_open','_Mfi_pgset','_Mfi_prevu',
+ '_Mfi_print','_Mfi_quit','_Mfi_revrt','_Mfi_savas','_Mfi_save','_Mfi_send',
+ '_Mfi_setup','_Mfi_sp100','_Mfi_sp200','_Mfi_sp300','_Mfi_sp400','_Mfile',
+ '_Mfiler','_Mfirst','_Mlabel','_Mlast','_Mline','_Mmacro',
+ '_Mmbldr','_Mpr_beaut','_Mpr_cancl','_Mpr_compl','_Mpr_do','_Mpr_docum',
+ '_Mpr_formwz','_Mpr_gener','_Mpr_graph','_Mpr_resum','_Mpr_sp100','_Mpr_sp200',
+ '_Mpr_sp300','_Mpr_suspend','_Mprog','_Mproj','_Mrc_appnd','_Mrc_chnge',
+ '_Mrc_cont','_Mrc_delet','_Mrc_goto','_Mrc_locat','_Mrc_recal','_Mrc_repl',
+ '_Mrc_seek','_Mrc_sp100','_Mrc_sp200','_Mrecord','_Mreport','_Mrqbe',
+ '_Mscreen','_Msm_data','_Msm_edit','_Msm_file','_Msm_format','_Msm_prog',
+ '_Msm_recrd','_Msm_systm','_Msm_text','_Msm_tools','_Msm_view','_Msm_windo',
+ '_Mst_about','_Mst_ascii','_Mst_calcu','_Mst_captr','_Mst_dbase','_Mst_diary',
+ '_Mst_filer','_Mst_help','_Mst_hphow','_Mst_hpsch','_Mst_macro','_Mst_office',
+ '_Mst_puzzl','_Mst_sp100','_Mst_sp200','_Mst_sp300','_Mst_specl','_Msysmenu',
+ '_Msystem','_Mtable','_Mtb_appnd','_Mtb_cpart','_Mtb_delet','_Mtb_delrc',
+ '_Mtb_goto','_Mtb_link','_Mtb_mvfld','_Mtb_mvprt','_Mtb_props','_Mtb_recal',
+ '_Mtb_sp100','_Mtb_sp200','_Mtb_sp300','_Mtb_sp400','_Mtb_szfld','_Mwi_arran',
+ '_Mwi_clear','_Mwi_cmd','_Mwi_color','_Mwi_debug','_Mwi_hide','_Mwi_hidea',
+ '_Mwi_min','_Mwi_move','_Mwi_rotat','_Mwi_showa','_Mwi_size','_Mwi_sp100',
+ '_Mwi_sp200','_Mwi_toolb','_Mwi_trace','_Mwi_view','_Mwi_zoom','_Mwindow',
+ '_Mwizards','_Mwz_all','_Mwz_form','_Mwz_foxdoc','_Mwz_import','_Mwz_label',
+ '_Mwz_mail','_Mwz_pivot','_Mwz_query','_Mwz_reprt','_Mwz_setup','_Mwz_table',
+ '_Mwz_upsizing','_Netware','_Oracle','_Padvance','_Pageno','_Pbpage',
+ '_Pcolno','_Pcopies','_Pdparms','_Pdriver','_Pdsetup','_Pecode',
+ '_Peject','_Pepage','_Pform','_Plength','_Plineno','_Ploffset',
+ '_Ppitch','_Pquality','_Pretext','_Pscode','_Pspacing','_Pwait',
+ '_Rmargin','_Runactivedoc','_Samples','_Screen','_Shell','_Spellchk',
+ '_Sqlserver','_Startup','_Tabs','_Tally','_Text','_Throttle',
+ '_Transport','_Triggerlevel','_Unix','_WebDevOnly','_WebMenu','_WebMsftHomePage',
+ '_WebVFPHomePage','_WebVfpOnlineSupport','_Windows','_Wizard','_Wrap','_scctext',
+ '_vfp','Additive','After','Again','Aindent','Alignright',
+ 'All','Alt','Alternate','And','Ansi','Any',
+ 'Aplabout','App','Array','As','Asc','Ascending',
+ 'Ascii','At','Attributes','Automatic','Autosave','Avg',
+ 'Bar','Before','Bell','Between','Bitmap','Blank',
+ 'Blink','Blocksize','Border','Bottom','Brstatus','Bucket',
+ 'Buffers','By','Candidate','Carry','Cascade','Catalog',
+ 'Cdx','Center','Century','Cga','Character','Check',
+ 'Classlib','Clock','Cnt','Codepage','Collate','Color',
+ 'Com1','Com2','Command','Compact','Compatible','Compress',
+ 'Confirm','Connection','Connections','Connstring','Console','Copies',
+ 'Cpcompile','Cpdialog','Csv','Currency','Cycle','Databases',
+ 'Datasource','Date','Db4','Dbc','Dbf','Dbmemo3',
+ 'Debug','Decimals','Defaultsource','Deletetables','Delimited','Delimiters',
+ 'Descending','Design','Development','Device','Dif','Disabled',
+ 'Distinct','Dlls','Dohistory','Dos','Dosmem','Double',
+ 'Driver','Duplex','Echo','Editwork','Ega25','Ega43',
+ 'Ems','Ems64','Encrypt','Encryption','Environment','Escape',
+ 'Events','Exact','Except','Exe','Exists','Expression',
+ 'Extended','F','Fdow','Fetch','Field','Fields',
+ 'File','Files','Fill','Fixed','Float','Foldconst',
+ 'Font','Footer','Force','Foreign','Fox2x','Foxplus',
+ 'Free','Freeze','From','Fullpath','Fw2','Fweek',
+ 'Get','Gets','Global','Group','Grow','Halfheight',
+ 'Having','Heading','Headings','Helpfilter','History','Hmemory',
+ 'Hours','Id','In','Indexes','Information','Instruct',
+ 'Int','Integer','Intensity','Intersect','Into','Is',
+ 'Isometric','Key','Keycolumns','Keycomp','Keyset','Last',
+ 'Ledit','Level','Library','Like','Linked','Lock',
+ 'Logerrors','Long','Lpartition','Mac','Macdesktop','Machelp',
+ 'Mackey','Macros','Mark','Master','Max','Maxmem',
+ 'Mdi','Memlimit','Memory','Memos','Memowidth','Memvar',
+ 'Menus','Messages','Middle','Min','Minimize','Minus',
+ 'Mod','Modal','Module','Mono43','Movers','Multilocks',
+ 'Mvarsiz','Mvcount','N','Near','Negotiate','Noalias',
+ 'Noappend','Noclear','Noclose','Noconsole','Nocptrans','Nodata',
+ 'Nodebug','Nodelete','Nodup','Noedit','Noeject','Noenvironment',
+ 'Nofloat','Nofollow','Nogrow','Noinit','Nolgrid','Nolink',
+ 'Nolock','Nomargin','Nomdi','Nomenu','Nominimize','Nomodify'
+ ),
+ 3 => array('Nomouse','None','Nooptimize','Nooverwrite','Noprojecthook','Noprompt',
+ 'Noread','Norefresh','Norequery','Norgrid','Norm','Normal',
+ 'Nosave','Noshadow','Noshow','Nospace','Not','Notab',
+ 'Notify','Noupdate','Novalidate','Noverify','Nowait','Nowindow',
+ 'Nowrap','Nozoom','Npv','Null','Number','Objects',
+ 'Odometer','Of','Off','Oleobjects','Only','Optimize',
+ 'Or','Orientation','Output','Outshow','Overlay','Overwrite',
+ 'Pad','Palette','Paperlength','Papersize','Paperwidth','Password',
+ 'Path','Pattern','Pause','Pdox','Pdsetup','Pen',
+ 'Pfs','Pixels','Plain','Popups','Precision','Preference',
+ 'Preview','Primary','Printer','Printquality','Procedures','Production',
+ 'Program','Progwork','Project','Prompt','Query','Random',
+ 'Range','Readborder','Readerror','Record','Recover','Redit',
+ 'Reference','References','Relative','Remote','Reprocess','Resource',
+ 'Rest','Restrict','Rgb','Right','Row','Rowset',
+ 'Rpd','Runtime','Safety','Same','Sample','Say',
+ 'Scale','Scheme','Scoreboard','Screen','Sdf','Seconds',
+ 'Selection','Shadows','Shared','Sheet','Shell','Shift',
+ 'Shutdown','Single','Some','Sortwork','Space','Sql',
+ 'Standalone','Status','Std','Step','Sticky','String',
+ 'Structure','Subclass','Summary','Sylk','Sysformats','Sysmenus',
+ 'System','T','Tab','Tables','Talk','Tedit',
+ 'Textmerge','Time','Timeout','Titles','Tmpfiles','To',
+ 'Topic','Transaction','Trap','Trbetween','Trigger','Ttoption',
+ 'Typeahead','Udfparms','Union','Unique','Userid','Users',
+ 'Values','Var','Verb','Vga25','Vga50','Views',
+ 'Volume','Where','Windows','Wk1','Wk3','Wks',
+ 'Workarea','Wp','Wr1','Wrap','Wrk','Xcmdfile',
+ 'Xl5','Xl8','Xls','Y','Yresolution','Zoom',
+ 'Activate','ActivateCell','Add','AddColumn','AddItem','AddListItem',
+ 'AddObject','AddProperty','AddToSCC','AfterBuild','AfterCloseTables','AfterDock',
+ 'AfterRowColChange','BeforeBuild','BeforeDock','BeforeOpenTables','BeforeRowColChange','Box',
+ 'Build','CheckIn','CheckOut','Circle','Clear','ClearData',
+ 'Cleanup','Click','CloneObject','CloseEditor','CloseTables','Cls',
+ 'CommandTargetExec','CommandTargetQueryStas','ContainerRelease','DataToClip','DblClick','Deactivate',
+ 'Delete','DeleteColumn','Deleted','Destroy','DoCmd','Dock',
+ 'DoScroll','DoVerb','DownClick','Drag','DragDrop','DragOver',
+ 'DropDown','Draw','EnterFocus','Error','ErrorMessage','Eval',
+ 'ExitFocus','FormatChange','GetData','GetFormat','GetLatestVersion','GoBack',
+ 'GotFocus','GoForward','GridHitTest','Hide','HideDoc','IndexToItemId',
+ 'Init','InteractiveChange','Item','ItemIdToIndex','KeyPress','Line',
+ 'Load','LostFocus','Message','MiddleClick','MouseDown','MouseMove',
+ 'MouseUp','MouseWheel','Move','Moved','NavigateTo','Newobject',
+ 'OLECompleteDrag','OLEDrag','OLEDragDrop','OLEDragOver','OLEGiveFeedback','OLESetData',
+ 'OLEStartDrag','OpenEditor','OpenTables','Paint','Point','Print',
+ 'ProgrammaticChange','PSet','QueryAddFile','QueryModifyFile','QueryRemoveFile','QueryRunFile',
+ 'QueryUnload','RangeHigh','RangeLow','ReadActivate','ReadExpression','ReadDeactivate',
+ 'ReadMethod','ReadShow','ReadValid','ReadWhen','Refresh','Release',
+ 'RemoveFromSCC','RemoveItem','RemoveListItem','RemoveObject','Requery','RequestData',
+ 'Reset','ResetToDefault','Resize','RightClick','SaveAs','SaveAsClass',
+ 'Scrolled','SetAll','SetData','SetFocus','SetFormat','SetMain',
+ 'SetVar','SetViewPort','ShowDoc','ShowWhatsThis','TextHeight','TextWidth',
+ 'Timer','UIEnable','UnDock','UndoCheckOut','Unload','UpClick',
+ 'Valid','WhatsThisMode','When','WriteExpression','WriteMethod','ZOrder',
+ 'ATGetColors','ATListColors','Accelerate','ActiveColumn','ActiveControl','ActiveForm',
+ 'ActiveObjectId','ActivePage','ActiveProject','ActiveRow','AddLineFeeds','Alias',
+ 'Alignment','AllowAddNew','AllowHeaderSizing','AllowResize','AllowRowSizing','AllowTabs',
+ 'AlwaysOnTop','Application','AutoActivate','AutoCenter','AutoCloseTables','AutoIncrement',
+ 'AutoOpenTables','AutoRelease','AutoSize','AutoVerbMenu','AutoYield','AvailNum',
+ 'BackColor','BackStyle','BaseClass','BorderColor','BorderStyle','BorderWidth',
+ 'Bound','BoundColumn','BoundTo','BrowseAlignment','BrowseCellMarg','BrowseDestWidth',
+ 'BufferMode','BufferModeOverride','BuildDateTime','ButtonCount','ButtonIndex','Buttons',
+ 'CLSID','CanAccelerate','CanGetFocus','CanLoseFocus','Cancel','Caption',
+ 'ChildAlias','ChildOrder','Class','ClassLibrary','ClipControls','ClipRect',
+ 'Closable','ColorScheme','ColorSource','ColumnCount','ColumnHeaders','ColumnLines',
+ 'ColumnOrder','ColumnWidths','Columns','Comment','ContinuousScroll','ControlBox',
+ 'ControlCount','ControlIndex','ControlSource','Controls','CurrentControl','CurrentX',
+ 'CurrentY','CursorSource','Curvature','DataSession','DataSessionId','DataSourceObj',
+ 'DataType','Database','DateFormat','DateMark','DefButton','DefButtonOrig',
+ 'DefHeight','DefLeft','DefTop','DefWidth','Default','DefaultFilePath',
+ 'DefineWindows','DeleteMark','Desktop','Dirty','DisabledBackColor','DisabledByEOF',
+ 'DisabledForeColor','DisabledItemBackColor','DisabledItemForeColor','DisabledPicture','DispPageHeight','DispPageWidth',
+ 'DisplayCount','DisplayValue','DoCreate','DockPosition','Docked','DocumentFile',
+ 'DownPicture','DragIcon','DragMode','DragState','DrawMode','DrawStyle',
+ 'DrawWidth','DynamicAlignment','DynamicBackColor','DynamicCurrentControl','DynamicFontBold','DynamicFontItalic',
+ 'DynamicFontName','DynamicFontOutline','DynamicFontShadow','DynamicFontSize','DynamicFontStrikethru','DynamicFontUnderline',
+ 'DynamicForeColor','EditFlags','Enabled','EnabledByReadLock','Encrypted','EnvLevel',
+ 'ErasePage','FileClass','FileClassLibrary','FillColor','FillStyle','Filter',
+ 'FirstElement','FontBold','FontItalic','FontName','FontOutline','FontShadow',
+ 'FontSize','FontStrikethru','FontUnderline','ForceFocus','ForeColor','FormCount',
+ 'FormIndex','FormPageCount','FormPageIndex','Format','Forms','FoxFont',
+ 'FullName','GoFirst','GoLast','GridLineColor','GridLineWidth','GridLines'
+ ),
+ 4 => array('HPROJ','HWnd','HalfHeightCaption','HasClip','HeaderGap','HeaderHeight',
+ 'Height','HelpContextID','HideSelection','Highlight','HomeDir','HostName',
+ 'HotKey','HscrollSmallChange','IMEMode','Icon','IgnoreInsert','InResize',
+ 'Increment','IncrementalSearch','InitialSelectedAlias','InputMask','Instancing','IntegralHeight',
+ 'Interval','ItemBackColor','ItemData','ItemForeColor','ItemIDData','ItemTips',
+ 'JustReadLocked','KeyPreview','KeyboardHighValue','KeyboardLowValue','LastModified','Left',
+ 'LeftColumn','LineSlant','LinkMaster','List','ListCount','ListIndex',
+ 'ListItem','ListItemId','LockDataSource','LockScreen','MDIForm','MainClass',
+ 'MainFile','Margin','MaxButton','MaxHeight','MaxLeft','MaxLength',
+ 'MaxTop','MaxWidth','MemoWindow','MinButton','MinHeight','MinWidth',
+ 'MouseIcon','MousePointer','Movable','MoverBars','MultiSelect','Name',
+ 'NapTime','NewIndex','NewItemId','NoDataOnLoad','NoDefine','NotifyContainer',
+ 'NullDisplay','NumberOfElements','OLEDragMode','OLEDragPicture','OLEDropEffects','OLEDropHasData',
+ 'OLEDropMode','OLERequestPendingTimeOut','OLEServerBusyRaiseError','OLEServerBusyTimeOut','OLETypeAllowed','OleClass',
+ 'OleClassId','OleControlContainer','OleIDispInValue','OleIDispOutValue','OleIDispatchIncoming','OleIDispatchOutgoing',
+ 'OnResize','OneToMany','OpenViews','OpenWindow','PageCount','PageHeight',
+ 'PageOrder','PageWidth','Pages','Panel','PanelLink','Parent',
+ 'ParentAlias','ParentClass','Partition','PasswordChar','Picture','ProcessID',
+ 'ProgID','ProjectHookClass','ProjectHookLibrary','Projects','ReadColors','ReadCycle',
+ 'ReadFiller','ReadLock','ReadMouse','ReadOnly','ReadSave','ReadSize',
+ 'ReadTimeout','RecordMark','RecordSource','RecordSourceType','Rect','RelationalExpr',
+ 'RelativeColumn','RelativeRow','ReleaseErase','ReleaseType','ReleaseWindows','Resizable',
+ 'RightToLeft','RowHeight','RowSource','RowSourceType','SCCProvider','SCCStatus',
+ 'SDIForm','ScaleMode','ScrollBars','SelLength','SelStart','SelText',
+ 'SelectOnEntry','Selected','SelectedBackColor','SelectedForeColor','SelectedID','SelectedItemBackColor',
+ 'SelectedItemForeColor','SelfEdit','ServerClass','ServerClassLibrary','ServerHelpFile','ServerName',
+ 'ServerProject','ShowTips','ShowWindow','Sizable','Size<height>','Size<maxlength>',
+ 'Size<width>','Skip','SkipForm','Sorted','SourceType','Sparse',
+ 'SpecialEffect','SpinnerHighValue','SpinnerLowValue','SplitBar','StartMode','StatusBarText',
+ 'Stretch','StrictDateEntry','Style','SystemRefCount','TabIndex','TabStop',
+ 'TabStretch','TabStyle','Tabhit','Tabs','Tag','TerminateRead',
+ 'ThreadID','TitleBar','ToolTipText','Top','TopIndex','TopItemId',
+ 'TypeLibCLSID','TypeLibDesc','TypeLibName','UnlockDataSource','Value','ValueDirty',
+ 'VersionComments','VersionCompany','VersionCopyright','VersionDescription','VersionNumber','VersionProduct',
+ 'VersionTrademarks','View','ViewPortHeight','ViewPortLeft','ViewPortTop','ViewPortWidth',
+ 'Visible','VscrollSmallChange','WasActive','WasOpen','WhatsThisButton','WhatsThisHelp',
+ 'WhatsThisHelpID','Width','WindowList','WindowNTIList','WindowState','WindowType',
+ 'WordWrap','ZOrderSet','ActiveDoc','Checkbox','Column','ComboBox',
+ 'CommandButton','CommandGroup','Container','Control','Cursor','Custom',
+ 'DataEnvironment','EditBox','Empty','FontClass','Form','Formset',
+ 'General','Grid','Header','HyperLink','Image','Label',
+ 'ListBox','Memo','OleBaseControl','OleBoundControl','OleClassIDispOut','OleControl',
+ 'OptionButton','OptionGroup','Page','PageFrame','ProjectHook','RectClass',
+ 'Relation','Session','Shape','Spinner','TextBox' ,'Toolbar'
+ ),
+ ),
+ 'SYMBOLS' => array("!", "@", "$", "%", "(", ")", "-", "+", "=", "/", "{", "}", "[", "]", ":", ";", ",", " ", ".", "*", "&"),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => true,
+ 1 => false,
+ 2 => false,
+ 3 => false,
+ 4 => false,
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: blue;',
+ 2 => 'color: blue;',
+ 3 => 'color: blue;',
+ 4 => 'color: blue;'
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: green; font-style: italic;',
+ 2 => 'color: green font-style: italic;',
+ 'MULTI' => 'color: #808080; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #000099; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: blue;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #ff0000;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #cc66cc;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #006600;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: blue;'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'SCRIPT' => array(
+ )
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_NEVER,
+ 'SCRIPT_DELIMITERS' => array(
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ )
+);
+
+?>
\ No newline at end of file diff --git a/inc/geshi/xml.php b/inc/geshi/xml.php new file mode 100644 index 000000000..b6c116c76 --- /dev/null +++ b/inc/geshi/xml.php @@ -0,0 +1,145 @@ +<?php +/************************************************************************************* + * xml.php + * ------- + * Author: Nigel McNie (oracle.shinoda@gmail.com) + * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/) + * Release Version: 1.0.1 + * CVS Revision Version: $Revision: 1.1 $ + * Date Started: 2004/09/01 + * Last Modified: $Date: 2004/11/29 08:46:25 $ + * + * XML language file for GeSHi. Based on the idea/file by Christian Weiske + * + * CHANGES + * ------- + * 2004/11/27 (1.0.1) + * - Added support for multiple object splitters + * 2004/10/27 (1.0.0) + * - First Release + * + * TODO (updated 2004/11/27) + * ------------------------- + * * Check regexps work and correctly highlight XML stuff and nothing else + * + ************************************************************************************* + * + * This file is part of GeSHi. + * + * GeSHi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GeSHi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GeSHi; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ************************************************************************************/ + +$language_data = array ( + 'LANG_NAME' => 'HTML', + 'COMMENT_SINGLE' => array(), + 'COMMENT_MULTI' => array('<!--' => '-->'), + 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, + 'QUOTEMARKS' => array("'", '"'), + 'ESCAPE_CHAR' => '\\', + 'KEYWORDS' => array( + ), + 'SYMBOLS' => array( + ), + 'CASE_SENSITIVE' => array( + GESHI_COMMENTS => false, + ), + 'STYLES' => array( + 'KEYWORDS' => array( + ), + 'COMMENTS' => array( + 'MULTI' => 'color: #808080; font-style: italic;' + ), + 'ESCAPE_CHAR' => array( + 0 => 'color: #000099; font-weight: bold;' + ), + 'BRACKETS' => array( + 0 => 'color: #66cc66;' + ), + 'STRINGS' => array( + 0 => 'color: #ff0000;' + ), + 'NUMBERS' => array( + 0 => 'color: #cc66cc;' + ), + 'METHODS' => array( + ), + 'SYMBOLS' => array( + 0 => 'color: #66cc66;' + ), + 'SCRIPT' => array( + 0 => 'color: #00bbdd;', + 1 => 'color: #ddbb00;', + 2 => 'color: #339933;', + 3 => 'color: #009900;' + ), + 'REGEXPS' => array( + 0 => 'color: #000066;', + 1 => 'font-weight: bold; color: black;', + 2 => 'font-weight: bold; color: black;', + ) + ), + 'URLS' => array( + ), + 'OOLANG' => false, + 'OBJECT_SPLITTERS' => array( + ), + 'REGEXPS' => array( + 0 => array( + GESHI_SEARCH => '(((xml:)?[a-z\-]+))(=)', + GESHI_REPLACE => '\\1', + GESHI_MODIFIERS => 'i', + GESHI_BEFORE => '', + GESHI_AFTER => '\\4' + ), + 1 => array( + GESHI_SEARCH => '(</?[a-z0-9]*(>)?)', + GESHI_REPLACE => '\\1', + GESHI_MODIFIERS => 'i', + GESHI_BEFORE => '', + GESHI_AFTER => '' + ), + 2 => array( + GESHI_SEARCH => '((/)?>)', + GESHI_REPLACE => '\\1', + GESHI_MODIFIERS => 'i', + GESHI_BEFORE => '', + GESHI_AFTER => '' + ) + ), + 'STRICT_MODE_APPLIES' => GESHI_ALWAYS, + 'SCRIPT_DELIMITERS' => array( + 0 => array( + '<!DOCTYPE' => '>' + ), + 1 => array( + '&' => ';' + ), + 2 => array( + '<![CDATA[' => ']]>' + ), + 3 => array( + '<' => '>' + ) + ), + 'HIGHLIGHT_STRICT_BLOCK' => array( + 0 => false, + 1 => false, + 2 => false, + 3 => true + ) +); + +?>
\ No newline at end of file diff --git a/inc/html.php b/inc/html.php new file mode 100644 index 000000000..a28bd2dca --- /dev/null +++ b/inc/html.php @@ -0,0 +1,970 @@ +<? +include_once("inc/format.php"); + +/** + * Convenience function to quickly build a wikilink + */ +function html_wikilink($url,$name='',$search=''){ + global $conf; + $link = array(); + $link['url'] = $url; + $link['name'] = $name; + $link = format_link_wiki($link); + + if($search){ + ($conf['userewrite']) ? $link['url'].='?s=' : $link['url'].='&s='; + $link['url'] .= urlencode($search); + } + + return format_link_build($link); +} + +/** + * The loginform + */ +function html_login(){ + global $lang; + global $conf; + global $ID; + + print parsedLocale('login'); + ?> + <div align="center"> + <form action="<?=script()?>" accept-charset="<?=$lang['encoding']?>" method="post"> + <fieldset> + <legend><?=$lang['btn_login']?></legend> + <input type="hidden" name="id" value="<?=$ID?>" /> + <input type="hidden" name="do" value="login" /> + <label> + <span><?=$lang['user']?></span> + <input type="text" name="u" value="<?=formText($_REQUEST['u'])?>" class="edit" /> + </label><br /> + <label> + <span><?=$lang['pass']?></span> + <input type="password" name="p" class="edit" /> + </label><br /> + <input type="submit" value="<?=$lang['btn_login']?>" class="button" /> + </fieldset> + </form> + <? + if($conf['openregister']){ + print '<p>'; + print $lang['reghere']; + print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>'; + print '</p>'; + } + ?> + </div> + <? + if(@file_exists('includes/login.txt')){ + print io_cacheParse('includes/login.txt'); + } +} + +/** + * shows the edit/source/show button dependent on current mode + */ +function html_editbutton(){ + global $ID; + global $REV; + global $ACT; + global $INFO; + + if($ACT == 'show' || $ACT == 'search'){ + if($INFO['writable']){ + if($INFO['exists']){ + $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); + }else{ + $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); + } + }else{ + $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); + } + }else{ + $r = html_btn('show',$ID,'v',array('do' => 'show')); + } + return $r; +} + +function html_secedit_button($section,$p){ + global $ID; + global $lang; + $secedit = ''; + if($p) $secedit .= "</p>\n"; + $secedit .= '<div class="secedit">'; + $secedit .= html_btn('secedit',$ID,'', + array('do' => 'edit', + 'lines' => "$section"), + 'post'); + $secedit .= '</div>'; + if($p) $secedit .= "\n<p>"; + return $secedit; +} + +function html_secedit($text,$show=true){ + global $INFO; + if($INFO['writable'] && $show){ + $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e', + "html_secedit_button('\\1',true)", + $text); + $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e', + "html_secedit_button('\\1',false)", + $text); + }else{ + $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text); + } + return $text; +} + +/** + * displays the breadcrumbs trace + */ +function html_breadcrumbs(){ + global $lang; + global $conf; + + //check if enabled + if(!$conf['breadcrumbs']) return; + + $crumbs = breadcrumbs(); //setup crumb trace + print '<div class="breadcrumbs">'; + print $lang['breadcrumb'].':'; + foreach ($crumbs as $crumb){ + print ' » '; + print '<a href="'.wl($crumb).'" class="breadcrumbs" onclick="return svchk()" onkeypress="return svchk()" title="'.$crumb.'">'.noNS($crumb).'</a>'; + } + print '</div>'; +} + +/** + * display the HTML head and metadata + */ +function html_head(){ + global $ID; + global $ACT; + global $INFO; + global $conf; + global $lang; + + print '<'.'?xml version="1.0"?'.">\n"; + print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'; + print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; + print "\n"; +?> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=$conf['lang']?>" lang="<?=$conf['lang']?>" dir="ltr"> + <head> + <title><?=$ID?> [<?=$conf['title']?>]</title> + <meta http-equiv="Content-Type" content="text/html; charset=<?=$lang['encoding']?>" /> + <meta name="generator" content="DokuWiki <?=DOKUWIKIVERSION?>" /> + <link rel="stylesheet" media="screen" type="text/css" href="<?=getBaseURL()?>style.css" /> + <link rel="stylesheet" media="print" type="text/css" href="<?=getBaseURL()?>print.css" /> + <link rel="shortcut icon" href="<?=getBaseURL()?>images/favicon.ico" /> + <link rel="start" href="<?=wl()?>" /> + <link rel="contents" href="<?=wl($ID,'do=index')?>" title="<?=$lang['index']?>" /> + <link rel="alternate" type="application/rss+xml" title="Recent Changes" href="<?=getBaseURL()?>feed.php" /> + <link rel="alternate" type="application/rss+xml" title="Current Namespace" href="<?=getBaseURL()?>feed.php?mode=list&ns=<?=$INFO['namespace']?>" /> + <link rel="alternate" type="text/html" title="Plain HTML" href="<?=wl($ID,'do=export_html')?>" /> + <link rel="alternate" type="text/plain" title="Wiki Markup" href="<?=wl($ID, 'do=export_raw')?>" /> +<? + if($ACT=='show' || $ACT=='export_html'){ + if($INFO['exists']){ + print ' <meta name="robots" content="index,follow" />'."\n"; + print ' <meta name="date" content="'.date('Y-m-d\TH:i:sO',$INFO['lastmod']).'" />'."\n"; + }else{ + print ' <meta name="robots" content="noindex,follow" />'."\n"; + } + }else{ + print ' <meta name="robots" content="noindex,nofollow" />'."\n"; + } +?> + + <script language="JavaScript" type="text/javascript"> + var alertText = '<?=$lang['qb_alert']?>'; + var notSavedYet = '<?=$lang['notsavedyet']?>'; + var baseURL = '<?=getBaseURL()?>'; + </script> + <script language="JavaScript" type="text/javascript" src="<?=getBaseURL()?>script.js"></script> + + <!--[if gte IE 5]> + <style type="text/css"> + /* that IE 5+ conditional comment makes this only visible in IE 5+ */ + img { behavior: url("<?=getBaseURL()?>pngbehavior.htc"); } /* IE bugfix for transparent PNGs */ + </style> + <![endif]--> + + <?@include("includes/meta.html")?> + </head> +<? +} + +/** + * Displays a button (using it's own form) + */ +function html_btn($name,$id,$akey,$params,$method='get'){ + global $conf; + global $lang; + + $label = $lang['btn_'.$name]; + + $ret = ''; + + $id = idfilter($id); + + //make nice URLs even for buttons + $link = getBaseURL().'/'; + $link = preg_replace('#//$#','/',$link); + if(!$conf['userewrite']){ + $script = $link.'doku.php'; + $params['id'] = $id; + }else{ + $script = $link.$id; + } + + $ret .= '<form class="button" method="'.$method.'" action="'.$script.'" onsubmit="return svchk()">'; + + reset($params); + while (list($key, $val) = each($params)) { + $ret .= '<input type="hidden" name="'.$key.'" '; + $ret .= 'value="'.htmlspecialchars($val).'" />'; + } + + $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; + if($akey){ + $ret .= 'title="ALT+'.strtoupper($akey).'" '; + $ret .= 'accesskey="'.$akey.'" '; + } + $ret .= '/>'; + $ret .= '</form>'; + + return $ret; +} + +/** + * Check for the given permission or prints an error + */ +function html_acl($perm){ + global $INFO; + if($INFO['perm'] >= $perm) return true; + + print parsedLocale('denied'); + return false; +} + +/** + * Displays the page header and calls html_head() + */ +function html_header(){ + global $ID; + global $REV; + global $lang; + global $conf; + html_head(); +?> +<body> + <div class="all"> + <? + html_msgarea(); + @include("includes/topheader.html") + ?> + <div class="header"> + <div class="pagename"> + [[<a href="<?=wl($ID,'do=backlink')?>" onclick="return svchk()" onkeypress="return svchk()"><?=$ID?></a>]] + </div> + <div class="logo"> + <a href="<?=wl()?>" name="top" accesskey="h" title="[ALT+H]" onclick="return svchk()" onkeypress="return svchk()"><?=$conf['title']?></a> + </div> + </div> + <?@include("includes/header.html")?> + + <div class="bar" id="bar_top"> + <div class="bar-left" id="bar_topleft"> + <?=html_editbutton()?> + <?=html_btn(revs,$ID,'r',array('do' => 'revisions'))?> + </div> + + <div class="bar-right" id="bar_topright"> + <?=html_btn(recent,'','r',array('do' => 'recent'))?> + <form action="<?=wl()?>" accept-charset="<?=$lang['encoding']?>"> + <input type="hidden" name="do" value="search" /> + <input type="text" name="id" class="edit" /> + <input type="submit" value="<?=$lang['btn_search']?>" class="button" /> + </form> + </div> + </div> + + <? + flush(); + html_breadcrumbs(); + @include("includes/pageheader.html"); + ?> + <div class="page"> + <!-- wikipage start --> +<? +} + +/** + * Displays some Metadata like who's logged in and the last modified + * date - do not confuse this with the HTML meta header. + */ +function html_metainfo(){ + global $conf; + global $lang; + global $INFO; + global $REV; + + $fn = $INFO['filepath']; + if(!$conf['fullpath']){ + if($REV){ + $fn = str_replace(realpath($conf['olddir']).DIRECTORY_SEPARATOR,'',$fn); + }else{ + $fn = str_replace(realpath($conf['datadir']).DIRECTORY_SEPARATOR,'',$fn); + } + } + $date = date($conf['dformat'],$INFO['lastmod']); + + print '<div class="meta">'; + if($_SERVER['REMOTE_USER']){ + print '<div class="user">'; + print $lang['loggedinas'].': '.$_SERVER['REMOTE_USER']; + print '</div>'; + } + print ' '; + if($INFO['exists']){ + print $fn; + print ' · '; + print $lang['lastmod']; + print ': '; + print $date; + if($INFO['locked']){ + print ' · '; + print $lang['lockedby']; + print ': '; + print $INFO['locked']; + } + } + print '</div>'; +} + +function html_footer(){ + global $ID; + global $REV; + global $INFO; + global $lang; + global $conf; +?> + <!-- wikipage stop --> + </div> + <div class="clearer"> </div> + <? + flush(); + @include("includes/pagefooter.html"); + html_metainfo(); + ?> + <div class="bar" id="bar_bottom"> + <div class="bar-left" id="bar_bottomleft"> + <?=html_editbutton()?> + <?=html_btn(revs,$ID,'r',array('do' => 'revisions'))?> + </div> + + <div class="bar-right" id="bar_bottomright"> + <? + if($conf['useacl']){ + if($_SERVER['REMOTE_USER']){ + print html_btn('logout',$ID,'',array('do' => 'logout',)); + }else{ + print html_btn('login',$ID,'',array('do' => 'login')); + } + } + ?> + <?=html_btn(index,$ID,'x',array('do' => 'index'))?> + <a href="#top"><input type="button" class="button" value="<?=$lang['btn_top']?>" /></a> + </div> + </div> + <?@include("includes/footer.html")?> + </div> + </body> + </html> +<? +} + +function html_toc($toc){ + global $lang; + $ret = ''; + $ret .= '<div class="toc">'; + $ret .= '<div class="tocheader">'; + $ret .= $lang['toc']; + $ret .= ' <script type="text/javascript">'; + $ret .= 'showTocToggle("+","-")'; + $ret .= '</script>'; + $ret .= '</div>'; + $ret .= '<div id="tocinside">'; + $ret .= html_buildlist($toc,'toc','html_list_toc'); + $ret .= '</div>'; + $ret .= '</div>'; + return $ret; +} + +/** + * User function for html_buildlist() + */ +function html_list_toc($item){ + $ret = ''; + $ret .= '<a href="#'.$item['id'].'" class="toc">'; + $ret .= $item['name']; + $ret .= '</a>'; + return $ret; +} + +function html_show($text=''){ + global $ID; + global $REV; + global $HIGH; + //disable section editing for old revisions or in preview + if($text || $REV){ + global $parser; + $parser['secedit'] = false; + } + + if ($text){ + //PreviewHeader + print parsedLocale('preview'); + print '<div class="preview">'; + print html_secedit(parse($text),false); + print '</div>'; + }else{ + if ($REV) print parsedLocale('showrev'); + $html = parsedWiki($ID,$REV,true); + $html = html_secedit($html); + print html_hilight($html,$HIGH); + } +} + +/** + * Highlights searchqueries in HTML code + */ +function html_hilight($html,$query){ + $queries = preg_split ("/\s/",$query,-1,PREG_SPLIT_NO_EMPTY); + foreach ($queries as $q){ + $q = preg_quote($q,'/'); + $html = preg_replace("/((<[^>]*)|$q)/ie", '"\2"=="\1"? "\1":"<span class=\"search_hit\">\1</span>"', $html); + } + return $html; +} + +/** + * This function runs a search and displays the result + */ +function html_search(){ + require_once("inc/search.php"); + global $conf; + global $QUERY; + global $ID; + global $lang; + + print parsedLocale('searchpage'); + flush(); + + //do quick pagesearch + $data = array(); + search($data,$conf['datadir'],'search_pagename',array(query => $QUERY)); + if(count($data)){ + sort($data); + print '<div class="search_quickresult">'; + print '<b>'.$lang[quickhits].':</b><br />'; + foreach($data as $row){ + print '<div class="search_quickhits">'; + print html_wikilink(':'.$row['id'],$row['id']); + print '</div> '; + } + //clear float (see http://www.complexspiral.com/publications/containing-floats/) + print '<div class="clearer"> </div>'; + print '</div>'; + } + flush(); + + //do fulltext search + $data = array(); + search($data,$conf['datadir'],'search_fulltext',array(query => $QUERY)); + if(count($data)){ + usort($data,'sort_search_fulltext'); + foreach($data as $row){ + print '<div class="search_result">'; + print html_wikilink(':'.$row['id'],$row['id'],$QUERY); + print ': <span class="search_cnt">'.$row['count'].' '.$lang['hits'].'</span><br />'; + print '<div class="search_snippet">'.$row['snippet'].'</div>'; + print '</div>'; + } + }else{ + print '<div align="center">'.$lang['nothingfound'].'</div>'; + } +} + +function html_locked($ip){ + global $ID; + global $conf; + global $lang; + + $locktime = filemtime(wikiFN($ID).'.lock'); + $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); + $min = round(($conf['locktime'] - (time() - $locktime) )/60); + + print parsedLocale('locked'); + print '<ul>'; + print '<li><b>'.$lang['lockedby'].':</b> '.$ip.'</li>'; + print '<li><b>'.$lang['lockexpire'].':</b> '.$expire.' ('.$min.' min)</li>'; + print '</ul>'; +} + +function html_revisions(){ + global $ID; + global $INFO; + global $conf; + global $lang; + $revisions = getRevisions($ID); + $date = @date($conf['dformat'],$INFO['lastmod']); + + print parsedLocale('revisions'); + print '<ul>'; + if($INFO['exists']){ + print '<li>'.$date.' <a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ('.$lang['current'].')</li>'; + } + + foreach($revisions as $rev){ + $date = date($conf['dformat'],$rev); + print '<li>'; + print $date.' <a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> '; + print '<a href="'.wl($ID,"rev=$rev,do=diff").'">['.$lang['diff'].']</a>'; + print '</li>'; + } + print '</ul>'; +} + +function html_recent(){ + global $conf; + $recents = getRecents(0,true); + + print parsedLocale('recent'); + print '<ul>'; + foreach(array_keys($recents) as $id){ + $date = date($conf['dformat'],$recents[$id]['date']); + print '<li>'; + print $date.' '.html_wikilink($id,$id); + print ' '.htmlspecialchars($recents[$id]['sum']); + print ' <span class="user">('; + print $recents[$id]['ip']; + if($recents[$id]['user']) print ' '.$recents[$id]['user']; + print ')</span>'; + print '</li>'; + } + print '</ul>'; +} + +function html_index($ns){ + require_once("inc/search.php"); + global $conf; + global $ID; + $dir = $conf['datadir']; + $ns = cleanID($ns); + if(empty($ns)){ + $ns = dirname(str_replace(':','/',$ID)); + if($ns == '.') $ns =''; + } + $ns = str_replace(':','/',$ns); + + print parsedLocale('index'); + + $data = array(); + search($data,$conf['datadir'],'search_index',array('ns' => $ns)); + print html_buildlist($data,'idx','html_list_index'); +} + +/** + * User function for html_buildlist() + */ +function html_list_index($item){ + $ret = ''; + $base = ':'.$item['id']; + $base = substr($base,strrpos($base,':')+1); + if($item['type']=='d'){ + $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">'; + $ret .= $base; + $ret .= '</a>'; + }else{ + $ret .= html_wikilink(':'.$item['id']); + } + return $ret; +} + +/** + * Build an unordered list from the given $data array + * Each item in the array has to have a 'level' property + * the item itself gets printed by the given $func user + * function + */ +function html_buildlist($data,$class,$func){ + $level = 0; + $opens = 0; + $ret = ''; + + foreach ($data as $item){ + + if( $item['level'] > $level ){ + //open new list + $ret .= "\n<ul class=\"$class\">\n"; + }elseif( $item['level'] < $level ){ + //close last item + $ret .= "</li>\n"; + for ($i=0; $i<($level - $item['level']); $i++){ + //close higher lists + $ret .= "</ul>\n</li>\n"; + } + }else{ + //close last item + $ret .= "</li>\n"; + } + + //remember current level + $level = $item['level']; + + //print item + $ret .= '<li class="level'.$item['level'].'">'; + $ret .= '<span class="li">'; + $ret .= $func($item); //user function + $ret .= '</span>'; + } + + //close remaining items and lists + for ($i=0; $i < $level; $i++){ + $ret .= "</li></ul>\n"; + } + + return $ret; +} + +function html_backlinks(){ + require_once("inc/search.php"); + global $ID; + global $conf; + + if(preg_match('#^(.*):(.*)$#',$ID,$matches)){ + $opts['ns'] = $matches[1]; + $opts['name'] = $matches[2]; + }else{ + $opts['ns'] = ''; + $opts['name'] = $ID; + } + + print parsedLocale('backlinks'); + + $data = array(); + search($data,$conf['datadir'],'search_backlinks',$opts); + sort($data); + + print '<ul class="idx">'; + foreach($data as $row){ + print '<li>'; + print html_wikilink(':'.$row['id'],$row['id']); + print '</li>'; + } + print '</ul>'; +} + +function html_diff($text='',$intro=true){ + require_once("inc/DifferenceEngine.php"); + global $ID; + global $REV; + global $lang; + global $conf; + if($text){ + $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), + split("\n",htmlspecialchars(cleanText($text)))); + $left = '<a class="wikilink1" href="'.wl($ID).'">'. + $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'. + $lang['current']; + $right = $lang['yours']; + }else{ + $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$REV))), + split("\n",htmlspecialchars(rawWiki($ID,'')))); + $left = '<a class="wikilink1" href="'.wl($ID,"rev=$REV").'">'. + $ID.' '.date($conf['dformat'],$REV).'</a>'; + $right = '<a class="wikilink1" href="'.wl($ID).'">'. + $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. + $lang['current']; + } + $tdf = new TableDiffFormatter(); + if($intro) print parsedLocale('diff'); + ?> + <table class="diff" width="100%"> + <tr> + <td colspan="2" width="50%" class="diff-header"> + <?=$left?> + </td> + <td colspan="2" width="50%" class="diff-header"> + <?=$right?> + </td> + </tr> + <?=$tdf->format($df)?> + </table> + <? +} + +function html_conflict($text,$summary){ + global $ID; + global $lang; + + print parsedLocale('conflict'); + ?> + <form name="editform" method="post" action="<?=script()?>" accept-charset="<?=$lang['encoding']?>"> + <input type="hidden" name="id" value="<?=$ID?>" /> + <input type="hidden" name="wikitext" value="<?=formText($text)?>" /> + <input type="hidden" name="summary" value="<?=formText($summary)?>" /> + + <div align="center"> + <input class="button" type="submit" name="do" value="<?=$lang['btn_save']?>" accesskey="s" title="[ALT+S]" /> + <input class="button" type="submit" name="do" value="<?=$lang['btn_cancel']?>" /> + </div> + </form> + <br /><br /><br /><br /> + <? +} + +/** + * Prints the glovbal message array + */ +function html_msgarea(){ + global $MSG; + + if(!isset($MSG)) return; + + foreach($MSG as $msg){ + print '<div class="'.$msg['lvl'].'">'; + print $msg['msg']; + print '</div>'; + } +} + +/** + * Prints the registration form + */ +function html_register(){ + global $lang; + global $ID; + + print parsedLocale('register'); +?> + <div align="center"> + <form name="register" method="post" action="<?=wl($ID)?>" accept-charset="<?=$lang['encoding']?>"> + <input type="hidden" name="do" value="register" /> + <input type="hidden" name="save" value="1" /> + <fieldset> + <legend><?=$lang['register']?></legend> + <label> + <?=$lang['user']?> + <input type="text" name="login" class="edit" size="50" value="<?=formText($_POST['login'])?>" /> + </label><br /> + <label> + <?=$lang['fullname']?> + <input type="text" name="fullname" class="edit" size="50" value="<?=formText($_POST['fullname'])?>" /> + </label><br /> + <label> + <?=$lang['email']?> + <input type="text" name="email" class="edit" size="50" value="<?=formText($_POST['email'])?>" /> + </label><br /> + <input type="submit" class="button" value="<?=$lang['register']?>" /> + </fieldset> + </form> + </div> +<? +} + +/** + * This displays the edit form (lots of logic included) + */ +function html_edit($text=null,$include='edit'){ //FIXME: include needed? + global $ID; + global $REV; + global $DATE; + global $RANGE; + global $PRE; + global $SUF; + global $INFO; + global $SUM; + global $lang; + global $conf; + + //check for create permissions first + if(!$INFO['exists'] && !html_acl(AUTH_CREATE)) return; + + //set summary default + if(!$SUM){ + if($REV){ + $SUM = $lang['restored']; + }elseif(!$INFO['exists']){ + $SUM = $lang['created']; + } + } + + //no text? Load it! + if(!isset($text)){ + $pr = false; //no preview mode + if($RANGE){ + list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); + }else{ + $text = rawWiki($ID,$REV); + } + }else{ + $pr = true; //preview mode + } + + $wr = $INFO['writable']; + if($wr){ + if ($REV) print parsedLocale('editrev'); + print parsedLocale($include); + }else{ + print parsedLocale('read'); + $ro='readonly="readonly"'; + } + if(!$DATE) $DATE = $INFO['lastmod']; +?> + <form name="editform" method="post" action="<?=script()?>" accept-charset="<?=$lang['encoding']?>" onsubmit="return svchk()"> + <input type="hidden" name="id" value="<?=$ID?>" /> + <input type="hidden" name="rev" value="<?=$REV?>" /> + <input type="hidden" name="date" value="<?=$DATE?>" /> + <input type="hidden" name="prefix" value="<?=formText($PRE)?>" /> + <input type="hidden" name="suffix" value="<?=formText($SUF)?>" /> + <table style="width:99%"> + <tr> + <td class="toolbar" colspan="3"> + <?if($wr){?> + <script language="JavaScript" type="text/javascript"> + <?/* sets changed to true when previewed */?> + textChanged = <? ($pr) ? print 'true' : print 'false' ?>; + + formatButton('images/bold.png','<?=$lang['qb_bold']?>','**','**','<?=$lang['qb_bold']?>','b'); + formatButton('images/italic.png','<?=$lang['qb_italic']?>',"\/\/","\/\/",'<?=$lang['qb_italic']?>','i'); + formatButton('images/underline.png','<?=$lang['qb_underl']?>','__','__','<?=$lang['qb_underl']?>','u'); + formatButton('images/code.png','<?=$lang['qb_code']?>','\'\'','\'\'','<?=$lang['qb_code']?>','c'); + + formatButton('images/fonth1.png','<?=$lang['qb_h1']?>','====== ',' ======\n','<?=$lang['qb_h1']?>','1'); + formatButton('images/fonth2.png','<?=$lang['qb_h2']?>','===== ',' =====\n','<?=$lang['qb_h2']?>','2'); + formatButton('images/fonth3.png','<?=$lang['qb_h3']?>','==== ',' ====\n','<?=$lang['qb_h3']?>','3'); + formatButton('images/fonth4.png','<?=$lang['qb_h4']?>','=== ',' ===\n','<?=$lang['qb_h4']?>','4'); + formatButton('images/fonth5.png','<?=$lang['qb_h5']?>','== ',' ==\n','<?=$lang['qb_h5']?>','5'); + + formatButton('images/link.png','<?=$lang['qb_link']?>','[[',']]','<?=$lang['qb_link']?>','l'); + formatButton('images/extlink.png','<?=$lang['qb_extlink']?>','[[',']]','http://www.example.com|<?=$lang['qb_extlink']?>'); + + formatButton('images/list.png','<?=$lang['qb_ol']?>',' - ','\n','<?=$lang['qb_ol']?>'); + formatButton('images/list_ul.png','<?=$lang['qb_ul']?>',' * ','\n','<?=$lang['qb_ul']?>'); + + insertButton('images/rule.png','<?=$lang['qb_hr']?>','----\n'); + mediaButton('images/image.png','<?=$lang['qb_media']?>','m','<?=$INFO['namespace']?>'); + + <? + if($conf['useacl'] && $_SERVER['REMOTE_USER']){ + echo "insertButton('images/sig.png','".$lang['qb_sig']."','".html_signature()."','y');"; + } + ?> + </script> + <?}?> + </td> + </tr> + <tr> + <td colspan="3"> + <textarea name="wikitext" id="wikitext" <?=$ro?> cols="80" rows="10" class="edit" onchange="textChanged = true;" tabindex="1"><?="\n".formText($text)?></textarea> + </td> + </tr> + <tr> + <td> + <?if($wr){?> + <input class="button" type="submit" name="do" value="<?=$lang['btn_save']?>" accesskey="s" title="[ALT+S]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="3" /> + <input class="button" type="submit" name="do" value="<?=$lang['btn_preview']?>" accesskey="p" title="[ALT+P]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="4" /> + <input class="button" type="submit" name="do" value="<?=$lang['btn_cancel']?>" tabindex="5" /> + <?}?> + </td> + <td> + <?if($wr){?> + <?=$lang['summary']?>: + <input type="text" class="edit" name="summary" size="50" value="<?=formText($SUM)?>" tabindex="2" /> + <?}?> + </td> + <td align="right"> + <script type="text/javascript"> + showSizeCtl(); + <?if($wr){?> + init_locktimer(<?=$conf['locktime']-60?>,'<?=$lang['willexpire']?>'); + document.editform.wikitext.focus(); + <?}?> + </script> + </td> + </tr> + </table> + </form> +<? +} + +/** + * prepares the signature string as configured in the config + */ +function html_signature(){ + global $conf; + global $INFO; + + $sig = $conf['signature']; + $sig = strftime($sig); + $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig); + $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig); + $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig); + $sig = str_replace('@DATE@',date($conf['dformat']),$sig); + return $sig; +} + +/** + * prints some debug info + */ +function html_debug(){ + global $conf; + + print '<html><body>'; + + print '<p>When reporting bugs please send all the following '; + print 'output as a mail to andi@splitbrain.org '; + print 'The best way to do this is to save this page in your browser</p>'; + + print '<b>$_SERVER:</b><pre>'; + print_r($_SERVER); + print '</pre>'; + + print '<b>$conf:</b><pre>'; + print_r($conf); + print '</pre>'; + + print '<b>abs baseURL:</b><pre>'; + print getBaseURL(true); + print '</pre>'; + + print '<b>rel baseURL:</b><pre>'; + print dirname($_SERVER['PHP_SELF']).'/'; + print '</pre>'; + + print '<b>PHP Version:</b><pre>'; + print phpversion(); + print '</pre>'; + + print '<b>locale:</b><pre>'; + print setlocale(LC_ALL,0); + print '</pre>'; + + print '<b>Environment:</b><pre>'; + print_r($_ENV); + print '</pre>'; + + print '<b>PHP settings:</b><pre>'; + $inis = ini_get_all(); + print_r($inis); + print '</pre>'; + + print '</body></html>'; +} + +?> diff --git a/inc/io.php b/inc/io.php new file mode 100644 index 000000000..c84604a43 --- /dev/null +++ b/inc/io.php @@ -0,0 +1,139 @@ +<? +require_once("inc/common.php"); +require_once("inc/parser.php"); + + + + +/** + * Returns the parsed text from the given sourcefile. Uses cache + * if exists. Creates it if not. + */ +function io_cacheParse($file){ + global $conf; + global $CACHEGROUP; + global $parser; //we read parser options + $parsed = ''; + $cache = $conf['datadir'].'/.cache/'; + $cache .= md5($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].$CACHEGROUP); + $purge = $conf['datadir'].'/.cache/purgefile'; + + // check if cache can be used + $cachetime = @filemtime($cache); + + if( @file_exists($cache) // does the cachefile exist + && @file_exists($file) // and does the source exist + && !isset($_REQUEST['purge']) // no purge param was set + && filesize($cache) // and contains the cachefile any data + && ((time() - $cachetime) < $conf['cachetime']) // and is cachefile young enough + && ($cachetime > filemtime($file)) // and newer than the source + && ($cachetime > @filemtime($purge)) // and newer than the purgefile + && ($cachetime > filemtime('conf/dokuwiki.php')) // and newer than the config file + && ($cachetime > @filemtime('conf/local.php')) // and newer than the local config file + && ($cachetime > filemtime('inc/parser.php')) // and newer than the parser + && ($cachetime > filemtime('inc/format.php'))) // and newer than the formating functions + { + $parsed = io_readFile($cache); //give back cache + $parsed .= "\n<!-- cachefile $cache used -->\n"; + }elseif(@file_exists($file)){ + $parsed = parse(io_readFile($file)); //sets global parseroptions + if($parser['cache']){ + io_saveFile($cache,$parsed); //save cachefile + $parsed .= "\n<!-- no cachefile used, but created -->\n"; + }else{ + @unlink($cache); //try to delete cachefile + $parsed .= "\n<!-- no cachefile used, caching forbidden -->\n"; + } + } + + return $parsed; +} + +/** + * Returns content of $file as cleaned string. Uses gzip if extension + * is .gz + */ +function io_readFile($file){ + $ret = ''; + if(@file_exists($file)){ + if(substr($file,-3) == '.gz'){ + $ret = join('',gzfile($file)); + }else{ + $ret = join('',file($file)); + } + } + return cleanText($ret); +} + +/** + * Saves $content to $file. Uses gzip if extension + * is .gz + * + * returns true on success + */ +function io_saveFile($file,$content){ + io_makeFileDir($file); + if(substr($file,-3) == '.gz'){ + $fh = @gzopen($file,'wb9'); + if(!$fh){ + msg("Writing $file failed",-1); + return false; + } + gzwrite($fh, $content); + gzclose($fh); + }else{ + $fh = @fopen($file,'wb'); + if(!$fh){ + msg("Writing $file failed",-1); + return false; + } + fwrite($fh, $content); + fclose($fh); + } + return true; +} + +/** + * Create the directory needed for the given file + */ +function io_makeFileDir($file){ + global $conf; + + $dir = dirname($file); + umask($conf['dmask']); + if(!is_dir($dir)){ + io_mkdir_p($dir) || msg("Creating directory $dir failed",-1); + } + umask($conf['umask']); +} + +/** + * Creates a directory hierachy. + * + * @see http://www.php.net/manual/en/function.mkdir.php + * @author <saint@corenova.com> + */ +function io_mkdir_p($target){ + if (is_dir($target)||empty($target)) return 1; // best case check first + if (@file_exists($target) && !is_dir($target)) return 0; + if (io_mkdir_p(substr($target,0,strrpos($target,'/')))) + return @mkdir($target,0777); // crawl back up & create dir tree + return 0; +} + +/** + * Runs an external command and returns it's output as string + * inspired by a patch by Harry Brueckner <harry_b@eml.cc> + */ +function io_runcmd($cmd){ + $fh = popen($cmd, "r"); + if(!$fh) return false; + $ret = ''; + while (!feof($fh)) { + $ret .= fread($fh, 8192); + } + pclose($fh); + return $ret; +} + +?> diff --git a/inc/magpie/extlib/Snoopy.class.inc b/inc/magpie/extlib/Snoopy.class.inc new file mode 100644 index 000000000..532ecba10 --- /dev/null +++ b/inc/magpie/extlib/Snoopy.class.inc @@ -0,0 +1,899 @@ +<?php + +/************************************************* + +Snoopy - the PHP net client +Author: Monte Ohrt <monte@ispi.net> +Copyright (c): 1999-2000 ispi, all rights reserved +Version: 1.0 + + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +You may contact the author of Snoopy by e-mail at: +monte@ispi.net + +Or, write to: +Monte Ohrt +CTO, ispi +237 S. 70th suite 220 +Lincoln, NE 68510 + +The latest version of Snoopy can be obtained from: +http://snoopy.sourceforge.com + +*************************************************/ + +class Snoopy +{ + /**** Public variables ****/ + + /* user definable vars */ + + var $host = "www.php.net"; // host name we are connecting to + var $port = 80; // port we are connecting to + var $proxy_host = ""; // proxy host to use + var $proxy_port = ""; // proxy port to use + var $agent = "Snoopy v1.0"; // agent we masquerade as + var $referer = ""; // referer info to pass + var $cookies = array(); // array of cookies to pass + // $cookies["username"]="joe"; + var $rawheaders = array(); // array of raw headers to send + // $rawheaders["Content-type"]="text/html"; + + var $maxredirs = 5; // http redirection depth maximum. 0 = disallow + var $lastredirectaddr = ""; // contains address of last redirected address + var $offsiteok = true; // allows redirection off-site + var $maxframes = 0; // frame content depth maximum. 0 = disallow + var $expandlinks = true; // expand links to fully qualified URLs. + // this only applies to fetchlinks() + // or submitlinks() + var $passcookies = true; // pass set cookies back through redirects + // NOTE: this currently does not respect + // dates, domains or paths. + + var $user = ""; // user for http authentication + var $pass = ""; // password for http authentication + + // http accept types + var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; + + var $results = ""; // where the content is put + + var $error = ""; // error messages sent here + var $response_code = ""; // response code returned from server + var $headers = array(); // headers returned from server sent here + var $maxlength = 500000; // max return data length (body) + var $read_timeout = 0; // timeout on read operations, in seconds + // supported only since PHP 4 Beta 4 + // set to 0 to disallow timeouts + var $timed_out = false; // if a read operation timed out + var $status = 0; // http request status + + var $curl_path = "/usr/bin/curl"; + // Snoopy will use cURL for fetching + // SSL content if a full system path to + // the cURL binary is supplied here. + // set to false if you do not have + // cURL installed. See http://curl.haxx.se + // for details on installing cURL. + // Snoopy does *not* use the cURL + // library functions built into php, + // as these functions are not stable + // as of this Snoopy release. + + // send Accept-encoding: gzip? + var $use_gzip = true; + + /**** Private variables ****/ + + var $_maxlinelen = 4096; // max line length (headers) + + var $_httpmethod = "GET"; // default http request method + var $_httpversion = "HTTP/1.0"; // default http request version + var $_submit_method = "POST"; // default submit method + var $_submit_type = "application/x-www-form-urlencoded"; // default submit type + var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type + var $_redirectaddr = false; // will be set if page fetched is a redirect + var $_redirectdepth = 0; // increments on an http redirect + var $_frameurls = array(); // frame src urls + var $_framedepth = 0; // increments on frame depth + + var $_isproxy = false; // set if using a proxy server + var $_fp_timeout = 30; // timeout for socket connection + +/*======================================================================*\ + Function: fetch + Purpose: fetch the contents of a web page + (and possibly other protocols in the + future like ftp, nntp, gopher, etc.) + Input: $URI the location of the page to fetch + Output: $this->results the output text from the fetch +\*======================================================================*/ + + function fetch($URI) + { + + //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); + $URI_PARTS = parse_url($URI); + if (!empty($URI_PARTS["user"])) + $this->user = $URI_PARTS["user"]; + if (!empty($URI_PARTS["pass"])) + $this->pass = $URI_PARTS["pass"]; + + switch($URI_PARTS["scheme"]) + { + case "http": + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_connect($fp)) + { + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httprequest($URI,$fp,$URI,$this->_httpmethod); + } + else + { + $path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httprequest($path, $fp, $URI, $this->_httpmethod); + } + + $this->_disconnect($fp); + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + $this->fetch($this->_redirectaddr); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + } + else + { + return false; + } + return true; + break; + case "https": + if(!$this->curl_path || (!is_executable($this->curl_path))) { + $this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n"; + return false; + } + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httpsrequest($URI,$URI,$this->_httpmethod); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httpsrequest($path, $URI, $this->_httpmethod); + } + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + $this->fetch($this->_redirectaddr); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + return true; + break; + default: + // not a valid protocol + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; + return false; + break; + } + return true; + } + + + +/*======================================================================*\ + Private functions +\*======================================================================*/ + + +/*======================================================================*\ + Function: _striplinks + Purpose: strip the hyperlinks from an html document + Input: $document document to strip. + Output: $match an array of the links +\*======================================================================*/ + + function _striplinks($document) + { + preg_match_all("'<\s*a\s+.*href\s*=\s* # find <a href= + ([\"\'])? # find single or double quote + (?(1) (.*?)\\1 | ([^\s\>]+)) # if quote found, match up to next matching + # quote, otherwise match up to next space + 'isx",$document,$links); + + + // catenate the non-empty matches from the conditional subpattern + + while(list($key,$val) = each($links[2])) + { + if(!empty($val)) + $match[] = $val; + } + + while(list($key,$val) = each($links[3])) + { + if(!empty($val)) + $match[] = $val; + } + + // return the links + return $match; + } + +/*======================================================================*\ + Function: _stripform + Purpose: strip the form elements from an html document + Input: $document document to strip. + Output: $match an array of the links +\*======================================================================*/ + + function _stripform($document) + { + preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); + + // catenate the matches + $match = implode("\r\n",$elements[0]); + + // return the links + return $match; + } + + + +/*======================================================================*\ + Function: _striptext + Purpose: strip the text from an html document + Input: $document document to strip. + Output: $text the resulting text +\*======================================================================*/ + + function _striptext($document) + { + + // I didn't use preg eval (//e) since that is only available in PHP 4.0. + // so, list your entities one by one here. I included some of the + // more common ones. + + $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript + "'<[\/\!]*?[^<>]*?>'si", // strip out html tags + "'([\r\n])[\s]+'", // strip out white space + "'&(quote|#34);'i", // replace html entities + "'&(amp|#38);'i", + "'&(lt|#60);'i", + "'&(gt|#62);'i", + "'&(nbsp|#160);'i", + "'&(iexcl|#161);'i", + "'&(cent|#162);'i", + "'&(pound|#163);'i", + "'&(copy|#169);'i" + ); + $replace = array( "", + "", + "\\1", + "\"", + "&", + "<", + ">", + " ", + chr(161), + chr(162), + chr(163), + chr(169)); + + $text = preg_replace($search,$replace,$document); + + return $text; + } + +/*======================================================================*\ + Function: _expandlinks + Purpose: expand each link into a fully qualified URL + Input: $links the links to qualify + $URI the full URI to get the base from + Output: $expandedLinks the expanded links +\*======================================================================*/ + + function _expandlinks($links,$URI) + { + + preg_match("/^[^\?]+/",$URI,$match); + + $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); + + $search = array( "|^http://".preg_quote($this->host)."|i", + "|^(?!http://)(\/)?(?!mailto:)|i", + "|/\./|", + "|/[^\/]+/\.\./|" + ); + + $replace = array( "", + $match."/", + "/", + "/" + ); + + $expandedLinks = preg_replace($search,$replace,$links); + + return $expandedLinks; + } + +/*======================================================================*\ + Function: _httprequest + Purpose: go get the http data from the server + Input: $url the url to fetch + $fp the current open file pointer + $URI the full URI + $body body contents to send if any (POST) + Output: +\*======================================================================*/ + + function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") + { + if($this->passcookies && $this->_redirectaddr) + $this->setcookies(); + + $URI_PARTS = parse_url($URI); + if(empty($url)) + $url = "/"; + $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; + if(!empty($this->agent)) + $headers .= "User-Agent: ".$this->agent."\r\n"; + if(!empty($this->host) && !isset($this->rawheaders['Host'])) + $headers .= "Host: ".$this->host."\r\n"; + if(!empty($this->accept)) + $headers .= "Accept: ".$this->accept."\r\n"; + + if($this->use_gzip) { + // make sure PHP was built with --with-zlib + // and we can handle gzipp'ed data + if ( function_exists(gzinflate) ) { + $headers .= "Accept-encoding: gzip\r\n"; + } + else { + trigger_error( + "use_gzip is on, but PHP was built without zlib support.". + " Requesting file(s) without gzip encoding.", + E_USER_NOTICE); + } + } + + if(!empty($this->referer)) + $headers .= "Referer: ".$this->referer."\r\n"; + if(!empty($this->cookies)) + { + if(!is_array($this->cookies)) + $this->cookies = (array)$this->cookies; + + reset($this->cookies); + if ( count($this->cookies) > 0 ) { + $cookie_headers .= 'Cookie: '; + foreach ( $this->cookies as $cookieKey => $cookieVal ) { + $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; + } + $headers .= substr($cookie_headers,0,-2) . "\r\n"; + } + } + if(!empty($this->rawheaders)) + { + if(!is_array($this->rawheaders)) + $this->rawheaders = (array)$this->rawheaders; + while(list($headerKey,$headerVal) = each($this->rawheaders)) + $headers .= $headerKey.": ".$headerVal."\r\n"; + } + if(!empty($content_type)) { + $headers .= "Content-type: $content_type"; + if ($content_type == "multipart/form-data") + $headers .= "; boundary=".$this->_mime_boundary; + $headers .= "\r\n"; + } + if(!empty($body)) + $headers .= "Content-length: ".strlen($body)."\r\n"; + if(!empty($this->user) || !empty($this->pass)) + $headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n"; + + $headers .= "\r\n"; + + // set the read timeout if needed + if ($this->read_timeout > 0) + socket_set_timeout($fp, $this->read_timeout); + $this->timed_out = false; + + fwrite($fp,$headers.$body,strlen($headers.$body)); + + $this->_redirectaddr = false; + unset($this->headers); + + // content was returned gzip encoded? + $is_gzipped = false; + + while($currentHeader = fgets($fp,$this->_maxlinelen)) + { + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) + { + $this->status=-100; + return false; + } + + // if($currentHeader == "\r\n") + if(preg_match("/^\r?\n$/", $currentHeader) ) + break; + + // if a header begins with Location: or URI:, set the redirect + if(preg_match("/^(Location:|URI:)/i",$currentHeader)) + { + // get URL portion of the redirect + preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches); + // look for :// in the Location header to see if hostname is included + if(!preg_match("|\:\/\/|",$matches[2])) + { + // no host in the path, so prepend + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; + // eliminate double slash + if(!preg_match("|^/|",$matches[2])) + $this->_redirectaddr .= "/".$matches[2]; + else + $this->_redirectaddr .= $matches[2]; + } + else + $this->_redirectaddr = $matches[2]; + } + + if(preg_match("|^HTTP/|",$currentHeader)) + { + if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status)) + { + $this->status= $status[1]; + } + $this->response_code = $currentHeader; + } + + if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) { + $is_gzipped = true; + } + + $this->headers[] = $currentHeader; + } + + # $results = fread($fp, $this->maxlength); + $results = ""; + while ( $data = fread($fp, $this->maxlength) ) { + $results .= $data; + if ( + strlen($results) > $this->maxlength ) { + break; + } + } + + // gunzip + if ( $is_gzipped ) { + // per http://www.php.net/manual/en/function.gzencode.php + $results = substr($results, 10); + $results = gzinflate($results); + } + + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) + { + $this->status=-100; + return false; + } + + // check if there is a a redirect meta tag + + if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) + { + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); + } + + // have we hit our frame depth and is there frame src to fetch? + if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) + { + $this->results[] = $results; + for($x=0; $x<count($match[1]); $x++) + $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); + } + // have we already fetched framed content? + elseif(is_array($this->results)) + $this->results[] = $results; + // no framed content + else + $this->results = $results; + + return true; + } + +/*======================================================================*\ + Function: _httpsrequest + Purpose: go get the https data from the server using curl + Input: $url the url to fetch + $URI the full URI + $body body contents to send if any (POST) + Output: +\*======================================================================*/ + + function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") + { + if($this->passcookies && $this->_redirectaddr) + $this->setcookies(); + + $headers = array(); + + $URI_PARTS = parse_url($URI); + if(empty($url)) + $url = "/"; + // GET ... header not needed for curl + //$headers[] = $http_method." ".$url." ".$this->_httpversion; + if(!empty($this->agent)) + $headers[] = "User-Agent: ".$this->agent; + if(!empty($this->host)) + $headers[] = "Host: ".$this->host; + if(!empty($this->accept)) + $headers[] = "Accept: ".$this->accept; + if(!empty($this->referer)) + $headers[] = "Referer: ".$this->referer; + if(!empty($this->cookies)) + { + if(!is_array($this->cookies)) + $this->cookies = (array)$this->cookies; + + reset($this->cookies); + if ( count($this->cookies) > 0 ) { + $cookie_str = 'Cookie: '; + foreach ( $this->cookies as $cookieKey => $cookieVal ) { + $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; + } + $headers[] = substr($cookie_str,0,-2); + } + } + if(!empty($this->rawheaders)) + { + if(!is_array($this->rawheaders)) + $this->rawheaders = (array)$this->rawheaders; + while(list($headerKey,$headerVal) = each($this->rawheaders)) + $headers[] = $headerKey.": ".$headerVal; + } + if(!empty($content_type)) { + if ($content_type == "multipart/form-data") + $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; + else + $headers[] = "Content-type: $content_type"; + } + if(!empty($body)) + $headers[] = "Content-length: ".strlen($body); + if(!empty($this->user) || !empty($this->pass)) + $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); + + for($curr_header = 0; $curr_header < count($headers); $curr_header++) + $cmdline_params .= " -H \"".$headers[$curr_header]."\""; + + if(!empty($body)) + $cmdline_params .= " -d \"$body\""; + + if($this->read_timeout > 0) + $cmdline_params .= " -m ".$this->read_timeout; + + $headerfile = uniqid(time()); + + # accept self-signed certs + $cmdline_params .= " -k"; + exec($this->curl_path." -D \"/tmp/$headerfile\"".$cmdline_params." ".$URI,$results,$return); + + if($return) + { + $this->error = "Error: cURL could not retrieve the document, error $return."; + return false; + } + + + $results = implode("\r\n",$results); + + $result_headers = file("/tmp/$headerfile"); + + $this->_redirectaddr = false; + unset($this->headers); + + for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) + { + + // if a header begins with Location: or URI:, set the redirect + if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) + { + // get URL portion of the redirect + preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches); + // look for :// in the Location header to see if hostname is included + if(!preg_match("|\:\/\/|",$matches[2])) + { + // no host in the path, so prepend + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; + // eliminate double slash + if(!preg_match("|^/|",$matches[2])) + $this->_redirectaddr .= "/".$matches[2]; + else + $this->_redirectaddr .= $matches[2]; + } + else + $this->_redirectaddr = $matches[2]; + } + + if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) + { + $this->response_code = $result_headers[$currentHeader]; + if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match)) + { + $this->status= $match[1]; + } + } + $this->headers[] = $result_headers[$currentHeader]; + } + + // check if there is a a redirect meta tag + + if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) + { + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); + } + + // have we hit our frame depth and is there frame src to fetch? + if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) + { + $this->results[] = $results; + for($x=0; $x<count($match[1]); $x++) + $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); + } + // have we already fetched framed content? + elseif(is_array($this->results)) + $this->results[] = $results; + // no framed content + else + $this->results = $results; + + unlink("/tmp/$headerfile"); + + return true; + } + +/*======================================================================*\ + Function: setcookies() + Purpose: set cookies for a redirection +\*======================================================================*/ + + function setcookies() + { + for($x=0; $x<count($this->headers); $x++) + { + if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match)) + $this->cookies[$match[1]] = $match[2]; + } + } + + +/*======================================================================*\ + Function: _check_timeout + Purpose: checks whether timeout has occurred + Input: $fp file pointer +\*======================================================================*/ + + function _check_timeout($fp) + { + if ($this->read_timeout > 0) { + $fp_status = socket_get_status($fp); + if ($fp_status["timed_out"]) { + $this->timed_out = true; + return true; + } + } + return false; + } + +/*======================================================================*\ + Function: _connect + Purpose: make a socket connection + Input: $fp file pointer +\*======================================================================*/ + + function _connect(&$fp) + { + if(!empty($this->proxy_host) && !empty($this->proxy_port)) + { + $this->_isproxy = true; + $host = $this->proxy_host; + $port = $this->proxy_port; + } + else + { + $host = $this->host; + $port = $this->port; + } + + $this->status = 0; + + if($fp = fsockopen( + $host, + $port, + $errno, + $errstr, + $this->_fp_timeout + )) + { + // socket connection succeeded + + return true; + } + else + { + // socket connection failed + $this->status = $errno; + switch($errno) + { + case -3: + $this->error="socket creation failed (-3)"; + case -4: + $this->error="dns lookup failure (-4)"; + case -5: + $this->error="connection refused or timed out (-5)"; + default: + $this->error="connection failed (".$errno.")"; + } + return false; + } + } +/*======================================================================*\ + Function: _disconnect + Purpose: disconnect a socket connection + Input: $fp file pointer +\*======================================================================*/ + + function _disconnect($fp) + { + return(fclose($fp)); + } + + +/*======================================================================*\ + Function: _prepare_post_body + Purpose: Prepare post body according to encoding type + Input: $formvars - form variables + $formfiles - form upload files + Output: post body +\*======================================================================*/ + + function _prepare_post_body($formvars, $formfiles) + { + settype($formvars, "array"); + settype($formfiles, "array"); + + if (count($formvars) == 0 && count($formfiles) == 0) + return; + + switch ($this->_submit_type) { + case "application/x-www-form-urlencoded": + reset($formvars); + while(list($key,$val) = each($formvars)) { + if (is_array($val) || is_object($val)) { + while (list($cur_key, $cur_val) = each($val)) { + $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; + } + } else + $postdata .= urlencode($key)."=".urlencode($val)."&"; + } + break; + + case "multipart/form-data": + $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); + + reset($formvars); + while(list($key,$val) = each($formvars)) { + if (is_array($val) || is_object($val)) { + while (list($cur_key, $cur_val) = each($val)) { + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; + $postdata .= "$cur_val\r\n"; + } + } else { + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; + $postdata .= "$val\r\n"; + } + } + + reset($formfiles); + while (list($field_name, $file_names) = each($formfiles)) { + settype($file_names, "array"); + while (list(, $file_name) = each($file_names)) { + if (!is_readable($file_name)) continue; + + $fp = fopen($file_name, "r"); + $file_content = fread($fp, filesize($file_name)); + fclose($fp); + $base_name = basename($file_name); + + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; + $postdata .= "$file_content\r\n"; + } + } + $postdata .= "--".$this->_mime_boundary."--\r\n"; + break; + } + + return $postdata; + } +} + +?> diff --git a/inc/magpie/rss_cache.inc b/inc/magpie/rss_cache.inc new file mode 100644 index 000000000..5b4e37db3 --- /dev/null +++ b/inc/magpie/rss_cache.inc @@ -0,0 +1,184 @@ +<?php +/* + * Project: MagpieRSS: a simple RSS integration tool + * File: rss_cache.inc, a simple, rolling(no GC), cache + * for RSS objects, keyed on URL. + * Author: Kellan Elliott-McCrea <kellan@protest.net> + * Version: 0.51 + * License: GPL + * + * The lastest version of MagpieRSS can be obtained from: + * http://magpierss.sourceforge.net + * + * For questions, help, comments, discussion, etc., please join the + * Magpie mailing list: + * http://lists.sourceforge.net/lists/listinfo/magpierss-general + * + */ + +class RSSCache { + var $BASE_CACHE = './cache'; // where the cache files are stored + var $MAX_AGE = 3600; // when are files stale, default one hour + var $ERROR = ""; // accumulate error messages + + function RSSCache ($base='', $age='') { + if ( $base ) { + $this->BASE_CACHE = $base; + } + if ( $age ) { + $this->MAX_AGE = $age; + } + + // attempt to make the cache directory + if ( ! @file_exists( $this->BASE_CACHE ) ) { + $status = @mkdir( $this->BASE_CACHE, 0755 ); + + // if make failed + if ( ! $status ) { + $this->error( + "Cache couldn't make dir '" . $this->BASE_CACHE . "'." + ); + } + } + } + +/*=======================================================================*\ + Function: set + Purpose: add an item to the cache, keyed on url + Input: url from wich the rss file was fetched + Output: true on sucess +\*=======================================================================*/ + function set ($url, $rss) { + $this->ERROR = ""; + $cache_file = $this->file_name( $url ); + $fp = @fopen( $cache_file, 'w' ); + + if ( ! $fp ) { + $this->error( + "Cache unable to open file for writing: $cache_file" + ); + return 0; + } + + + $data = $this->serialize( $rss ); + fwrite( $fp, $data ); + fclose( $fp ); + + return $cache_file; + } + +/*=======================================================================*\ + Function: get + Purpose: fetch an item from the cache + Input: url from wich the rss file was fetched + Output: cached object on HIT, false on MISS +\*=======================================================================*/ + function get ($url) { + $this->ERROR = ""; + $cache_file = $this->file_name( $url ); + + if ( ! @file_exists( $cache_file ) ) { + $this->debug( + "Cache doesn't contain: $url (cache file: $cache_file)" + ); + return 0; + } + + $fp = @fopen($cache_file, 'r'); + if ( ! $fp ) { + $this->error( + "Failed to open cache file for reading: $cache_file" + ); + return 0; + } + + $data = fread( $fp, filesize($cache_file) ); + $rss = $this->unserialize( $data ); + + return $rss; + } + +/*=======================================================================*\ + Function: check_cache + Purpose: check a url for membership in the cache + and whether the object is older then MAX_AGE (ie. STALE) + Input: url from wich the rss file was fetched + Output: cached object on HIT, false on MISS +\*=======================================================================*/ + function check_cache ( $url ) { + $this->ERROR = ""; + $filename = $this->file_name( $url ); + + if ( @file_exists( $filename ) ) { + // find how long ago the file was added to the cache + // and whether that is longer then MAX_AGE + $mtime = filemtime( $filename ); + $age = time() - $mtime; + if ( $this->MAX_AGE > $age ) { + // object exists and is current + return 'HIT'; + } + else { + // object exists but is old + return 'STALE'; + } + } + else { + // object does not exist + return 'MISS'; + } + } + +/*=======================================================================*\ + Function: serialize +\*=======================================================================*/ + function serialize ( $rss ) { + return serialize( $rss ); + } + +/*=======================================================================*\ + Function: unserialize +\*=======================================================================*/ + function unserialize ( $data ) { + return unserialize( $data ); + } + +/*=======================================================================*\ + Function: file_name + Purpose: map url to location in cache + Input: url from wich the rss file was fetched + Output: a file name +\*=======================================================================*/ + function file_name ($url) { + $filename = md5( $url ); + return join( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) ); + } + +/*=======================================================================*\ + Function: error + Purpose: register error +\*=======================================================================*/ + function error ($errormsg, $lvl=E_USER_WARNING) { + // append PHP's error message if track_errors enabled + if ( isset($php_errormsg) ) { + $errormsg .= " ($php_errormsg)"; + } + $this->ERROR = $errormsg; + if ( MAGPIE_DEBUG ) { + trigger_error( $errormsg, $lvl); + } + else { + error_log( $errormsg, 0); + } + } + + function debug ($debugmsg, $lvl=E_USER_NOTICE) { + if ( MAGPIE_DEBUG ) { + $this->error("MagpieRSS [debug] $debugmsg", $lvl); + } + } + +} + +?> diff --git a/inc/magpie/rss_fetch.inc b/inc/magpie/rss_fetch.inc new file mode 100644 index 000000000..5c559baef --- /dev/null +++ b/inc/magpie/rss_fetch.inc @@ -0,0 +1,438 @@ +<?php +/* + * Project: MagpieRSS: a simple RSS integration tool + * File: rss_fetch.inc, a simple functional interface + to fetching and parsing RSS files, via the + function fetch_rss() + * Author: Kellan Elliott-McCrea <kellan@protest.net> + * License: GPL + * + * The lastest version of MagpieRSS can be obtained from: + * http://magpierss.sourceforge.net + * + * For questions, help, comments, discussion, etc., please join the + * Magpie mailing list: + * magpierss-general@lists.sourceforge.net + * + */ + +// Setup MAGPIE_DIR for use on hosts that don't include +// the current path in include_path. +// with thanks to rajiv and smarty +if (!defined('DIR_SEP')) { + define('DIR_SEP', DIRECTORY_SEPARATOR); +} + +if (!defined('MAGPIE_DIR')) { + define('MAGPIE_DIR', dirname(__FILE__) . DIR_SEP); +} + +require_once( MAGPIE_DIR . 'rss_parse.inc' ); +require_once( MAGPIE_DIR . 'rss_cache.inc' ); + +// for including 3rd party libraries +define('MAGPIE_EXTLIB', MAGPIE_DIR . 'extlib' . DIR_SEP); +require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc'); + + +/* + * CONSTANTS - redefine these in your script to change the + * behaviour of fetch_rss() currently, most options effect the cache + * + * MAGPIE_CACHE_ON - Should Magpie cache parsed RSS objects? + * For me a built in cache was essential to creating a "PHP-like" + * feel to Magpie, see rss_cache.inc for rationale + * + * + * MAGPIE_CACHE_DIR - Where should Magpie cache parsed RSS objects? + * This should be a location that the webserver can write to. If this + * directory does not already exist Mapie will try to be smart and create + * it. This will often fail for permissions reasons. + * + * + * MAGPIE_CACHE_AGE - How long to store cached RSS objects? In seconds. + * + * + * MAGPIE_CACHE_FRESH_ONLY - If remote fetch fails, throw error + * instead of returning stale object? + * + * MAGPIE_DEBUG - Display debugging notices? + * +*/ + + +/*=======================================================================*\ + Function: fetch_rss: + Purpose: return RSS object for the give url + maintain the cache + Input: url of RSS file + Output: parsed RSS object (see rss_parse.inc) + + NOTES ON CACHEING: + If caching is on (MAGPIE_CACHE_ON) fetch_rss will first check the cache. + + NOTES ON RETRIEVING REMOTE FILES: + If conditional gets are on (MAGPIE_CONDITIONAL_GET_ON) fetch_rss will + return a cached object, and touch the cache object upon recieving a + 304. + + NOTES ON FAILED REQUESTS: + If there is an HTTP error while fetching an RSS object, the cached + version will be return, if it exists (and if MAGPIE_CACHE_FRESH_ONLY is off) +\*=======================================================================*/ + +define('MAGPIE_VERSION', '0.61'); + +$MAGPIE_ERROR = ""; + +function fetch_rss ($url) { + // initialize constants + init(); + + if ( !isset($url) ) { + error("fetch_rss called without a url"); + return false; + } + + // if cache is disabled + if ( !MAGPIE_CACHE_ON ) { + // fetch file, and parse it + $resp = _fetch_remote_file( $url ); + if ( is_success( $resp->status ) ) { + return _response_to_rss( $resp ); + } + else { + error("Failed to fetch $url and cache is off"); + return false; + } + } + // else cache is ON + else { + // Flow + // 1. check cache + // 2. if there is a hit, make sure its fresh + // 3. if cached obj fails freshness check, fetch remote + // 4. if remote fails, return stale object, or error + + $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); + + if (MAGPIE_DEBUG and $cache->ERROR) { + debug($cache->ERROR, E_USER_WARNING); + } + + + $cache_status = 0; // response of check_cache + $request_headers = array(); // HTTP headers to send with fetch + $rss = 0; // parsed RSS object + $errormsg = 0; // errors, if any + + if (!$cache->ERROR) { + // return cache HIT, MISS, or STALE + $cache_status = $cache->check_cache( $url ); + } + + // if object cached, and cache is fresh, return cached obj + if ( $cache_status == 'HIT' ) { + $rss = $cache->get( $url ); + if ( isset($rss) and $rss ) { + $rss->from_cache = 1; + if ( MAGPIE_DEBUG > 1) { + debug("MagpieRSS: Cache HIT", E_USER_NOTICE); + } + return $rss; + } + } + + // else attempt a conditional get + + // setup headers + if ( $cache_status == 'STALE' ) { + $rss = $cache->get( $url ); + if ( $rss->etag and $rss->last_modified ) { + $request_headers['If-None-Match'] = $rss->etag; + $request_headers['If-Last-Modified'] = $rss->last_modified; + } + } + + $resp = _fetch_remote_file( $url, $request_headers ); + + if (isset($resp) and $resp) { + if ($resp->status == '304' ) { + // we have the most current copy + if ( MAGPIE_DEBUG > 1) { + debug("Got 304 for $url"); + } + // reset cache on 304 (at minutillo insistent prodding) + $cache->set($url, $rss); + return $rss; + } + elseif ( is_success( $resp->status ) ) { + $rss = _response_to_rss( $resp ); + if ( $rss ) { + if (MAGPIE_DEBUG > 1) { + debug("Fetch successful"); + } + // add object to cache + $cache->set( $url, $rss ); + return $rss; + } + } + else { + $errormsg = "Failed to fetch $url. "; + if ( $resp->error ) { + # compensate for Snoopy's annoying habbit to tacking + # on '\n' + $http_error = substr($resp->error, 0, -2); + $errormsg .= "(HTTP Error: $http_error)"; + } + else { + $errormsg .= "(HTTP Response: " . $resp->response_code .')'; + } + } + } + else { + $errormsg = "Unable to retrieve RSS file for unknown reasons."; + } + + // else fetch failed + + // attempt to return cached object + if ($rss) { + if ( MAGPIE_DEBUG ) { + debug("Returning STALE object for $url"); + } + return $rss; + } + + // else we totally failed + error( $errormsg ); + + return false; + + } // end if ( !MAGPIE_CACHE_ON ) { +} // end fetch_rss() + +/*=======================================================================*\ + Function: error + Purpose: set MAGPIE_ERROR, and trigger error +\*=======================================================================*/ + +function error ($errormsg, $lvl=E_USER_WARNING) { + global $MAGPIE_ERROR; + + // append PHP's error message if track_errors enabled + if ( isset($php_errormsg) ) { + $errormsg .= " ($php_errormsg)"; + } + if ( $errormsg ) { + $errormsg = "MagpieRSS: $errormsg"; + $MAGPIE_ERROR = $errormsg; + trigger_error( $errormsg, $lvl); + } +} + +function debug ($debugmsg, $lvl=E_USER_NOTICE) { + trigger_error("MagpieRSS [debug] $debugmsg", $lvl); +} + +/*=======================================================================*\ + Function: magpie_error + Purpose: accessor for the magpie error variable +\*=======================================================================*/ +function magpie_error ($errormsg="") { + global $MAGPIE_ERROR; + + if ( isset($errormsg) and $errormsg ) { + $MAGPIE_ERROR = $errormsg; + } + + return $MAGPIE_ERROR; +} + +/*=======================================================================*\ + Function: _fetch_remote_file + Purpose: retrieve an arbitrary remote file + Input: url of the remote file + headers to send along with the request (optional) + Output: an HTTP response object (see Snoopy.class.inc) +\*=======================================================================*/ +function _fetch_remote_file ($url, $headers = "" ) { + // Snoopy is an HTTP client in PHP + $client = new Snoopy(); + $client->agent = MAGPIE_USER_AGENT; + $client->read_timeout = MAGPIE_FETCH_TIME_OUT; + $client->use_gzip = MAGPIE_USE_GZIP; + if (is_array($headers) ) { + $client->rawheaders = $headers; + } + + @$client->fetch($url); + return $client; + +} + +/*=======================================================================*\ + Function: _response_to_rss + Purpose: parse an HTTP response object into an RSS object + Input: an HTTP response object (see Snoopy) + Output: parsed RSS object (see rss_parse) +\*=======================================================================*/ +function _response_to_rss ($resp) { + $rss = new MagpieRSS( $resp->results ); + + // if RSS parsed successfully + if ( $rss and !$rss->ERROR) { + + // find Etag, and Last-Modified + foreach($resp->headers as $h) { + // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" + if (strpos($h, ": ")) { + list($field, $val) = explode(": ", $h, 2); + } + else { + $field = $h; + $val = ""; + } + + if ( $field == 'ETag' ) { + $rss->etag = $val; + } + + if ( $field == 'Last-Modified' ) { + $rss->last_modified = $val; + } + } + + return $rss; + } // else construct error message + else { + $errormsg = "Failed to parse RSS file."; + + if ($rss) { + $errormsg .= " (" . $rss->ERROR . ")"; + } + error($errormsg); + + return false; + } // end if ($rss and !$rss->error) +} + +/*=======================================================================*\ + Function: init + Purpose: setup constants with default values + check for user overrides +\*=======================================================================*/ +function init () { + if ( defined('MAGPIE_INITALIZED') ) { + return; + } + else { + define('MAGPIE_INITALIZED', 1); + } + + if ( !defined('MAGPIE_CACHE_ON') ) { + define('MAGPIE_CACHE_ON', 1); + } + + if ( !defined('MAGPIE_CACHE_DIR') ) { + define('MAGPIE_CACHE_DIR', './cache'); + } + + if ( !defined('MAGPIE_CACHE_AGE') ) { + define('MAGPIE_CACHE_AGE', 60*60); // one hour + } + + if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { + define('MAGPIE_CACHE_FRESH_ONLY', 0); + } + + if ( !defined('MAGPIE_DEBUG') ) { + define('MAGPIE_DEBUG', 0); + } + + if ( !defined('MAGPIE_USER_AGENT') ) { + $ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net'; + + if ( MAGPIE_CACHE_ON ) { + $ua = $ua . ')'; + } + else { + $ua = $ua . '; No cache)'; + } + + define('MAGPIE_USER_AGENT', $ua); + } + + if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { + define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout + } + + // use gzip encoding to fetch rss files if supported? + if ( !defined('MAGPIE_USE_GZIP') ) { + define('MAGPIE_USE_GZIP', true); + } +} + +// NOTE: the following code should really be in Snoopy, or at least +// somewhere other then rss_fetch! + +/*=======================================================================*\ + HTTP STATUS CODE PREDICATES + These functions attempt to classify an HTTP status code + based on RFC 2616 and RFC 2518. + + All of them take an HTTP status code as input, and return true or false + + All this code is adapted from LWP's HTTP::Status. +\*=======================================================================*/ + + +/*=======================================================================*\ + Function: is_info + Purpose: return true if Informational status code +\*=======================================================================*/ +function is_info ($sc) { + return $sc >= 100 && $sc < 200; +} + +/*=======================================================================*\ + Function: is_success + Purpose: return true if Successful status code +\*=======================================================================*/ +function is_success ($sc) { + return $sc >= 200 && $sc < 300; +} + +/*=======================================================================*\ + Function: is_redirect + Purpose: return true if Redirection status code +\*=======================================================================*/ +function is_redirect ($sc) { + return $sc >= 300 && $sc < 400; +} + +/*=======================================================================*\ + Function: is_error + Purpose: return true if Error status code +\*=======================================================================*/ +function is_error ($sc) { + return $sc >= 400 && $sc < 600; +} + +/*=======================================================================*\ + Function: is_client_error + Purpose: return true if Error status code, and its a client error +\*=======================================================================*/ +function is_client_error ($sc) { + return $sc >= 400 && $sc < 500; +} + +/*=======================================================================*\ + Function: is_client_error + Purpose: return true if Error status code, and its a server error +\*=======================================================================*/ +function is_server_error ($sc) { + return $sc >= 500 && $sc < 600; +} + +?> diff --git a/inc/magpie/rss_parse.inc b/inc/magpie/rss_parse.inc new file mode 100644 index 000000000..337dc3596 --- /dev/null +++ b/inc/magpie/rss_parse.inc @@ -0,0 +1,547 @@ +<?php +/* + * Project: MagpieRSS: a simple RSS integration tool + * File: rss_parse.inc - parse an RSS or Atom feed + * return as a simple object. + * + * Handles RSS 0.9x, RSS 2.0, RSS 1.0, and Atom 0.3 + * + * The lastest version of MagpieRSS can be obtained from: + * http://magpierss.sourceforge.net + * + * For questions, help, comments, discussion, etc., please join the + * Magpie mailing list: + * magpierss-general@lists.sourceforge.net + * + * Author: Kellan Elliott-McCrea <kellan@protest.net> + * Version: 0.6a + * License: GPL + * + * + * ABOUT MAGPIE's APPROACH TO PARSING: + * - Magpie is based on expat, an XML parser, and therefore will only parse + * valid XML files. This includes all properly constructed RSS or Atom. + * + * - Magpie is an inclusive parser. It will include any elements that + * it can turn into a key value pair in the parsed feed object it returns. + * + * - Magpie supports namespaces, and will return any elements found in a + * namespace in a sub-array, with the key point to that array being the + * namespace prefix. + * (e.g. if an item contains a <dc:date> element, then that date can + * be accessed at $item['dc']['date'] + * + * - Magpie supports nested elements by combining the names. If an item + * includes XML like: + * <author> + * <name>Kellan</name> + * </author> + * + * The name field is accessible at $item['author_name'] + * + * - Magpie makes no attempt validate a feed beyond insuring that it + * is valid XML. + * RSS validators are readily available on the web at: + * http://feeds.archive.org/validator/ + * http://www.ldodds.com/rss_validator/1.0/validator.html + * + * + * EXAMPLE PARSED RSS ITEM: + * + * Magpie tries to parse RSS into easy to use PHP datastructures. + * + * For example, Magpie on encountering (a rather complex) RSS 1.0 item entry: + * + * <item rdf:about="http://protest.net/NorthEast/calendrome.cgi?span=event&ID=210257"> + * <title>Weekly Peace Vigil</title> + * <link>http://protest.net/NorthEast/calendrome.cgi?span=event&ID=210257</link> + * <description>Wear a white ribbon</description> + * <dc:subject>Peace</dc:subject> + * <ev:startdate>2002-06-01T11:00:00</ev:startdate> + * <ev:location>Northampton, MA</ev:location> + * <ev:type>Protest</ev:type> + * </item> + * + * Would transform it into the following associative array, and push it + * onto the array $rss-items + * + * array( + * title => 'Weekly Peace Vigil', + * link => 'http://protest.net/NorthEast/calendrome.cgi?span=event&ID=210257', + * description => 'Wear a white ribbon', + * dc => array ( + * subject => 'Peace' + * ), + * ev => array ( + * startdate => '2002-06-01T11:00:00', + * enddate => '2002-06-01T12:00:00', + * type => 'Protest', + * location => 'Northampton, MA' + * ) + * ) + * + * + * + * A FEW NOTES ON PARSING Atom FEEDS + * + * Atom support is considered alpha. Atom elements will be often be available + * as their RSS equivalent, summary is available as description for example. + * + * Elements of mode=xml, as flattened into a single string, just as if they + * had been wrapped in a CDATA container. + * + * See: http://laughingmeme.org/archives/001676.html + * + */ + +define('RSS', 'RSS'); +define('ATOM', 'Atom'); + + +class MagpieRSS { + /* + * Hybrid parser, and object. (probably a bad idea! :) + * + * Useage Example: + * + * $some_rss = "<?xml version="1.0"...... + * + * $rss = new MagpieRSS( $some_rss ); + * + * // print rss chanel title + * echo $rss->channel['title']; + * + * // print the title of each item + * foreach ($rss->items as $item ) { + * echo $item[title]; + * } + * + * see: rss_fetch.inc for a simpler interface + */ + + var $parser; + + var $current_item = array(); // item currently being parsed + var $items = array(); // collection of parsed items + var $channel = array(); // hash of channel fields + var $textinput = array(); + var $image = array(); + var $feed_type; + var $feed_version; + + // parser variables + var $stack = array(); // parser stack + var $inchannel = false; + var $initem = false; + var $incontent = false; // if in Atom <content mode="xml"> field + var $intextinput = false; + var $inimage = false; + var $current_field = ''; + var $current_namespace = false; + + var $ERROR = ""; + + var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); +/*======================================================================*\ + Function: MagpieRSS + Purpose: Constructor, sets up XML parser,parses source, + and populates object.. + Input: String containing the RSS to be parsed +\*======================================================================*/ + function MagpieRSS ($source) { + + # if PHP xml isn't compiled in, die + # + if (!function_exists('xml_parser_create')) { + $this->error( "Failed to load PHP's XML Extension. " . + "http://www.php.net/manual/en/ref.xml.php", + E_USER_ERROR ); + } + + $parser = @xml_parser_create(); + + if (!is_resource($parser)) + { + $this->error( "Failed to create an instance of PHP's XML parser. " . + "http://www.php.net/manual/en/ref.xml.php", + E_USER_ERROR ); + } + + + $this->parser = $parser; + + # pass in parser, and a reference to this object + # setup handlers + # + xml_set_object( $this->parser, $this ); + xml_set_element_handler($this->parser, + 'feed_start_element', 'feed_end_element' ); + + xml_set_character_data_handler( $this->parser, 'feed_cdata' ); + + $status = xml_parse( $this->parser, $source ); + + if (! $status ) { + $errorcode = xml_get_error_code( $this->parser ); + if ( $errorcode != XML_ERROR_NONE ) { + $xml_error = xml_error_string( $errorcode ); + $error_line = xml_get_current_line_number($this->parser); + $error_col = xml_get_current_column_number($this->parser); + $errormsg = "$xml_error at line $error_line, column $error_col"; + + $this->error( $errormsg ); + } + } + + xml_parser_free( $this->parser ); + + $this->normalize(); + } + + function feed_start_element($p, $element, &$attrs) { + $el = $element = strtolower($element); + $attrs = array_change_key_case($attrs, CASE_LOWER); + + // check for a namespace, and split if found + $ns = false; + if ( strpos( $element, ':' ) ) { + list($ns, $el) = split( ':', $element, 2); + } + if ( $ns and $ns != 'rdf' ) { + $this->current_namespace = $ns; + } + + # if feed type isn't set, then this is first element of feed + # identify feed from root element + # + if (!isset($this->feed_type) ) { + if ( $el == 'rdf' ) { + $this->feed_type = RSS; + $this->feed_version = '1.0'; + } + elseif ( $el == 'rss' ) { + $this->feed_type = RSS; + $this->feed_version = $attrs['version']; + } + elseif ( $el == 'feed' ) { + $this->feed_type = ATOM; + $this->feed_version = $attrs['version']; + $this->inchannel = true; + } + return; + } + + if ( $el == 'channel' ) + { + $this->inchannel = true; + } + elseif ($el == 'item' or $el == 'entry' ) + { + $this->initem = true; + if ( isset($attrs['rdf:about']) ) { + $this->current_item['about'] = $attrs['rdf:about']; + } + } + + // if we're in the default namespace of an RSS feed, + // record textinput or image fields + elseif ( + $this->feed_type == RSS and + $this->current_namespace == '' and + $el == 'textinput' ) + { + $this->intextinput = true; + } + + elseif ( + $this->feed_type == RSS and + $this->current_namespace == '' and + $el == 'image' ) + { + $this->inimage = true; + } + + # handle atom content constructs + elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) + { + // avoid clashing w/ RSS mod_content + if ($el == 'content' ) { + $el = 'atom_content'; + } + + $this->incontent = $el; + + + } + + // if inside an Atom content construct (e.g. content or summary) field treat tags as text + elseif ($this->feed_type == ATOM and $this->incontent ) + { + // if tags are inlined, then flatten + $attrs_str = join(' ', + array_map('map_attrs', + array_keys($attrs), + array_values($attrs) ) ); + + $this->append_content( "<$element $attrs_str>" ); + + array_unshift( $this->stack, $el ); + } + + // Atom support many links per containging element. + // Magpie treats link elements of type rel='alternate' + // as being equivalent to RSS's simple link element. + // + elseif ($this->feed_type == ATOM and $el == 'link' ) + { + if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) + { + $link_el = 'link'; + } + else { + $link_el = 'link_' . $attrs['rel']; + } + + $this->append($link_el, $attrs['href']); + } + // set stack[0] to current element + else { + array_unshift($this->stack, $el); + } + } + + + + function feed_cdata ($p, $text) { + + if ($this->feed_type == ATOM and $this->incontent) + { + $this->append_content( $text ); + } + else { + $current_el = join('_', array_reverse($this->stack)); + $this->append($current_el, $text); + } + } + + function feed_end_element ($p, $el) { + $el = strtolower($el); + + if ( $el == 'item' or $el == 'entry' ) + { + $this->items[] = $this->current_item; + $this->current_item = array(); + $this->initem = false; + } + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) + { + $this->intextinput = false; + } + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) + { + $this->inimage = false; + } + elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) + { + $this->incontent = false; + } + elseif ($el == 'channel' or $el == 'feed' ) + { + $this->inchannel = false; + } + elseif ($this->feed_type == ATOM and $this->incontent ) { + // balance tags properly + // note: i don't think this is actually neccessary + if ( $this->stack[0] == $el ) + { + $this->append_content("</$el>"); + } + else { + $this->append_content("<$el />"); + } + + array_shift( $this->stack ); + } + else { + array_shift( $this->stack ); + } + + $this->current_namespace = false; + } + + function concat (&$str1, $str2="") { + if (!isset($str1) ) { + $str1=""; + } + $str1 .= $str2; + } + + + + function append_content($text) { + if ( $this->initem ) { + $this->concat( $this->current_item[ $this->incontent ], $text ); + } + elseif ( $this->inchannel ) { + $this->concat( $this->channel[ $this->incontent ], $text ); + } + } + + // smart append - field and namespace aware + function append($el, $text) { + if (!$el) { + return; + } + if ( $this->current_namespace ) + { + if ( $this->initem ) { + $this->concat( + $this->current_item[ $this->current_namespace ][ $el ], $text); + } + elseif ($this->inchannel) { + $this->concat( + $this->channel[ $this->current_namespace][ $el ], $text ); + } + elseif ($this->intextinput) { + $this->concat( + $this->textinput[ $this->current_namespace][ $el ], $text ); + } + elseif ($this->inimage) { + $this->concat( + $this->image[ $this->current_namespace ][ $el ], $text ); + } + } + else { + if ( $this->initem ) { + $this->concat( + $this->current_item[ $el ], $text); + } + elseif ($this->intextinput) { + $this->concat( + $this->textinput[ $el ], $text ); + } + elseif ($this->inimage) { + $this->concat( + $this->image[ $el ], $text ); + } + elseif ($this->inchannel) { + $this->concat( + $this->channel[ $el ], $text ); + } + + } + } + + function normalize () { + // if atom populate rss fields + if ( $this->is_atom() ) { + $this->channel['descripton'] = $this->channel['tagline']; + for ( $i = 0; $i < count($this->items); $i++) { + $item = $this->items[$i]; + if ( isset($item['summary']) ) + $item['description'] = $item['summary']; + if ( isset($item['atom_content'])) + $item['content']['encoded'] = $item['atom_content']; + + $this->items[$i] = $item; + } + } + elseif ( $this->is_rss() ) { + $this->channel['tagline'] = $this->channel['description']; + for ( $i = 0; $i < count($this->items); $i++) { + $item = $this->items[$i]; + if ( isset($item['description'])) + $item['summary'] = $item['description']; + if ( isset($item['content']['encoded'] ) ) + $item['atom_content'] = $item['content']['encoded']; + + $this->items[$i] = $item; + } + } + } + + function error ($errormsg, $lvl=E_USER_WARNING) { + // append PHP's error message if track_errors enabled + if ( $php_errormsg ) { + $errormsg .= " ($php_errormsg)"; + } + $this->ERROR = $errormsg; + if ( MAGPIE_DEBUG ) { + trigger_error( $errormsg, $lvl); + } + else { + error_log( $errormsg, 0); + } + } + + function is_rss () { + if ( $this->feed_type == RSS ) { + return $this->feed_version; + } + else { + return false; + } + } + + function is_atom() { + if ( $this->feed_type == ATOM ) { + return $this->feed_version; + } + else { + return false; + } + } + +/*======================================================================*\ + EVERYTHING BELOW HERE IS FOR DEBUGGING PURPOSES +\*======================================================================*/ + function show_list () { + echo "<ol>\n"; + foreach ($this->items as $item) { + echo "<li>", $this->show_item( $item ); + } + echo "</ol>"; + } + + function show_channel () { + echo "channel:<br>"; + echo "<ul>"; + while ( list($key, $value) = each( $this->channel ) ) { + echo "<li> $key: $value"; + } + echo "</ul>"; + } + + function show_item ($item) { + echo "item: $item[title]"; + echo "<ul>"; + while ( list($key, $value) = each($item) ) { + if ( is_array($value) ) { + echo "<br><b>$key</b>"; + echo "<ul>"; + while ( list( $ns_key, $ns_value) = each( $value ) ) { + echo "<li>$ns_key: $ns_value"; + } + echo "</ul>"; + } + else { + echo "<li> $key: $value"; + } + } + echo "</ul>"; + } + +/*======================================================================*\ + END DEBUGGING FUNCTIONS +\*======================================================================*/ + + + +} # end class RSS + +function map_attrs($k, $v) { + return "$k=\"$v\""; +} + + +?> diff --git a/inc/magpie/rss_utils.inc b/inc/magpie/rss_utils.inc new file mode 100644 index 000000000..655db8a19 --- /dev/null +++ b/inc/magpie/rss_utils.inc @@ -0,0 +1,67 @@ +<?php +/* + * Project: MagpieRSS: a simple RSS integration tool + * File: rss_utils.inc, utility methods for working with RSS + * Author: Kellan Elliott-McCrea <kellan@protest.net> + * Version: 0.51 + * License: GPL + * + * The lastest version of MagpieRSS can be obtained from: + * http://magpierss.sourceforge.net + * + * For questions, help, comments, discussion, etc., please join the + * Magpie mailing list: + * magpierss-general@lists.sourceforge.net + */ + + +/*======================================================================*\ + Function: parse_w3cdtf + Purpose: parse a W3CDTF date into unix epoch + + NOTE: http://www.w3.org/TR/NOTE-datetime +\*======================================================================*/ + +function parse_w3cdtf ( $date_str ) { + + # regex to match wc3dtf + $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; + + if ( preg_match( $pat, $date_str, $match ) ) { + list( $year, $month, $day, $hours, $minutes, $seconds) = + array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); + + # calc epoch for current date assuming GMT + $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); + + $offset = 0; + if ( $match[10] == 'Z' ) { + # zulu time, aka GMT + } + else { + list( $tz_mod, $tz_hour, $tz_min ) = + array( $match[8], $match[9], $match[10]); + + # zero out the variables + if ( ! $tz_hour ) { $tz_hour = 0; } + if ( ! $tz_min ) { $tz_min = 0; } + + $offset_secs = (($tz_hour*60)+$tz_min)*60; + + # is timezone ahead of GMT? then subtract offset + # + if ( $tz_mod == '+' ) { + $offset_secs = $offset_secs * -1; + } + + $offset = $offset_secs; + } + $epoch = $epoch + $offset; + return $epoch; + } + else { + return -1; + } +} + +?> diff --git a/inc/parser.php b/inc/parser.php new file mode 100644 index 000000000..5b8a1323e --- /dev/null +++ b/inc/parser.php @@ -0,0 +1,763 @@ +<? +include_once("inc/common.php"); +include_once("inc/html.php"); +include_once("inc/format.php"); +require_once("lang/en/lang.php"); +require_once("lang/".$conf['lang']."/lang.php"); + +/** + * The main parser function. Accepts raw data and returns + * valid xhtml +*/ +function parse($text){ + global $parser; + global $conf; + $table = array(); + $hltable = array(); + + //preparse + $text = preparse($text,$table,$hltable); + + //padding with a newline + $text = "\n".$text."\n"; + + #for link matching + $urls = '(https?|telnet|gopher|file|wais|ftp|ed2k|irc)'; + $ltrs = '\w'; + $gunk = '/\#~:.?+=&%@!\-'; + $punc = '.:?\-;,'; + $host = $ltrs.$punc; + $any = $ltrs.$gunk.$punc; + + /* first pass */ + + //preformated texts + firstpass($table,$text,"#<nowiki>(.*?)</nowiki>#se","preformat('\\1','nowiki')"); + firstpass($table,$text,"#%%(.*?)%%#se","preformat('\\1','nowiki')"); + firstpass($table,$text,"#<code( (\w+))?>(.*?)</code>#se","preformat('\\3','code','\\2')"); + firstpass($table,$text,"#<file>(.*?)</file>#se","preformat('\\1','file')"); + + // html and php includes + firstpass($table,$text,"#<html>(.*?)</html>#se","preformat('\\1','html')"); + firstpass($table,$text,"#<php>(.*?)</php>#se","preformat('\\1','php')"); + + // codeblocks + firstpass($table,$text,"/(\n( {2,}|\t)[^\*\-\n ][^\n]+)(\n( {2,}|\t)[^\n]*)*/se","preformat('\\0','block')","\n"); + + //check if toc is wanted + if(!isset($parser['toc'])){ + if(strpos($text,'~~NOTOC~~')!== false){ + $text = str_replace('~~NOTOC~~','',$text); + $parser['toc'] = false; + }else{ + $parser['toc'] = true; + } + } + + //check if this file may be cached + if(!isset($parser['cache'])){ + if(strpos($text,'~~NOCACHE~~')!=false){ + $text = str_replace('~~NOCACHE~~','',$text); + $parser['cache'] = false; + }else{ + $parser['cache'] = true; + } + } + + //headlines + format_headlines($table,$hltable,$text); + + //links + firstpass($table,$text,"#\[\[([^\]]+?)\]\]#ie","linkformat('\\1')"); + + //media + firstpass($table,$text,"/\{\{([^\}]+)\}\}/se","mediaformat('\\1')"); + + //match full URLs (adapted from Perl cookbook) + firstpass($table,$text,"#(\b)($urls://[$any]+?)([$punc]*[^$any])#ie","linkformat('\\2')",'\1','\4'); + + //short www URLs + firstpass($table,$text,"#(\b)(www\.[$host]+?\.[$host]+?[$any]+?)([$punc]*[^$any])#ie","linkformat('http://\\2|\\2')",'\1','\3'); + + //windows shares + firstpass($table,$text,"#([$gunk$punc\s])(\\\\\\\\[$host]+?\\\\[$any]+?)([$punc]*[^$any])#ie","linkformat('\\2')",'\1','\3'); + + //short ftp URLs + firstpass($table,$text,"#(\b)(ftp\.[$host]+?\.[$host]+?[$any]+?)([$punc]*[^$any])#ie","linkformat('ftp://\\2')",'\1','\3'); + + // email@domain.tld + firstpass($table,$text,"#<([\w0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)>#ie", "linkformat('\\1@\\2')"); + + //CamelCase if wanted + if($conf['camelcase']){ + firstpass($table,$text,"#(\b)([A-Z]+[a-z]+[A-Z][A-Za-z]*)(\b)#se","linkformat('\\2')",'\1','\3'); + } + + $text = htmlspecialchars($text); + + //smileys + smileys($table,$text); + + //acronyms + acronyms($table,$text); + + /* second pass for simple formating */ + $text = simpleformat($text); + + /* third pass - insert the matches from 1st pass */ + reset($table); + while (list($key, $val) = each($table)) { + $text = str_replace($key,$val,$text); + } + + /* remove empty paragraphs */ + $text = preg_replace('"<p>\n*</p>"','',$text); + + /* remove padding */ + $text = trim($text); + return $text; +} + +/** + * This preparses the text by walking it line by line. This + * is the only place where linenumbers are still available (needed + * for section edit. Some precautions have to be taken to not change + * any noparse block. + */ +function preparse($text,&$table,&$hltable){ + $lines = split("\n",$text); + + //prepare a tokens for paragraphs + $po = mkToken(); + $table[$po] = "<p>"; + $pc = mkToken(); + $table[$pc] = "</p>"; + + for ($l=0; $l<count($lines); $l++){ + //temporay line holder + $line = $lines[$l]; + + //look for end of multiline noparse areas + if($noparse){ + if(preg_match("#^.*?$noparse#",$line)){ + $noparse = ''; + $line = preg_replace("#^.*?$noparse#",$line,1); + }else{ + continue; + } + } + + if(!$noparse){ + //skip indented lines + if(preg_match('#^( |\t)#',$line)) continue; + //remove norparse areas which open and close on the same line + $line = preg_replace("#<nowiki>(.*?)</nowiki>#","",$line); + $line = preg_replace("#%%(.*?)%%#","",$line); + $line = preg_replace("#<code( (\w+))?>(.*?)</code>#","",$line); + $line = preg_replace("#<file>(.*?)</file>#","",$line); + $line = preg_replace("#<html>(.*?)</html>#","",$line); + $line = preg_replace("#<php>(.*?)</php>#","",$line); + //check for start of multiline noparse areas + if(preg_match('#^.*?<(nowiki|code|php|html|file)( (\w+))?>#',$line,$matches)){ + list($noparse) = split(" ",$matches[1]); //remove options + $noparse = '</'.$noparse.'>'; + continue; + }elseif(preg_match('#^.*?%%#',$line)){ + $noparse = '%%'; + continue; + } + } + + //handle headlines + if(preg_match('/^(\s)*(==+)(.+?)(==+)(\s*)$/',$lines[$l],$matches)){ + //get token + $tk = tokenize_headline($hltable,$matches[2],$matches[3],$l); + //replace line with token + $lines[$l] = $tk; + } + + //handle paragraphs + if(empty($lines[$l])){ + $lines[$l] = "$pc\n$po"; + } + } + + //reassemble full text + $text = join("\n",$lines); + //open first and close last paragraph + $text = "$po\n$text\n$pc"; + + return $text; +} + +/** + * This function adds some information about the given headline + * to a lookuptable to be processed later. Returns a unique token + * that idetifies the headline later + */ +function tokenize_headline(&$hltable,$pre,$hline,$lno){ + switch (strlen($pre)){ + case 2: + $lvl = 5; + break; + case 3: + $lvl = 4; + break; + case 4: + $lvl = 3; + break; + case 5: + $lvl = 2; + break; + default: + $lvl = 1; + break; + } + $token = mkToken(); + $hltable[] = array( 'name' => htmlspecialchars(trim($hline)), + 'level' => $lvl, + 'line' => $lno, + 'token' => $token ); + return $token; +} + +function format_headlines(&$table,&$hltable,&$text){ + global $parser; + global $conf; + global $lang; + global $ID; + + // walk the headline table prepared in preparsing + $last = 0; + $cnt = 0; + $hashs = array(); + foreach($hltable as $hl){ + $cnt++; + + //make unique headlinehash + $hash = cleanID($hl['name']); + $i=2; + while(in_array($hash,$hashs)) + $hash = cleanID($hl['name']).$i++; + $hashs[] = $hash; + + // build headline + $headline = "</p>\n"; //close paragraph + if($cnt - 1) $headline .= '</div>'; //no close on first HL + $headline .= '<a name="'.$hash.'"></a>'; + $headline .= '<h'.$hl['level'].'>'; + $headline .= $hl['name']; + $headline .= '</h'.$hl['level'].'>'; + $headline .= '<div class="level'.$hl['level'].'">'; + $headline .= "\n<p>"; //open new paragraph + + //remember for autoTOC + if($hl['level'] <= $conf['maxtoclevel']){ + $content[] = array('id' => $hash, + 'name' => $hl['name'], + 'level' => $hl['level']); + } + + //add link for section edit for HLs 1, and 3 + if( ($hl['level'] <= $conf['maxseclevel']) && + ($hl['line'] - $last > 1)){ + $secedit = '<!-- SECTION ['.$last.'-'.($hl['line'] - 1).'] -->'; + $headline = $secedit.$headline; + $last = $hl['line']; + } + + //put headline into firstpasstable + $table[$hl['token']] = $headline; + } + + //add link for editing the last section + if($last){ + $secedit = '<!-- SECTION ['.$last.'-] -->'; + $token = mktoken(); + $text .= $token; + $table[$token] = $secedit; + } + + //close last div + if ($cnt){ + $token = mktoken(); + $text .= $token; + $table[$token] = '</div>'; + } + + //prepend toc + if ($parser['toc'] && count($content) > 2){ + $token = mktoken(); + $text = $token.$text; + $table[$token] = html_toc($content); + } +} + +/** + * Formats various link types using the functions from format.php + */ +function linkformat($match){ + global $conf; + //unescape + $match = str_replace('\\"','"',$match); + + //prepare variables for the formaters + $link = array(); + list($link['url'],$link['name']) = split('\|',$match,2); + $link['url'] = trim($link['url']); + $link['name'] = trim($link['name']); + $link['class'] = ''; + $link['target'] = ''; + $link['style'] = ''; + $link['pre'] = ''; + $link['suf'] = ''; + $link['more'] = ''; + + //save real name for image check + $realname = $link['name']; + + /* put it into the right formater */ + if(strpos($link['url'],'>')){ + // InterWiki + $link = format_link_interwiki($link); + }elseif(preg_match('#^([a-z0-9]+?){1}://#i',$link['url'])){ + // external URL + $link = format_link_externalurl($link); + }elseif(preg_match("/^\\\\\\\\([a-z0-9\-_.]+)\\\\(.+)$/",$link['url'])){ + // windows shares + $link = format_link_windows($link); + }elseif(preg_match('#([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i',$link['url'])){ + // email + $link = format_link_email($link); + }else{ + // wiki link + $link = format_link_wiki($link); + } + + //is realname an image? use media formater + if(preg_match('#^{{.*?\.(gif|png|jpe?g)(\?.*?)?\s*(\|.*?)?}}$#',$realname)){ + $link['name'] = substr($realname,2,-2); + $link = format_link_media($link); + } + + // build the replacement with the variables set by the formaters + return format_link_build($link); +} + +/** + * Simple text formating and typography is done here + */ +function simpleformat($text){ + global $conf; + + $text = preg_replace('/__(.+?)__/s','<u>\1</u>',$text); //underline + $text = preg_replace('/\/\/(.+?)\/\//s','<em>\1</em>',$text); //emphasize + $text = preg_replace('/\*\*(.+?)\*\*/s','<strong>\1</strong>',$text); //bold + $text = preg_replace('/\'\'(.+?)\'\'/s','<code>\1</code>',$text); //code + $text = preg_replace('#<del>(.*?)</del>#is','<del>\1</del>',$text); //deleted + $text = preg_replace('/^(\s)*----+(\s*)$/m',"</p>\n<hr noshade=\"noshade\" size=\"1\" />\n<p>",$text); //hr + + //sub and superscript + $text = preg_replace('#<sub>(.*?)</sub>#is','<sub>\1</sub>',$text); + $text = preg_replace('#<sup>(.*?)</sup>#is','<sup>\1</sup>',$text); + + //do quoting + $text = preg_replace("/\n((>)[^\n]*?\n)+/se","'\n'.quoteformat('\\0').'\n'",$text); + + // Typography + if($conf['typography']){ + $text = preg_replace('/([^-])--([^-])/s','\1–\2',$text); //endash + $text = preg_replace('/([^-])---([^-])/s','\1—\2',$text); //emdash + $text = preg_replace('/"([^\"]+?)"/s','“\1”',$text); //curly quotes + $text = preg_replace('/(\s)\'(\S)/m','\1‘\2',$text); //single open quote + $text = preg_replace('/(\S)\'/','\1’',$text); //single closing quote or apostroph + $text = preg_replace('/\.\.\./','\1…\2',$text); //ellipse + $text = preg_replace('/(\d+)x(\d+)/i','\1×\2',$text); //640x480 + + $text = preg_replace('/>>/i','»',$text); // >> + $text = preg_replace('/<</i','«',$text); // << + + $text = preg_replace('/<->/i','↔',$text); // <-> + $text = preg_replace('/<-/i','←',$text); // <- + $text = preg_replace('/->/i','→',$text); // -> + + $text = preg_replace('/<=>/i','⇔',$text); // <=> + $text = preg_replace('/<=/i','⇐',$text); // <= + $text = preg_replace('/=>/i','⇒',$text); // => + + $text = preg_replace('/\(c\)/i','©',$text); // copyrigtht + $text = preg_replace('/\(r\)/i','®',$text); // registered + $text = preg_replace('/\(tm\)/i','™',$text); // trademark + } + + //forced linebreaks + $text = preg_replace('#\\\\\\\\(\s)#',"<br />\\1",$text); + + // lists (blocks leftover after blockformat) + $text = preg_replace("/(\n( {2,}|\t)[\*\-][^\n]+)(\n( {2,}|\t)[^\n]*)*/se","\"\\n\".listformat('\\0')",$text); + + // tables + $text = preg_replace("/\n(([\|\^][^\n]*?)+[\|\^] *\n)+/se","\"\\n\".tableformat('\\0')",$text); + + // footnotes + $text = footnotes($text); + + // run custom text replacements + $text = customs($text); + + return $text; +} + +/** + * Does the footnote formating + */ +function footnotes($text){ + $num = 0; + while (preg_match('/\(\((.+?)\)\)/s',$text,$match)){ + $num++; + $fn = $match[1]; + $linkt = '<a href="#fn'.$num.'" name="fnt'.$num.'" class="fn_top">'.$num.')</a>'; + $linkb = '<a href="#fnt'.$num.'" name="fn'.$num.'" class="fn_bot">'.$num.')</a>'; + + $text = preg_replace('/ ?\(\((.+?)\)\)/s',$linkt,$text,1); + if($num == 1) $text .= '<div class="footnotes">'; + $text .= '<div class="fn">'.$linkb.' '.$fn.'</div>'; + } + + if($num) $text .= '</div>'; + return $text; +} + +/** + * Replaces smileys with their graphic equivalents + */ +function smileys(&$table,&$text){ + $smileys = file('conf/smileys.conf'); + foreach($smileys as $smiley){ + $smiley = preg_replace('/#.*$/','',$smiley); //ignore comments + $smiley = trim($smiley); + if(empty($smiley)) continue; + $sm = preg_split('/\s+/',$smiley,2); + $sm[1] = '<img src="'.getBaseURL().'smileys/'.$sm[1].'" align="middle" alt="'.$sm[0].'" />'; + $sm[0] = preg_quote($sm[0],'/'); + firstpass($table,$text,'/(\W)'.$sm[0].'(\W)/s',$sm[1],"\\1","\\2"); + } +} + +/** + * Adds acronym tags to known acronyms + */ +function acronyms(&$table,&$text){ + $acronyms = file('conf/acronyms.conf'); + foreach($acronyms as $acro){ + $acro = preg_replace('/#.*$/','',$acro); //ignore comments + $acro = trim($acro); + if(empty($acro)) continue; + list($ac,$desc) = preg_split('/\s+/',$acro,2); + $ac = preg_quote($ac,'/'); + firstpass($table,$text,'/(\b)('.$ac.')(\b)/s',"<acronym title=\"$desc\">\\2</acronym>","\\1","\\3"); + } +} + + +/** + * Applies custom text replacements + */ +function customs($text){ + $reps = file ('conf/custom.conf'); + foreach($reps as $rep){ + //strip comments only outside a regexp + $rep = preg_replace('/#[^\/]*$/','',$rep); //ignore comments + $rep = trim($rep); + if(empty($rep)) continue; + if(preg_match('#^(/.+/\w*)\s+\'(.*)\'$#',$rep,$matches)){ + $text = preg_replace($matches[1],$matches[2],$text); + } + } + return $text; +} + +function firstpass(&$table,&$text,$regexp,$replace,$lpad='',$rpad=''){ + //extended regexps have to be disabled for inserting the token + //and later reenabled when handling the actual code: + $ext=''; + if(substr($regexp,-1) == 'e'){ + $ext='e'; + $regexp = substr($regexp,0,-1); + } + + while(preg_match($regexp,$text,$matches)){ + $token = mkToken(); + $match = $matches[0]; + $text = preg_replace($regexp,$lpad.$token.$rpad,$text,1); + $table[$token] = preg_replace($regexp.$ext,$replace,$match); + } +} + +function mkToken(){ + return '~'.md5(uniqid(rand(), true)).'~'; +} + +/** + * Do quote blocks + * + * FIXME fix paragraphs + */ +function quoteformat($block){ + $block = trim($block); + $lines = split("\n",$block); + + $lvl = 0; + $ret = ""; + foreach ($lines as $line){ + //remove '>' and count them + $cnt = 0; + while(substr($line,0,4) == '>'){ + $line = substr($line,4); + $cnt++; + } + //compare to last level and open or close new divs if needed + if($cnt > $lvl){ + $ret .= "</p>\n"; + for ($i=0; $i< $cnt - $lvl; $i++){ + $ret .= '<div class="quote">'; + } + $ret .= "\n<p>"; + }elseif($cnt < $lvl){ + $ret .= "\n</p>"; + for ($i=0; $i< $lvl - $cnt; $i++){ + $ret .= "</div>\n"; + } + $ret .= "<p>\n"; + }elseif(empty($line)){ + $ret .= "</p>\n<p>"; + } + //keep rest of line but trim left whitespaces + $ret .= ltrim($line)."\n"; + //remember level + $lvl = $cnt; + } + + //close remaining divs + $ret .= "</p>\n"; + for ($i=0; $i< $lvl; $i++){ + $ret .= "</div>\n"; + } + $ret .= "<p>\n"; + + return "$ret"; +} + +function tableformat($block) { + $block = trim($block); + $lines = split("\n",$block); + $ret = ""; + //build a row array + $rows = array(); + for($r=0; $r < count($lines); $r++){ + $line = $lines[$r]; + //remove last seperator and trailing whitespace + $line = preg_replace('/[\|\^]\s*$/', '', $line); + $c = -1; //prepare colcounter) + for($chr=0; $chr < strlen($line); $chr++){ + if($line[$chr] == '^'){ + $c++; + $rows[$r][$c]['head'] = true; + $rows[$r][$c]['data'] = ''; + }elseif($line[$chr] == '|'){ + $c++; + $rows[$r][$c]['head'] = false; + $rows[$r][$c]['data'] = ''; + }else{ + $rows[$r][$c]['data'].= $line[$chr]; + } + } + } + + //build table + $ret .= "</p>\n<table class=\"inline\">\n"; + for($r=0; $r < count($rows); $r++){ + $ret .= " <tr>\n"; + + for ($c=0; $c < count($rows[$r]); $c++){ + $cspan=1; + $data = trim($rows[$r][$c]['data']); + $head = $rows[$r][$c]['head']; + + //join cells if next is empty + while($c < count($rows[$r])-1 && $rows[$r][$c+1]['data'] == ''){ + $c++; + $cspan++; + } + if($cspan > 1){ + $cspan = 'colspan="'.$cspan.'"'; + }else{ + $cspan = ''; + } + + if ($head) { + $ret .= " <th class=\"inline\" $cspan>$data</th>\n"; + } else { + $ret .= " <td class=\"inline\" $cspan>$data</td>\n"; + } + } + $ret .= " </tr>\n"; + } + $ret .= "</table>\n<p>"; + + return $ret; +} + +function listformat($block){ + //remove 1st newline + $block = substr($block,1); + //unescape + $block = str_replace('\\"','"',$block); + +//dbg($block); + + //walk line by line + $ret=''; + $lst=0; + $lvl=0; + $enc=0; + $lines = split("\n",$block); + + //build an item array + $cnt=0; + $items = array(); + foreach ($lines as $line){ + //get intendion level + $lvl = 0; + $lvl += floor(strspn($line,' ')/2); + $lvl += strspn($line,"\t"); + //remove indents + $line = preg_replace('/^[ \t]+/','',$line); + //get type of list + (substr($line,0,1) == '-') ? $type='ol' : $type='ul'; + // remove bullet and following spaces + $line = preg_replace('/^[*\-]\s*/','',$line); + //add item to the list + $items[$cnt]['level'] = $lvl; + $items[$cnt]['type'] = $type; + $items[$cnt]['text'] = $line; + //increase counter + $cnt++; + } + + $level = 0; + $opens = array(); + + foreach ($items as $item){ + if( $item['level'] > $level ){ + //open new list + $ret .= "\n<".$item['type'].">\n"; + array_push($opens,$item['type']); + }elseif( $item['level'] < $level ){ + //close last item + $ret .= "</li>\n"; + for ($i=0; $i<($level - $item['level']); $i++){ + //close higher lists + $ret .= '</'.array_pop($opens).">\n</li>\n"; + } + }elseif($item['type'] != $opens[count($opens)-1]){ + //close last list and open new + $ret .= '</'.array_pop($opens).">\n</li>\n"; + $ret .= "\n<".$item['type'].">\n"; + array_push($opens,$item['type']); + }else{ + //close last item + $ret .= "</li>\n"; + } + + //remember current level and type + $level = $item['level']; + + //print item + $ret .= '<li class="level'.$item['level'].'">'; + $ret .= '<span class="li">'.$item['text'].'</span>'; + } + + //close remaining items and lists + while ($open = array_pop($opens)){ + $ret .= "</li>\n"; + $ret .= '</'.$open.">\n"; + } + return "</p>\n".$ret."\n<p>"; +} + +function preformat($text,$type,$option=''){ + global $conf; + //unescape + $text = str_replace('\\"','"',$text); + + if($type == 'php' && !$conf['phpok']) $type='file'; + if($type == 'html' && !$conf['htmlok']) $type='file'; + + switch ($type){ + case 'php': + ob_start(); + eval($text); + $text = ob_get_contents(); + ob_end_clean(); + break; + case 'html': + break; + case 'nowiki': + $text = htmlspecialchars($text); + break; + case 'file': + $text = htmlspecialchars($text); + $text = "</p>\n<pre class=\"file\">".$text."</pre>\n<p>"; + break; + case 'code': + if(empty($option)){ + $text = htmlspecialchars($text); + $text = '<pre class="code">'.$text.'</pre>'; + }else{ + //strip leading blank line + $text = preg_replace('/^\s*?\n/','',$text); + //use geshi for highlighting + require_once("inc/geshi.php"); + $geshi = new GeSHi($text, strtolower($option), "inc/geshi"); + $geshi->enable_classes(); + $geshi->set_header_type(GESHI_HEADER_PRE); + $geshi->set_overall_class('code'); + $geshi->set_link_target($conf['target']['extern']); + $text = $geshi->parse_code(); + } + $text = "</p>\n".$text."\n<p>"; + break; + case 'block': + $text = substr($text,1); //remove 1st newline + $lines = split("\n",$text); //break into lines + $text = ''; + foreach($lines as $line){ + $text .= substr($line,2)."\n"; //remove indents + } + $text = htmlspecialchars($text); + $text = "</p>\n<pre class=\"pre\">".$text."</pre>\n<p>"; + break; + } + return $text; +} + +function mediaformat($text){ + global $conf; + + //unescape + $text = str_replace('\\"','"',$text); + + // format RSS + if(substr($text,0,4) == 'rss>'){ + return format_rss(substr($text,4)); + } + + //handle normal media stuff + $link = array(); + $link['name'] = $text; + $link = format_link_media($link); + return format_link_build($link); +} + +?> diff --git a/inc/search.php b/inc/search.php new file mode 100644 index 000000000..bb941a3f3 --- /dev/null +++ b/inc/search.php @@ -0,0 +1,301 @@ +<? + +require_once("inc/common.php"); + +/** + * This function recurses into a given base directory + * and calls the supplied function for each file and directory + */ +function search(&$data,$base,$func,$opts,$dir='',$lvl=1){ + $dirs = array(); + $files = array(); + + //read in directories and files + $dh = @opendir($base.'/'.$dir); + if(!$dh) return; + while(($file = readdir($dh)) !== false){ + if(preg_match('/^\./',$file)) continue; //skip hidden files and upper dirs + if(is_dir($base.'/'.$dir.'/'.$file)){ + $dirs[] = $dir.'/'.$file; + continue; + } + $files[] = $dir.'/'.$file; + } + closedir($dh); + sort($files); + sort($dirs); + + //give directories to userfunction then recurse + foreach($dirs as $dir){ + if ($func($data,$base,$dir,'d',$lvl,$opts)){ + search($data,$base,$func,$opts,$dir,$lvl+1); + } + } + //now handle the files + foreach($files as $file){ + $func($data,$base,$file,'f',$lvl,$opts); + } +} + +/** + * The following functions are userfunctions to use with the search + * function above. This function is called for every found file or + * directory. When a directory is given to the function it has to + * decide if this directory should be traversed (true) or not (false) + * The function has to accept the following parameters: + * + * &$data - Reference to the result data structure + * $base - Base usually $conf['datadir'] + * $file - current file or directory relative to $base + * $type - Type either 'd' for directory or 'f' for file + * $lvl - Current recursion depht + * $opts - option array as given to search() + * + * return values for files are ignored + * + * All functions should check the ACL for document READ rights + * namespaces (directories) are NOT checked as this would break + * the recursion (You can have an nonreadable dir over a readable + * one deeper nested) + */ + +/** + * This function build the browsable index of pages + * + * $opts['ns'] is the current namespace + */ +function search_index(&$data,$base,$file,$type,$lvl,$opts){ + $return = true; + + if($type == 'd' && !preg_match('#^'.$file.'(/|$)#','/'.$opts['ns'])){ + //add but don't recurse + $return = false; + }elseif($type == 'f' && !preg_match('#\.txt$#',$file)){ + //don't add + return false; + } + + //check ACL + $id = pathID($file); + if($type=='f' && auth_quickaclcheck($id) < AUTH_READ){ + return false; + } + + $data[]=array( 'id' => $id, + 'type' => $type, + 'level' => $lvl ); + return $return; +} + +/** + * This function lists all namespaces + */ +function search_namespaces(&$data,$base,$file,$type,$lvl,$opts){ + if($type == 'f') return true; //nothing to do on files + + $id = pathID($file); + $data[]=array( 'id' => $id, + 'type' => $type, + 'level' => $lvl ); + return true; +} + +/** + * This function lists all mediafiles in a namespace + */ +function search_media(&$data,$base,$file,$type,$lvl,$opts){ + //we do nothing with directories + if($type == 'd') return false; + + $info = array(); + $info['id'] = pathID($file); + + //check ACL for namespace (we have no ACL for mediafiles) + if(auth_quickaclcheck(getNS($info['id']).':*') < AUTH_READ){ + return false; + } + + $info['file'] = basename($file); + $info['size'] = filesize($base.'/'.$file); + if(preg_match("/\.(jpe?g|gif|png)$/",$file)){ + $info['isimg'] = true; + $info['info'] = getimagesize($base.'/'.$file); + }else{ + $info['isimg'] = false; + } + $data[] = $info; + + return false; +} + +/** + * This function just lists documents (for RSS namespace export) + */ +function search_list(&$data,$base,$file,$type,$lvl,$opts){ + //we do nothing with directories + if($type == 'd') return false; + if(preg_match('#\.txt$#',$file)){ + //check ACL + $id = pathID($file); + if(auth_quickaclcheck($id) < AUTH_READ){ + return false; + } + $data[]['id'] = $id;; + } + return false; +} + +/** + * Quicksearch for searching matching pagenames + * + * $opts['query'] is the search query + */ +function search_pagename(&$data,$base,$file,$type,$lvl,$opts){ + //we do nothing with directories + if($type == 'd') return true; + //only search txt files + if(!preg_match('#\.txt$#',$file)) return true; + + //simple stringmatching + if(strpos($file,$opts['query']) !== false){ + //check ACL + $id = pathID($file); + if(auth_quickaclcheck($id) < AUTH_READ){ + return false; + } + $data[]['id'] = $id; + } + + return true; +} + +/** + * Search for backlinks to a given page + * + * $opts['ns'] namespace of the page + * $opts['name'] name of the page without namespace + */ +function search_backlinks(&$data,$base,$file,$type,$lvl,$opts){ + //we do nothing with directories + if($type == 'd') return true;; + //only search txt files + if(!preg_match('#\.txt$#',$file)) return true;; + + //get text + $text = io_readfile($base.'/'.$file); + + //absolute search id + $sid = cleanID($opts['ns'].':'.$opts['name']); + + //construct current namespace + $cid = pathID($file); + $cns = getNS($cid); + + //check ACL + if(auth_quickaclcheck($cid) < AUTH_READ){ + return false; + } + + //match all links + //FIXME may be incorrect because of code blocks + // CamelCase isn't supported, too + preg_match_all('#\[\[(.+?)\]\]#si',$text,$matches,PREG_SET_ORDER); + foreach($matches as $match){ + //get ID from link and discard most non wikilinks + list($mid) = split('\|',$match[1],2); + if(preg_match("#^(https?|telnet|gopher|file|wais|ftp|ed2k|irc)://#",$mid)) continue; + if(preg_match("#\w+>#",$mid)) continue; + $mns = getNS($mid); + //namespace starting with "." - prepend current namespace + if(strpos($mns,'.')===0){ + $mid = $cns.":".substr($mid,1); + } + if($mns===false){ + //no namespace in link? add current + $mid = "$cns:$mid"; + } + $mid = cleanID($mid); + + if ($mid == $sid){ + $data[]['id'] = $cid; + break; + } + } +} + +/** + * Fulltextsearch + * + * $opts['query'] is the search query + */ +function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){ + //we do nothing with directories + if($type == 'd') return true;; + //only search txt files + if(!preg_match('#\.txt$#',$file)) return true;; + + //check ACL + $id = pathID($file); + if(auth_quickaclcheck($id) < AUTH_READ){ + return false; + } + + //get text + $text = io_readfile($base.'/'.$file); + + //create regexp from queries + $qpreg = preg_split('/\s+/',preg_quote($opts['query'],'#')); + $qpreg = '('.join('|',$qpreg).')'; + + //do the fulltext search + $matches = array(); + if($cnt = preg_match_all('#'.$qpreg.'#si',$text,$matches)){ + //this is not the best way for snippet generation but the fastest I could find + //split query and only use the first token + $q = preg_split('/\s+/',$opts['query'],2); + $q = $q[0]; + $p = strpos(strtolower($text),$q); + $f = $p - 100; + $l = strlen($q) + 200; + if($f < 0) $f = 0; + $snippet = '<span class="search_sep"> ... </span>'. + htmlspecialchars(substr($text,$f,$l)). + '<span class="search_sep"> ... </span>'; + $snippet = preg_replace('#'.$qpreg.'#si','<span class="search_hit">\\1</span>',$snippet); + + $data[] = array( + 'id' => $id, + 'count' => $cnt, + 'snippet' => $snippet, + ); + } + + return true; +} + +/** + * Callback sort function for use with usort to sort the data + * structure created by search_fulltext. Sorts descending by count + */ +function sort_search_fulltext($a,$b){ + if($a['count'] > $b['count']){ + return -1; + }elseif($a['count'] < $b['count']){ + return 1; + }else{ + return strcmp($a['id'],$b['id']); + } +} + +/** + * translates a document path to an ID + */ +function pathID($path){ + $id = str_replace('/',':',$path); + $id = preg_replace('#\.txt$#','',$id); + $id = preg_replace('#^:+#','',$id); + $id = preg_replace('#:+$#','',$id); + return $id; +} + +?> |