summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-02-17 23:20:40 +0100
committerAndreas Gohr <andi@splitbrain.org>2006-02-17 23:20:40 +0100
commit98c868589ee0757f176239cf289cbd007bb74852 (patch)
treeeb48a172b0f1a423b93ffff35f8adf8d579383c1 /inc
parent1c73890c5027011d808d38c583561abc309e8086 (diff)
downloadrpg-98c868589ee0757f176239cf289cbd007bb74852.tar.gz
rpg-98c868589ee0757f176239cf289cbd007bb74852.tar.bz2
file cleanups
This patch cleans up the source code to satisfy the coding guidelines (see http://wiki.splitbrain.org/wiki:development#coding_style) It converts files to UNIX lineendings and removes tabs and trailing whitespace. Not all files were cleaned yet. darcs-hash:20060217222040-7ad00-bba3d2bee3b5aa7cbb5184258abd50805cd071bf.gz
Diffstat (limited to 'inc')
-rw-r--r--inc/DifferenceEngine.php1832
-rw-r--r--inc/HTTPClient.php16
-rw-r--r--inc/JSON.php144
-rw-r--r--inc/JpegMeta.php18
-rw-r--r--inc/actions.php26
-rw-r--r--inc/admin_acl.php34
-rw-r--r--inc/aspell.php8
-rw-r--r--inc/auth/basic.class.php26
-rw-r--r--inc/auth/ldap.class.php58
-rw-r--r--inc/auth/mysql.class.php144
-rw-r--r--inc/auth/plain.class.php96
-rw-r--r--inc/auth/punbb.class.php6
-rw-r--r--inc/cliopts.php98
-rw-r--r--inc/confutils.php4
-rw-r--r--inc/feedcreator.class.php2440
-rw-r--r--inc/fulltext.php4
-rw-r--r--inc/html.php68
-rw-r--r--inc/indexer.php28
-rw-r--r--inc/init.php2
-rw-r--r--inc/io.php34
-rw-r--r--inc/mail.php6
-rw-r--r--inc/pageutils.php10
-rw-r--r--inc/parser/handler.php590
-rw-r--r--inc/parser/lexer.php62
-rw-r--r--inc/parser/parser.php292
-rw-r--r--inc/parser/renderer.php156
-rw-r--r--inc/parser/spamcheck.php22
-rw-r--r--inc/parser/wiki.php134
-rw-r--r--inc/parser/xhtml.php222
-rw-r--r--inc/parser/xhtmlsummary.php170
-rw-r--r--inc/parserutils.php26
-rw-r--r--inc/pluginutils.php4
-rw-r--r--inc/search.php20
-rw-r--r--inc/template.php20
-rw-r--r--inc/toolbar.php8
-rw-r--r--inc/utf8.php170
36 files changed, 3499 insertions, 3499 deletions
diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php
index 038fd4fac..82cf0404a 100644
--- a/inc/DifferenceEngine.php
+++ b/inc/DifferenceEngine.php
@@ -10,91 +10,91 @@
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;
- }
+ 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);
- }
+ 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);
- }
+ 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);
- }
+ 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);
- }
+ 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
+ * 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
+ * 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
+ * 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.
@@ -104,575 +104,575 @@ class _DiffOp_Change extends _DiffOp {
*/
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;
- }
-
-
- /**
+ 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;
- }
-
- /**
+ * [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;
- }
- }
- }
-
- /**
+ *
+ * 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]');
- }
- }
- }
+ * 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
+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);
- }
+ 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);
- }
- }
- }
+ /**
+ * 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);
+ }
+ }
+ }
}
/**
@@ -684,253 +684,253 @@ extends Diff
*/
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);
- }
+ /**
+ * 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
- *
+ * Additions by Axel Boldt follow, partly taken from diff.php, phpwiki-1.3.3
+ *
*/
-define('NBSP', "\xA0"); // iso-8859-x non-breaking space.
+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;
- }
+ 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();
- }
+ 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();
+ }
}
/**
@@ -966,16 +966,16 @@ class UnifiedDiffFormatter extends DiffFormatter
}
/**
- * Wikipedia Table style diff formatter.
- *
+ * Wikipedia Table style diff formatter.
+ *
*/
class TableDiffFormatter extends DiffFormatter
{
- function TableDiffFormatter() {
- $this->leading_context_lines = 2;
- $this->trailing_context_lines = 2;
- }
-
+ function TableDiffFormatter() {
+ $this->leading_context_lines = 2;
+ $this->trailing_context_lines = 2;
+ }
+
function _pre($text){
$text = htmlspecialchars($text);
$text = str_replace(' ',' &nbsp;',$text);
@@ -986,76 +986,76 @@ class TableDiffFormatter extends DiffFormatter
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;
- }
+ $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 _start_block( $header ) {
+ print( $header );
+ }
- function _end_block() {
- }
+ function _end_block() {
+ }
- function _lines( $lines, $prefix=' ', $color="white" ) {
- }
+ function _lines( $lines, $prefix=' ', $color="white" ) {
+ }
- function addedLine( $line ) {
+ function addedLine( $line ) {
$line = str_replace(' ','&nbsp; ',$line);
- return '<td>+</td><td class="diff-addedline">' .
- $line.'</td>';
- }
+ return '<td>+</td><td class="diff-addedline">' .
+ $line.'</td>';
+ }
- function deletedLine( $line ) {
+ function deletedLine( $line ) {
$line = str_replace(' ','&nbsp; ',$line);
- return '<td>-</td><td class="diff-deletedline">' .
- $line.'</td>';
- }
+ return '<td>-</td><td class="diff-deletedline">' .
+ $line.'</td>';
+ }
- function emptyLine() {
+ function emptyLine() {
$line = str_replace(' ','&nbsp; ',$line);
- return '<td colspan="2">&nbsp;</td>';
- }
+ return '<td colspan="2">&nbsp;</td>';
+ }
- function contextLine( $line ) {
+ function contextLine( $line ) {
$line = str_replace(' ','&nbsp; ',$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
- }
+ 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/HTTPClient.php b/inc/HTTPClient.php
index 0ed34de44..1b9e82fe6 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -18,7 +18,7 @@ define('HTTP_NL',"\r\n");
* @author Andreas Goetz <cpuidle@gmx.de>
*/
class DokuHTTPClient extends HTTPClient {
-
+
/**
* Constructor.
*
@@ -187,7 +187,7 @@ class HTTPClient {
// stop time
$start = time();
-
+
// open socket
$socket = @fsockopen($server,$port,$errno, $errstr, $this->timeout);
if (!$socket){
@@ -269,7 +269,7 @@ class HTTPClient {
}
}
}
-
+
// close socket
$status = socket_get_status($socket);
fclose($socket);
@@ -286,7 +286,7 @@ class HTTPClient {
// handle headers and cookies
$this->resp_headers = $this->_parseHeaders($r_headers);
if(isset($this->resp_headers['set-cookie'])){
- foreach ($this->resp_headers['set-cookie'] as $c){
+ foreach ($this->resp_headers['set-cookie'] as $c){
list($key, $value, $foo) = split('=', $cookie);
$this->cookies[$key] = $value;
}
@@ -389,14 +389,14 @@ class HTTPClient {
* @author Andreas Goetz <cpuidle@gmx.de>
*/
function _getCookies(){
- foreach ($this->cookies as $key => $val){
+ foreach ($this->cookies as $key => $val){
if ($headers) $headers .= '; ';
$headers .= $key.'='.$val;
- }
-
+ }
+
if ($headers) $headers = "Cookie: $headers".HTTP_NL;
return $headers;
- }
+ }
/**
* Encode data for posting
diff --git a/inc/JSON.php b/inc/JSON.php
index 2958d3419..09a837da7 100644
--- a/inc/JSON.php
+++ b/inc/JSON.php
@@ -1,9 +1,9 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-/**
+/**
* Converts to and from JSON format.
- *
+ *
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
@@ -13,7 +13,7 @@
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
- *
+ *
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
@@ -34,7 +34,7 @@
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
@@ -46,9 +46,9 @@
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
- *
- * @category
- * @package
+ *
+ * @category
+ * @package
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
@@ -96,21 +96,21 @@ define('JSON_LOOSE_TYPE', 10);
*/
define('JSON_STRICT_TYPE', 11);
-/**
+/**
* Converts to and from JSON format.
*
- * @category
- * @package
+ * @category
+ * @package
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version
- * @link
- * @see
- * @since
- * @deprecated
+ * @version
+ * @link
+ * @see
+ * @since
+ * @deprecated
*/
class JSON
{
@@ -147,17 +147,17 @@ class JSON
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
-
+
case 'NULL':
return 'null';
-
+
case 'integer':
return sprintf('%d', $var);
-
+
case 'double':
case 'float':
return sprintf('%f', $var);
-
+
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
@@ -168,9 +168,9 @@ class JSON
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
-
+
$ord_var_c = ord($var{$c});
-
+
switch ($ord_var_c) {
case 0x08: $ascii .= '\b'; break;
case 0x09: $ascii .= '\t'; break;
@@ -184,12 +184,12 @@ class JSON
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
-
+
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
-
+
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -199,7 +199,7 @@ class JSON
$utf16 = utf8_to_utf16be($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
-
+
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -211,7 +211,7 @@ class JSON
$utf16 = utf8_to_utf16be($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
-
+
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -224,7 +224,7 @@ class JSON
$utf16 = utf8_to_utf16be($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
-
+
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -238,7 +238,7 @@ class JSON
$utf16 = utf8_to_utf16be($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
-
+
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -255,9 +255,9 @@ class JSON
break;
}
}
-
+
return '"'.$ascii.'"';
-
+
case 'array':
/*
* As per JSON spec if any array key is not an integer
@@ -268,7 +268,7 @@ class JSON
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
- *
+ *
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
@@ -276,8 +276,8 @@ class JSON
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
-
- // treat as a JSON object
+
+ // treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
return sprintf('{%s}', join(',', array_map(array($this, 'name_value'),
array_keys($var),
@@ -286,18 +286,18 @@ class JSON
// treat it like a regular array
return sprintf('[%s]', join(',', array_map(array($this, 'encode'), $var)));
-
+
case 'object':
$vars = get_object_vars($var);
return sprintf('{%s}', join(',', array_map(array($this, 'name_value'),
array_keys($vars),
- array_values($vars))));
+ array_values($vars))));
default:
return '';
}
}
-
+
/**
* encodes an arbitrary variable into JSON format, alias for encode()
*/
@@ -305,7 +305,7 @@ class JSON
{
return $this->encode($var);
}
-
+
/** function name_value
* array-walking function for use in generating JSON-formatted name-value pairs
*
@@ -318,7 +318,7 @@ class JSON
function name_value($name, $value)
{
return (sprintf("%s:%s", $this->encode(strval($name)), $this->encode($value)));
- }
+ }
/**
* reduce a string by removing leading and trailing comments and whitespace
@@ -331,18 +331,18 @@ class JSON
function reduce_string($str)
{
$str = preg_replace(array(
-
+
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
-
+
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
-
+
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
-
+
), '', $str);
-
+
// eliminate extraneous space
return trim($str);
}
@@ -362,17 +362,17 @@ class JSON
function decode($str)
{
$str = $this->reduce_string($str);
-
+
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
-
+
case 'null':
return null;
-
+
default:
if (is_numeric($str)) {
// Lookie-loo, it's a number
@@ -385,19 +385,19 @@ class JSON
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
-
+
} elseif (preg_match('/^("|\').+("|\')$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
-
+
for ($c = 0; $c < $strlen_chrs; ++$c) {
-
+
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
-
+
switch ($substr_chrs_c_2) {
case '\b': $utf8 .= chr(0x08); $c+=1; break;
case '\t': $utf8 .= chr(0x09); $c+=1; break;
@@ -414,7 +414,7 @@ class JSON
$utf8 .= $chrs{++$c};
}
break;
-
+
default:
if (preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6))) {
// single, escaped unicode character
@@ -423,30 +423,30 @@ class JSON
//$utf8 .= mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
$utf8 .= utf16be_to_utf8($utf16);
$c+=5;
-
+
} elseif(($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F)) {
$utf8 .= $chrs{$c};
-
+
} elseif(($ord_chrs_c & 0xE0) == 0xC0) {
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2); $c += 1;
-
+
} elseif(($ord_chrs_c & 0xF0) == 0xE0) {
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3); $c += 2;
-
+
} elseif(($ord_chrs_c & 0xF8) == 0xF0) {
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4); $c += 3;
-
+
} elseif(($ord_chrs_c & 0xFC) == 0xF8) {
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5); $c += 4;
-
+
} elseif(($ord_chrs_c & 0xFE) == 0xFC) {
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -458,9 +458,9 @@ class JSON
}
}
-
+
return $utf8;
-
+
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
@@ -476,14 +476,14 @@ class JSON
$obj = new stdClass();
}
}
-
+
array_push($stk, array('what' => JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
-
+
if ($chrs == '') {
if (reset($stk) == JSON_IN_ARR) {
return $arr;
@@ -495,14 +495,14 @@ class JSON
}
//print("\nparsing {$chrs}\n");
-
+
$strlen_chrs = strlen($chrs);
-
+
for ($c = 0; $c <= $strlen_chrs; ++$c) {
-
+
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
-
+
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
@@ -590,16 +590,16 @@ class JSON
// found a comment end, and we're in one now
array_pop($stk);
$c++;
-
+
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
-
+
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
-
+
}
-
+
if (reset($stk) == JSON_IN_ARR) {
return $arr;
@@ -607,11 +607,11 @@ class JSON
return $obj;
}
-
+
}
}
}
-
+
/**
* decodes a JSON string into appropriate variable; alias for decode()
*/
@@ -619,7 +619,7 @@ class JSON
{
return $this->decode($var);
}
-
+
}
-
+
?>
diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php
index eb9ab8627..885f565e2 100644
--- a/inc/JpegMeta.php
+++ b/inc/JpegMeta.php
@@ -3,7 +3,7 @@
* JPEG metadata reader/writer
*
* @license PHP license 2.0 (http://www.php.net/license/2_02.txt)
- * @link http://www.zonageek.com/software/php/jpeg/index.php
+ * @link http://www.zonageek.com/software/php/jpeg/index.php
* @author Sebastian Delmont <sdelmont@zonageek.com>
* @author Andreas Gohr <andi@splitbrain.org>
* @todo Add support for Maker Notes, Extend for GIF and PNG metadata
@@ -121,7 +121,7 @@ class JpegMeta
return $info;
}
-
+
/**
* Convinience function to access nearly all available Data
* through one function
@@ -154,7 +154,7 @@ class JpegMeta
}
if($info != false) break;
}
-
+
if($info === false) $info = $alt;
if(is_array($info)){
if(isset($info['val'])){
@@ -214,7 +214,7 @@ class JpegMeta
if (isset($this->_info['dates'][$field])) {
return $this->_info['dates'][$field];
}
-
+
return false;
}
@@ -232,7 +232,7 @@ class JpegMeta
if (isset($this->_info['file'][$field])) {
return $this->_info['file'][$field];
}
-
+
return false;
}
@@ -848,7 +848,7 @@ class JpegMeta
}
return false;
}
-
+
/*************************************************************/
/* PRIVATE FUNCTIONS (Internal Use Only!) */
/*************************************************************/
@@ -1325,7 +1325,7 @@ class JpegMeta
return false;
}
- $pos = 0;
+ $pos = 0;
$this->_info['jfif'] = array();
@@ -1395,7 +1395,7 @@ class JpegMeta
return false;
}
- $pos = 0;
+ $pos = 0;
$this->_info['sof'] = array();
@@ -2353,7 +2353,7 @@ class JpegMeta
}
/*************************************************************/
- function _write8BIM(&$data, $pos, $type, $header, &$value)
+ function _write8BIM(&$data, $pos, $type, $header, &$value)
{
$signature = "8BIM";
diff --git a/inc/actions.php b/inc/actions.php
index eb43bb13f..8c76fc0ff 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -39,7 +39,7 @@ function act_dispatch(){
//check if user is asking to (un)subscribe a page
if($ACT == 'subscribe' || $ACT == 'unsubscribe')
$ACT = act_subscription($ACT);
-
+
//check permissions
$ACT = act_permcheck($ACT);
@@ -47,17 +47,17 @@ function act_dispatch(){
if($ACT == 'register' && register()){
$ACT = 'login';
}
-
+
if ($ACT == 'resendpwd' && act_resendpwd()) {
$ACT = 'login';
}
-
+
//update user profile
if (($ACT == 'profile') && updateprofile()) {
msg($lang['profchanged'],1);
$ACT = 'show';
}
-
+
//save
if($ACT == 'save')
$ACT = act_save($ACT);
@@ -66,7 +66,7 @@ function act_dispatch(){
if(($ACT == 'edit' || $ACT == 'preview') && $INFO['editable']){
$ACT = act_edit($ACT);
}else{
- unlock($ID); //try to unlock
+ unlock($ID); //try to unlock
}
//handle export
@@ -84,12 +84,12 @@ function act_dispatch(){
// retrieve admin plugin name from $_REQUEST['page']
if ($_REQUEST['page']) {
$pluginlist = plugin_list('admin');
- if (in_array($_REQUEST['page'], $pluginlist)) {
+ if (in_array($_REQUEST['page'], $pluginlist)) {
// attempt to load the plugin
if ($plugin =& plugin_load('admin',$_REQUEST['page']) !== NULL)
$plugin->handle();
}
- }
+ }
/*
if($_REQUEST['page'] == 'acl'){
require_once(DOKU_INC.'inc/admin_acl.php');
@@ -99,7 +99,7 @@ function act_dispatch(){
}
//call template FIXME: all needed vars available?
- header('Content-Type: text/html; charset=utf-8');
+ header('Content-Type: text/html; charset=utf-8');
include(template('main.php'));
// output for the commands is now handled in inc/templates.php
// in function tpl_content()
@@ -205,7 +205,7 @@ function act_save($act){
saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM,$_REQUEST['minor']); //use pretty mode for con
//unlock it
unlock($ID);
-
+
//show it
session_write_close();
header("Location: ".wl($ID,'',true));
@@ -220,7 +220,7 @@ function act_save($act){
function act_auth($act){
global $ID;
global $INFO;
-
+
//already logged in?
if($_SERVER['REMOTE_USER'] && $act=='login')
return 'show';
@@ -229,9 +229,9 @@ function act_auth($act){
if($act=='logout'){
$lockedby = checklock($ID); //page still locked?
if($lockedby == $_SERVER['REMOTE_USER'])
- unlock($ID); //try to unlock
+ unlock($ID); //try to unlock
- // do the logout stuff
+ // do the logout stuff
auth_logoff();
// rebuild info array
@@ -318,7 +318,7 @@ function act_subscription($act){
global $ID;
global $INFO;
global $lang;
-
+
$file=metaFN($ID,'.mlist');
if ($act=='subscribe' && !$INFO['subscribed']){
if ($INFO['userinfo']['mail']){
diff --git a/inc/admin_acl.php b/inc/admin_acl.php
index 7027fe8dc..fdcf871b6 100644
--- a/inc/admin_acl.php
+++ b/inc/admin_acl.php
@@ -37,7 +37,7 @@ function admin_acl_handler(){
if($cmd == 'save'){
admin_acl_del($scope, $user);
- admin_acl_add($scope, $user, $perm);
+ admin_acl_add($scope, $user, $perm);
}elseif($cmd == 'delete'){
admin_acl_del($scope, $user);
}
@@ -60,9 +60,9 @@ function admin_acl_handler(){
*/
function get_acl_config($id){
global $AUTH_ACL;
-
+
$acl_config=array();
-
+
// match exact name
$matches = preg_grep('/^'.$id.'\s+.*/',$AUTH_ACL);
if(count($matches)){
@@ -73,7 +73,7 @@ function get_acl_config($id){
$acl_config[$acl[0]][] = array( 'name' => $acl[1], 'perm' => $acl[2]);
}
}
-
+
$specific_found=array();
// match ns
while(($id=getNS($id)) !== false){
@@ -88,7 +88,7 @@ function get_acl_config($id){
}
}
}
-
+
//include *-config
$matches = preg_grep('/^\*\s+.*/',$AUTH_ACL);
if(count($matches)){
@@ -102,11 +102,11 @@ function get_acl_config($id){
}
}
}
-
+
//sort
//FIXME: better sort algo: first sort by key, then sort by first value
krsort($acl_config, SORT_STRING);
-
+
return($acl_config);
}
@@ -118,16 +118,16 @@ function get_acl_config($id){
*/
function admin_acl_add($acl_scope, $acl_user, $acl_level){
$acl_config = join("",file(DOKU_CONF.'acl.auth.php'));
-
+
// max level for pagenames is edit
if(strpos($acl_scope,'*') === false) {
if($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT;
}
-
+
$new_acl = "$acl_scope\t$acl_user\t$acl_level\n";
-
+
$new_config = $acl_config.$new_acl;
-
+
return io_saveFile(DOKU_CONF.'acl.auth.php', $new_config);
}
@@ -140,10 +140,10 @@ function admin_acl_del($acl_scope, $acl_user){
$acl_config = file(DOKU_CONF.'acl.auth.php');
$acl_pattern = '^'.preg_quote($acl_scope,'/').'\s+'.$acl_user.'\s+[0-8].*$';
-
+
// save all non!-matching #FIXME invert is available from 4.2.0 only!
$new_config = preg_grep("/$acl_pattern/", $acl_config, PREG_GREP_INVERT);
-
+
return io_saveFile(DOKU_CONF.'acl.auth.php', join('',$new_config));
}
@@ -172,7 +172,7 @@ function admin_acl_html(){
//current config
$acls = get_acl_config($ID);
foreach ($acls as $id => $acl){
- admin_acl_html_current($id,$acl);
+ admin_acl_html_current($id,$acl);
}
ptln('</table>');
@@ -246,10 +246,10 @@ function admin_acl_html_new(){
ptln(' <input type="hidden" name="do" value="admin" />',4);
ptln(' <input type="hidden" name="page" value="acl" />',4);
ptln(' <input type="hidden" name="acl_cmd" value="save" />',4);
-
+
//scope select
ptln($lang['acl_perms'],4);
- ptln(admin_acl_html_dropdown($ID),4);
+ ptln(admin_acl_html_dropdown($ID),4);
$att = array( 'name' => 'acl_type',
'class' => 'edit',
@@ -384,7 +384,7 @@ function admin_acl_html_checkboxes($setperm,$ispage){
'value' => $perm );
//dynamic attributes
if($setperm >= $perm) $atts['checked'] = 'checked';
-# if($perm > AUTH_READ) $atts['onchange'] = #FIXME JS to autoadd lower perms
+# if($perm > AUTH_READ) $atts['onchange'] = #FIXME JS to autoadd lower perms
if($ispage && $perm > AUTH_EDIT) $atts['disabled'] = 'disabled';
//build code
diff --git a/inc/aspell.php b/inc/aspell.php
index 570656795..fe1ad9dc6 100644
--- a/inc/aspell.php
+++ b/inc/aspell.php
@@ -74,7 +74,7 @@ class Aspell{
var $encoding = 'iso8859-1';
var $mode = PSPELL_NORMAL;
var $version = 0;
-
+
var $args='';
/**
@@ -86,7 +86,7 @@ class Aspell{
$this->language = $language;
$this->jargon = $jargon;
$this->encoding = $encoding;
- }
+ }
/**
* Set the spelling mode like pspell_config_mode()
@@ -187,7 +187,7 @@ class Aspell{
$string = "^".str_replace("\n", "\n^",$text);
fwrite($pipes[0],$string); // send text to Aspell
fclose($pipes[0]);
-
+
// read Aspells response from stdin
while (!feof($pipes[1])) {
$out .= fread($pipes[1], 8192);
@@ -201,7 +201,7 @@ class Aspell{
$tmp = array();
preg_match('/^\@.*Aspell (\d+)\.(\d+).(\d+)/',$out,$tmp);
$this->version = $tmp[1]*100 + $tmp[2]*10 + $tmp[3];
-
+
if ($this->version <= 603) // version 0.60.3
$r = $terse ? "\n*\n\$1" : "\n\$1"; // replacement for broken Aspell
else
diff --git a/inc/auth/basic.class.php b/inc/auth/basic.class.php
index 6046edea1..faffa4cea 100644
--- a/inc/auth/basic.class.php
+++ b/inc/auth/basic.class.php
@@ -2,12 +2,12 @@
/**
* auth/basic.class.php
*
- * foundation authorisation class
+ * foundation authorisation class
* all auth classes should inherit from this class
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
-
+
class auth_basic {
var $success = true;
@@ -40,11 +40,11 @@ class auth_basic {
* Carry out sanity checks to ensure the object is
* able to operate. Set capabilities in $this->cando
* array here
- *
+ *
* Set $this->success to false if checks fail
*
* @author Christopher Smith <chris@jalakai.co.uk>
- */
+ */
function auth_basic() {
// the base class constructor does nothing, derived class
// constructors do the real work
@@ -166,7 +166,7 @@ class auth_basic {
msg("no valid authorisation system in use", -1);
return false;
}
-
+
/**
* Return user info [ MUST BE OVERRIDDEN ]
*
@@ -184,13 +184,13 @@ class auth_basic {
msg("no valid authorisation system in use", -1);
return false;
}
-
+
/**
* Create a new User [implement only where required/possible]
*
* Returns false if the user already exists, null when an error
* occured and true if everything went well.
- *
+ *
* The new user HAS TO be added to the default group by this
* function!
*
@@ -202,7 +202,7 @@ class auth_basic {
msg("authorisation method does not allow creation of new users", -1);
return null;
}
-
+
/**
* Modify user data [implement only where required/possible]
*
@@ -217,7 +217,7 @@ class auth_basic {
msg("authorisation method does not allow modifying of user data", -1);
return false;
}
-
+
/**
* Delete one or more users [implement only where required/possible]
*
@@ -244,7 +244,7 @@ class auth_basic {
msg("authorisation method does not provide user counts", -1);
return 0;
}
-
+
/**
* Bulk retrieval of user data [implement only where required/possible]
*
@@ -260,10 +260,10 @@ class auth_basic {
msg("authorisation method does not support mass retrieval of user data", -1);
return array();
}
-
+
/**
* Define a group [implement only where required/possible]
- *
+ *
* Set addGroup capability when implemented
*
* @author Chris Smith <chris@jalakai.co.uk>
@@ -276,7 +276,7 @@ class auth_basic {
/**
* Retrieve groups [implement only where required/possible]
- *
+ *
* Set getGroups capability when implemented
*
* @author Chris Smith <chris@jalakai.co.uk>
diff --git a/inc/auth/ldap.class.php b/inc/auth/ldap.class.php
index de1c8570b..49643d3bf 100644
--- a/inc/auth/ldap.class.php
+++ b/inc/auth/ldap.class.php
@@ -2,12 +2,12 @@
/**
* auth/basic.class.php
*
- * foundation authorisation class
+ * foundation authorisation class
* all auth classes should inherit from this class
*
* @author Chris Smith <chris@jalakaic.co.uk>
*/
-
+
class auth_ldap extends auth_basic {
var $cnf = null;
var $con = null;
@@ -28,17 +28,17 @@ class auth_ldap extends auth_basic {
// capabilities are set
}
- /**
- * Check user+password
- *
- * Checks if the given user exists and the given
- * plaintext password is correct by trying to bind
+ /**
+ * Check user+password
+ *
+ * Checks if the given user exists and the given
+ * plaintext password is correct by trying to bind
* to the LDAP server
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @return bool
- */
- function checkPass($user,$pass){
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @return bool
+ */
+ function checkPass($user,$pass){
// reject empty password
if(empty($pass)) return false;
if(!$this->_openLDAP()) return false;
@@ -108,17 +108,17 @@ class auth_ldap extends auth_basic {
}
return false;
- }
-
- /**
- * Return user info [ MUST BE OVERRIDDEN ]
- *
- * 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
+ }
+
+ /**
+ * Return user info [ MUST BE OVERRIDDEN ]
+ *
+ * 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:
@@ -130,9 +130,9 @@ class auth_ldap extends auth_basic {
* @author Trouble
* @author Dan Allen <dan.j.allen@gmail.com>
* @auhtor <evaldas.auryla@pheur.org>
- * @return array containing user data or false
+ * @return array containing user data or false
*/
- function getUserData($user) {
+ function getUserData($user) {
global $conf;
if(!$this->_openLDAP()) return false;
@@ -227,8 +227,8 @@ class auth_ldap extends auth_basic {
}
return $info;
- }
-
+ }
+
/**
* Make LDAP filter strings.
*
@@ -237,7 +237,7 @@ class auth_ldap extends auth_basic {
*
* filter string ldap search filter with placeholders
* placeholders array array with the placeholders
- *
+ *
* @author Troels Liebe Bentsen <tlb@rapanden.dk>
* @return string
*/
@@ -254,7 +254,7 @@ class auth_ldap extends auth_basic {
$filter = str_replace('%{'.$match.'}', $value, $filter);
}
return $filter;
- }
+ }
/**
* Opens a connection to the configured LDAP server and sets the wnated
diff --git a/inc/auth/mysql.class.php b/inc/auth/mysql.class.php
index bd8fc42c6..632a97b5d 100644
--- a/inc/auth/mysql.class.php
+++ b/inc/auth/mysql.class.php
@@ -7,19 +7,19 @@
* @author Chris Smith <chris@jalakai.co.uk>
* @author Matthias Grimm <matthias.grimmm@sourceforge.net>
*/
-
-define('DOKU_AUTH', dirname(__FILE__));
+
+define('DOKU_AUTH', dirname(__FILE__));
require_once(DOKU_AUTH.'/basic.class.php');
class auth_mysql extends auth_basic {
-
+
var $dbcon = 0;
var $dbver = 0; // database version
var $dbrev = 0; // database revision
var $dbsub = 0; // database subrevision
var $cnf = null;
var $defaultgroup = "";
-
+
/**
* Constructor
*
@@ -30,17 +30,17 @@ class auth_mysql extends auth_basic {
*/
function auth_mysql() {
global $conf;
-
+
if (method_exists($this, 'auth_basic'))
parent::auth_basic();
-
+
if(!function_exists('mysql_connect')) {
if ($this->cnf['debug'])
msg("MySQL err: PHP MySQL extension not found.",-1);
$this->success = false;
return;
}
-
+
$this->cnf = $conf['auth']['mysql'];
$this->defaultgroup = $conf['defaultgroup'];
@@ -82,7 +82,7 @@ class auth_mysql extends auth_basic {
}
/**
- * Check if the given config strings are set
+ * Check if the given config strings are set
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
* @return bool
@@ -115,16 +115,16 @@ class auth_mysql extends auth_basic {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
- */
+ */
function checkPass($user,$pass){
$rc = false;
-
+
if($this->_openDB()) {
$sql = str_replace('%{user}',addslashes($user),$this->cnf['checkPass']);
$sql = str_replace('%{pass}',addslashes($pass),$sql);
$sql = str_replace('%{dgroup}',addslashes($this->defaultgroup),$sql);
$result = $this->_queryDB($sql);
-
+
if($result !== false && count($result) == 1) {
if($this->cnf['forwardClearPass'] == 1)
$rc = true;
@@ -145,7 +145,7 @@ class auth_mysql extends auth_basic {
* mail string email addres of the user
* grps array list of groups the user is in
*
- * @param $user user's nick to get data for
+ * @param $user user's nick to get data for
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
@@ -166,7 +166,7 @@ class auth_mysql extends auth_basic {
*
* Create a new User. Returns false if the user already exists,
* null when an error occured and true if everything went well.
- *
+ *
* The new user will be added to the default group by this
* function if grps are not specified (default behaviour).
*
@@ -188,7 +188,7 @@ class auth_mysql extends auth_basic {
// set defaultgroup if no groups were given
if ($grps == null)
$grps = array($this->defaultgroup);
-
+
$this->_lockTables("WRITE");
$pwd = $this->cnf['forwardClearPass'] ? $pwd : auth_cryptPassword($pwd);
$rc = $this->_addUser($user,$pwd,$name,$mail,$grps);
@@ -198,12 +198,12 @@ class auth_mysql extends auth_basic {
}
return null; // return error
}
-
+
/**
* Modify user data [public function]
*
* An existing user dataset will be modified. Changes are given in an array.
- *
+ *
* The dataset update will be rejected if the user name should be changed
* to an already existing one.
*
@@ -229,10 +229,10 @@ class auth_mysql extends auth_basic {
*/
function modifyUser($user, $changes) {
$rc = false;
-
+
if (!is_array($changes) || !count($changes))
return true; // nothing to change
-
+
if($this->_openDB()) {
$this->_lockTables("WRITE");
@@ -243,17 +243,17 @@ class auth_mysql extends auth_basic {
$groups = $this->_getGroups($user);
$grpadd = array_diff($changes['grps'], $groups);
$grpdel = array_diff($groups, $changes['grps']);
-
+
foreach($grpadd as $group)
if (($this->_addUserToGroup($uid, $group, 1)) == false)
$rc = false;
-
+
foreach($grpdel as $group)
if (($this->_delUserFromGroup($uid, $group)) == false)
$rc = false;
- }
+ }
}
-
+
$this->_unlockTables();
$this->_closeDB();
}
@@ -273,7 +273,7 @@ class auth_mysql extends auth_basic {
*/
function deleteUsers($users) {
$count = 0;
-
+
if($this->_openDB()) {
if (is_array($users) && count($users)) {
$this->_lockTables("WRITE");
@@ -287,7 +287,7 @@ class auth_mysql extends auth_basic {
}
return $count;
}
-
+
/**
* [public function]
*
@@ -300,10 +300,10 @@ class auth_mysql extends auth_basic {
*/
function getUserCount($filter=array()) {
$rc = 0;
-
+
if($this->_openDB()) {
$sql = $this->_createSQLFilter($this->cnf['getUsers'], $filter);
-
+
if ($this->dbver >= 4) {
$sql = substr($sql, 6); /* remove 'SELECT' or 'select' */
$sql = "SELECT SQL_CALC_FOUND_ROWS".$sql." LIMIT 1";
@@ -312,12 +312,12 @@ class auth_mysql extends auth_basic {
$rc = $result[0]['FOUND_ROWS()'];
} else if (($result = $this->_queryDB($sql)))
$rc = count($result);
-
+
$this->_closeDB();
}
return $rc;
}
-
+
/**
* Bulk retrieval of user data. [public function]
*
@@ -330,7 +330,7 @@ class auth_mysql extends auth_basic {
*/
function retrieveUsers($first=0,$limit=10,$filter=array()) {
$out = array();
-
+
if($this->_openDB()) {
$this->_lockTables("READ");
$sql = $this->_createSQLFilter($this->cnf['getUsers'], $filter);
@@ -340,7 +340,7 @@ class auth_mysql extends auth_basic {
foreach ($result as $user)
if (($info = $this->_getUserInfo($user['user'])))
$out[$user['user']] = $info;
-
+
$this->_unlockTables();
$this->_closeDB();
}
@@ -349,16 +349,16 @@ class auth_mysql extends auth_basic {
/**
* Give user membership of a group [public function]
- *
+ *
* @param $user
- * @param $group
+ * @param $group
* @return bool true on success, false on error
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
*/
function joinGroup($user, $group) {
$rc = false;
-
+
if ($this->_openDB()) {
$this->_lockTables("WRITE");
$uid = $this->_getUserID($user);
@@ -380,7 +380,7 @@ class auth_mysql extends auth_basic {
*/
function leaveGroup($user, $group) {
$rc = false;
-
+
if ($this->_openDB()) {
$this->_lockTables("WRITE");
$uid = $this->_getUserID($user);
@@ -390,7 +390,7 @@ class auth_mysql extends auth_basic {
}
return $rc;
}
-
+
/**
* Adds a user to a group.
*
@@ -410,7 +410,7 @@ class auth_mysql extends auth_basic {
*/
function _addUserToGroup($uid, $group, $force=0) {
$newgroup = 0;
-
+
if (($this->dbcon) && ($uid)) {
$gid = $this->_getGroupID($group);
if (!$gid) {
@@ -421,7 +421,7 @@ class auth_mysql extends auth_basic {
}
if (!$gid) return false; // group didn't exist and can't be created
}
-
+
$sql = str_replace('%{uid}', addslashes($uid),$this->cnf['addUserGroup']);
$sql = str_replace('%{user}', addslashes($user),$sql);
$sql = str_replace('%{gid}', addslashes($gid),$sql);
@@ -448,7 +448,7 @@ class auth_mysql extends auth_basic {
*/
function _delUserFromGroup($uid, $group) {
$rc = false;
-
+
if (($this->dbcon) && ($uid)) {
$gid = $this->_getGroupID($group);
if ($gid) {
@@ -461,7 +461,7 @@ class auth_mysql extends auth_basic {
}
return $rc;
}
-
+
/**
* Retrieves a list of groups the user is a member off.
*
@@ -477,11 +477,11 @@ class auth_mysql extends auth_basic {
*/
function _getGroups($user) {
$groups = array();
-
+
if($this->dbcon) {
$sql = str_replace('%{user}',addslashes($user),$this->cnf['getGroups']);
$result = $this->_queryDB($sql);
-
+
if(count($result)) {
foreach($result as $row)
$groups[] = $row['group'];
@@ -493,7 +493,7 @@ class auth_mysql extends auth_basic {
/**
* Retrieves the user id of a given user name
- *
+ *
* The database connection must already be established
* for this function to work. Otherwise it will return
* 'false'.
@@ -511,7 +511,7 @@ class auth_mysql extends auth_basic {
}
return false;
}
-
+
/**
* Adds a new User to the database.
*
@@ -535,16 +535,16 @@ class auth_mysql extends auth_basic {
$sql = str_replace('%{user}', addslashes($user),$this->cnf['addUser']);
$sql = str_replace('%{pass}', addslashes($pwd),$sql);
$sql = str_replace('%{name}', addslashes($name),$sql);
- $sql = str_replace('%{email}',addslashes($mail),$sql);
+ $sql = str_replace('%{email}',addslashes($mail),$sql);
$uid = $this->_modifyDB($sql);
-
+
if ($uid) {
foreach($grps as $group) {
$uid = $this->_getUserID($user);
$gid = $this->_addUserToGroup($uid, $group, 1);
if ($gid === false) break;
}
-
+
if ($gid) return true;
else {
/* remove the new user and all group relations if a group can't
@@ -560,10 +560,10 @@ class auth_mysql extends auth_basic {
}
return false;
}
-
+
/**
* Deletes a given user and all his group references.
- *
+ *
* The database connection must already be established
* for this function to work. Otherwise it will return
* 'false'.
@@ -638,7 +638,7 @@ class auth_mysql extends auth_basic {
if($this->dbcon) {
foreach ($changes as $item => $value) {
- if ($item == 'user') {
+ if ($item == 'user') {
if (($this->_getUserID($changes['user']))) {
$err = 1; /* new username already exists */
break; /* abort update */
@@ -673,7 +673,7 @@ class auth_mysql extends auth_basic {
/**
* Retrieves the group id of a given group name
- *
+ *
* The database connection must already be established
* for this function to work. Otherwise it will return
* 'false'.
@@ -691,19 +691,19 @@ class auth_mysql extends auth_basic {
}
return false;
}
-
+
/**
* Opens a connection to a database and saves the handle for further
* usage in the object. The successful call to this functions is
* essential for most functions in this object.
- *
+ *
* @return bool
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
*/
function _openDB() {
if (!$this->dbcon) {
- $con = @mysql_connect ($this->cnf['server'], $this->cnf['user'], $this->cnf['password']);
+ $con = @mysql_connect ($this->cnf['server'], $this->cnf['user'], $this->cnf['password']);
if ($con) {
if ((mysql_select_db($this->cnf['database'], $con))) {
if ((preg_match("/^(\d+)\.(\d+)\.(\d+).*/", mysql_get_server_info ($con), $result)) == 1) {
@@ -711,13 +711,13 @@ class auth_mysql extends auth_basic {
$this->dbrev = $result[2];
$this->dbsub = $result[3];
}
- $this->dbcon = $con;
+ $this->dbcon = $con;
return true; // connection and database successfully opened
} else {
mysql_close ($con);
if ($this->cnf['debug'])
msg("MySQL err: No access to database {$this->cnf['database']}.", -1);
- }
+ }
} else if ($this->cnf['debug'])
msg ("MySQL err: Connection to {$this->cnf['user']}@{$this->cnf['server']} not possible.", -1);
@@ -725,7 +725,7 @@ class auth_mysql extends auth_basic {
}
return true; // connection already open
}
-
+
/**
* Closes a database connection.
*
@@ -737,19 +737,19 @@ class auth_mysql extends auth_basic {
$this->dbcon = 0;
}
}
-
+
/**
* Sends a SQL query to the database and transforms the result into
* an associative array.
- *
- * This function is only able to handle queries that returns a
+ *
+ * This function is only able to handle queries that returns a
* table such as SELECT.
*
* @param $query SQL string that contains the query
* @return array with the result table
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
- */
+ */
function _queryDB($query) {
if ($this->dbcon) {
$result = @mysql_query($query,$this->dbcon);
@@ -764,10 +764,10 @@ class auth_mysql extends auth_basic {
}
return false;
}
-
+
/**
* Sends a SQL query to the database
- *
+ *
* This function is only able to handle queries that returns
* either nothing or an id value such as INPUT, DELETE, UPDATE, etc.
*
@@ -775,7 +775,7 @@ class auth_mysql extends auth_basic {
* @return insert id or 0, false on error
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
- */
+ */
function _modifyDB($query) {
if ($this->dbcon) {
$result = @mysql_query($query,$this->dbcon);
@@ -788,7 +788,7 @@ class auth_mysql extends auth_basic {
}
return false;
}
-
+
/**
* Locked a list of tables for exclusive access so that modifications
* to the database can't be disturbed by other threads. The list
@@ -806,7 +806,7 @@ class auth_mysql extends auth_basic {
* @param $mode could be 'READ' or 'WRITE'
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
- */
+ */
function _lockTables($mode) {
if ($this->dbcon) {
if (is_array($this->cnf['TablesToLock']) && !empty($this->cnf['TablesToLock'])) {
@@ -830,7 +830,7 @@ class auth_mysql extends auth_basic {
* abrogated.
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
- */
+ */
function _unlockTables() {
if ($this->dbcon) {
$this->_modifyDB("UNLOCK TABLES");
@@ -838,7 +838,7 @@ class auth_mysql extends auth_basic {
}
return false;
}
-
+
/**
* Transforms the filter settings in an filter string for a SQL database
* The database connection must already be established, otherwise the
@@ -854,7 +854,7 @@ class auth_mysql extends auth_basic {
function _createSQLFilter($sql, $filter) {
$SQLfilter = "";
$cnt = 0;
-
+
if ($this->dbcon) {
foreach ($filter as $item => $pattern) {
$tmp = addslashes('%'.mysql_real_escape_string($pattern, $this->dbcon).'%');
@@ -872,11 +872,11 @@ class auth_mysql extends auth_basic {
$SQLfilter .= str_replace('%{group}',$tmp,$this->cnf['FilterGroup']);
}
}
-
+
// we have to check SQLfilter here and must not use $cnt because if
// any of cnf['Filter????'] is not defined, a malformed SQL string
// would be generated.
-
+
if (strlen($SQLfilter)) {
$glue = strpos(strtolower($sql),"where") ? " AND " : " WHERE ";
$sql = $sql.$glue.$SQLfilter;
@@ -885,8 +885,8 @@ class auth_mysql extends auth_basic {
return $sql;
}
-
-
+
+
}
//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/auth/plain.class.php b/inc/auth/plain.class.php
index 9ab3bc70a..3ed014262 100644
--- a/inc/auth/plain.class.php
+++ b/inc/auth/plain.class.php
@@ -6,8 +6,8 @@
* @author Andreas Gohr <andi@splitbrain.org>
* @author Chris Smith <chris@jalakai.co.uk>
*/
-
-define('DOKU_AUTH', dirname(__FILE__));
+
+define('DOKU_AUTH', dirname(__FILE__));
require_once(DOKU_AUTH.'/basic.class.php');
define('AUTH_USERFILE',DOKU_CONF.'users.auth.php');
@@ -15,22 +15,22 @@ define('AUTH_USERFILE',DOKU_CONF.'users.auth.php');
// we only accept page ids for auth_plain
if(isset($_REQUEST['u']))
$_REQUEST['u'] = cleanID($_REQUEST['u']);
-
+
class auth_plain extends auth_basic {
var $users = null;
var $_pattern = array();
-
- /**
- * Constructor
- *
- * Carry out sanity checks to ensure the object is
- * able to operate. Set capabilities.
- *
+
+ /**
+ * Constructor
+ *
+ * Carry out sanity checks to ensure the object is
+ * able to operate. Set capabilities.
+ *
* @author Christopher Smith <chris@jalakai.co.uk>
- */
- function auth_plain() {
- if (!@is_readable(AUTH_USERFILE)){
+ */
+ function auth_plain() {
+ if (!@is_readable(AUTH_USERFILE)){
$this->success = false;
}else{
if(@is_writable(AUTH_USERFILE)){
@@ -45,7 +45,7 @@ class auth_plain extends auth_basic {
$this->cando['getUsers'] = true;
$this->cando['getUserCount'] = true;
}
- }
+ }
/**
* Check user+password [required auth function]
@@ -57,10 +57,10 @@ class auth_plain extends auth_basic {
* @return bool
*/
function checkPass($user,$pass){
-
+
$userinfo = $this->getUserData($user);
if ($userinfo === false) return false;
-
+
return auth_verifyPassword($pass,$this->users[$user]['pass']);
}
@@ -87,7 +87,7 @@ class auth_plain extends auth_basic {
*
* Returns false if the user already exists, null when an error
* occured and true if everything went well.
- *
+ *
* The new user will be added to the default group by this
* function if grps are not specified (default behaviour).
*
@@ -96,28 +96,28 @@ class auth_plain extends auth_basic {
*/
function createUser($user,$pwd,$name,$mail,$grps=null){
global $conf;
-
+
// user mustn't already exist
if ($this->getUserData($user) !== false) return false;
-
+
$pass = auth_cryptPassword($pwd);
-
+
// set default group if no groups specified
if (!is_array($grps)) $grps = array($conf['defaultgroup']);
// prepare user line
- $groups = join(',',$grps);
+ $groups = join(',',$grps);
$userline = join(':',array($user,$pass,$name,$mail,$groups))."\n";
if (io_saveFile(AUTH_USERFILE,$userline,true)) {
$this->users[$user] = compact('pass','name','mail','grps');
return $pwd;
}
-
+
msg('The '.AUTH_USERFILE.' file is not writable. Please inform the Wiki-Admin',-1);
return null;
}
-
+
/**
* Modify user data
*
@@ -130,7 +130,7 @@ class auth_plain extends auth_basic {
global $conf;
global $ACT;
global $INFO;
-
+
// sanity checks, user must already exist and there must be something to change
if (($userinfo = $this->getUserData($user)) === false) return false;
if (!is_array($changes) || !count($changes)) return true;
@@ -138,31 +138,31 @@ class auth_plain extends auth_basic {
// update userinfo with new data, remembering to encrypt any password
$newuser = $user;
foreach ($changes as $field => $value) {
- if ($field == 'user') {
+ if ($field == 'user') {
$newuser = $value;
continue;
}
if ($field == 'pass') $value = auth_cryptPassword($value);
$userinfo[$field] = $value;
}
-
+
$groups = join(',',$userinfo['grps']);
$userline = join(':',array($newuser, $userinfo['pass'], $userinfo['name'], $userinfo['mail'], $groups))."\n";
-
+
if (!$this->deleteUsers(array($user))) {
msg('Unable to modify user data. Please inform the Wiki-Admin',-1);
return false;
}
-
+
if (!io_saveFile(AUTH_USERFILE,$userline,true)) {
msg('There was an error modifying your user data. You should register again.',-1);
// FIXME, user has been deleted but not recreated, should force a logout and redirect to login page
$ACT == 'register';
return false;
}
-
+
$this->users[$newuser] = $userinfo;
- return true;
+ return true;
}
/**
@@ -173,18 +173,18 @@ class auth_plain extends auth_basic {
* @return int the number of users deleted
*/
function deleteUsers($users) {
-
+
if (!is_array($users) || empty($users)) return 0;
if ($this->users === null) $this->_loadUserData();
-
+
$deleted = array();
foreach ($users as $user) {
if (isset($this->users[$user])) $deleted[] = preg_quote($user,'/');
}
if (empty($deleted)) return 0;
-
+
$pattern = '/^('.join('|',$deleted).'):/';
if (io_deleteFromFile(AUTH_USERFILE,$pattern,true)) {
@@ -198,7 +198,7 @@ class auth_plain extends auth_basic {
$count -= $count($this->users());
return $count;
}
-
+
/**
* Return a count of the number of user which meet $filter criteria
*
@@ -208,18 +208,18 @@ class auth_plain extends auth_basic {
if($this->users === null) $this->_loadUserData();
- if (!count($filter)) return count($this->users);
-
+ if (!count($filter)) return count($this->users);
+
$count = 0;
$this->_constructPattern($filter);
-
+
foreach ($this->users as $user => $info) {
$count += $this->_filter($user, $info);
}
-
+
return $count;
}
-
+
/**
* Bulk retrieval of user data
*
@@ -234,12 +234,12 @@ class auth_plain extends auth_basic {
if ($this->users === null) $this->_loadUserData();
ksort($this->users);
-
+
$i = 0;
$count = 0;
$out = array();
$this->_constructPattern($filter);
-
+
foreach ($this->users as $user => $info) {
if ($this->_filter($user, $info)) {
if ($i >= $start) {
@@ -253,7 +253,7 @@ class auth_plain extends auth_basic {
return $out;
}
-
+
/**
* Load all user data
*
@@ -265,23 +265,23 @@ class auth_plain extends auth_basic {
$this->users = array();
if(!@file_exists(AUTH_USERFILE)) return;
-
+
$lines = file(AUTH_USERFILE);
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]);
-
+
$this->users[$row[0]]['pass'] = $row[1];
$this->users[$row[0]]['name'] = urldecode($row[2]);
$this->users[$row[0]]['mail'] = $row[3];
$this->users[$row[0]]['grps'] = $groups;
}
}
-
+
/**
* return 1 if $user + $info match $filter criteria, 0 otherwise
*
@@ -300,14 +300,14 @@ class auth_plain extends auth_basic {
}
return 1;
}
-
+
function _constructPattern($filter) {
$this->_pattern = array();
foreach ($filter as $item => $pattern) {
// $this->_pattern[$item] = '/'.preg_quote($pattern,"/").'/'; // don't allow regex characters
$this->_pattern[$item] = '/'.str_replace('/','\/',$pattern).'/'; // allow regex characters
}
- }
+ }
}
//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/auth/punbb.class.php b/inc/auth/punbb.class.php
index 455432d51..9a380728a 100644
--- a/inc/auth/punbb.class.php
+++ b/inc/auth/punbb.class.php
@@ -24,8 +24,8 @@ class auth_punbb extends auth_mysql {
*/
function auth_punbb(){
global $conf;
- $this->cando['external'] = true;
- $this->cando['logoff'] = true;
+ $this->cando['external'] = true;
+ $this->cando['logoff'] = true;
// make sure we use a crypt understood by punbb
if(function_exists('sha1')){
@@ -73,7 +73,7 @@ class auth_punbb extends auth_mysql {
(username, password, email, realname)
VALUES ('%{user}', '%{pass}', '%{email}', '%{name}')";
$conf['auth']['mysql']['addGroup'] = "INSERT INTO ${db_prefix}groups (g_title) VALUES ('%{group}')";
- $conf['auth']['mysql']['addUserGroup']= "UPDATE ${db_prefix}users
+ $conf['auth']['mysql']['addUserGroup']= "UPDATE ${db_prefix}users
SET group_id=%{gid}
WHERE id='%{uid}'";
$conf['auth']['mysql']['delGroup'] = "DELETE FROM ${db_prefix}groups WHERE g_id='%{gid}'";
diff --git a/inc/cliopts.php b/inc/cliopts.php
index 592b529a0..074f48772 100644
--- a/inc/cliopts.php
+++ b/inc/cliopts.php
@@ -32,18 +32,18 @@ if (version_compare(phpversion(), '4.3.0', '<') || php_sapi_name() == 'cgi') {
// Handle output buffering
@ob_end_flush();
ob_implicit_flush(TRUE);
-
+
// PHP ini settings
set_time_limit(0);
ini_set('track_errors', TRUE);
ini_set('html_errors', FALSE);
ini_set('magic_quotes_runtime', FALSE);
-
+
// Define stream constants
define('STDIN', fopen('php://stdin', 'r'));
define('STDOUT', fopen('php://stdout', 'w'));
define('STDERR', fopen('php://stderr', 'w'));
-
+
// Close the streams on script termination
register_shutdown_function(
create_function('',
@@ -69,7 +69,7 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
*
*/
class Doku_Cli_Opts {
-
+
/**
* <?php ?>
* @see http://www.sitepoint.com/article/php-command-line-1/3
@@ -80,40 +80,40 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
*/
function & getOptions($bin_file, $short_options, $long_options = null) {
$args = Doku_Cli_Opts::readPHPArgv();
-
+
if ( Doku_Cli_Opts::isError($args) ) {
return $args;
}
-
+
// Compatibility between "php extensions.php" and "./extensions.php"
if ( realpath($_SERVER['argv'][0]) == $bin_file ) {
$options = Doku_Cli_Opts::getOpt($args,$short_options,$long_options);
} else {
$options = Doku_Cli_Opts::getOpt2($args,$short_options,$long_options);
}
-
+
if ( Doku_Cli_Opts::isError($options) ) {
return $options;
}
-
+
$container = new Doku_Cli_Opts_Container($options);
return $container;
}
-
+
function getopt2($args, $short_options, $long_options = null) {
return Doku_Cli_Opts::doGetopt(
2, $args, $short_options, $long_options
);
}
-
+
function getopt($args, $short_options, $long_options = null) {
return Doku_Cli_Opts::doGetopt(
1, $args, $short_options, $long_options
);
}
-
+
function doGetopt($version, $args, $short_options, $long_options = null) {
-
+
// in case you pass directly readPHPArgv() as the first arg
if (Doku_Cli_Opts::isError($args)) {
return $args;
@@ -123,13 +123,13 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
}
$opts = array();
$non_opts = array();
-
+
settype($args, 'array');
-
+
if ($long_options && is_array($long_options)) {
sort($long_options);
}
-
+
/*
* Preserve backwards compatibility with callers that relied on
* erroneous POSIX fix.
@@ -139,10 +139,10 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
array_shift($args);
}
}
-
+
reset($args);
while (list($i, $arg) = each($args)) {
-
+
/* The special element '--' means explicit end of
options. Treat the rest of the arguments as non-options
and end the loop. */
@@ -150,7 +150,7 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
$non_opts = array_merge($non_opts, array_slice($args, $i + 1));
break;
}
-
+
if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
$non_opts = array_merge($non_opts, array_slice($args, $i));
break;
@@ -164,15 +164,15 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
return $error;
}
}
-
+
return array($opts, $non_opts);
}
-
+
function _parseShortOption($arg, $short_options, &$opts, &$args) {
for ($i = 0; $i < strlen($arg); $i++) {
$opt = $arg{$i};
$opt_arg = null;
-
+
/* Try to find the short option in the specifier string. */
if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':')
{
@@ -181,7 +181,7 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
"Unrecognized option -- $opt"
);
}
-
+
if (strlen($spec) > 1 && $spec{1} == ':') {
if (strlen($spec) > 2 && $spec{2} == ':') {
if ($i + 1 < strlen($arg)) {
@@ -205,25 +205,25 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
);
}
}
-
+
$opts[] = array($opt, $opt_arg);
}
}
-
+
function _parseLongOption($arg, $long_options, &$opts, &$args) {
@list($opt, $opt_arg) = explode('=', $arg);
$opt_len = strlen($opt);
-
+
for ($i = 0; $i < count($long_options); $i++) {
$long_opt = $long_options[$i];
$opt_start = substr($long_opt, 0, $opt_len);
-
+
/* Option doesn't match. Go on to the next one. */
if ($opt_start != $opt)
continue;
-
+
$opt_rest = substr($long_opt, $opt_len);
-
+
/* Check that the options uniquely matches one of the allowed
options. */
if ($opt_rest != '' && $opt{0} != '=' &&
@@ -234,7 +234,7 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
"Option --$opt is ambiguous"
);
}
-
+
if (substr($long_opt, -1) == '=') {
if (substr($long_opt, -2) != '==') {
/* Long option requires an argument.
@@ -252,17 +252,17 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
"Option --$opt doesn't allow an argument"
);
}
-
+
$opts[] = array('--' . $opt, $opt_arg);
return;
}
-
+
return Doku_Cli_Opts::raiseError(
DOKU_CLI_OPTS_UNKNOWN_OPT,
"Unrecognized option --$opt"
);
}
-
+
function readPHPArgv() {
global $argv;
if (!is_array($argv)) {
@@ -279,11 +279,11 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
}
return $argv;
}
-
+
function raiseError($code, $msg) {
return new Doku_Cli_Opts_Error($code, $msg);
}
-
+
function isError($obj) {
return is_a($obj, 'Doku_Cli_Opts_Error');
}
@@ -292,31 +292,31 @@ define('DOKU_CLI_OPTS_ARG_READ',5);//Could not read argv
//------------------------------------------------------------------------------
class Doku_Cli_Opts_Error {
-
+
var $code;
var $msg;
-
+
function Doku_Cli_Opts_Error($code, $msg) {
$this->code = $code;
$this->msg = $msg;
}
-
+
function getMessage() {
return $this->msg;
}
-
+
function isError() {
return TRUE;
}
-
+
}
//------------------------------------------------------------------------------
class Doku_Cli_Opts_Container {
-
+
var $options = array();
var $args = array();
-
+
function Doku_Cli_Opts_Container($options) {
foreach ( $options[0] as $option ) {
if ( FALSE !== ( strpos($option[0], '--') ) ) {
@@ -326,35 +326,35 @@ class Doku_Cli_Opts_Container {
}
$this->options[$opt_name] = $option[1];
}
-
-
+
+
$this->args = $options[1];
}
-
+
function has($option) {
return array_key_exists($option, $this->options);
}
-
+
function get($option) {
if ( isset($this->options[$option]) ) {
return ( $this->options[$option] ) ;
}
}
-
+
function arg($index) {
if ( isset($this->args[$index]) ) {
return $this->args[$index];
}
}
-
+
function numArgs() {
return count($this->args);
}
-
+
function hasArgs() {
return count($this->args) !== 0;
}
-
+
function isError() {
return FALSE;
}
diff --git a/inc/confutils.php b/inc/confutils.php
index cc1d8064a..b800f5f53 100644
--- a/inc/confutils.php
+++ b/inc/confutils.php
@@ -1,7 +1,7 @@
<?php
/**
* Utilities for collecting data from config files
- *
+ *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Harry Fuecks <hfuecks@gmail.com>
*/
@@ -159,7 +159,7 @@ function confToHash($file,$lower=false) {
$conf[$line[0]] = $line[1];
}
}
-
+
return $conf;
}
diff --git a/inc/feedcreator.class.php b/inc/feedcreator.class.php
index 09cecb613..f66d8afc6 100644
--- a/inc/feedcreator.class.php
+++ b/inc/feedcreator.class.php
@@ -24,68 +24,68 @@ GNU General Public License for more details: <http://www.gnu.org/licenses/gpl.tx
Changelog:
v1.7.1
- fixed a syntax bug
- fixed left over debug code
+ 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 Sren Fuhrmann of golem.de)
- improved changing ATOM versions handling (thanks to August Trometer)
- improved the UniversalFeedCreator's useCached method (thanks to Sren Fuhrmann of golem.de)
- added charset output in HTTP headers (thanks to Sren Fuhrmann of golem.de)
- added Slashdot namespace to RSS 1.0 (thanks to Sren 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 Stphane 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
+ 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 Sren Fuhrmann of golem.de)
+ improved changing ATOM versions handling (thanks to August Trometer)
+ improved the UniversalFeedCreator's useCached method (thanks to Sren Fuhrmann of golem.de)
+ added charset output in HTTP headers (thanks to Sren Fuhrmann of golem.de)
+ added Slashdot namespace to RSS 1.0 (thanks to Sren 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 Stphane 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/???
-
+ 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
+ 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
+ added images to feeds
+ now includes most RSS 0.91 attributes
+ added RSS 2.0 feeds
v1.0 06-24-03
- initial release
+ initial release
@@ -93,51 +93,51 @@ v1.0 06-24-03
/*** GENERAL USAGE *********************************************************
-include("feedcreator.class.php");
+include("feedcreator.class.php");
-$rss = new UniversalFeedCreator();
+$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";
+$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"];
+$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.";
+$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;
-
+$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);
-}
+ $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
@@ -168,43 +168,43 @@ define("FEEDCREATOR_VERSION", "FeedCreator 1.7.1");
* @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;
+ /**
+ * 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;
}
@@ -215,15 +215,15 @@ class FeedItem extends HtmlDescribable {
* @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;
+ /**
+ * Mandatory attributes of an image.
+ */
+ var $title, $url, $link;
+
+ /**
+ * Optional attributes of an image.
+ */
+ var $width, $height, $description;
}
@@ -233,82 +233,82 @@ class FeedImage extends HtmlDescribable {
* 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();
- }
+ /**
+ * 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
+ * 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;
- }
+ /**
+ * 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;
+ }
}
@@ -324,101 +324,101 @@ class FeedHtmlField {
* @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);
- }
+ 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);
+ }
/**
@@ -451,240 +451,240 @@ class UniversalFeedCreator extends FeedCreator {
*/
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 />";
- }
- }
+ /**
+ * 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 />";
+ }
+ }
}
@@ -693,92 +693,92 @@ class FeedCreator extends HtmlDescribable {
* 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;
- }
+ 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;
+ }
}
@@ -791,80 +791,80 @@ class FeedDate {
*/
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";
- }
+ /**
+ * 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";
+ }
$creator = $this->getAuthor($this->items[$i]->author, $this->items[$i]->authorEmail);
- if ($creator) {
- $feed.= " <dc:creator>".htmlspecialchars($creator)."</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;
- }
+ if ($creator) {
+ $feed.= " <dc:creator>".htmlspecialchars($creator)."</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;
+ }
/**
* Compose the RSS-1.0 author field.
*
* @author Joe Lapp <joe.lapp@pobox.com>
*/
-
+
function getAuthor($author, $email) {
if($author) {
if($email) {
@@ -873,7 +873,7 @@ class RSSCreator10 extends FeedCreator {
return $author;
}
return $email;
- }
+ }
}
@@ -887,145 +887,145 @@ class RSSCreator10 extends FeedCreator {
*/
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";
-
+ /**
+ * 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";
+
$author = $this->getAuthor($this->items[$i]->author, $this->items[$i]->authorEmail);
- if ($author) {
- $feed.= " <author>".htmlspecialchars($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;
- }
+ if ($author) {
+ $feed.= " <author>".htmlspecialchars($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;
+ }
/**
* Compose the RSS-0.91 and RSS-2.0 author field.
*
* @author Joe Lapp <joe.lapp@pobox.com>
*/
-
+
function getAuthor($author, $email) {
if($author && $email) {
return $email.' ('.$author.')';
}
return $email;
- }
+ }
}
@@ -1042,7 +1042,7 @@ class RSSCreator20 extends RSSCreator091 {
function RSSCreator20() {
parent::_setRSSVersion("2.0");
}
-
+
}
@@ -1055,44 +1055,44 @@ class RSSCreator20 extends RSSCreator091 {
* @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;
- }
+
+ 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;
+ }
}
@@ -1104,7 +1104,7 @@ class PIECreator01 extends FeedCreator {
* 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,
+ * 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.
*
@@ -1114,71 +1114,71 @@ class PIECreator01 extends FeedCreator {
*/
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, " ");
+ 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, " ");
$author = $this->items[$i]->author;
$authorEmail = $this->items[$i]->authorEmail;
- if ($author || $authorEmail) {
- $feed.= " <author>\n";
+ if ($author || $authorEmail) {
+ $feed.= " <author>\n";
if($author) {
- $feed.= " <name>".htmlspecialchars($author)."</name>\n";
- }
+ $feed.= " <name>".htmlspecialchars($author)."</name>\n";
+ }
if($authorEmail) {
- $feed.= " <email>".htmlspecialchars($authorEmail)."</email>\n";
+ $feed.= " <email>".htmlspecialchars($authorEmail)."</email>\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;
- }
+ }
+
+ if ($this->items[$i]->description!="") {
+ $feed.= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n";
+ }
+ $feed.= " </entry>\n";
+ }
+ $feed.= "</feed>\n";
+ return $feed;
+ }
}
@@ -1191,380 +1191,380 @@ class AtomCreator03 extends FeedCreator {
*/
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";
- }
+ 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;
- }
+ 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
+ * 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.
+ * 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";
- }
-}
+ 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
+ * 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";
- }
-
-}
+ 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");
+//include("feedcreator.class.php");
-$rss = new UniversalFeedCreator();
-$rss->useCached();
-$rss->title = "PHP news";
-$rss->description = "daily news from the PHP scripting world";
+$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;
+$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.";
+$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);
-//}
+$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");
+echo $rss->saveFeed("RSS0.91", "feed.xml");
diff --git a/inc/fulltext.php b/inc/fulltext.php
index 34520f0c5..fd974c949 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -159,7 +159,7 @@ function ft_pageLookup($id,$pageonly=true){
if(!preg_match('/'.$id.'/',noNS($pages[$i]))){
unset($pages[$i]);
continue;
- }
+ }
}
if(!@file_exists(wikiFN($pages[$i]))){
unset($pages[$i]);
@@ -257,7 +257,7 @@ function ft_queryParser($query){
$q['phrases'] = array();
$q['and'] = array();
$q['not'] = array();
-
+
// handle phrase searches
while(preg_match('/"(.*?)"/',$query,$match)){
$q['phrases'][] = $match[1];
diff --git a/inc/html.php b/inc/html.php
index 0e5454d4e..f9acd7325 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -19,7 +19,7 @@ function html_wikilink($id,$name=NULL,$search=''){
static $xhtml_renderer = NULL;
if(is_null($xhtml_renderer)){
require_once(DOKU_INC.'inc/parser/xhtml.php');
- $xhtml_renderer = new Doku_Renderer_xhtml();
+ $xhtml_renderer = new Doku_Renderer_xhtml();
}
return $xhtml_renderer->internallink($id,$name,$search,true);
@@ -47,7 +47,7 @@ function html_login(){
global $lang;
global $conf;
global $ID;
- global $auth;
+ global $auth;
print p_locale_xhtml('login');
?>
@@ -186,15 +186,15 @@ function html_topbtn(){
function html_backtomedia_button($params,$akey=''){
global $conf;
global $lang;
-
+
$ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php"><div class="no">';
-
+
reset($params);
while (list($key, $val) = each($params)) {
$ret .= '<input type="hidden" name="'.$key.'" ';
$ret .= 'value="'.htmlspecialchars($val).'" />';
}
-
+
$ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" ';
if($akey){
$ret .= 'title="ALT+'.strtoupper($akey).'" ';
@@ -214,15 +214,15 @@ function html_backtomedia_button($params,$akey=''){
function html_btn($name,$id,$akey,$params,$method='get'){
global $conf;
global $lang;
-
+
$label = $lang['btn_'.$name];
-
+
$ret = '';
//filter id (without urlencoding)
$id = idfilter($id,false);
- //make nice URLs even for buttons
+ //make nice URLs even for buttons
if($conf['userewrite'] == 2){
$script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
}elseif($conf['userewrite']){
@@ -231,15 +231,15 @@ function html_btn($name,$id,$akey,$params,$method='get'){
$script = DOKU_BASE.DOKU_SCRIPT;
$params['id'] = $id;
}
-
+
$ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">';
-
+
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).'" ';
@@ -266,7 +266,7 @@ function html_show($txt=''){
}else{
$secedit = true;
}
-
+
if ($txt){
//PreviewHeader
print '<br id="scroll__here" />';
@@ -300,11 +300,11 @@ function html_hilight($html,$query){
return $html;
}
-/**
+/**
* Callback used by html_hilight()
*
* @author Harry Fuecks <hfuecks@gmail.com>
- */
+ */
function html_hilight_callback($m) {
$hlight = unslash($m[0]);
if ( !isset($m[2])) {
@@ -391,7 +391,7 @@ function html_locked(){
global $conf;
global $lang;
global $INFO;
-
+
$locktime = filemtime(wikiFN($ID).'.lock');
$expire = @date($conf['dformat'], $locktime + $conf['locktime'] );
$min = round(($conf['locktime'] - (time() - $locktime) )/60);
@@ -413,9 +413,9 @@ function html_revisions(){
global $INFO;
global $conf;
global $lang;
- $revisions = getRevisions($ID);
+ $revisions = getRevisions($ID);
$date = @date($conf['dformat'],$INFO['lastmod']);
-
+
print p_locale_xhtml('revisions');
print '<ul>';
if($INFO['exists']){
@@ -494,11 +494,11 @@ function html_recent($first=0){
$first=0;
$recents = getRecents(0,$conf['recent'] + 1,getNS($ID));
}
- $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
+ $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
print p_locale_xhtml('recent');
print '<ul>';
-
+
foreach($recents as $recent){
$date = date($conf['dformat'],$recent['date']);
print ($recent['minor']) ? '<li class="minor">' : '<li>';
@@ -549,7 +549,7 @@ function html_recent($first=0){
print '<div class="pagenav">';
$last = $first + $conf['recent'];
if ($first > 0) {
- $first -= $conf['recent'];
+ $first -= $conf['recent'];
if ($first < 0) $first = 0;
print '<div class="pagenav-prev">';
print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
@@ -674,7 +674,7 @@ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
$ret .= "</li>\n";
}
- //remember current level
+ //remember current level
$level = $item['level'];
//print item
@@ -832,7 +832,7 @@ function html_register(){
<?php echo $lang['user']?>
<input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
</label><br />
-
+
<?php
if (!$conf['autopasswd']) {
?>
@@ -877,7 +877,7 @@ function html_updateprofile(){
global $auth;
print p_locale_xhtml('updateprofile');
-
+
if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
?>
@@ -891,7 +891,7 @@ function html_updateprofile(){
<label class="block">
<?php echo $lang['user']?>
<input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" />
- </label><br />
+ </label><br />
<label class="block">
<?php echo $lang['fullname']?>
<input type="text" name="fullname" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
@@ -911,15 +911,15 @@ function html_updateprofile(){
<input type="password" name="passchk" class="edit" size="50" />
</label><br />
<?php } ?>
-
+
<?php if ($conf['profileconfirm']) { ?>
<br />
<label class="block">
<?php echo $lang['oldpass']?>
- <input type="password" name="oldpass" class="edit" size="50" />
+ <input type="password" name="oldpass" class="edit" size="50" />
</label><br />
<?php } ?>
-
+
<input type="submit" class="button" value="<?php echo $lang['btn_save']?>" />
<input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" />
</fieldset>
@@ -982,7 +982,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
}
if(!$DATE) $DATE = $INFO['lastmod'];
-
+
?>
<div style="width:99%;">
<form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"><div class="no">
@@ -1038,7 +1038,7 @@ function html_minoredit(){
// minor edits are for logged in users only
if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
return;
- }
+ }
$p = array();
$p['name'] = 'minor';
@@ -1087,11 +1087,11 @@ function html_debug(){
print '<b>DOKU_BASE:</b><pre>';
print DOKU_BASE;
print '</pre>';
-
+
print '<b>abs DOKU_BASE:</b><pre>';
print DOKU_URL;
print '</pre>';
-
+
print '<b>rel DOKU_BASE:</b><pre>';
print dirname($_SERVER['PHP_SELF']).'/';
print '</pre>';
@@ -1142,7 +1142,7 @@ function html_admin(){
$menu = array();
foreach ($pluginlist as $p) {
if($obj =& plugin_load('admin',$p) === NULL) continue;
- $menu[] = array('plugin' => $p,
+ $menu[] = array('plugin' => $p,
'prompt' => $obj->getMenuText($conf['lang']),
'sort' => $obj->getMenuSort()
);
@@ -1162,7 +1162,7 @@ function html_admin(){
if (!$conf['openregister']){
ptln('<li><div class="li"><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></div></li>');
}
-
+
ptln('</ul>');
}
@@ -1175,7 +1175,7 @@ function html_resendpwd() {
global $lang;
global $conf;
global $ID;
-
+
print p_locale_xhtml('resendpwd');
?>
<div class="centeralign">
diff --git a/inc/indexer.php b/inc/indexer.php
index cc2a9ebbf..fa3803665 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -50,31 +50,31 @@ function idx_getPageWords($page){
$words = array();
foreach ($tokens as $word => $count) {
- // simple filter to restrict use of utf8_stripspecials
+ // simple filter to restrict use of utf8_stripspecials
if (preg_match('/[^0-9A-Za-z]/u', $word)) {
// handle asian chars as single words (may fail on older PHP version)
$asia = @preg_replace('/('.IDX_ASIAN.')/u','\1 ',$word);
if(!is_null($asia)) $word = $asia; //recover from regexp failure
$arr = explode(' ', utf8_stripspecials($word,' ','._\-:\*'));
$arr = array_count_values($arr);
-
+
foreach ($arr as $w => $c) {
if (!is_numeric($w) && strlen($w) < 3) continue;
- $w = utf8_strtolower($w);
+ $w = utf8_strtolower($w);
$words[$w] = $c * $count + (isset($words[$w]) ? $words[$w] : 0);
}
} else {
if (!is_numeric($word) && strlen($word) < 3) continue;
- $word = strtolower($word);
+ $word = strtolower($word);
$words[$word] = $count + (isset($words[$word]) ? $words[$word] : 0);
}
}
// arrive here with $words = array(word => frequency)
-
+
$index = array(); //resulting index
foreach ($words as $word => $freq) {
- if (is_int(array_search("$word\n",$stopwords))) continue;
+ if (is_int(array_search("$word\n",$stopwords))) continue;
$wid = array_search("$word\n",$word_idx);
if(!is_int($wid)){
$word_idx[] = "$word\n";
@@ -82,7 +82,7 @@ function idx_getPageWords($page){
}
$index[$wid] = $freq;
}
-
+
// save back word index
$fh = fopen($conf['cachedir'].'/word.idx','w');
if(!$fh){
@@ -91,7 +91,7 @@ function idx_getPageWords($page){
}
fwrite($fh,join('',$word_idx));
fclose($fh);
-
+
return $index;
}
@@ -133,7 +133,7 @@ function idx_addPage($page){
if(!$idx || !$tmp){
trigger_error("Failed to open index files", E_USER_ERROR);
return false;
- }
+ }
// copy from index to temp file, modifying were needed
$lno = 0;
@@ -233,7 +233,7 @@ function idx_lookup($words){
foreach($words as $word){
$result[$word] = array();
$wild = 0;
- $xword = $word;
+ $xword = $word;
// check for wildcards
if(substr($xword,0,1) == '*'){
@@ -244,7 +244,7 @@ function idx_lookup($words){
$xword = substr($xword,0,-1);
$wild += 2;
}
-
+
// look for the ID(s) for the given word
if($wild){ // handle wildcard search
$cnt = count($word_idx);
@@ -276,7 +276,7 @@ function idx_lookup($words){
if(!$idx){
msg("Failed to open index file",-1);
return false;
- }
+ }
// Walk the index til the lines are found
$docs = array(); // hold docs found
@@ -288,7 +288,7 @@ function idx_lookup($words){
$line .= fgets($idx, 4096);
if(substr($line,-1) != "\n") continue;
if($lno > $srch) break; // shouldn't happen
-
+
// do we want this line?
if($lno == $srch){
@@ -358,7 +358,7 @@ function idx_parseIndexLine(&$page_idx,$line){
* @param string $string the query as given by the user
* @param arrayref $stopwords array of stopwords
* @param boolean $wc are wildcards allowed?
- *
+ *
* @todo make combined function to use alone or in getPageWords
*/
function idx_tokenizer($string,&$stopwords,$wc=false){
diff --git a/inc/init.php b/inc/init.php
index ac1349473..65c64515c 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -181,7 +181,7 @@ function getBaseURL($abs=false){
$dir = str_replace('\\','/',$dir); #bugfix for weird WIN behaviour
$dir = preg_replace('#//+#','/',$dir);
-
+
//handle script in lib/exe dir
$dir = preg_replace('!lib/exe/$!','',$dir);
diff --git a/inc/io.php b/inc/io.php
index f882d9b36..72b963520 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -21,7 +21,7 @@ function io_sweepNS($id){
//scan all namespaces
while(($id = getNS($id)) !== false){
- $dir = $conf['datadir'].'/'.str_replace(':','/',$id);
+ $dir = $conf['datadir'].'/'.str_replace(':','/',$id);
$dir = utf8_encodeFN($dir);
//try to delete dir else return
@@ -115,7 +115,7 @@ function io_deleteFromFile($file,$badline,$regex=false){
// remove all matching lines
if ($regex) {
- $lines = preg_grep($badline,$lines,PREG_GREP_INVERT);
+ $lines = preg_grep($badline,$lines,PREG_GREP_INVERT);
} else {
$pos = array_search($badline,$lines); //return null or false if not found
while(is_int($pos)){
@@ -158,7 +158,7 @@ function io_deleteFromFile($file,$badline,$regex=false){
* inside $conf['lockdir']
*
* It waits maximal 3 seconds for the lock, after this time
- * the lock is assumed to be stale and the function goes on
+ * the lock is assumed to be stale and the function goes on
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
@@ -170,7 +170,7 @@ function io_lock($file){
$lockDir = $conf['lockdir'].'/'.md5($file);
@ignore_user_abort(1);
-
+
$timeStart = time();
do {
//waited longer than 3 seconds? -> stale lock
@@ -207,7 +207,7 @@ function io_makeFileDir($file){
if(!is_dir($dir)){
io_mkdir_p($dir) || msg("Creating directory $dir failed",-1);
}
- umask($conf['umask']);
+ umask($conf['umask']);
}
/**
@@ -247,7 +247,7 @@ function io_mkdir_ftp($dir){
msg("FTP support not found - safemode workaround not usable",-1);
return false;
}
-
+
$conn = @ftp_connect($conf['ftp']['host'],$conf['ftp']['port'],10);
if(!$conn){
msg("FTP connection failed",-1);
@@ -271,11 +271,11 @@ function io_mkdir_ftp($dir){
/**
* downloads a file from the net and saves it
*
- * if $useAttachment is false,
+ * if $useAttachment is false,
* - $file is the full filename to save the file, incl. path
* - if successful will return true, false otherwise
-
- * if $useAttachment is true,
+
+ * if $useAttachment is true,
* - $file is the directory where the file should be saved
* - if successful will return the name used for the saved file, false otherwise
*
@@ -289,25 +289,25 @@ function io_download($url,$file,$useAttachment=false,$defaultName=''){
$data = $http->get($url);
if(!$data) return false;
-
+
if ($useAttachment) {
$name = '';
if (isset($http->resp_headers['content-disposition'])) {
$content_disposition = $http->resp_headers['content-disposition'];
- $match=array();
- if (is_string($content_disposition) &&
+ $match=array();
+ if (is_string($content_disposition) &&
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) {
-
+
$name = basename($match[1]);
}
-
+
}
-
+
if (!$name) {
if (!$defaultName) return false;
- $name = $defaultName;
+ $name = $defaultName;
}
-
+
$file = $file.$name;
}
diff --git a/inc/mail.php b/inc/mail.php
index eeef4f66b..b4ca10551 100644
--- a/inc/mail.php
+++ b/inc/mail.php
@@ -22,7 +22,7 @@
* @param string $to Receiver of the mail (multiple seperated by commas)
* @param string $subject Mailsubject
* @param string $body Messagebody
- * @param string $from Sender address
+ * @param string $from Sender address
* @param string $cc CarbonCopy receiver (multiple seperated by commas)
* @param string $bcc BlindCarbonCopy receiver (multiple seperated by commas)
* @param string $headers Additional Headers (seperated by MAILHEADER_EOL
@@ -122,7 +122,7 @@ function mail_encode_address($string,$header='',$names=true){
$text = '=?UTF-8?Q?'.mail_quotedprintable_encode($text).'?=';
}
}
-
+
// add to header comma seperated and in new line to avoid too long headers
if($headers != '') $headers .= ','.MAILHEADER_EOL.' ';
$headers .= $text.$addr;
@@ -140,7 +140,7 @@ function mail_encode_address($string,$header='',$names=true){
* Uses a regular expresion to check if a given mail address is valid
*
* May not be completly RFC conform!
- *
+ *
* @link http://www.webmasterworld.com/forum88/135.htm
*
* @param string $email the address to check
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 53e5b2aba..2a07b5fe6 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -1,7 +1,7 @@
<?php
/**
* Utilities for handling pagenames
- *
+ *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
* @todo Combine similar functions like {wiki,media,meta}FN()
@@ -15,7 +15,7 @@
*
* For $param='id' $conf['start'] is returned if no id was found.
* If the second parameter is true (default) the ID is cleaned.
- *
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getID($param='id',$clean=true){
@@ -54,7 +54,7 @@ function getID($param='id',$clean=true){
}
if($clean) $id = cleanID($id);
if(empty($id) && $param=='id') $id = $conf['start'];
-
+
return $id;
}
@@ -72,7 +72,7 @@ function cleanID($id,$ascii=false){
global $conf;
global $lang;
static $sepcharpat = null;
-
+
$sepchar = $conf['sepchar'];
if($sepcharpat == null) // build string only once to save clock cycles
$sepcharpat = '#\\'.$sepchar.'+#';
@@ -88,7 +88,7 @@ function cleanID($id,$ascii=false){
$id = strtr($id,'/',$sepchar);
}
- if($conf['deaccent'] == 2 || $ascii) $id = utf8_romanize($id);
+ if($conf['deaccent'] == 2 || $ascii) $id = utf8_romanize($id);
if($conf['deaccent'] || $ascii) $id = utf8_deaccent($id,-1);
//remove specials
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index a1f2fe4c7..3609e23a8 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -2,51 +2,51 @@
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
class Doku_Handler {
-
+
var $Renderer = NULL;
-
+
var $CallWriter = NULL;
-
+
var $calls = array();
-
+
var $meta = array(
'section' => FALSE,
'toc' => TRUE,
'cache' => TRUE,
);
-
+
var $rewriteBlocks = TRUE;
-
+
function Doku_Handler() {
$this->CallWriter = & new Doku_Handler_CallWriter($this);
}
-
+
function _addCall($handler, $args, $pos) {
$call = array($handler,$args, $pos);
$this->CallWriter->writeCall($call);
}
-
+
function _finalize(){
if ( $this->meta['section'] ) {
$S = & new Doku_Handler_Section();
$this->calls = $S->process($this->calls);
}
-
+
if ( $this->rewriteBlocks ) {
$B = & new Doku_Handler_Block();
$this->calls = $B->process($this->calls);
}
-
+
if ( $this->meta['toc'] ) {
$T = & new Doku_Handler_Toc();
$this->calls = $T->process($this->calls);
}
-
+
array_unshift($this->calls,array('document_start',array(),0));
$last_call = end($this->calls);
array_push($this->calls,array('document_end',array(),$last_call[2]));
}
-
+
function fetch() {
$call = each($this->calls);
if ( $call ) {
@@ -66,24 +66,24 @@ class Doku_Handler {
*/
function plugin($match, $state, $pos, $pluginname){
$data = array($match);
- $plugin =& plugin_load('syntax',$pluginname);
+ $plugin =& plugin_load('syntax',$pluginname);
if($plugin != null){
$data = $plugin->handle($match, $state, $pos, $this);
}
$this->_addCall('plugin',array($pluginname,$data,$pos),$pos);
return TRUE;
}
-
+
function base($match, $state, $pos) {
switch ( $state ) {
case DOKU_LEXER_UNMATCHED:
$this->_addCall('cdata',array($match), $pos);
return TRUE;
break;
-
+
}
}
-
+
function header($match, $state, $pos) {
$match = trim($match);
$levels = array(
@@ -95,23 +95,23 @@ class Doku_Handler {
);
$hsplit = preg_split( '/(={2,})/u', $match,-1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
-
+
// Locate the level - default to level 1 if no match (title contains == signs)
if ( isset($hsplit[0]) && array_key_exists($hsplit[0], $levels) ) {
$level = $levels[$hsplit[0]];
} else {
$level = 1;
}
-
+
// Strip markers and whitespaces
$title = trim($match,'=');
$title = trim($title,' ');
-
+
$this->_addCall('header',array($title,$level,$pos), $pos);
$this->meta['section'] = TRUE;
return TRUE;
}
-
+
function notoc($match, $state, $pos) {
$this->meta['toc'] = FALSE;
return TRUE;
@@ -121,22 +121,22 @@ class Doku_Handler {
$this->_addCall('nocache',array(),$pos);
return TRUE;
}
-
+
function linebreak($match, $state, $pos) {
$this->_addCall('linebreak',array(),$pos);
return TRUE;
}
-
+
function eol($match, $state, $pos) {
$this->_addCall('eol',array(),$pos);
return TRUE;
}
-
+
function hr($match, $state, $pos) {
$this->_addCall('hr',array(),$pos);
return TRUE;
}
-
+
function _nestingTag($match, $state, $pos, $name) {
switch ( $state ) {
case DOKU_LEXER_ENTER:
@@ -150,48 +150,48 @@ class Doku_Handler {
break;
}
}
-
+
function strong($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'strong');
return TRUE;
}
-
+
function emphasis($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'emphasis');
return TRUE;
}
-
+
function underline($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'underline');
return TRUE;
}
-
+
function monospace($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'monospace');
return TRUE;
}
-
+
function subscript($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'subscript');
return TRUE;
}
-
+
function superscript($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'superscript');
return TRUE;
}
-
+
function deleted($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'deleted');
return TRUE;
}
-
-
+
+
function footnote($match, $state, $pos) {
$this->_nestingTag($match, $state, $pos, 'footnote');
return TRUE;
}
-
+
function listblock($match, $state, $pos) {
switch ( $state ) {
case DOKU_LEXER_ENTER:
@@ -214,38 +214,38 @@ class Doku_Handler {
}
return TRUE;
}
-
+
function unformatted($match, $state, $pos) {
if ( $state == DOKU_LEXER_UNMATCHED ) {
$this->_addCall('unformatted',array($match), $pos);
}
return TRUE;
}
-
+
function php($match, $state, $pos) {
- global $conf;
+ global $conf;
if ( $state == DOKU_LEXER_UNMATCHED ) {
- if ($conf['phpok']) {
- $this->_addCall('php',array($match), $pos);
- } else {
- $this->_addCall('file',array($match), $pos);
- }
+ if ($conf['phpok']) {
+ $this->_addCall('php',array($match), $pos);
+ } else {
+ $this->_addCall('file',array($match), $pos);
+ }
}
return TRUE;
}
-
+
function html($match, $state, $pos) {
- global $conf;
+ global $conf;
if ( $state == DOKU_LEXER_UNMATCHED ) {
- if($conf['htmlok']){
- $this->_addCall('html',array($match), $pos);
- } else {
- $this->_addCall('file',array($match), $pos);
- }
+ if($conf['htmlok']){
+ $this->_addCall('html',array($match), $pos);
+ } else {
+ $this->_addCall('file',array($match), $pos);
+ }
}
return TRUE;
}
-
+
function preformatted($match, $state, $pos) {
switch ( $state ) {
case DOKU_LEXER_ENTER:
@@ -266,47 +266,47 @@ class Doku_Handler {
$this->_addCall('preformatted_content',array($match), $pos);
break;
}
-
+
return TRUE;
}
-
+
function file($match, $state, $pos) {
if ( $state == DOKU_LEXER_UNMATCHED ) {
$this->_addCall('file',array($match), $pos);
}
return TRUE;
}
-
+
function quote($match, $state, $pos) {
-
+
switch ( $state ) {
-
+
case DOKU_LEXER_ENTER:
$ReWriter = & new Doku_Handler_Quote($this->CallWriter);
$this->CallWriter = & $ReWriter;
$this->_addCall('quote_start',array($match), $pos);
break;
-
+
case DOKU_LEXER_EXIT:
$this->_addCall('quote_end',array(), $pos);
$this->CallWriter->process();
$ReWriter = & $this->CallWriter;
$this->CallWriter = & $ReWriter->CallWriter;
break;
-
+
case DOKU_LEXER_MATCHED:
$this->_addCall('quote_newline',array($match), $pos);
break;
-
+
case DOKU_LEXER_UNMATCHED:
$this->_addCall('cdata',array($match), $pos);
break;
-
+
}
-
+
return TRUE;
}
-
+
function code($match, $state, $pos) {
switch ( $state ) {
case DOKU_LEXER_UNMATCHED:
@@ -327,64 +327,64 @@ class Doku_Handler {
}
return TRUE;
}
-
+
function acronym($match, $state, $pos) {
$this->_addCall('acronym',array($match), $pos);
return TRUE;
}
-
+
function smiley($match, $state, $pos) {
$this->_addCall('smiley',array($match), $pos);
return TRUE;
}
-
+
function wordblock($match, $state, $pos) {
$this->_addCall('wordblock',array($match), $pos);
return TRUE;
}
-
+
function entity($match, $state, $pos) {
$this->_addCall('entity',array($match), $pos);
return TRUE;
}
-
+
function multiplyentity($match, $state, $pos) {
preg_match_all('/\d+/',$match,$matches);
$this->_addCall('multiplyentity',array($matches[0][0],$matches[0][1]), $pos);
return TRUE;
}
-
+
function singlequoteopening($match, $state, $pos) {
$this->_addCall('singlequoteopening',array(), $pos);
return TRUE;
}
-
+
function singlequoteclosing($match, $state, $pos) {
$this->_addCall('singlequoteclosing',array(), $pos);
return TRUE;
}
-
+
function doublequoteopening($match, $state, $pos) {
$this->_addCall('doublequoteopening',array(), $pos);
return TRUE;
}
-
+
function doublequoteclosing($match, $state, $pos) {
$this->_addCall('doublequoteclosing',array(), $pos);
return TRUE;
}
-
+
function camelcaselink($match, $state, $pos) {
$this->_addCall('camelcaselink',array($match), $pos);
return TRUE;
}
-
+
/*
*/
function internallink($match, $state, $pos) {
// Strip the opening and closing markup
$link = preg_replace(array('/^\[\[/','/\]\]$/u'),'',$match);
-
+
// Split title from URL
$link = preg_split('/\|/u',$link,2);
if ( !isset($link[1]) ) {
@@ -444,20 +444,20 @@ class Doku_Handler {
return TRUE;
}
-
+
function filelink($match, $state, $pos) {
$this->_addCall('filelink',array($match, NULL), $pos);
return TRUE;
}
-
+
function windowssharelink($match, $state, $pos) {
$this->_addCall('windowssharelink',array($match, NULL), $pos);
return TRUE;
}
-
+
function media($match, $state, $pos) {
$p = Doku_Handler_Parse_Media($match);
-
+
$this->_addCall(
$p['type'],
array($p['src'], $p['title'], $p['align'], $p['width'],
@@ -472,7 +472,7 @@ class Doku_Handler {
$this->_addCall('rss',array($link),$pos);
return TRUE;
}
-
+
function externallink($match, $state, $pos) {
// Prevent use of multibyte strings in URLs
// See: http://www.boingboing.net/2005/02/06/shmoo_group_exploit_.html
@@ -480,26 +480,26 @@ class Doku_Handler {
/*if ( strlen($match) != utf8_strlen($match) ) {
$this->_addCall('cdata',array($match), $pos);
} else {*/
-
+
$this->_addCall('externallink',array($match, NULL), $pos);
//}
return TRUE;
}
-
+
function emaillink($match, $state, $pos) {
$email = preg_replace(array('/^</','/>$/'),'',$match);
$this->_addCall('emaillink',array($email, NULL), $pos);
return TRUE;
}
-
+
function table($match, $state, $pos) {
switch ( $state ) {
-
+
case DOKU_LEXER_ENTER:
-
+
$ReWriter = & new Doku_Handler_Table($this->CallWriter);
$this->CallWriter = & $ReWriter;
-
+
$this->_addCall('table_start', array(), $pos);
//$this->_addCall('table_row', array(), $pos);
if ( trim($match) == '^' ) {
@@ -508,20 +508,20 @@ class Doku_Handler {
$this->_addCall('tablecell', array(), $pos);
}
break;
-
+
case DOKU_LEXER_EXIT:
$this->_addCall('table_end', array(), $pos);
$this->CallWriter->process();
$ReWriter = & $this->CallWriter;
$this->CallWriter = & $ReWriter->CallWriter;
break;
-
+
case DOKU_LEXER_UNMATCHED:
if ( trim($match) != '' ) {
$this->_addCall('cdata',array($match), $pos);
}
break;
-
+
case DOKU_LEXER_MATCHED:
if ( $match == ' ' ){
$this->_addCall('cdata', array($match), $pos);
@@ -551,15 +551,15 @@ function Doku_Handler_Parse_Media($match) {
// Strip the opening and closing markup
$link = preg_replace(array('/^\{\{/','/\}\}$/u'),'',$match);
-
+
// Split title from URL
$link = preg_split('/\|/u',$link,2);
-
-
+
+
// Check alignment
$ralign = (bool)preg_match('/^ /',$link[0]);
$lalign = (bool)preg_match('/ $/',$link[0]);
-
+
// Logic = what's that ;)...
if ( $lalign & $ralign ) {
$align = 'center';
@@ -570,15 +570,15 @@ function Doku_Handler_Parse_Media($match) {
} else {
$align = NULL;
}
-
+
// The title...
if ( !isset($link[1]) ) {
$link[1] = NULL;
}
-
+
//remove aligning spaces
$link[0] = trim($link[0]);
-
+
//split into src and parameters (using the very last questionmark)
$pos = strrpos($link[0], '?');
if($pos !== false){
@@ -606,14 +606,14 @@ function Doku_Handler_Parse_Media($match) {
}else{
$linking = 'details';
}
-
+
//get caching command
if (preg_match('/(nocache|recache)/i',$param,$cachemode)){
$cache = $cachemode[1];
}else{
$cache = 'cache';
}
-
+
// Check whether this is a local or remote image
if ( preg_match('#^(https?|ftp)#i',$src) ) {
$call = 'externalmedia';
@@ -631,23 +631,23 @@ function Doku_Handler_Parse_Media($match) {
'cache'=>$cache,
'linking'=>$linking,
);
-
+
return $params;
}
//------------------------------------------------------------------------
class Doku_Handler_CallWriter {
-
+
var $Handler;
-
+
function Doku_Handler_CallWriter(& $Handler) {
$this->Handler = & $Handler;
}
-
+
function writeCall($call) {
$this->Handler->calls[] = $call;
}
-
+
function writeCalls($calls) {
$this->Handler->calls = array_merge($this->Handler->calls, $calls);
}
@@ -655,27 +655,27 @@ class Doku_Handler_CallWriter {
//------------------------------------------------------------------------
class Doku_Handler_List {
-
+
var $CallWriter;
-
+
var $calls = array();
var $listCalls = array();
var $listStack = array();
-
+
function Doku_Handler_List(& $CallWriter) {
$this->CallWriter = & $CallWriter;
}
-
+
function writeCall($call) {
$this->calls[] = $call;
}
-
+
// Probably not needed but just in case...
function writeCalls($calls) {
$this->calls = array_merge($this->calls, $calls);
$this->CallWriter->writeCalls($this->calls);
}
-
+
//------------------------------------------------------------------------
function process() {
foreach ( $this->calls as $call ) {
@@ -694,26 +694,26 @@ class Doku_Handler_List {
break;
}
}
-
+
$this->CallWriter->writeCalls($this->listCalls);
}
-
+
//------------------------------------------------------------------------
function listStart($call) {
$depth = $this->interpretSyntax($call[1][0], $listType);
-
+
$this->initialDepth = $depth;
$this->listStack[] = array($listType, $depth);
-
+
$this->listCalls[] = array('list'.$listType.'_open',array(),$call[2]);
$this->listCalls[] = array('listitem_open',array(1),$call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
}
-
+
//------------------------------------------------------------------------
function listEnd($call) {
$closeContent = TRUE;
-
+
while ( $list = array_pop($this->listStack) ) {
if ( $closeContent ) {
$this->listCalls[] = array('listcontent_close',array(),$call[2]);
@@ -723,109 +723,109 @@ class Doku_Handler_List {
$this->listCalls[] = array('list'.$list[0].'_close', array(), $call[2]);
}
}
-
+
//------------------------------------------------------------------------
function listOpen($call) {
$depth = $this->interpretSyntax($call[1][0], $listType);
$end = end($this->listStack);
-
+
// Not allowed to be shallower than initialDepth
if ( $depth < $this->initialDepth ) {
$depth = $this->initialDepth;
}
-
+
//------------------------------------------------------------------------
if ( $depth == $end[1] ) {
-
+
// Just another item in the list...
if ( $listType == $end[0] ) {
$this->listCalls[] = array('listcontent_close',array(),$call[2]);
$this->listCalls[] = array('listitem_close',array(),$call[2]);
$this->listCalls[] = array('listitem_open',array($depth-1),$call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
-
+
// Switched list type...
} else {
-
+
$this->listCalls[] = array('listcontent_close',array(),$call[2]);
$this->listCalls[] = array('listitem_close',array(),$call[2]);
$this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]);
$this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]);
$this->listCalls[] = array('listitem_open', array($depth-1), $call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
-
+
array_pop($this->listStack);
$this->listStack[] = array($listType, $depth);
}
-
+
//------------------------------------------------------------------------
// Getting deeper...
} else if ( $depth > $end[1] ) {
-
+
$this->listCalls[] = array('listcontent_close',array(),$call[2]);
$this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]);
$this->listCalls[] = array('listitem_open', array($depth-1), $call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
-
+
$this->listStack[] = array($listType, $depth);
-
+
//------------------------------------------------------------------------
// Getting shallower ( $depth < $end[1] )
} else {
$this->listCalls[] = array('listcontent_close',array(),$call[2]);
$this->listCalls[] = array('listitem_close',array(),$call[2]);
$this->listCalls[] = array('list'.$end[0].'_close',array(),$call[2]);
-
+
// Throw away the end - done
array_pop($this->listStack);
-
+
while (1) {
$end = end($this->listStack);
-
+
if ( $end[1] <= $depth ) {
-
+
// Normalize depths
$depth = $end[1];
-
+
$this->listCalls[] = array('listitem_close',array(),$call[2]);
-
+
if ( $end[0] == $listType ) {
$this->listCalls[] = array('listitem_open',array($depth-1),$call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
-
+
} else {
// Switching list type...
$this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]);
$this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]);
$this->listCalls[] = array('listitem_open', array($depth-1), $call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
-
+
array_pop($this->listStack);
$this->listStack[] = array($listType, $depth);
}
-
+
break;
-
+
// Haven't dropped down far enough yet.... ( $end[1] > $depth )
} else {
-
+
$this->listCalls[] = array('listitem_close',array(),$call[2]);
$this->listCalls[] = array('list'.$end[0].'_close',array(),$call[2]);
-
+
array_pop($this->listStack);
-
+
}
-
+
}
-
+
}
}
-
+
//------------------------------------------------------------------------
function listContent($call) {
$this->listCalls[] = $call;
}
-
+
//------------------------------------------------------------------------
function interpretSyntax($match, & $type) {
if ( substr($match,-1) == '*' ) {
@@ -839,29 +839,29 @@ class Doku_Handler_List {
//------------------------------------------------------------------------
class Doku_Handler_Preformatted {
-
+
var $CallWriter;
-
+
var $calls = array();
var $pos;
var $text ='';
-
-
-
+
+
+
function Doku_Handler_Preformatted(& $CallWriter) {
$this->CallWriter = & $CallWriter;
}
-
+
function writeCall($call) {
$this->calls[] = $call;
}
-
+
// Probably not needed but just in case...
function writeCalls($calls) {
$this->calls = array_merge($this->calls, $calls);
$this->CallWriter->writeCalls($this->calls);
}
-
+
function process() {
foreach ( $this->calls as $call ) {
switch ($call[0]) {
@@ -884,42 +884,42 @@ class Doku_Handler_Preformatted {
//------------------------------------------------------------------------
class Doku_Handler_Quote {
-
+
var $CallWriter;
-
+
var $calls = array();
-
+
var $quoteCalls = array();
-
+
function Doku_Handler_Quote(& $CallWriter) {
$this->CallWriter = & $CallWriter;
}
-
+
function writeCall($call) {
$this->calls[] = $call;
}
-
+
// Probably not needed but just in case...
function writeCalls($calls) {
$this->calls = array_merge($this->calls, $calls);
$this->CallWriter->writeCalls($this->calls);
}
-
+
function process() {
-
+
$quoteDepth = 1;
-
+
foreach ( $this->calls as $call ) {
switch ($call[0]) {
-
+
case 'quote_start':
-
+
$this->quoteCalls[] = array('quote_open',array(),$call[2]);
-
+
case 'quote_newline':
-
+
$quoteLength = $this->getDepth($call[1][0]);
-
+
if ( $quoteLength > $quoteDepth ) {
$quoteDiff = $quoteLength - $quoteDepth;
for ( $i = 1; $i <= $quoteDiff; $i++ ) {
@@ -931,32 +931,32 @@ class Doku_Handler_Quote {
$this->quoteCalls[] = array('quote_close',array(),$call[2]);
}
}
-
+
$quoteDepth = $quoteLength;
-
+
break;
-
+
case 'quote_end':
-
+
if ( $quoteDepth > 1 ) {
$quoteDiff = $quoteDepth - 1;
for ( $i = 1; $i <= $quoteDiff; $i++ ) {
$this->quoteCalls[] = array('quote_close',array(),$call[2]);
}
}
-
+
$this->quoteCalls[] = array('quote_close',array(),$call[2]);
-
+
$this->CallWriter->writeCalls($this->quoteCalls);
break;
-
+
default:
$this->quoteCalls[] = $call;
break;
}
}
}
-
+
function getDepth($marker) {
preg_match('/>{1,}/', $marker, $matches);
$quoteLength = strlen($matches[0]);
@@ -966,9 +966,9 @@ class Doku_Handler_Quote {
//------------------------------------------------------------------------
class Doku_Handler_Table {
-
+
var $CallWriter;
-
+
var $calls = array();
var $tableCalls = array();
var $maxCols = 0;
@@ -976,21 +976,21 @@ class Doku_Handler_Table {
var $currentCols = 0;
var $firstCell = FALSE;
var $lastCellType = 'tablecell';
-
+
function Doku_Handler_Table(& $CallWriter) {
$this->CallWriter = & $CallWriter;
}
-
+
function writeCall($call) {
$this->calls[] = $call;
}
-
+
// Probably not needed but just in case...
function writeCalls($calls) {
$this->calls = array_merge($this->calls, $calls);
$this->CallWriter->writeCalls($this->calls);
}
-
+
//------------------------------------------------------------------------
function process() {
foreach ( $this->calls as $call ) {
@@ -1017,18 +1017,18 @@ class Doku_Handler_Table {
}
$this->CallWriter->writeCalls($this->tableCalls);
}
-
+
function tableStart($call) {
$this->tableCalls[] = array('table_open',array(),$call[2]);
$this->tableCalls[] = array('tablerow_open',array(),$call[2]);
$this->firstCell = TRUE;
}
-
+
function tableEnd($call) {
$this->tableCalls[] = array('table_close',array(),$call[2]);
$this->finalizeTable();
}
-
+
function tableRowOpen($call) {
$this->tableCalls[] = $call;
$this->currentCols = 0;
@@ -1036,16 +1036,16 @@ class Doku_Handler_Table {
$this->lastCellType = 'tablecell';
$this->maxRows++;
}
-
+
function tableRowClose($call) {
// Strip off final cell opening and anything after it
while ( $discard = array_pop($this->tableCalls ) ) {
-
+
if ( $discard[0] == 'tablecell_open' || $discard[0] == 'tableheader_open') {
-
+
// Its a spanning element - put it back and close it
if ( $discard[1][0] > 1 ) {
-
+
$this->tableCalls[] = $discard;
if ( strstr($discard[0],'cell') ) {
$name = 'tablecell';
@@ -1054,50 +1054,50 @@ class Doku_Handler_Table {
}
$this->tableCalls[] = array($name.'_close',array(),$call[2]);
}
-
+
break;
}
}
$this->tableCalls[] = $call;
-
+
if ( $this->currentCols > $this->maxCols ) {
$this->maxCols = $this->currentCols;
}
}
-
+
function tableCell($call) {
if ( !$this->firstCell ) {
-
+
// Increase the span
$lastCall = end($this->tableCalls);
-
+
// A cell call which follows an open cell means an empty cell so span
if ( $lastCall[0] == 'tablecell_open' || $lastCall[0] == 'tableheader_open' ) {
$this->tableCalls[] = array('colspan',array(),$call[2]);
-
+
}
-
+
$this->tableCalls[] = array($this->lastCellType.'_close',array(),$call[2]);
$this->tableCalls[] = array($call[0].'_open',array(1,NULL),$call[2]);
$this->lastCellType = $call[0];
-
+
} else {
-
+
$this->tableCalls[] = array($call[0].'_open',array(1,NULL),$call[2]);
$this->lastCellType = $call[0];
$this->firstCell = FALSE;
-
+
}
-
+
$this->currentCols++;
}
-
+
function tableDefault($call) {
$this->tableCalls[] = $call;
}
-
+
function finalizeTable() {
-
+
// Add the max cols and rows to the table opening
if ( $this->tableCalls[0][0] == 'table_open' ) {
// Adjust to num cols not num col delimeters
@@ -1106,30 +1106,30 @@ class Doku_Handler_Table {
} else {
trigger_error('First element in table call list is not table_open');
}
-
+
$lastRow = 0;
$lastCell = 0;
$toDelete = array();
-
+
// Look for the colspan elements and increment the colspan on the
// previous non-empty opening cell. Once done, delete all the cells
// that contain colspans
foreach ( $this->tableCalls as $key => $call ) {
-
+
if ( $call[0] == 'tablerow_open' ) {
-
+
$lastRow = $key;
-
+
} else if ( $call[0] == 'tablecell_open' || $call[0] == 'tableheader_open' ) {
-
+
$lastCell = $key;
-
+
} else if ( $call[0] == 'table_align' ) {
-
+
// If the previous element was a cell open, align right
if ( $this->tableCalls[$key-1][0] == 'tablecell_open' || $this->tableCalls[$key-1][0] == 'tableheader_open' ) {
$this->tableCalls[$key-1][1][1] = 'right';
-
+
// If the next element if the close of an element, align either center or left
} else if ( $this->tableCalls[$key+1][0] == 'tablecell_close' || $this->tableCalls[$key+1][0] == 'tableheader_close' ) {
if ( $this->tableCalls[$lastCell][1][1] == 'right' ) {
@@ -1137,29 +1137,29 @@ class Doku_Handler_Table {
} else {
$this->tableCalls[$lastCell][1][1] = 'left';
}
-
+
}
-
+
// Now convert the whitespace back to cdata
$this->tableCalls[$key][0] = 'cdata';
} else if ( $call[0] == 'colspan' ) {
-
+
$this->tableCalls[$key-1][1][0] = FALSE;
-
+
for($i = $key-2; $i > $lastRow; $i--) {
-
+
if ( $this->tableCalls[$i][0] == 'tablecell_open' || $this->tableCalls[$i][0] == 'tableheader_open' ) {
-
+
if ( FALSE !== $this->tableCalls[$i][1][0] ) {
$this->tableCalls[$i][1][0]++;
break;
}
-
-
+
+
}
}
-
+
$toDelete[] = $key-1;
$toDelete[] = $key;
$toDelete[] = $key+1;
@@ -1191,36 +1191,36 @@ class Doku_Handler_Table {
//------------------------------------------------------------------------
class Doku_Handler_Section {
-
+
function process($calls) {
-
+
$sectionCalls = array();
$inSection = FALSE;
-
+
foreach ( $calls as $call ) {
-
+
if ( $call[0] == 'header' ) {
-
+
if ( $inSection ) {
$sectionCalls[] = array('section_close',array(), $call[2]);
}
-
+
$sectionCalls[] = $call;
$sectionCalls[] = array('section_open',array($call[1][1]), $call[2]);
$inSection = TRUE;
-
+
} else {
$sectionCalls[] = $call;
}
}
-
+
if ( $inSection ) {
$sectionCalls[] = array('section_close',array(), $call[2]);
}
-
+
return $sectionCalls;
}
-
+
}
/**
@@ -1229,15 +1229,15 @@ class Doku_Handler_Section {
* @author Harry Fuecks <hfuecks@gmail.com>
*/
class Doku_Handler_Block {
-
+
var $calls = array();
-
+
var $blockStack = array();
-
+
var $inParagraph = FALSE;
var $atStart = TRUE;
var $skipEolKey = -1;
-
+
// Blocks these should not be inside paragraphs
var $blockOpen = array(
'header',
@@ -1247,7 +1247,7 @@ class Doku_Handler_Block {
'section_open', // Needed to prevent p_open between header and section_open
'code','file','hr','preformatted',
);
-
+
var $blockClose = array(
'header',
'listu_close','listo_close','listitem_close','listcontent_close',
@@ -1256,16 +1256,16 @@ class Doku_Handler_Block {
'section_close', // Needed to prevent p_close after section_close
'code','file','hr','preformatted',
);
-
+
// Stacks can contain paragraphs
var $stackOpen = array(
'footnote_open','section_open',
);
-
+
var $stackClose = array(
'footnote_close','section_close',
);
-
+
/**
* Constructor. Adds loaded syntax plugins to the block and stack
@@ -1292,7 +1292,7 @@ class Doku_Handler_Block {
}
}
}
-
+
/**
* Close a paragraph if needed
*
@@ -1313,7 +1313,7 @@ class Doku_Handler_Block {
break;
}
}
-
+
if(trim($content)==''){
//remove the whole paragraph
array_splice($this->calls,$i);
@@ -1321,7 +1321,7 @@ class Doku_Handler_Block {
$this->calls[] = array('p_close',array(), $pos);
}
}
-
+
/**
* Processes the whole instruction stack to open and close paragraphs
*
@@ -1333,7 +1333,7 @@ class Doku_Handler_Block {
foreach ( $calls as $key => $call ) {
$cname = $call[0];
if($cname == 'plugin') $cname='plugin_'.$call[1][0];
-
+
// Process blocks which are stack like... (contain linefeeds)
if ( in_array($cname,$this->stackOpen ) ) {
/*
@@ -1344,7 +1344,7 @@ class Doku_Handler_Block {
}
*/
$this->calls[] = $call;
-
+
// Hack - footnotes shouldn't immediately contain a p_open
if ( $cname != 'footnote_open' ) {
$this->addToStack();
@@ -1353,9 +1353,9 @@ class Doku_Handler_Block {
}
continue;
}
-
+
if ( in_array($cname,$this->stackClose ) ) {
-
+
if ( $this->inParagraph ) {
//$this->calls[] = array('p_close',array(), $call[2]);
$this->closeParagraph($call[2]);
@@ -1364,11 +1364,11 @@ class Doku_Handler_Block {
$this->removeFromStack();
continue;
}
-
+
if ( !$this->atStart ) {
-
+
if ( $cname == 'eol' ) {
-
+
/* XXX
if ( $this->inParagraph ) {
@@ -1391,7 +1391,7 @@ class Doku_Handler_Block {
$this->calls[] = array('p_open',array(), $call[2]);
$this->inParagraph = TRUE;
-
+
# Mark the next instruction for skipping
$this->skipEolKey = $key+1;
@@ -1401,9 +1401,9 @@ class Doku_Handler_Block {
}
}
-
+
} else {
-
+
$storeCall = TRUE;
if ( $this->inParagraph && in_array($cname, $this->blockOpen) ) {
//$this->calls[] = array('p_close',array(), $call[2]);
@@ -1412,7 +1412,7 @@ class Doku_Handler_Block {
$this->calls[] = $call;
$storeCall = FALSE;
}
-
+
if ( in_array($cname, $this->blockClose) ) {
if ( $this->inParagraph ) {
//$this->calls[] = array('p_close',array(), $call[2]);
@@ -1423,7 +1423,7 @@ class Doku_Handler_Block {
$this->calls[] = $call;
$storeCall = FALSE;
}
-
+
// This really sucks and suggests this whole class sucks but...
if ( isset($calls[$key+1])
&&
@@ -1431,21 +1431,21 @@ class Doku_Handler_Block {
&&
!in_array($calls[$key+1][0], $this->blockClose)
) {
-
+
$this->calls[] = array('p_open',array(), $call[2]);
$this->inParagraph = TRUE;
}
}
-
+
if ( $storeCall ) {
$this->calls[] = $call;
}
-
+
}
-
-
+
+
} else {
-
+
// Unless there's already a block at the start, start a paragraph
if ( !in_array($cname,$this->blockOpen) ) {
$this->calls[] = array('p_open',array(), $call[2]);
@@ -1458,11 +1458,11 @@ class Doku_Handler_Block {
$this->calls[] = $call;
$this->atStart = FALSE;
}
-
+
}
-
+
}
-
+
if ( $this->inParagraph ) {
if ( $cname == 'p_open' ) {
// Ditch the last call
@@ -1477,16 +1477,16 @@ class Doku_Handler_Block {
$this->calls[] = $last_call;
}
}
-
+
return $this->calls;
}
-
+
function addToStack($newStart = TRUE) {
$this->blockStack[] = array($this->atStart, $this->inParagraph);
$this->atStart = $newStart;
$this->inParagraph = FALSE;
}
-
+
function removeFromStack() {
$state = array_pop($this->blockStack);
$this->atStart = $state[0];
@@ -1504,30 +1504,30 @@ define('DOKU_TOCBRANCH_CLOSE',6);
define('DOKU_TOC_CLOSE',7);
class Doku_Handler_Toc {
-
+
var $calls = array();
var $tocStack = array();
var $toc = array();
var $numHeaders = 0;
-
+
function process($calls) {
#FIXME can this be done better?
-
+
global $conf;
-
+
if ( isset($conf['toptoclevel']) ) {
// retrieve vars once to save time
$toplevel = $conf['toptoclevel'];
} else {
$toplevel = 0;
}
-
+
if ( isset($conf['maxtoclevel']) ) {
$maxlevel = $conf['maxtoclevel'];
} else {
$maxlevel = 0;
}
-
+
foreach ( $calls as $call ) {
if ( !isset($call[1][1]) ) {
$this->calls[] = $call;
@@ -1540,42 +1540,42 @@ class Doku_Handler_Toc {
}
$this->calls[] = $call;
}
-
+
// Complete the table of contents then prepend to the calls
$this->finalizeToc($call);
return $this->calls;
}
-
+
function addToToc($depth, $call) {
-
+
// If it's the opening item...
if ( count ( $this->toc) == 0 ) {
-
+
$this->addTocCall($call, DOKU_TOC_OPEN);
-
+
for ( $i = 1; $i <= $depth; $i++ ) {
-
+
$this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCBRANCH_OPEN);
-
+
if ( $i != $depth ) {
$this->addTocCall(array($call[0],array($call[1][0], $i, '', TRUE),$call[2]), DOKU_TOCITEM_OPEN);
} else {
$this->addTocCall(array($call[0],array($call[1][0], $i),$call[2]), DOKU_TOCITEM_OPEN);
$this->addTocCall(array($call[0],array($call[1][0], $i),$call[2]), DOKU_TOC_ELEMENT);
}
-
+
$this->tocStack[] = $i;
-
+
}
return;
}
-
+
$currentDepth = end($this->tocStack);
$initialDepth = $currentDepth;
-
+
// Create new branches as needed
if ( $depth > $currentDepth ) {
-
+
for ($i = $currentDepth+1; $i <= $depth; $i++ ) {
$this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCBRANCH_OPEN);
// It's just a filler
@@ -1586,11 +1586,11 @@ class Doku_Handler_Toc {
}
$this->tocStack[] = $i;
}
-
+
$currentDepth = $i-1;
-
+
}
-
+
// Going down
if ( $depth < $currentDepth ) {
for ( $i = $currentDepth; $i >= $depth; $i-- ) {
@@ -1606,27 +1606,27 @@ class Doku_Handler_Toc {
}
}
}
-
+
if ( $depth == $initialDepth ) {
$this->addTocCall($call, DOKU_TOCITEM_CLOSE);
$this->addTocCall($call, DOKU_TOCITEM_OPEN);
}
-
+
$this->addTocCall($call, DOKU_TOC_ELEMENT);
-
-
+
+
}
-
+
function addTocCall($call, $type) {
switch ( $type ) {
case DOKU_TOC_OPEN:
$this->toc[] = array('toc_open',array(),$call[2]);
break;
-
+
case DOKU_TOCBRANCH_OPEN:
$this->toc[] = array('tocbranch_open',array($call[1][1]),$call[2]);
break;
-
+
case DOKU_TOCITEM_OPEN:
if ( isset( $call[1][3] ) ) {
$this->toc[] = array('tocitem_open',array($call[1][1], TRUE),$call[2]);
@@ -1634,19 +1634,19 @@ class Doku_Handler_Toc {
$this->toc[] = array('tocitem_open',array($call[1][1]),$call[2]);
}
break;
-
+
case DOKU_TOC_ELEMENT:
$this->toc[] = array('tocelement',array($call[1][1],$call[1][0]),$call[2]);
break;
-
+
case DOKU_TOCITEM_CLOSE:
$this->toc[] = array('tocitem_close',array($call[1][1]),$call[2]);
break;
-
+
case DOKU_TOCBRANCH_CLOSE:
$this->toc[] = array('tocbranch_close',array($call[1][1]),$call[2]);
break;
-
+
case DOKU_TOC_CLOSE:
if ( count($this->toc) > 0 ) {
$this->toc[] = array('toc_close',array(),$call[2]);
@@ -1654,7 +1654,7 @@ class Doku_Handler_Toc {
break;
}
}
-
+
function finalizeToc($call) {
global $conf;
if ( isset($conf['maxtoclevel']) && $this->numHeaders < $conf['maxtoclevel'] ) {
@@ -1669,7 +1669,7 @@ class Doku_Handler_Toc {
$this->addTocCall($call, DOKU_TOC_CLOSE);
$this->calls = array_merge($this->toc, $this->calls);
}
-
+
}
diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php
index e096fd045..e764fa236 100644
--- a/inc/parser/lexer.php
+++ b/inc/parser/lexer.php
@@ -37,7 +37,7 @@ class Doku_LexerParallelRegex {
var $_labels;
var $_regex;
var $_case;
-
+
/**
* Constructor. Starts with no patterns.
* @param boolean $case True for case sensitive, false
@@ -50,7 +50,7 @@ class Doku_LexerParallelRegex {
$this->_labels = array();
$this->_regex = null;
}
-
+
/**
* Adds a pattern with an optional label.
* @param mixed $pattern Perl style regex. Must be UTF-8
@@ -68,7 +68,7 @@ class Doku_LexerParallelRegex {
$this->_labels[$count] = $label;
$this->_regex = null;
}
-
+
/**
* Attempts to match all patterns at once against
* a string.
@@ -86,7 +86,7 @@ class Doku_LexerParallelRegex {
$match = "";
return false;
}
-
+
$match = $matches[0];
$size = count($matches);
for ($i = 1; $i < $size; $i++) {
@@ -96,7 +96,7 @@ class Doku_LexerParallelRegex {
}
return true;
}
-
+
/**
* Attempts to split the string against all patterns at once
*
@@ -111,20 +111,20 @@ class Doku_LexerParallelRegex {
if (count($this->_patterns) == 0) {
return false;
}
-
+
if (! preg_match($this->_getCompoundedRegex(), $subject, $matches)) {
$split = array($subject, "", "");
return false;
}
-
+
$idx = count($matches)-2;
list($pre, $post) = preg_split($this->_patterns[$idx].$this->_getPerlMatchingFlags(), $subject, 2);
-
+
$split = array($pre, $matches[0], $post);
return isset($this->_labels[$idx]) ? $this->_labels[$idx] : true;
}
-
+
/**
* Compounds the patterns into a single
* regular expression separated with the
@@ -137,7 +137,7 @@ class Doku_LexerParallelRegex {
if ($this->_regex == null) {
$cnt = count($this->_patterns);
for ($i = 0; $i < $cnt; $i++) {
-
+
// Replace lookaheads / lookbehinds with marker
$m = "\1\1";
$pattern = preg_replace(
@@ -167,7 +167,7 @@ class Doku_LexerParallelRegex {
array('\/', '\(', '\)'),
$pattern
);
-
+
// Restore lookaheads / lookbehinds
$pattern = preg_replace(
array (
@@ -190,14 +190,14 @@ class Doku_LexerParallelRegex {
),
$pattern
);
-
+
$this->_patterns[$i] = '('.$pattern.')';
}
$this->_regex = "/" . implode("|", $this->_patterns) . "/" . $this->_getPerlMatchingFlags();
}
return $this->_regex;
}
-
+
/**
* Accessor for perl regex mode flags to use.
* @return string Perl regex flags.
@@ -215,7 +215,7 @@ class Doku_LexerParallelRegex {
*/
class Doku_LexerStateStack {
var $_stack;
-
+
/**
* Constructor. Starts in named state.
* @param string $start Starting state name.
@@ -224,7 +224,7 @@ class Doku_LexerStateStack {
function Doku_LexerStateStack($start) {
$this->_stack = array($start);
}
-
+
/**
* Accessor for current state.
* @return string State.
@@ -233,7 +233,7 @@ class Doku_LexerStateStack {
function getCurrent() {
return $this->_stack[count($this->_stack) - 1];
}
-
+
/**
* Adds a state to the stack and sets it
* to be the current state.
@@ -243,7 +243,7 @@ class Doku_LexerStateStack {
function enter($state) {
array_push($this->_stack, $state);
}
-
+
/**
* Leaves the current state and reverts
* to the previous one.
@@ -275,7 +275,7 @@ class Doku_Lexer {
var $_mode;
var $_mode_handlers;
var $_case;
-
+
/**
* Sets up the lexer in case insensitive matching
* by default.
@@ -292,7 +292,7 @@ class Doku_Lexer {
$this->_mode = &new Doku_LexerStateStack($start);
$this->_mode_handlers = array();
}
-
+
/**
* Adds a token search pattern for a particular
* parsing mode. The pattern does not change the
@@ -310,7 +310,7 @@ class Doku_Lexer {
}
$this->_regexes[$mode]->addPattern($pattern);
}
-
+
/**
* Adds a pattern that will enter a new parsing
* mode. Useful for entering parenthesis, strings,
@@ -330,7 +330,7 @@ class Doku_Lexer {
}
$this->_regexes[$mode]->addPattern($pattern, $new_mode);
}
-
+
/**
* Adds a pattern that will exit the current mode
* and re-enter the previous one.
@@ -345,7 +345,7 @@ class Doku_Lexer {
}
$this->_regexes[$mode]->addPattern($pattern, "__exit");
}
-
+
/**
* Adds a pattern that has a special mode. Acts as an entry
* and exit pattern in one go, effectively calling a special
@@ -364,7 +364,7 @@ class Doku_Lexer {
}
$this->_regexes[$mode]->addPattern($pattern, "_$special");
}
-
+
/**
* Adds a mapping from a mode to another handler.
* @param string $mode Mode to be remapped.
@@ -374,7 +374,7 @@ class Doku_Lexer {
function mapHandler($mode, $handler) {
$this->_mode_handlers[$mode] = $handler;
}
-
+
/**
* Splits the page text into tokens. Will fail
* if the handlers report an error or if no
@@ -410,7 +410,7 @@ class Doku_Lexer {
}
return $this->_invokeParser($raw, DOKU_LEXER_UNMATCHED, $pos);
}
-
+
/**
* Sends the matched token and any leading unmatched
* text to the parser changing the lexer to a new
@@ -448,7 +448,7 @@ class Doku_Lexer {
}
return $this->_invokeParser($matched, DOKU_LEXER_MATCHED, $matchPos);
}
-
+
/**
* Tests to see if the new mode is actually to leave
* the current mode and pop an item from the matching
@@ -460,7 +460,7 @@ class Doku_Lexer {
function _isModeEnd($mode) {
return ($mode === "__exit");
}
-
+
/**
* Test to see if the mode is one where this mode
* is entered for this token only and automatically
@@ -472,7 +472,7 @@ class Doku_Lexer {
function _isSpecialMode($mode) {
return (strncmp($mode, "_", 1) == 0);
}
-
+
/**
* Strips the magic underscore marking single token
* modes.
@@ -483,7 +483,7 @@ class Doku_Lexer {
function _decodeSpecial($mode) {
return substr($mode, 1);
}
-
+
/**
* Calls the parser method named after the current
* mode. Empty content will be ignored. The lexer
@@ -512,7 +512,7 @@ class Doku_Lexer {
return $this->_parser->$handler($content, $is_match, $pos);
}
-
+
/**
* Tries to match a chunk of text and if successful
* removes the recognised chunk and any leading
@@ -567,7 +567,7 @@ function Doku_Lexer_Escape($str) {
'/\|/',
'/\:/'
);
-
+
$escaped = array(
'\.',
'\\\\\\\\',
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 7a3342fbf..d5e8f4552 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -32,10 +32,10 @@ $PARSER_MODES = array(
'windowssharelink','filelink','notoc',
'nocache','multiplyentity','quotes','rss'),
- // modes which have a start and end token but inside which
+ // modes which have a start and end token but inside which
// no other modes should be applied
'protected' => array('preformatted','code','file','php','html'),
-
+
// inside this mode no wiki markup should be applied but lineendings
// and whitespace isn't preserved
'disabled' => array('unformatted'),
@@ -51,15 +51,15 @@ $PARSER_MODES = array(
* For an intro to the Lexer see: wiki:parser
*/
class Doku_Parser {
-
+
var $Handler;
-
+
var $Lexer;
-
+
var $modes = array();
-
+
var $connected = FALSE;
-
+
function addBaseMode(& $BaseMode) {
$this->modes['base'] = & $BaseMode;
if ( !$this->Lexer ) {
@@ -67,7 +67,7 @@ class Doku_Parser {
}
$this->modes['base']->Lexer = & $this->Lexer;
}
-
+
/**
* PHP preserves order of associative elements
* Mode sequence is important
@@ -79,36 +79,36 @@ class Doku_Parser {
$Mode->Lexer = & $this->Lexer;
$this->modes[$name] = & $Mode;
}
-
+
function connectModes() {
-
+
if ( $this->connected ) {
return;
}
-
+
foreach ( array_keys($this->modes) as $mode ) {
-
+
// Base isn't connected to anything
if ( $mode == 'base' ) {
continue;
}
-
+
$this->modes[$mode]->preConnect();
-
+
foreach ( array_keys($this->modes) as $cm ) {
-
+
if ( $this->modes[$cm]->accepts($mode) ) {
$this->modes[$mode]->connectTo($cm);
}
-
+
}
-
+
$this->modes[$mode]->postConnect();
}
-
+
$this->connected = TRUE;
}
-
+
function parse($doc) {
if ( $this->Lexer ) {
$this->connectModes();
@@ -121,7 +121,7 @@ class Doku_Parser {
return FALSE;
}
}
-
+
}
//-------------------------------------------------------------------
@@ -136,9 +136,9 @@ class Doku_Parser {
* @author Harry Fuecks <hfuecks@gmail.com>
*/
class Doku_Parser_Mode {
-
+
var $Lexer;
-
+
var $allowedModes = array();
// returns a number used to determine in which order modes are added
@@ -149,24 +149,24 @@ class Doku_Parser_Mode {
// Called before any calls to connectTo
function preConnect() {}
- // Connects the mode
+ // Connects the mode
function connectTo($mode) {}
// Called after all calls to connectTo
function postConnect() {}
-
+
function accepts($mode) {
return in_array($mode, $this->allowedModes );
}
-
+
}
//-------------------------------------------------------------------
class Doku_Parser_Mode_base extends Doku_Parser_Mode {
-
+
function Doku_Parser_Mode_base() {
global $PARSER_MODES;
-
+
$this->allowedModes = array_merge (
$PARSER_MODES['container'],
$PARSER_MODES['baseonly'],
@@ -185,10 +185,10 @@ class Doku_Parser_Mode_base extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_footnote extends Doku_Parser_Mode {
-
+
function Doku_Parser_Mode_footnote() {
global $PARSER_MODES;
-
+
$this->allowedModes = array_merge (
$PARSER_MODES['container'],
$PARSER_MODES['formatting'],
@@ -196,20 +196,20 @@ class Doku_Parser_Mode_footnote extends Doku_Parser_Mode {
$PARSER_MODES['protected'],
$PARSER_MODES['disabled']
);
-
+
}
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern(
'\x28\x28(?=.*\x29\x29)',$mode,'footnote'
);
}
-
+
function postConnect() {
$this->Lexer->addExitPattern(
'\x29\x29','footnote'
);
-
+
}
function getSort() {
@@ -219,17 +219,17 @@ class Doku_Parser_Mode_footnote extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_header extends Doku_Parser_Mode {
-
+
function preConnect() {
//we're not picky about the closing ones, two are enough
-
+
// Header 1 is special case - match 6 or more
$this->Lexer->addSpecialPattern(
'[ \t]*={6,}[^\n]+={2,}[ \t]*(?=\n)',
'base',
'header'
);
-
+
// For the rest, match exactly
for ( $i = 5; $i > 1; $i--) {
$this->Lexer->addSpecialPattern(
@@ -239,7 +239,7 @@ class Doku_Parser_Mode_header extends Doku_Parser_Mode {
);
}
}
-
+
function getSort() {
return 50;
}
@@ -247,11 +247,11 @@ class Doku_Parser_Mode_header extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_notoc extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addSpecialPattern('~~NOTOC~~',$mode,'notoc');
}
-
+
function getSort() {
return 30;
}
@@ -259,19 +259,19 @@ class Doku_Parser_Mode_notoc extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_nocache extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addSpecialPattern('~~NOCACHE~~',$mode,'nocache');
- }
-
+ }
+
function getSort() {
return 40;
}
-}
-
+}
+
//-------------------------------------------------------------------
class Doku_Parser_Mode_linebreak extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addSpecialPattern('\x5C{2}(?=\s)',$mode,'linebreak');
}
@@ -283,7 +283,7 @@ class Doku_Parser_Mode_linebreak extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_eol extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$badModes = array('listblock','table');
if ( in_array($mode, $badModes) ) {
@@ -306,64 +306,64 @@ class Doku_Parser_Mode_hr extends Doku_Parser_Mode {
function getSort() {
return 160;
- }
+ }
}
//-------------------------------------------------------------------
class Doku_Parser_Mode_formatting extends Doku_Parser_Mode {
var $type;
-
+
var $formatting = array (
'strong' => array (
'entry'=>'\*\*(?=.*\*\*)',
'exit'=>'\*\*',
'sort'=>70
),
-
+
'emphasis'=> array (
- 'entry'=>'//(?=[^\x00]*[^:]//)', //hack for bug #384
+ 'entry'=>'//(?=[^\x00]*[^:]//)', //hack for bug #384
'exit'=>'//',
'sort'=>80
),
-
+
'underline'=> array (
'entry'=>'__(?=.*__)',
'exit'=>'__',
'sort'=>90
),
-
+
'monospace'=> array (
'entry'=>'\x27\x27(?=.*\x27\x27)',
'exit'=>'\x27\x27',
'sort'=>100
),
-
+
'subscript'=> array (
'entry'=>'<sub>(?=.*\x3C/sub\x3E)',
'exit'=>'</sub>',
'sort'=>110
),
-
+
'superscript'=> array (
'entry'=>'<sup>(?=.*\x3C/sup\x3E)',
'exit'=>'</sup>',
'sort'=>120
),
-
+
'deleted'=> array (
'entry'=>'<del>(?=.*\x3C/del\x3E)',
'exit'=>'</del>',
'sort'=>130
),
);
-
+
function Doku_Parser_Mode_formatting($type) {
global $PARSER_MODES;
-
+
if ( !array_key_exists($type, $this->formatting) ) {
trigger_error('Invalid formatting type '.$type, E_USER_WARNING);
}
-
+
$this->type = $type;
// formatting may contain other formatting but not it self
@@ -379,28 +379,28 @@ class Doku_Parser_Mode_formatting extends Doku_Parser_Mode {
$PARSER_MODES['disabled']
);
}
-
+
function connectTo($mode) {
-
+
// Can't nest formatting in itself
if ( $mode == $this->type ) {
return;
}
-
+
$this->Lexer->addEntryPattern(
$this->formatting[$this->type]['entry'],
$mode,
$this->type
);
}
-
+
function postConnect() {
-
+
$this->Lexer->addExitPattern(
$this->formatting[$this->type]['exit'],
$this->type
);
-
+
}
function getSort() {
@@ -413,7 +413,7 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode {
function Doku_Parser_Mode_listblock() {
global $PARSER_MODES;
-
+
$this->allowedModes = array_merge (
$PARSER_MODES['formatting'],
$PARSER_MODES['substition'],
@@ -423,16 +423,16 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode {
// $this->allowedModes[] = 'footnote';
}
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('\n {2,}[\-\*]',$mode,'listblock');
$this->Lexer->addEntryPattern('\n\t{1,}[\-\*]',$mode,'listblock');
-
+
$this->Lexer->addPattern('\n {2,}[\-\*]','listblock');
$this->Lexer->addPattern('\n\t{1,}[\-\*]','listblock');
-
+
}
-
+
function postConnect() {
$this->Lexer->addExitPattern('\n','listblock');
}
@@ -444,10 +444,10 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_table extends Doku_Parser_Mode {
-
+
function Doku_Parser_Mode_table() {
global $PARSER_MODES;
-
+
$this->allowedModes = array_merge (
$PARSER_MODES['formatting'],
$PARSER_MODES['substition'],
@@ -455,12 +455,12 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode {
$PARSER_MODES['protected']
);
}
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('\n\^',$mode,'table');
$this->Lexer->addEntryPattern('\n\|',$mode,'table');
}
-
+
function postConnect() {
$this->Lexer->addPattern('\n\^','table');
$this->Lexer->addPattern('\n\|','table');
@@ -478,12 +478,12 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_unformatted extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('<nowiki>(?=.*\x3C/nowiki\x3E)',$mode,'unformatted');
$this->Lexer->addEntryPattern('%%(?=.*%%)',$mode,'unformattedalt');
}
-
+
function postConnect() {
$this->Lexer->addExitPattern('</nowiki>','unformatted');
$this->Lexer->addExitPattern('%%','unformattedalt');
@@ -497,11 +497,11 @@ class Doku_Parser_Mode_unformatted extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_php extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('<php>(?=.*\x3C/php\x3E)',$mode,'php');
}
-
+
function postConnect() {
$this->Lexer->addExitPattern('</php>','php');
}
@@ -513,11 +513,11 @@ class Doku_Parser_Mode_php extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_html extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('<html>(?=.*\x3C/html\x3E)',$mode,'html');
}
-
+
function postConnect() {
$this->Lexer->addExitPattern('</html>','html');
}
@@ -529,38 +529,38 @@ class Doku_Parser_Mode_html extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_preformatted extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
// Has hard coded awareness of lists...
$this->Lexer->addEntryPattern('\n (?![\*\-])',$mode,'preformatted');
$this->Lexer->addEntryPattern('\n\t(?![\*\-])',$mode,'preformatted');
-
+
// How to effect a sub pattern with the Lexer!
$this->Lexer->addPattern('\n ','preformatted');
$this->Lexer->addPattern('\n\t','preformatted');
}
-
+
function postConnect() {
$this->Lexer->addExitPattern('\n','preformatted');
}
function getSort() {
return 20;
- }
+ }
}
//-------------------------------------------------------------------
class Doku_Parser_Mode_code extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('<code(?=.*\x3C/code\x3E)',$mode,'code');
}
-
+
function postConnect() {
$this->Lexer->addExitPattern('</code>','code');
}
-
+
function getSort() {
return 200;
}
@@ -568,15 +568,15 @@ class Doku_Parser_Mode_code extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_file extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('<file>(?=.*\x3C/file\x3E)',$mode,'file');
}
-
+
function postConnect() {
$this->Lexer->addExitPattern('</file>','file');
}
-
+
function getSort() {
return 210;
}
@@ -584,10 +584,10 @@ class Doku_Parser_Mode_file extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_quote extends Doku_Parser_Mode {
-
+
function Doku_Parser_Mode_quote() {
global $PARSER_MODES;
-
+
$this->allowedModes = array_merge (
$PARSER_MODES['formatting'],
$PARSER_MODES['substition'],
@@ -598,16 +598,16 @@ class Doku_Parser_Mode_quote extends Doku_Parser_Mode {
#$this->allowedModes[] = 'preformatted';
#$this->allowedModes[] = 'unformatted';
}
-
+
function connectTo($mode) {
$this->Lexer->addEntryPattern('\n>{1,}',$mode,'quote');
}
-
+
function postConnect() {
$this->Lexer->addPattern('\n>{1,}','quote');
$this->Lexer->addExitPattern('\n','quote');
}
-
+
function getSort() {
return 220;
}
@@ -618,23 +618,23 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
// A list
var $acronyms = array();
var $pattern = '';
-
+
function Doku_Parser_Mode_acronym($acronyms) {
$this->acronyms = $acronyms;
}
-
+
function preConnect() {
$bound = '[\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]';
$acronyms = array_map('Doku_Lexer_Escape',$this->acronyms);
$this->pattern = '(?<=^|'.$bound.')(?:'.join('|',$acronyms).')(?='.$bound.')';
}
-
+
function connectTo($mode) {
if ( strlen($this->pattern) > 0 ) {
- $this->Lexer->addSpecialPattern($this->pattern,$mode,'acronym');
+ $this->Lexer->addSpecialPattern($this->pattern,$mode,'acronym');
}
}
-
+
function getSort() {
return 240;
}
@@ -645,11 +645,11 @@ class Doku_Parser_Mode_smiley extends Doku_Parser_Mode {
// A list
var $smileys = array();
var $pattern = '';
-
+
function Doku_Parser_Mode_smiley($smileys) {
$this->smileys = $smileys;
}
-
+
function preConnect() {
$sep = '';
foreach ( $this->smileys as $smiley ) {
@@ -657,13 +657,13 @@ class Doku_Parser_Mode_smiley extends Doku_Parser_Mode {
$sep = '|';
}
}
-
+
function connectTo($mode) {
if ( strlen($this->pattern) > 0 ) {
- $this->Lexer->addSpecialPattern($this->pattern,$mode,'smiley');
+ $this->Lexer->addSpecialPattern($this->pattern,$mode,'smiley');
}
}
-
+
function getSort() {
return 230;
}
@@ -674,31 +674,31 @@ class Doku_Parser_Mode_wordblock extends Doku_Parser_Mode {
// A list
var $badwords = array();
var $pattern = '';
-
+
function Doku_Parser_Mode_wordblock($badwords) {
$this->badwords = $badwords;
}
-
+
function preConnect() {
-
+
if ( count($this->badwords) == 0 ) {
return;
}
-
+
$sep = '';
foreach ( $this->badwords as $badword ) {
$this->pattern .= $sep.'(?<=\b)(?i)'.Doku_Lexer_Escape($badword).'(?-i)(?=\b)';
$sep = '|';
}
-
+
}
-
+
function connectTo($mode) {
if ( strlen($this->pattern) > 0 ) {
$this->Lexer->addSpecialPattern($this->pattern,$mode,'wordblock');
}
}
-
+
function getSort() {
return 250;
}
@@ -712,11 +712,11 @@ class Doku_Parser_Mode_entity extends Doku_Parser_Mode {
// A list
var $entities = array();
var $pattern = '';
-
+
function Doku_Parser_Mode_entity($entities) {
$this->entities = $entities;
}
-
+
function preConnect() {
$sep = '';
foreach ( $this->entities as $entity ) {
@@ -724,13 +724,13 @@ class Doku_Parser_Mode_entity extends Doku_Parser_Mode {
$sep = '|';
}
}
-
+
function connectTo($mode) {
if ( strlen($this->pattern) > 0 ) {
$this->Lexer->addSpecialPattern($this->pattern,$mode,'entity');
}
}
-
+
function getSort() {
return 260;
}
@@ -739,15 +739,15 @@ class Doku_Parser_Mode_entity extends Doku_Parser_Mode {
//-------------------------------------------------------------------
// Implements the 640x480 replacement
class Doku_Parser_Mode_multiplyentity extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
-
+
$this->Lexer->addSpecialPattern(
'(?<=\b)\d+[xX]\d+(?=\b)',$mode,'multiplyentity'
);
}
-
+
function getSort() {
return 270;
}
@@ -755,9 +755,9 @@ class Doku_Parser_Mode_multiplyentity extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_quotes extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
-
+
$this->Lexer->addSpecialPattern(
'(?<=^|\s)\'(?=\S)',$mode,'singlequoteopening'
);
@@ -772,7 +772,7 @@ class Doku_Parser_Mode_quotes extends Doku_Parser_Mode {
);
}
-
+
function getSort() {
return 280;
}
@@ -780,13 +780,13 @@ class Doku_Parser_Mode_quotes extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_camelcaselink extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addSpecialPattern(
'\b[A-Z]+[a-z]+[A-Z][A-Za-z]*\b',$mode,'camelcaselink'
);
}
-
+
function getSort() {
return 290;
}
@@ -794,12 +794,12 @@ class Doku_Parser_Mode_camelcaselink extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_internallink extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
// Word boundaries?
$this->Lexer->addSpecialPattern("\[\[.+?\]\]",$mode,'internallink');
}
-
+
function getSort() {
return 300;
}
@@ -807,12 +807,12 @@ class Doku_Parser_Mode_internallink extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_media extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
// Word boundaries?
$this->Lexer->addSpecialPattern("\{\{[^\}]+\}\}",$mode,'media');
}
-
+
function getSort() {
return 320;
}
@@ -831,33 +831,33 @@ class Doku_Parser_Mode_rss extends Doku_Parser_Mode {
}
//-------------------------------------------------------------------
-class Doku_Parser_Mode_externallink extends Doku_Parser_Mode {
+class Doku_Parser_Mode_externallink extends Doku_Parser_Mode {
var $schemes = array('http','https','telnet','gopher','wais','ftp','ed2k','irc');
var $patterns = array();
-
+
function preConnect() {
-
+
$ltrs = '\w';
$gunk = '/\#~:.?+=&%@!\-';
$punc = '.:?\-;,';
$host = $ltrs.$punc;
$any = $ltrs.$gunk.$punc;
-
+
foreach ( $this->schemes as $scheme ) {
$this->patterns[] = '\b(?i)'.$scheme.'(?-i)://['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
}
-
+
$this->patterns[] = '\b(?i)www?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
$this->patterns[] = '\b(?i)ftp?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
-
+
}
-
+
function connectTo($mode) {
foreach ( $this->patterns as $pattern ) {
$this->Lexer->addSpecialPattern($pattern,$mode,'externallink');
}
}
-
+
function getSort() {
return 330;
}
@@ -865,21 +865,21 @@ class Doku_Parser_Mode_externallink extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_filelink extends Doku_Parser_Mode {
-
+
var $pattern;
-
+
function preConnect() {
-
+
$ltrs = '\w';
$gunk = '/\#~:.?+=&%@!\-';
$punc = '.:?\-;,';
$host = $ltrs.$punc;
$any = $ltrs.$gunk.$punc;
-
+
$this->pattern = '\b(?i)file(?-i)://['.$any.']+?['.
$punc.']*[^'.$any.']';
}
-
+
function connectTo($mode) {
$this->Lexer->addSpecialPattern(
$this->pattern,$mode,'filelink');
@@ -892,18 +892,18 @@ class Doku_Parser_Mode_filelink extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_windowssharelink extends Doku_Parser_Mode {
-
+
var $pattern;
-
+
function preConnect() {
$this->pattern = "\\\\\\\\\w+?(?:\\\\[\w$]+)+";
}
-
+
function connectTo($mode) {
$this->Lexer->addSpecialPattern(
$this->pattern,$mode,'windowssharelink');
}
-
+
function getSort() {
return 350;
}
@@ -911,11 +911,11 @@ class Doku_Parser_Mode_windowssharelink extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_emaillink extends Doku_Parser_Mode {
-
+
function connectTo($mode) {
$this->Lexer->addSpecialPattern("<[\w0-9\-_.]+?@[\w\-]+\.[\w\-\.]+\.*[\w]+>",$mode,'emaillink');
}
-
+
function getSort() {
return 340;
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 7ac1c9d7b..a9c86c3f5 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -19,157 +19,157 @@ class Doku_Renderer {
function nocache() {
$this->info['cache'] = FALSE;
}
-
+
//handle plugin rendering
function plugin($name,$data){
- $plugin =& plugin_load('syntax',$name);
+ $plugin =& plugin_load('syntax',$name);
if($plugin != null){
- // determine mode from renderer class name - format = "Doku_Renderer_<mode>"
- $mode = substr(get_class($this), 14);
+ // determine mode from renderer class name - format = "Doku_Renderer_<mode>"
+ $mode = substr(get_class($this), 14);
$plugin->render($mode,$this,$data);
}
}
-
+
function document_start() {}
-
+
function document_end() {}
-
+
function toc_open() {}
-
+
function tocbranch_open($level) {}
-
+
function tocitem_open($level, $empty = FALSE) {}
-
+
function tocelement($level, $title) {}
-
+
function tocitem_close($level) {}
-
+
function tocbranch_close($level) {}
-
+
function toc_close() {}
-
+
function header($text, $level, $pos) {}
-
+
function section_open($level) {}
-
+
function section_close() {}
-
+
function cdata($text) {}
-
+
function p_open() {}
-
+
function p_close() {}
-
+
function linebreak() {}
-
+
function hr() {}
-
+
function strong_open() {}
-
+
function strong_close() {}
-
+
function emphasis_open() {}
-
+
function emphasis_close() {}
-
+
function underline_open() {}
-
+
function underline_close() {}
-
+
function monospace_open() {}
-
+
function monospace_close() {}
-
+
function subscript_open() {}
-
+
function subscript_close() {}
-
+
function superscript_open() {}
-
+
function superscript_close() {}
-
+
function deleted_open() {}
-
+
function deleted_close() {}
-
+
function footnote_open() {}
-
+
function footnote_close() {}
-
+
function listu_open() {}
-
+
function listu_close() {}
-
+
function listo_open() {}
-
+
function listo_close() {}
-
+
function listitem_open($level) {}
-
+
function listitem_close() {}
-
+
function listcontent_open() {}
-
+
function listcontent_close() {}
-
+
function unformatted($text) {}
-
+
function php($text) {}
-
+
function html($text) {}
-
+
function preformatted($text) {}
-
+
function file($text) {}
-
+
function quote_open() {}
-
+
function quote_close() {}
-
+
function code($text, $lang = NULL) {}
-
+
function acronym($acronym) {}
-
+
function smiley($smiley) {}
-
+
function wordblock($word) {}
-
+
function entity($entity) {}
-
+
// 640x480 ($x=640, $y=480)
function multiplyentity($x, $y) {}
-
+
function singlequoteopening() {}
-
+
function singlequoteclosing() {}
-
+
function doublequoteopening() {}
-
+
function doublequoteclosing() {}
-
+
// $link like 'SomePage'
function camelcaselink($link) {}
-
+
// $link like 'wiki:syntax', $title could be an array (media)
function internallink($link, $title = NULL) {}
-
+
// $link is full URL with scheme, $title could be an array (media)
function externallink($link, $title = NULL) {}
-
+
// $link is the original link - probably not much use
// $wikiName is an indentifier for the wiki
// $wikiUri is the URL fragment to append to some known URL
function interwikilink($link, $title = NULL, $wikiName, $wikiUri) {}
-
+
// Link to file on users OS, $title could be an array (media)
function filelink($link, $title = NULL) {}
-
+
// Link to a Windows share, , $title could be an array (media)
function windowssharelink($link, $title = NULL) {}
-
+
// function email($address, $title = NULL) {}
function emaillink($address, $name = NULL) {}
-
+
function internalmedialink (
$src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
) {}
@@ -177,21 +177,21 @@ class Doku_Renderer {
function externalmedialink(
$src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
) {}
-
+
function table_open($maxcols = NULL, $numrows = NULL){}
-
+
function table_close(){}
-
+
function tablerow_open(){}
-
+
function tablerow_close(){}
-
+
function tableheader_open($colspan = 1, $align = NULL){}
-
+
function tableheader_close(){}
-
+
function tablecell_open($colspan = 1, $align = NULL){}
-
+
function tablecell_close(){}
}
diff --git a/inc/parser/spamcheck.php b/inc/parser/spamcheck.php
index b1f473d8c..42b9781c5 100644
--- a/inc/parser/spamcheck.php
+++ b/inc/parser/spamcheck.php
@@ -4,44 +4,44 @@ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../')
require_once DOKU_INC . 'inc/parser/renderer.php';
class Doku_Renderer_SpamCheck extends Doku_Renderer {
-
+
// This should be populated by the code executing the instructions
var $currentCall;
-
+
// An array of instructions that contain spam
var $spamFound = array();
-
+
// pcre pattern for finding spam
var $spamPattern = '#^$#';
-
+
function internallink($link, $title = NULL) {
$this->_checkTitle($title);
}
-
+
function externallink($link, $title = NULL) {
$this->_checkLinkForSpam($link);
$this->_checkTitle($title);
}
-
+
function interwikilink($link, $title = NULL) {
$this->_checkTitle($title);
}
-
+
function filelink($link, $title = NULL) {
$this->_checkLinkForSpam($link);
$this->_checkTitle($title);
}
-
+
function windowssharelink($link, $title = NULL) {
$this->_checkLinkForSpam($link);
$this->_checkTitle($title);
}
-
+
function email($address, $title = NULL) {
$this->_checkLinkForSpam($address);
$this->_checkTitle($title);
}
-
+
function internalmedialink ($src) {
$this->_checkLinkForSpam($src);
}
@@ -55,7 +55,7 @@ class Doku_Renderer_SpamCheck extends Doku_Renderer {
$this->_checkLinkForSpam($title['src']);
}
}
-
+
// Pattern matching happens here
/**
* @TODO What about links like www.google.com - no http://
diff --git a/inc/parser/wiki.php b/inc/parser/wiki.php
index 2b24d2539..b393d6ec0 100644
--- a/inc/parser/wiki.php
+++ b/inc/parser/wiki.php
@@ -6,23 +6,23 @@
* Main issues lie with lists, quote and tables
*/
class Doku_Renderer_Wiki extends Doku_Renderer {
-
+
var $doc = '';
-
+
// This should be eliminated
var $listMarker = '*';
-
+
function document_start() {
ob_start();
}
-
+
function document_end() {
-
+
$this->doc .= ob_get_contents();
ob_end_clean();
}
-
+
function header($text, $level) {
$levels = array(
1=>'======',
@@ -31,7 +31,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
4=>'===',
5=>'==',
);
-
+
if ( isset($levels[$level]) ) {
$token = $levels[$level];
} else {
@@ -41,189 +41,189 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo trim($text);
echo " {$token}\n";
}
-
+
function cdata($text) {
echo $text;
}
-
+
function linebreak() {
echo '\\\\ ';
}
-
+
function hr() {
echo "\n----\n";
}
-
+
function strong_open() {
echo '**';
}
-
+
function strong_close() {
echo '**';
}
-
+
function emphasis_open() {
echo '//';
}
-
+
function emphasis_close() {
echo '//';
}
-
+
function underline_open() {
echo '__';
}
-
+
function underline_close() {
echo '__';
}
-
+
function monospace_open() {
echo "''";
}
-
+
function monospace_close() {
echo "''";
}
-
+
function subscript_open() {
echo '<sub>';
}
-
+
function subscript_close() {
echo '</sub>';
}
-
+
function superscript_open() {
echo '<sup>';
}
-
+
function superscript_close() {
echo '</sup>';
}
-
+
function deleted_open() {
echo '<del>';
}
-
+
function deleted_close() {
echo '</del>';
}
-
+
function footnote_open() {
echo '((';
}
-
+
function footnote_close() {
echo '))';
}
-
+
function listu_open() {
$this->listMarker = '*';
echo "\n";
}
-
+
function listo_open() {
$this->listMarker = '-';
echo "\n";
}
-
+
/**
* @TODO Problem here with nested lists
*/
function listitem_open($level) {
echo str_repeat(' ', $level).$this->listMarker;
}
-
+
function listitem_close() {
echo "\n";
}
-
+
function unformatted($text) {
echo '%%'.$text.'%%';
}
-
+
function php($text) {
echo "\n<php>\n$text\n</php>\n";
}
-
+
function html($text) {
echo "\n<html>\n$text\n</html>\n";
}
-
+
/**
* Indent?
*/
function preformatted($text) {
echo "\n<code>\n$text\n</code>\n";
}
-
+
function file($text) {
echo "\n<file>\n$text\n</file>\n";
}
-
+
/**
* Problem here with nested quotes
*/
function quote_open() {
echo '>';
}
-
+
function quote_close() {
echo "\n";
}
-
+
function code($text, $lang = NULL) {
if ( !$lang ) {
echo "\n<code>\n$text\n</code>\n";
} else {
echo "\n<code $lang>\n$text\n</code>\n";
}
-
+
}
-
+
function acronym($acronym) {
echo $acronym;
}
-
+
function smiley($smiley) {
echo $smiley;
}
-
+
function wordblock($word) {
echo $word;
}
-
+
function entity($entity) {
echo $entity;
}
-
+
// 640x480 ($x=640, $y=480)
function multiplyentity($x, $y) {
echo "{$x}x{$y}";
}
-
+
function singlequoteopening() {
echo "'";
}
-
+
function singlequoteclosing() {
echo "'";
}
-
+
function doublequoteopening() {
echo '"';
}
-
+
function doublequoteclosing() {
echo '"';
}
-
+
// $link like 'SomePage'
function camelcaselink($link) {
echo $link;
}
-
+
// $link like 'wikie:syntax', $title could be an array (media)
function internallink($link, $title = NULL) {
if ( $title ) {
@@ -232,7 +232,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo '[['.$link.']]';
}
}
-
+
// $link is full URL with scheme, $title could be an array (media)
function externallink($link, $title = NULL) {
if ( $title ) {
@@ -241,7 +241,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo '[['.$link.']]';
}
}
-
+
// $link is the original link - probably not much use
// $wikiName is an indentifier for the wiki
// $wikiUri is the URL fragment to append to some known URL
@@ -252,7 +252,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo '[['.$link.']]';
}
}
-
+
// Link to file on users OS, $title could be an array (media)
function filelink($link, $title = NULL) {
if ( $title ) {
@@ -261,7 +261,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo '[['.$link.']]';
}
}
-
+
// Link to a Windows share, , $title could be an array (media)
function windowssharelink($link, $title = NULL) {
if ( $title ) {
@@ -270,7 +270,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo '[['.$link.']]';
}
}
-
+
function email($address, $title = NULL) {
if ( $title ) {
echo '[['.$address.'|'.$title.']]';
@@ -278,14 +278,14 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo '[['.$address.']]';
}
}
-
+
// @TODO
function internalmedialink (
$src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
) {
-
+
}
-
+
// @TODO
function externalmedialink(
$src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL
@@ -296,23 +296,23 @@ class Doku_Renderer_Wiki extends Doku_Renderer {
echo '{{'.$src.'}}';
}
}
-
+
function table_open($maxcols = NULL, $numrows = NULL){}
-
+
function table_close(){}
-
+
function tablerow_open(){}
-
+
function tablerow_close(){}
-
+
function tableheader_open($colspan = 1, $align = NULL){}
-
+
function tableheader_close(){}
-
+
function tablecell_open($colspan = 1, $align = NULL){}
-
+
function tablecell_close(){}
-
+
}
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 5e898ab36..1c7343cda 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -21,16 +21,16 @@ if ( !defined('DOKU_TAB') ) {
require_once DOKU_INC . 'inc/parser/renderer.php';
/**
- * The Renderer
+ * The Renderer
*/
class Doku_Renderer_xhtml extends Doku_Renderer {
var $doc = '';
-
+
var $headers = array();
-
+
var $footnotes = array();
-
+
var $acronyms = array();
var $smileys = array();
var $badwords = array();
@@ -43,18 +43,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
function document_start() {
}
-
+
function document_end() {
// add button for last section if any and more than one
if($this->lastsec > 1) $this->_secedit($this->lastsec,'');
-
+
if ( count ($this->footnotes) > 0 ) {
$this->doc .= '<div class="footnotes">'.DOKU_LF;
$id = 0;
foreach ( $this->footnotes as $footnote ) {
$id++; // the number of the current footnote
-
+
// check its not a placeholder that indicates actual footnote text is elsewhere
if (substr($footnote, 0, 5) != "@@FNT") {
@@ -62,18 +62,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= '<div class="fn">';
$this->doc .= '<a href="#fnt'.$id.'" id="fn'.$id.'" name="fn'.$id.'" class="fn_bot">';
$this->doc .= $id.')</a> '.DOKU_LF;
-
+
// get any other footnotes that use the same markup
$alt = array_keys($this->footnotes, "@@FNT$id");
-
+
if (count($alt)) {
foreach ($alt as $ref) {
// set anchor and backlink for the other footnotes
$this->doc .= ', <a href="#fnt'.($ref+1).'" id="fn'.($ref+1).'" name="fn'.($ref+1).'" class="fn_bot">';
- $this->doc .= ($ref+1).')</a> '.DOKU_LF;
+ $this->doc .= ($ref+1).')</a> '.DOKU_LF;
}
}
-
+
// add footnote markup and close this footnote
$this->doc .= $footnote;
$this->doc .= '</div>' . DOKU_LF;
@@ -91,11 +91,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= '</div>'.DOKU_LF;
$this->doc .= '<div id="toc__inside">'.DOKU_LF;
}
-
+
function tocbranch_open($level) {
$this->doc .= '<ul class="toc">'.DOKU_LF;
}
-
+
function tocitem_open($level, $empty = FALSE) {
if ( !$empty ) {
$this->doc .= '<li class="level'.$level.'">';
@@ -103,28 +103,28 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= '<li class="clear">';
}
}
-
+
function tocelement($level, $title) {
$this->doc .= '<span class="li"><a href="#'.$this->_headerToLink($title).'" class="toc">';
$this->doc .= $this->_xmlEntities($title);
$this->doc .= '</a></span>';
}
-
+
function tocitem_close($level) {
$this->doc .= '</li>'.DOKU_LF;
}
-
+
function tocbranch_close($level) {
$this->doc .= '</ul>'.DOKU_LF;
}
-
+
function toc_close() {
$this->doc .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
}
-
+
function header($text, $level, $pos) {
global $conf;
- //handle section editing
+ //handle section editing
if($level <= $conf['maxseclevel']){
// add button for last section if any
if($this->lastsec) $this->_secedit($this->lastsec,$pos-1);
@@ -136,91 +136,91 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= $this->_xmlEntities($text);
$this->doc .= "</a></h$level>".DOKU_LF;
}
-
+
function section_open($level) {
$this->doc .= "<div class=\"level$level\">".DOKU_LF;
}
-
+
function section_close() {
$this->doc .= DOKU_LF.'</div>'.DOKU_LF;
}
-
+
function cdata($text) {
$this->doc .= $this->_xmlEntities($text);
}
-
+
function p_open() {
$this->doc .= DOKU_LF.'<p>'.DOKU_LF;
}
-
+
function p_close() {
$this->doc .= DOKU_LF.'</p>'.DOKU_LF;
}
-
+
function linebreak() {
$this->doc .= '<br/>'.DOKU_LF;
}
-
+
function hr() {
$this->doc .= '<hr />'.DOKU_LF;
}
-
+
function strong_open() {
$this->doc .= '<strong>';
}
-
+
function strong_close() {
$this->doc .= '</strong>';
}
-
+
function emphasis_open() {
$this->doc .= '<em>';
}
-
+
function emphasis_close() {
$this->doc .= '</em>';
}
-
+
function underline_open() {
$this->doc .= '<em class="u">';
}
-
+
function underline_close() {
$this->doc .= '</em>';
}
-
+
function monospace_open() {
$this->doc .= '<code>';
}
-
+
function monospace_close() {
$this->doc .= '</code>';
}
-
+
function subscript_open() {
$this->doc .= '<sub>';
}
-
+
function subscript_close() {
$this->doc .= '</sub>';
}
-
+
function superscript_open() {
$this->doc .= '<sup>';
}
-
+
function superscript_close() {
$this->doc .= '</sup>';
}
-
+
function deleted_open() {
$this->doc .= '<del>';
}
-
+
function deleted_close() {
$this->doc .= '</del>';
}
-
+
/**
* Callback for footnote start syntax
*
@@ -236,7 +236,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->store = $this->doc;
$this->doc = '';
}
-
+
/**
* Callback for footnote end syntax
*
@@ -251,10 +251,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$footnote = $this->doc;
$this->doc = $this->store;
$this->store = '';
-
+
// check to see if this footnote has been seen before
$i = array_search($footnote, $this->footnotes);
-
+
if ($i === false) {
// its a new footnote, add it to the $footnotes array
$id = count($this->footnotes)+1;
@@ -269,43 +269,43 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// output the footnote reference and link, incl. onmouseover for insitu footnote popup
$this->doc .= '<a href="#fn'.$id.'" name="fnt'.$id.'" id="fnt'.$id.'" class="fn_top" onmouseover="fnt(\''.$id.'\', this, event);">'.$id.')</a>';
}
-
+
function listu_open() {
$this->doc .= '<ul>'.DOKU_LF;
}
-
+
function listu_close() {
$this->doc .= '</ul>'.DOKU_LF;
}
-
+
function listo_open() {
$this->doc .= '<ol>'.DOKU_LF;
}
-
+
function listo_close() {
$this->doc .= '</ol>'.DOKU_LF;
}
-
+
function listitem_open($level) {
$this->doc .= '<li class="level'.$level.'">';
}
-
+
function listitem_close() {
$this->doc .= '</li>'.DOKU_LF;
}
-
+
function listcontent_open() {
$this->doc .= '<div class="li">';
}
-
+
function listcontent_close() {
$this->doc .= '</div>'.DOKU_LF;
}
-
+
function unformatted($text) {
$this->doc .= $this->_xmlEntities($text);
}
-
+
/**
* Execute PHP code if allowed
*
@@ -322,7 +322,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->file($text);
}
}
-
+
/**
* Insert HTML if allowed
*
@@ -336,23 +336,23 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->file($text);
}
}
-
+
function preformatted($text) {
$this->doc .= '<pre class="code">' . $this->_xmlEntities($text) . '</pre>'. DOKU_LF;
}
-
+
function file($text) {
$this->doc .= '<pre class="file">' . $this->_xmlEntities($text). '</pre>'. DOKU_LF;
}
-
+
function quote_open() {
$this->doc .= '<blockquote><div class="no">'.DOKU_LF;
}
-
+
function quote_close() {
$this->doc .= '</div></blockquote>'.DOKU_LF;
}
-
+
/**
* Callback for code text
*
@@ -362,7 +362,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*/
function code($text, $language = NULL) {
global $conf;
-
+
if ( is_null($language) ) {
$this->preformatted($text);
} else {
@@ -376,26 +376,26 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$geshi->set_header_type(GESHI_HEADER_PRE);
$geshi->set_overall_class("code $language");
$geshi->set_link_target($conf['target']['extern']);
-
+
$text = $geshi->parse_code();
$this->doc .= $text;
}
}
-
+
function acronym($acronym) {
-
+
if ( array_key_exists($acronym, $this->acronyms) ) {
-
+
$title = $this->_xmlEntities($this->acronyms[$acronym]);
-
+
$this->doc .= '<acronym title="'.$title
.'">'.$this->_xmlEntities($acronym).'</acronym>';
-
+
} else {
$this->doc .= $this->_xmlEntities($acronym);
}
}
-
+
function smiley($smiley) {
if ( array_key_exists($smiley, $this->smileys) ) {
$title = $this->_xmlEntities($this->smileys[$smiley]);
@@ -406,7 +406,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= $this->_xmlEntities($smiley);
}
}
-
+
/*
* not used
function wordblock($word) {
@@ -417,7 +417,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
*/
-
+
function entity($entity) {
if ( array_key_exists($entity, $this->entities) ) {
$this->doc .= $this->entities[$entity];
@@ -425,33 +425,33 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= $this->_xmlEntities($entity);
}
}
-
+
function multiplyentity($x, $y) {
$this->doc .= "$x&times;$y";
}
-
+
function singlequoteopening() {
$this->doc .= "&lsquo;";
}
-
+
function singlequoteclosing() {
$this->doc .= "&rsquo;";
}
-
+
function doublequoteopening() {
$this->doc .= "&ldquo;";
}
-
+
function doublequoteclosing() {
$this->doc .= "&rdquo;";
}
-
+
/**
*/
function camelcaselink($link) {
- $this->internallink($link,$link);
+ $this->internallink($link,$link);
}
-
+
function locallink($hash, $name = NULL){
global $ID;
@@ -488,10 +488,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
} else {
$class='media';
}
-
+
//keep hash anchor
list($id,$hash) = split('#',$id,2);
-
+
//prepare for formating
$link['target'] = $conf['target']['wiki'];
$link['style'] = '';
@@ -523,7 +523,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= $this->_formatLink($link);
}
}
-
+
function externallink($url, $name = NULL) {
global $conf;
@@ -532,13 +532,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// add protocol on simple short URLs
if(substr($url,0,3) == 'ftp' && (substr($url,0,6) != 'ftp://')) $url = 'ftp://'.$url;
if(substr($url,0,3) == 'www') $url = 'http://'.$url;
-
+
if ( !$isImage ) {
$class='urlextern';
} else {
$class='media';
}
-
+
//prepare for formating
$link['target'] = $conf['target']['extern'];
$link['style'] = '';
@@ -554,12 +554,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
//output formatted
$this->doc .= $this->_formatLink($link);
}
-
+
/**
*/
function interwikilink($match, $name = NULL, $wikiName, $wikiUri) {
global $conf;
-
+
$link = array();
$link['target'] = $conf['target']['interwiki'];
$link['pre'] = '';
@@ -615,7 +615,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
//output formatted
$this->doc .= $this->_formatLink($link);
}
-
+
/**
*/
function windowssharelink($url, $name = NULL) {
@@ -648,7 +648,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
//output formatted
$this->doc .= $this->_formatLink($link);
}
-
+
function emaillink($address, $name = NULL) {
global $conf;
//simple setup
@@ -658,7 +658,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['suf'] = '';
$link['style'] = '';
$link['more'] = '';
-
+
//we just test for image here - we need to encode the title our self
$this->_getLinkTitle($name, $address, $isImage);
if ( !$isImage ) {
@@ -675,9 +675,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}else{
$name = $this->_xmlEntities($name);
}
-
+
if($conf['mailguard'] == 'visible') $address = rawurlencode($address);
-
+
$link['url'] = 'mailto:'.$address;
$link['name'] = $name;
$link['title'] = $title;
@@ -685,7 +685,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
//output formatted
$this->doc .= $this->_formatLink($link);
}
-
+
function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
$height=NULL, $cache=NULL, $linking=NULL) {
global $conf;
@@ -719,7 +719,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
if ($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
else $this->doc .= $this->_formatLink($link);
}
-
+
/**
* @todo don't add link for flash
*/
@@ -759,7 +759,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Renders an RSS feed using Magpie
- *
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function rss ($url){
@@ -794,19 +794,19 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
function table_open($maxcols = NULL, $numrows = NULL){
$this->doc .= '<table class="inline">'.DOKU_LF;
}
-
+
function table_close(){
$this->doc .= '</table>'.DOKU_LF.'<br />'.DOKU_LF;
}
-
+
function tablerow_open(){
$this->doc .= DOKU_TAB . '<tr>' . DOKU_LF . DOKU_TAB . DOKU_TAB;
}
-
+
function tablerow_close(){
$this->doc .= DOKU_LF . DOKU_TAB . '</tr>' . DOKU_LF;
}
-
+
function tableheader_open($colspan = 1, $align = NULL){
$this->doc .= '<th';
if ( !is_null($align) ) {
@@ -817,11 +817,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
$this->doc .= '>';
}
-
+
function tableheader_close(){
$this->doc .= '</th>';
}
-
+
function tablecell_open($colspan = 1, $align = NULL){
$this->doc .= '<td';
if ( !is_null($align) ) {
@@ -832,11 +832,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
$this->doc .= '>';
}
-
+
function tablecell_close(){
$this->doc .= '</td>';
}
-
+
//----------------------------------------------------------
// Utils
@@ -898,7 +898,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Renders internal and external media
- *
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function _media ($src, $title=NULL, $align=NULL, $width=NULL,
@@ -911,7 +911,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
//add image tag
$ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"';
$ret .= ' class="media'.$align.'"';
-
+
if (!is_null($title)) {
$ret .= ' title="'.$this->_xmlEntities($title).'"';
$ret .= ' alt="'.$this->_xmlEntities($title).'"';
@@ -927,14 +927,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}else{
$ret .= ' alt=""';
}
-
+
if ( !is_null($width) )
$ret .= ' width="'.$this->_xmlEntities($width).'"';
-
+
if ( !is_null($height) )
$ret .= ' height="'.$this->_xmlEntities($height).'"';
- $ret .= ' />';
+ $ret .= ' />';
}elseif($mime == 'application/x-shockwave-flash'){
$ret .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'.
@@ -962,11 +962,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
return $ret;
}
-
+
function _xmlEntities($string) {
return htmlspecialchars($string);
}
-
+
/**
* Creates a linkid from a headline
*/
@@ -982,13 +982,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* This is just aplaceholder and gets replace by the button if
* section editing is allowed
- *
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function _secedit($f, $t){
$this->doc .= '<!-- SECTION ['.$f.'-'.$t.'] -->';
}
-
+
/**
* Construct a title and handle images in titles
*
@@ -1013,7 +1013,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
return $this->_imageTitle($title);
}
}
-
+
/**
* Returns an HTML code for images used in link titles
*
diff --git a/inc/parser/xhtmlsummary.php b/inc/parser/xhtmlsummary.php
index eeb684e57..669fa46e3 100644
--- a/inc/parser/xhtmlsummary.php
+++ b/inc/parser/xhtmlsummary.php
@@ -1,85 +1,85 @@
-<?php
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
-
-require_once DOKU_INC . 'inc/parser/xhtml.php';
-
-/**
-* The summary XHTML form selects either up to the first two paragraphs
-* it find in a page or the first section (whichever comes first)
-* It strips out the table of contents if one exists
-* Section divs are not used - everything should be nested in a single
-* div with CSS class "page"
-* Headings have their a name link removed and section editing links
-* removed
-* It also attempts to capture the first heading in a page for
-* use as the title of the page.
-*/
-class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml {
-
- // Namespace these variables to
- // avoid clashes with parent classes
- var $sum_paragraphs = 0;
- var $sum_capture = TRUE;
- var $sum_inSection = FALSE;
- var $sum_summary = '';
- var $sum_pageTitle = FALSE;
-
- function document_start() {
- $this->doc .= DOKU_LF.'<div>'.DOKU_LF;
- }
-
- function document_end() {
- $this->doc = $this->sum_summary;
- $this->doc .= DOKU_LF.'</div>'.DOKU_LF;
- }
-
- function toc_open() {
- $this->sum_summary .= $this->doc;
- }
-
- function toc_close() {
- $this->doc = '';
- }
-
- function header($text, $level, $pos) {
- if ( !$this->sum_pageTitle ) {
- $this->info['sum_pagetitle'] = $text;
- $this->sum_pageTitle = TRUE;
- }
- $this->doc .= DOKU_LF.'<h'.$level.'>';
- $this->doc .= $this->_xmlEntities($text);
- $this->doc .= "</h$level>".DOKU_LF;
- }
-
- function section_open($level) {
- if ( $this->sum_capture ) {
- $this->sum_inSection = TRUE;
- }
- }
-
- function section_close() {
- if ( $this->sum_capture && $this->sum_inSection ) {
- $this->sum_summary .= $this->doc;
- $this->sum_capture = FALSE;
- }
- }
-
- function p_open() {
- if ( $this->sum_capture && $this->sum_paragraphs < 2 ) {
- $this->sum_paragraphs++;
- }
- parent :: p_open();
- }
-
- function p_close() {
- parent :: p_close();
- if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) {
- $this->sum_summary .= $this->doc;
- $this->sum_capture = FALSE;
- }
- }
-
-}
-
-
-//Setup VIM: ex: et ts=2 enc=utf-8 :
+<?php
+if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
+
+require_once DOKU_INC . 'inc/parser/xhtml.php';
+
+/**
+* The summary XHTML form selects either up to the first two paragraphs
+* it find in a page or the first section (whichever comes first)
+* It strips out the table of contents if one exists
+* Section divs are not used - everything should be nested in a single
+* div with CSS class "page"
+* Headings have their a name link removed and section editing links
+* removed
+* It also attempts to capture the first heading in a page for
+* use as the title of the page.
+*/
+class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml {
+
+ // Namespace these variables to
+ // avoid clashes with parent classes
+ var $sum_paragraphs = 0;
+ var $sum_capture = TRUE;
+ var $sum_inSection = FALSE;
+ var $sum_summary = '';
+ var $sum_pageTitle = FALSE;
+
+ function document_start() {
+ $this->doc .= DOKU_LF.'<div>'.DOKU_LF;
+ }
+
+ function document_end() {
+ $this->doc = $this->sum_summary;
+ $this->doc .= DOKU_LF.'</div>'.DOKU_LF;
+ }
+
+ function toc_open() {
+ $this->sum_summary .= $this->doc;
+ }
+
+ function toc_close() {
+ $this->doc = '';
+ }
+
+ function header($text, $level, $pos) {
+ if ( !$this->sum_pageTitle ) {
+ $this->info['sum_pagetitle'] = $text;
+ $this->sum_pageTitle = TRUE;
+ }
+ $this->doc .= DOKU_LF.'<h'.$level.'>';
+ $this->doc .= $this->_xmlEntities($text);
+ $this->doc .= "</h$level>".DOKU_LF;
+ }
+
+ function section_open($level) {
+ if ( $this->sum_capture ) {
+ $this->sum_inSection = TRUE;
+ }
+ }
+
+ function section_close() {
+ if ( $this->sum_capture && $this->sum_inSection ) {
+ $this->sum_summary .= $this->doc;
+ $this->sum_capture = FALSE;
+ }
+ }
+
+ function p_open() {
+ if ( $this->sum_capture && $this->sum_paragraphs < 2 ) {
+ $this->sum_paragraphs++;
+ }
+ parent :: p_open();
+ }
+
+ function p_close() {
+ parent :: p_close();
+ if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) {
+ $this->sum_summary .= $this->doc;
+ $this->sum_capture = FALSE;
+ }
+ }
+
+}
+
+
+//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/parserutils.php b/inc/parserutils.php
index daeb94f50..45847d929 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -1,7 +1,7 @@
<?php
/**
* Utilities for collecting data from config files
- *
+ *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Andreas Gohr <andi@splitbrain.org>
@@ -24,7 +24,7 @@
function p_wiki_xhtml($id, $rev='', $excuse=true){
$file = wikiFN($id,$rev);
$ret = '';
-
+
//ensure $id is in global $ID (needed for parsing)
global $ID;
$keep = $ID;
@@ -217,7 +217,7 @@ function p_get_instructions($text){
// Create the parser
$Parser = & new Doku_Parser();
-
+
// Add the Handler
$Parser->Handler = & new Doku_Handler();
@@ -230,7 +230,7 @@ function p_get_instructions($text){
$p = $Parser->parse($text);
// dbg($p);
return $p;
-}
+}
/**
* returns all available parser syntax modes in correct order
@@ -252,12 +252,12 @@ function p_get_parsermodes(){
// we now collect all syntax modes and their objects, then they will
// be sorted and added to the parser in correct order
$modes = array();
-
+
// add syntax plugins
$pluginlist = plugin_list('syntax');
if(count($pluginlist)){
global $PARSER_MODES;
- $obj = null;
+ $obj = null;
foreach($pluginlist as $p){
if(!$obj =& plugin_load('syntax',$p)) continue; //attempt to load plugin into $obj
$PARSER_MODES[$obj->getType()][] = "plugin_$p"; //register mode type
@@ -285,18 +285,18 @@ function p_get_parsermodes(){
$class = "Doku_Parser_Mode_$m";
$obj = new $class();
$modes[] = array(
- 'sort' => $obj->getSort(),
+ 'sort' => $obj->getSort(),
'mode' => $m,
'obj' => $obj
);
}
-
+
// add formatting modes
$fmt_modes = array('strong','emphasis','underline','monospace',
'subscript','superscript','deleted');
foreach($fmt_modes as $m){
$obj = new Doku_Parser_Mode_formatting($m);
- $modes[] = array(
+ $modes[] = array(
'sort' => $obj->getSort(),
'mode' => $m,
'obj' => $obj
@@ -310,8 +310,8 @@ function p_get_parsermodes(){
$modes[] = array('sort' => $obj->getSort(), 'mode' => 'acronym','obj' => $obj );
$obj = new Doku_Parser_Mode_entity(array_keys(getEntities()));
$modes[] = array('sort' => $obj->getSort(), 'mode' => 'entity','obj' => $obj );
-
-
+
+
// add optional camelcase mode
if($conf['camelcase']){
$obj = new Doku_Parser_Mode_camelcaselink();
@@ -363,14 +363,14 @@ function p_render($mode,$instructions,& $info){
$Renderer->acronyms = getAcronyms();
$Renderer->interwiki = getInterwiki();
#$Renderer->badwords = getBadWords();
-
+
// Loop through the instructions
foreach ( $instructions as $instruction ) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]),$instruction[1]);
}
- //set info array
+ //set info array
$info = $Renderer->info;
// Return the output
diff --git a/inc/pluginutils.php b/inc/pluginutils.php
index fe51e5f13..1a60d60be 100644
--- a/inc/pluginutils.php
+++ b/inc/pluginutils.php
@@ -1,7 +1,7 @@
<?php
/**
* Utilities for handling plugins
- *
+ *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
@@ -72,7 +72,7 @@ function &plugin_load($type,$name){
//construct class and instanciate
$class = $type.'_plugin_'.$name;
if (!class_exists($class)) return null;
-
+
$DOKU_PLUGINS[$type][$name] = new $class;
return $DOKU_PLUGINS[$type][$name];
}
diff --git a/inc/search.php b/inc/search.php
index 4000c445d..254848d4b 100644
--- a/inc/search.php
+++ b/inc/search.php
@@ -222,14 +222,14 @@ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){
//only search txt files
if(!preg_match('#\.txt$#',$file)) return true;
- //simple stringmatching
+ //simple stringmatching
if (!empty($opts['query'])){
if(strpos($file,$opts['query']) !== false){
//check ACL
$id = pathID($file);
if(auth_quickaclcheck($id) < AUTH_READ){
return false;
- }
+ }
$data[]['id'] = $id;
}
}
@@ -287,7 +287,7 @@ function search_backlinks(&$data,$base,$file,$type,$lvl,$opts){
foreach($instructions as $ins){
if($ins[0] == 'internallink' || ($conf['camelcase'] && $ins[0] == 'camelcaselink') ){
$mid = $ins[1][0];
- resolve_pageid($cns,$mid,$exists); //exists is not used
+ resolve_pageid($cns,$mid,$exists); //exists is not used
if($mid == $sid){
//we have a match - finish
$data[]['id'] = $cid;
@@ -319,11 +319,11 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){
return false;
}
- //create regexp from queries
+ //create regexp from queries
$poswords = array();
$negwords = array();
$qpreg = preg_split('/\s+/',$opts['query']);
-
+
foreach($qpreg as $word){
switch(substr($word,0,1)){
case '-':
@@ -344,7 +344,7 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){
// a search without any posword is useless
if (!count($poswords)) return true;
-
+
$reg = '^(?=.*?'.join(')(?=.*?',$poswords).')';
$reg .= count($negwords) ? '((?!'.join('|',$negwords).').)*$' : '.*$';
search_regex($data,$base,$file,$reg,$poswords);
@@ -373,10 +373,10 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){
*/
function search_reference(&$data,$base,$file,$type,$lvl,$opts){
global $conf;
-
+
//we do nothing with directories
if($type == 'd') return true;
-
+
//only search txt files
if(!preg_match('#\.txt$#',$file)) return true;
@@ -384,7 +384,7 @@ function search_reference(&$data,$base,$file,$type,$lvl,$opts){
//'false' will skip subdirectories to speed search up.
$cnt = $conf['refshow'] > 0 ? $conf['refshow'] : 1;
if(count($data) >= $cnt) return false;
-
+
$reg = '\{\{ *\:?'.$opts['query'].' *(\|.*)?\}\}';
search_regex($data,$base,$file,$reg,array($opts['query']));
return true;
@@ -438,7 +438,7 @@ function search_regex(&$data,$base,$file,$reg,$words){
'snippet' => $snippet,
);
}
-
+
return true;
}
diff --git a/inc/template.php b/inc/template.php
index 3e9cd55ad..63e90118d 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -120,12 +120,12 @@ function tpl_content(){
break;
case 'profile' :
html_updateprofile();
- break;
+ break;
case 'admin':
tpl_admin();
break;
default:
- msg("Failed to handle command: ".hsc($ACT),-1);
+ msg("Failed to handle command: ".hsc($ACT),-1);
}
}
@@ -252,7 +252,7 @@ function tpl_pagelink($id,$name=NULL){
*/
function tpl_getparent($ID){
global $conf;
-
+
if ($ID != $conf['start']) {
$idparts = explode(':', $ID);
$pn = array_pop($idparts); // get the page name
@@ -270,7 +270,7 @@ function tpl_getparent($ID){
}
}
}
-
+
if (@file_exists(wikiFN($ID))) {
return $ID;
}
@@ -304,7 +304,7 @@ function tpl_button($type){
global $NS;
global $INFO;
global $conf;
- global $auth;
+ global $auth;
switch($type){
case 'edit':
@@ -393,7 +393,7 @@ function tpl_actionlink($type,$pre='',$suf=''){
global $ACT;
global $conf;
global $lang;
- global $auth;
+ global $auth;
switch($type){
case 'edit':
@@ -490,7 +490,7 @@ function tpl_actionlink($type,$pre='',$suf=''){
function tpl_searchform($ajax=true,$autocomplete=true){
global $lang;
global $ACT;
-
+
print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">';
print '<input type="hidden" name="do" value="search" />';
print '<input type="text" ';
@@ -705,7 +705,7 @@ function tpl_mediafilelist(){
ptln('('.$w.'&#215;'.$h.' '.filesize_h($item['size']).')',6);
ptln($del.'<br />',6);
ptln('<div class="imagemeta">',6);
-
+
//build thumbnail
print '<a href="javascript:mediaSelect(\''.$item['id'].'\')">';
@@ -726,7 +726,7 @@ function tpl_mediafilelist(){
print '<img src="'.$src.'" '.$att.' />';
print '</a>';
-
+
//read EXIF/IPTC data
$t = $item['meta']->getField('IPTC.Headline');
if($t) print '<strong>'.$t.'</strong><br />';
@@ -767,7 +767,7 @@ function tpl_showreferences(&$data){
global $lang;
$hidden=0; //count of hits without read permission
-
+
if(count($data)){
usort($data,'sort_search_fulltext');
foreach($data as $row){
diff --git a/inc/toolbar.php b/inc/toolbar.php
index 51dfa5b0d..12366af42 100644
--- a/inc/toolbar.php
+++ b/inc/toolbar.php
@@ -1,7 +1,7 @@
<?php
/**
* Editing toolbar functions
- *
+ *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
@@ -21,9 +21,9 @@ require_once(DOKU_INC.'inc/JSON.php');
function toolbar_JSdefines($varname){
global $ID;
global $conf;
- global $lang;
+ global $lang;
- // build button array
+ // build button array
$menu = array(
array(
'type' => 'format',
@@ -169,7 +169,7 @@ function toolbar_JSdefines($varname){
'key' => 'y',
),
);
-
+
// use JSON to build the JavaScript array
$json = new JSON();
print "var $varname = ".$json->encode($menu).";\n";
diff --git a/inc/utf8.php b/inc/utf8.php
index 723c470bb..3a223d3fb 100644
--- a/inc/utf8.php
+++ b/inc/utf8.php
@@ -123,7 +123,7 @@ function utf8_substr($str,$start,$length=null){
} else {
return join("",array_slice($ar[0],$start));
}
-}
+}
/**
* Unicode aware replacement for substr_replace()
@@ -142,7 +142,7 @@ function utf8_substr_replace($string, $replacement, $start , $length=0 ){
/**
* Unicode aware replacement for explode
*
- * @TODO support third limit arg
+ * @TODO support third limit arg
* @author Harry Fuecks <hfuecks@gmail.com>
* @see explode();
*/
@@ -182,7 +182,7 @@ function utf8_str_replace($s,$r,$str){
*/
function utf8_ltrim($str,$charlist=''){
if($charlist == '') return ltrim($str);
-
+
//quote charlist for use in a characterclass
$charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist);
@@ -198,10 +198,10 @@ function utf8_ltrim($str,$charlist=''){
*/
function utf8_rtrim($str,$charlist=''){
if($charlist == '') return rtrim($str);
-
+
//quote charlist for use in a characterclass
$charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist);
-
+
return preg_replace('/['.$charlist.']+$/u','',$str);
}
@@ -233,7 +233,7 @@ function utf8_strtolower($string){
return mb_strtolower($string,'utf-8');
global $UTF8_UPPER_TO_LOWER;
- $uni = utf8_to_unicode($string);
+ $uni = utf8_to_unicode($string);
$cnt = count($uni);
for ($i=0; $i < $cnt; $i++){
if($UTF8_UPPER_TO_LOWER[$uni[$i]]){
@@ -344,7 +344,7 @@ function utf8_strpos($haystack, $needle,$offset=0) {
trigger_error('Offset must be an integer',E_USER_WARNING);
return false;
}
-
+
$str = utf8_substr($str, $offset);
if ( false !== ($pos = utf8_strpos($str,$needle))){
@@ -379,7 +379,7 @@ function utf8_tohtml ($str) {
}
}
return $ret . substr($str, $last, $i); // append the last batch of regular characters
-}
+}
/**
* This function returns any UTF-8 encoded text as a list of
@@ -390,10 +390,10 @@ function utf8_tohtml ($str) {
* @see unicode_to_utf8()
*/
function utf8_to_unicode( &$str ) {
- $unicode = array();
+ $unicode = array();
$values = array();
$lookingFor = 1;
-
+
for ($i = 0; $i < strlen( $str ); $i++ ) {
$thisValue = ord( $str[ $i ] );
if ( $thisValue < 128 ) $unicode[] = $thisValue;
@@ -403,7 +403,7 @@ function utf8_to_unicode( &$str ) {
if ( count( $values ) == $lookingFor ) {
$number = ( $lookingFor == 3 ) ?
( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ):
- ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );
+ ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );
$unicode[] = $number;
$values = array();
$lookingFor = 1;
@@ -518,7 +518,7 @@ static $UTF8_LOWER_TO_UPPER = array(
0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102,
0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9,
0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122,
-);
+);
/**
* UTF-8 Case lookup table
@@ -540,20 +540,20 @@ $UTF8_UPPER_TO_LOWER = @array_flip($UTF8_LOWER_TO_UPPER);
* @see utf8_deaccent()
*/
$UTF8_LOWER_ACCENTS = array(
- 'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o',
- 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k',
- 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o',
- 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o',
- 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c',
- 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't',
- 'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l',
- 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z',
- 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't',
- 'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o',
- 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j',
- 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o',
- 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g',
- 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a',
+ 'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o',
+ 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k',
+ 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o',
+ 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o',
+ 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c',
+ 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't',
+ 'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l',
+ 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z',
+ 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't',
+ 'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o',
+ 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j',
+ 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o',
+ 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g',
+ 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a',
'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u',
);
@@ -567,20 +567,20 @@ $UTF8_LOWER_ACCENTS = array(
* @see utf8_deaccent()
*/
$UTF8_UPPER_ACCENTS = array(
- 'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O',
- 'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K',
- 'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O',
- 'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O',
- 'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C',
- 'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T',
- 'Ū' => 'U', 'Č' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L',
- 'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z',
- 'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T',
- 'Ŗ' => 'R', 'Ä' => 'Ae', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'Ue', 'Ò' => 'O',
- 'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J',
- 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O',
- 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G',
- 'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A',
+ 'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O',
+ 'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K',
+ 'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O',
+ 'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O',
+ 'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C',
+ 'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T',
+ 'Ū' => 'U', 'Č' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L',
+ 'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z',
+ 'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T',
+ 'Ŗ' => 'R', 'Ä' => 'Ae', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'Ue', 'Ò' => 'O',
+ 'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J',
+ 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O',
+ 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G',
+ 'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A',
'Û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae',
);
@@ -605,50 +605,50 @@ $UTF8_SPECIAL_CHARS = array(
0x005c, 0x005d, 0x005e, 0x0060, 0x007b, 0x007c, 0x007d, 0x007e,
0x007f, 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088,
0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, 0x0090, 0x0091, 0x0092,
- 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c,
- 0x009d, 0x009e, 0x009f, 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6,
- 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, 0x00b0,
- 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba,
- 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, 0x00d7, 0x00f7, 0x02c7, 0x02d8, 0x02d9,
- 0x02da, 0x02db, 0x02dc, 0x02dd, 0x0300, 0x0301, 0x0303, 0x0309, 0x0323, 0x0384,
- 0x0385, 0x0387, 0x03b2, 0x03c6, 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x05b0, 0x05b1,
- 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, 0x05b8, 0x05b9, 0x05bb, 0x05bc,
- 0x05bd, 0x05be, 0x05bf, 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f3, 0x05f4, 0x060c,
- 0x061b, 0x061f, 0x0640, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, 0x0650, 0x0651,
- 0x0652, 0x066a, 0x0e3f, 0x200c, 0x200d, 0x200e, 0x200f, 0x2013, 0x2014, 0x2015,
- 0x2017, 0x2018, 0x2019, 0x201a, 0x201c, 0x201d, 0x201e, 0x2020, 0x2021, 0x2022,
- 0x2026, 0x2030, 0x2032, 0x2033, 0x2039, 0x203a, 0x2044, 0x20a7, 0x20aa, 0x20ab,
- 0x20ac, 0x2116, 0x2118, 0x2122, 0x2126, 0x2135, 0x2190, 0x2191, 0x2192, 0x2193,
- 0x2194, 0x2195, 0x21b5, 0x21d0, 0x21d1, 0x21d2, 0x21d3, 0x21d4, 0x2200, 0x2202,
- 0x2203, 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, 0x220b, 0x220f, 0x2211, 0x2212,
- 0x2215, 0x2217, 0x2219, 0x221a, 0x221d, 0x221e, 0x2220, 0x2227, 0x2228, 0x2229,
- 0x222a, 0x222b, 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, 0x2261, 0x2264, 0x2265,
- 0x2282, 0x2283, 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, 0x22a5, 0x22c5, 0x2310,
- 0x2320, 0x2321, 0x2329, 0x232a, 0x2469, 0x2500, 0x2502, 0x250c, 0x2510, 0x2514,
- 0x2518, 0x251c, 0x2524, 0x252c, 0x2534, 0x253c, 0x2550, 0x2551, 0x2552, 0x2553,
- 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d,
- 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
- 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
- 0x2591, 0x2592, 0x2593, 0x25a0, 0x25b2, 0x25bc, 0x25c6, 0x25ca, 0x25cf, 0x25d7,
- 0x2605, 0x260e, 0x261b, 0x261e, 0x2660, 0x2663, 0x2665, 0x2666, 0x2701, 0x2702,
- 0x2703, 0x2704, 0x2706, 0x2707, 0x2708, 0x2709, 0x270c, 0x270d, 0x270e, 0x270f,
- 0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715, 0x2716, 0x2717, 0x2718, 0x2719,
- 0x271a, 0x271b, 0x271c, 0x271d, 0x271e, 0x271f, 0x2720, 0x2721, 0x2722, 0x2723,
- 0x2724, 0x2725, 0x2726, 0x2727, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d, 0x272e,
- 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738,
- 0x2739, 0x273a, 0x273b, 0x273c, 0x273d, 0x273e, 0x273f, 0x2740, 0x2741, 0x2742,
- 0x2743, 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274a, 0x274b, 0x274d,
- 0x274f, 0x2750, 0x2751, 0x2752, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c,
- 0x275d, 0x275e, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x277f,
- 0x2789, 0x2793, 0x2794, 0x2798, 0x2799, 0x279a, 0x279b, 0x279c, 0x279d, 0x279e,
- 0x279f, 0x27a0, 0x27a1, 0x27a2, 0x27a3, 0x27a4, 0x27a5, 0x27a6, 0x27a7, 0x27a8,
- 0x27a9, 0x27aa, 0x27ab, 0x27ac, 0x27ad, 0x27ae, 0x27af, 0x27b1, 0x27b2, 0x27b3,
- 0x27b4, 0x27b5, 0x27b6, 0x27b7, 0x27b8, 0x27b9, 0x27ba, 0x27bb, 0x27bc, 0x27bd,
- 0x27be, 0xf6d9, 0xf6da, 0xf6db, 0xf8d7, 0xf8d8, 0xf8d9, 0xf8da, 0xf8db, 0xf8dc,
- 0xf8dd, 0xf8de, 0xf8df, 0xf8e0, 0xf8e1, 0xf8e2, 0xf8e3, 0xf8e4, 0xf8e5, 0xf8e6,
- 0xf8e7, 0xf8e8, 0xf8e9, 0xf8ea, 0xf8eb, 0xf8ec, 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0,
- 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4, 0xf8f5, 0xf8f6, 0xf8f7, 0xf8f8, 0xf8f9, 0xf8fa,
- 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0xfe7c, 0xfe7d,
+ 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c,
+ 0x009d, 0x009e, 0x009f, 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6,
+ 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, 0x00b0,
+ 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba,
+ 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, 0x00d7, 0x00f7, 0x02c7, 0x02d8, 0x02d9,
+ 0x02da, 0x02db, 0x02dc, 0x02dd, 0x0300, 0x0301, 0x0303, 0x0309, 0x0323, 0x0384,
+ 0x0385, 0x0387, 0x03b2, 0x03c6, 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x05b0, 0x05b1,
+ 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, 0x05b8, 0x05b9, 0x05bb, 0x05bc,
+ 0x05bd, 0x05be, 0x05bf, 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f3, 0x05f4, 0x060c,
+ 0x061b, 0x061f, 0x0640, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, 0x0650, 0x0651,
+ 0x0652, 0x066a, 0x0e3f, 0x200c, 0x200d, 0x200e, 0x200f, 0x2013, 0x2014, 0x2015,
+ 0x2017, 0x2018, 0x2019, 0x201a, 0x201c, 0x201d, 0x201e, 0x2020, 0x2021, 0x2022,
+ 0x2026, 0x2030, 0x2032, 0x2033, 0x2039, 0x203a, 0x2044, 0x20a7, 0x20aa, 0x20ab,
+ 0x20ac, 0x2116, 0x2118, 0x2122, 0x2126, 0x2135, 0x2190, 0x2191, 0x2192, 0x2193,
+ 0x2194, 0x2195, 0x21b5, 0x21d0, 0x21d1, 0x21d2, 0x21d3, 0x21d4, 0x2200, 0x2202,
+ 0x2203, 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, 0x220b, 0x220f, 0x2211, 0x2212,
+ 0x2215, 0x2217, 0x2219, 0x221a, 0x221d, 0x221e, 0x2220, 0x2227, 0x2228, 0x2229,
+ 0x222a, 0x222b, 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, 0x2261, 0x2264, 0x2265,
+ 0x2282, 0x2283, 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, 0x22a5, 0x22c5, 0x2310,
+ 0x2320, 0x2321, 0x2329, 0x232a, 0x2469, 0x2500, 0x2502, 0x250c, 0x2510, 0x2514,
+ 0x2518, 0x251c, 0x2524, 0x252c, 0x2534, 0x253c, 0x2550, 0x2551, 0x2552, 0x2553,
+ 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d,
+ 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
+ 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
+ 0x2591, 0x2592, 0x2593, 0x25a0, 0x25b2, 0x25bc, 0x25c6, 0x25ca, 0x25cf, 0x25d7,
+ 0x2605, 0x260e, 0x261b, 0x261e, 0x2660, 0x2663, 0x2665, 0x2666, 0x2701, 0x2702,
+ 0x2703, 0x2704, 0x2706, 0x2707, 0x2708, 0x2709, 0x270c, 0x270d, 0x270e, 0x270f,
+ 0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715, 0x2716, 0x2717, 0x2718, 0x2719,
+ 0x271a, 0x271b, 0x271c, 0x271d, 0x271e, 0x271f, 0x2720, 0x2721, 0x2722, 0x2723,
+ 0x2724, 0x2725, 0x2726, 0x2727, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d, 0x272e,
+ 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738,
+ 0x2739, 0x273a, 0x273b, 0x273c, 0x273d, 0x273e, 0x273f, 0x2740, 0x2741, 0x2742,
+ 0x2743, 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274a, 0x274b, 0x274d,
+ 0x274f, 0x2750, 0x2751, 0x2752, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c,
+ 0x275d, 0x275e, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x277f,
+ 0x2789, 0x2793, 0x2794, 0x2798, 0x2799, 0x279a, 0x279b, 0x279c, 0x279d, 0x279e,
+ 0x279f, 0x27a0, 0x27a1, 0x27a2, 0x27a3, 0x27a4, 0x27a5, 0x27a6, 0x27a7, 0x27a8,
+ 0x27a9, 0x27aa, 0x27ab, 0x27ac, 0x27ad, 0x27ae, 0x27af, 0x27b1, 0x27b2, 0x27b3,
+ 0x27b4, 0x27b5, 0x27b6, 0x27b7, 0x27b8, 0x27b9, 0x27ba, 0x27bb, 0x27bc, 0x27bd,
+ 0x27be, 0xf6d9, 0xf6da, 0xf6db, 0xf8d7, 0xf8d8, 0xf8d9, 0xf8da, 0xf8db, 0xf8dc,
+ 0xf8dd, 0xf8de, 0xf8df, 0xf8e0, 0xf8e1, 0xf8e2, 0xf8e3, 0xf8e4, 0xf8e5, 0xf8e6,
+ 0xf8e7, 0xf8e8, 0xf8e9, 0xf8ea, 0xf8eb, 0xf8ec, 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0,
+ 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4, 0xf8f5, 0xf8f6, 0xf8f7, 0xf8f8, 0xf8f9, 0xf8fa,
+ 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0xfe7c, 0xfe7d,
);
/**
@@ -786,7 +786,7 @@ $UTF8_ROMANIZATION = array(
'ウォ'=>'who','ウゥ'=>'whu','ヱ'=>'wye','ヰ'=>'wyi','ジャ'=>'zha','ジェ'=>'zhe',
'ジィ'=>'zhi','ジョ'=>'zho','ジュ'=>'zhu','ジャ'=>'zya','ジェ'=>'zye','ジィ'=>'zyi',
'ジョ'=>'zyo','ジュ'=>'zyu',
-
+
// "Greeklish"
'Γ'=>'G','Δ'=>'E','Θ'=>'Th','Λ'=>'L','Ξ'=>'X','Π'=>'P','Σ'=>'S','Φ'=>'F','Ψ'=>'Ps',
'γ'=>'g','δ'=>'e','θ'=>'th','λ'=>'l','ξ'=>'x','π'=>'p','σ'=>'s','φ'=>'f','ψ'=>'ps',