]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/Theme.php
fix FileUser locking issues, new config ENABLE_PAGEPERM
[SourceForge/phpwiki.git] / lib / Theme.php
1 <?php rcs_id('$Id: Theme.php,v 1.100 2004-06-03 10:18:19 rurban Exp $');
2 /* Copyright (C) 2002,2004 $ThePhpWikiProgrammingTeam
3  *
4  * This file is part of PhpWiki.
5  * 
6  * PhpWiki is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * PhpWiki is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with PhpWiki; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 /**
22  * Customize output by themes: templates, css, special links functions, 
23  * and more formatting.
24  */
25
26 require_once(dirname(__FILE__).'/HtmlElement.php');
27
28 /**
29  * Make a link to a wiki page (in this wiki).
30  *
31  * This is a convenience function.
32  *
33  * @param mixed $page_or_rev
34  * Can be:<dl>
35  * <dt>A string</dt><dd>The page to link to.</dd>
36  * <dt>A WikiDB_Page object</dt><dd>The page to link to.</dd>
37  * <dt>A WikiDB_PageRevision object</dt><dd>A specific version of the page to link to.</dd>
38  * </dl>
39  *
40  * @param string $type
41  * One of:<dl>
42  * <dt>'unknown'</dt><dd>Make link appropriate for a non-existant page.</dd>
43  * <dt>'known'</dt><dd>Make link appropriate for an existing page.</dd>
44  * <dt>'auto'</dt><dd>Either 'unknown' or 'known' as appropriate.</dd>
45  * <dt>'button'</dt><dd>Make a button-style link.</dd>
46  * <dt>'if_known'</dt><dd>Only linkify if page exists.</dd>
47  * </dl>
48  * Unless $type of of the latter form, the link will be of class 'wiki', 'wikiunknown',
49  * 'named-wiki', or 'named-wikiunknown', as appropriate.
50  *
51  * @param mixed $label (string or XmlContent object)
52  * Label for the link.  If not given, defaults to the page name.
53  *
54  * @return XmlContent The link
55  */
56 function WikiLink ($page_or_rev, $type = 'known', $label = false) {
57     global $Theme, $request;
58
59     if ($type == 'button') {
60         return $Theme->makeLinkButton($page_or_rev, $label);
61     }
62
63     $version = false;
64     
65     if (isa($page_or_rev, 'WikiDB_PageRevision')) {
66         $version = $page_or_rev->getVersion();
67         if ($page_or_rev->isCurrent())
68             $version = false;
69         $page = $page_or_rev->getPage();
70         $pagename = $page->getName();
71         $wikipage = $pagename;
72         $exists = true;
73     }
74     elseif (isa($page_or_rev, 'WikiDB_Page')) {
75         $page = $page_or_rev;
76         $pagename = $page->getName();
77         $wikipage = $pagename;
78     }
79     elseif (isa($page_or_rev, 'WikiPageName')) {
80         $wikipage = $page_or_rev;
81         $pagename = $wikipage->name;
82     }
83     else {
84         $wikipage = new WikiPageName($page_or_rev, $request->getPage());
85         $pagename = $wikipage->name;
86     }
87     
88     if (!is_string($wikipage) and !$wikipage->isValid('strict'))
89         return $Theme->linkBadWikiWord($wikipage, $label);
90     
91     if ($type == 'auto' or $type == 'if_known') {
92         if (isset($page)) {
93             $current = $page->getCurrentRevision();
94             $exists = ! $current->hasDefaultContents();
95         }
96         else {
97             $dbi = $request->getDbh();
98             $exists = $dbi->isWikiPage($wikipage->name);
99         }
100     }
101     elseif ($type == 'unknown') {
102         $exists = false;
103     }
104     else {
105         $exists = true;
106     }
107
108     // FIXME: this should be somewhere else, if really needed.
109     // WikiLink makes A link, not a string of fancy ones.
110     // (I think that the fancy split links are just confusing.)
111     // Todo: test external ImageLinks http://some/images/next.gif
112     if (isa($wikipage, 'WikiPageName') and 
113         ! $label and 
114         strchr(substr($wikipage->shortName,1), SUBPAGE_SEPARATOR))
115     {
116         $parts = explode(SUBPAGE_SEPARATOR, $wikipage->shortName);
117         $last_part = array_pop($parts);
118         $sep = '';
119         $link = HTML::span();
120         foreach ($parts as $part) {
121             $path[] = $part;
122             $parent = join(SUBPAGE_SEPARATOR, $path);
123             if ($Theme->_autosplitWikiWords)
124                 $part = " " . $part;
125             if ($part)
126                 $link->pushContent($Theme->linkExistingWikiWord($parent, $sep . $part));
127             $sep = $Theme->_autosplitWikiWords ? ' ' . SUBPAGE_SEPARATOR : SUBPAGE_SEPARATOR;
128         }
129         if ($exists)
130             $link->pushContent($Theme->linkExistingWikiWord($wikipage, $sep . $last_part, $version));
131         else
132             $link->pushContent($Theme->linkUnknownWikiWord($wikipage, $sep . $last_part));
133         return $link;
134     }
135
136     if ($exists) {
137         return $Theme->linkExistingWikiWord($wikipage, $label, $version);
138     }
139     elseif ($type == 'if_known') {
140         if (!$label && isa($wikipage, 'WikiPageName'))
141             $label = $wikipage->shortName;
142         return HTML($label ? $label : $pagename);
143     }
144     else {
145         return $Theme->linkUnknownWikiWord($wikipage, $label);
146     }
147 }
148
149
150
151 /**
152  * Make a button.
153  *
154  * This is a convenience function.
155  *
156  * @param $action string
157  * One of <dl>
158  * <dt>[action]</dt><dd>Perform action (e.g. 'edit') on the selected page.</dd>
159  * <dt>[ActionPage]</dt><dd>Run the actionpage (e.g. 'BackLinks') on the selected page.</dd>
160  * <dt>'submit:'[name]</dt><dd>Make a form submission button with the given name.
161  *      ([name] can be blank for a nameless submit button.)</dd>
162  * <dt>a hash</dt><dd>Query args for the action. E.g.<pre>
163  *      array('action' => 'diff', 'previous' => 'author')
164  * </pre></dd>
165  * </dl>
166  *
167  * @param $label string
168  * A label for the button.  If ommited, a suitable default (based on the valued of $action)
169  * will be picked.
170  *
171  * @param $page_or_rev mixed
172  * Which page (& version) to perform the action on.
173  * Can be one of:<dl>
174  * <dt>A string</dt><dd>The pagename.</dd>
175  * <dt>A WikiDB_Page object</dt><dd>The page.</dd>
176  * <dt>A WikiDB_PageRevision object</dt><dd>A specific version of the page.</dd>
177  * </dl>
178  * ($Page_or_rev is ignored for submit buttons.)
179  */
180 function Button ($action, $label = false, $page_or_rev = false) {
181     global $Theme;
182
183     if (!is_array($action) && preg_match('/submit:(.*)/A', $action, $m))
184         return $Theme->makeSubmitButton($label, $m[1], $class = $page_or_rev);
185     else
186         return $Theme->makeActionButton($action, $label, $page_or_rev);
187 }
188
189
190 class Theme {
191     var $HTML_DUMP_SUFFIX = '';
192     var $DUMP_MODE = false, $dumped_images, $dumped_css; 
193
194     function Theme ($theme_name = 'default') {
195         $this->_name = $theme_name;
196         $this->_themes_dir = NormalizeLocalFileName("themes");
197         $this->_path  = defined('PHPWIKI_DIR') ? NormalizeLocalFileName("") : "";
198         $this->_theme = "themes/$theme_name";
199
200         if ($theme_name != 'default')
201             $this->_default_theme = new Theme;
202
203         $this->_css = array();
204     }
205
206     function file ($file) {
207         return $this->_path . "$this->_theme/$file";
208    } 
209
210     function _findFile ($file, $missing_okay = false) {
211         if (file_exists($this->file($file)))
212             return "$this->_theme/$file";
213
214         // FIXME: this is a short-term hack.  Delete this after all files
215         // get moved into themes/...
216         if (file_exists($this->_path . $file))
217             return $file;
218
219         if (isset($this->_default_theme)) {
220             return $this->_default_theme->_findFile($file, $missing_okay);
221         }
222         else if (!$missing_okay) {
223             trigger_error("$file: not found", E_USER_NOTICE);
224         }
225         return false;
226     }
227
228     function _findData ($file, $missing_okay = false) {
229         $path = $this->_findFile($file, $missing_okay);
230         if (!$path)
231             return false;
232
233         if (defined('DATA_PATH'))
234             return DATA_PATH . "/$path";
235         return $path;
236     }
237
238     ////////////////////////////////////////////////////////////////
239     //
240     // Date and Time formatting
241     //
242     ////////////////////////////////////////////////////////////////
243
244     // Note:  Windows' implemetation of strftime does not include certain
245         // format specifiers, such as %e (for date without leading zeros).  In
246         // general, see:
247         // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp
248         // As a result, we have to use %d, and strip out leading zeros ourselves.
249
250     var $_dateFormat = "%B %d, %Y";
251     var $_timeFormat = "%I:%M %p";
252
253     var $_showModTime = true;
254
255     /**
256      * Set format string used for dates.
257      *
258      * @param $fs string Format string for dates.
259      *
260      * @param $show_mod_time bool If true (default) then times
261      * are included in the messages generated by getLastModifiedMessage(),
262      * otherwise, only the date of last modification will be shown.
263      */
264     function setDateFormat ($fs, $show_mod_time = true) {
265         $this->_dateFormat = $fs;
266         $this->_showModTime = $show_mod_time;
267     }
268
269     /**
270      * Set format string used for times.
271      *
272      * @param $fs string Format string for times.
273      */
274     function setTimeFormat ($fs) {
275         $this->_timeFormat = $fs;
276     }
277
278     /**
279      * Format a date.
280      *
281      * Any time zone offset specified in the users preferences is
282      * taken into account by this method.
283      *
284      * @param $time_t integer Unix-style time.
285      *
286      * @return string The date.
287      */
288     function formatDate ($time_t) {
289         global $request;
290         
291         $offset_time = $time_t + 3600 * $request->getPref('timeOffset');
292         // strip leading zeros from date elements (ie space followed by zero)
293         return preg_replace('/ 0/', ' ', 
294                             strftime($this->_dateFormat, $offset_time));
295     }
296
297     /**
298      * Format a date.
299      *
300      * Any time zone offset specified in the users preferences is
301      * taken into account by this method.
302      *
303      * @param $time_t integer Unix-style time.
304      *
305      * @return string The time.
306      */
307     function formatTime ($time_t) {
308         //FIXME: make 24-hour mode configurable?
309         global $request;
310         $offset_time = $time_t + 3600 * $request->getPref('timeOffset');
311         return preg_replace('/^0/', ' ',
312                             strtolower(strftime($this->_timeFormat, $offset_time)));
313     }
314
315     /**
316      * Format a date and time.
317      *
318      * Any time zone offset specified in the users preferences is
319      * taken into account by this method.
320      *
321      * @param $time_t integer Unix-style time.
322      *
323      * @return string The date and time.
324      */
325     function formatDateTime ($time_t) {
326         return $this->formatDate($time_t) . ' ' . $this->formatTime($time_t);
327     }
328
329     /**
330      * Format a (possibly relative) date.
331      *
332      * If enabled in the users preferences, this method might
333      * return a relative day (e.g. 'Today', 'Yesterday').
334      *
335      * Any time zone offset specified in the users preferences is
336      * taken into account by this method.
337      *
338      * @param $time_t integer Unix-style time.
339      *
340      * @return string The day.
341      */
342     function getDay ($time_t) {
343         global $request;
344         
345         if ($request->getPref('relativeDates') && ($date = $this->_relativeDay($time_t))) {
346             return ucfirst($date);
347         }
348         return $this->formatDate($time_t);
349     }
350     
351     /**
352      * Format the "last modified" message for a page revision.
353      *
354      * @param $revision object A WikiDB_PageRevision object.
355      *
356      * @param $show_version bool Should the page version number
357      * be included in the message.  (If this argument is omitted,
358      * then the version number will be shown only iff the revision
359      * is not the current one.
360      *
361      * @return string The "last modified" message.
362      */
363     function getLastModifiedMessage ($revision, $show_version = 'auto') {
364         global $request;
365
366         // dates >= this are considered invalid.
367         if (! defined('EPOCH'))
368             define('EPOCH', 0); // seconds since ~ January 1 1970
369
370         $mtime = $revision->get('mtime');
371         if ($mtime <= EPOCH)
372             return fmt("Never edited");
373
374         if ($show_version == 'auto')
375             $show_version = !$revision->isCurrent();
376
377         if ($request->getPref('relativeDates') && ($date = $this->_relativeDay($mtime))) {
378             if ($this->_showModTime)
379                 $date =  sprintf(_("%s at %s"),
380                                  $date, $this->formatTime($mtime));
381             
382             if ($show_version)
383                 return fmt("Version %s, saved %s", $revision->getVersion(), $date);
384             else
385                 return fmt("Last edited %s", $date);
386         }
387
388         if ($this->_showModTime)
389             $date = $this->formatDateTime($mtime);
390         else
391             $date = $this->formatDate($mtime);
392         
393         if ($show_version)
394             return fmt("Version %s, saved on %s", $revision->getVersion(), $date);
395         else
396             return fmt("Last edited on %s", $date);
397     }
398     
399     function _relativeDay ($time_t) {
400         global $request;
401         
402         if (is_numeric($request->getPref('timeOffset')))
403           $offset = 3600 * $request->getPref('timeOffset');
404         else 
405           $offset = 0;          
406
407         $now = time() + $offset;
408         $today = localtime($now, true);
409         $time = localtime($time_t + $offset, true);
410
411         if ($time['tm_yday'] == $today['tm_yday'] && $time['tm_year'] == $today['tm_year'])
412             return _("today");
413         
414         // Note that due to daylight savings chages (and leap seconds), $now minus
415         // 24 hours is not guaranteed to be yesterday.
416         $yesterday = localtime($now - (12 + $today['tm_hour']) * 3600, true);
417         if ($time['tm_yday'] == $yesterday['tm_yday'] && $time['tm_year'] == $yesterday['tm_year'])
418             return _("yesterday");
419
420         return false;
421     }
422
423     /**
424      * Format the "Author" and "Owner" messages for a page revision.
425      */
426     function getOwnerMessage ($page) {
427         if (!ENABLE_PAGEPERM or !class_exists("PagePermission"))
428             return '';
429         $dbi =& $GLOBALS['request']->_dbi;
430         $owner = $page->getOwner();
431         if ($owner) {
432             if ( $dbi->isWikiPage($owner) )
433                 return fmt("Owner: %s", WikiLink($owner));
434             else
435                 return fmt("Owner: \"%s\"", $owner);
436         }
437     }
438
439     function getAuthorMessage ($revision, $only_authenticated = true) {
440         $dbi =& $GLOBALS['request']->_dbi;
441         $author = $revision->get('author_id');
442         if ( $author or $only_authenticated ) {
443             if (!$author) $author = $revision->get('author');
444             if (!$author) return '';
445             if ( $dbi->isWikiPage($author) )
446                 return fmt("by %s", WikiLink($author));
447             else
448                 return fmt("by \"%s\"", $author);
449         }
450     }
451
452     ////////////////////////////////////////////////////////////////
453     //
454     // Hooks for other formatting
455     //
456     ////////////////////////////////////////////////////////////////
457
458     //FIXME: PHP 4.1 Warnings
459     //lib/Theme.php:84: Notice[8]: The call_user_method() function is deprecated,
460     //use the call_user_func variety with the array(&$obj, "method") syntax instead
461
462     function getFormatter ($type, $format) {
463         $method = strtolower("get${type}Formatter");
464         if (method_exists($this, $method))
465             return $this->{$method}($format);
466         return false;
467     }
468
469     ////////////////////////////////////////////////////////////////
470     //
471     // Links
472     //
473     ////////////////////////////////////////////////////////////////
474
475     var $_autosplitWikiWords = false;
476
477     function setAutosplitWikiWords($autosplit=false) {
478         $this->_autosplitWikiWords = $autosplit ? true : false;
479     }
480
481     function maybeSplitWikiWord ($wikiword) {
482         if ($this->_autosplitWikiWords)
483             return SplitPagename($wikiword);
484         else
485             return $wikiword;
486     }
487
488     var $_anonEditUnknownLinks = true;
489     function setAnonEditUnknownLinks($anonedit=true) {
490         $this->_anonEditUnknownLinks = $anonedit ? true : false;
491     }
492
493     function linkExistingWikiWord($wikiword, $linktext = '', $version = false) {
494         global $request;
495
496         if ($version !== false)
497             $url = WikiURL($wikiword, array('version' => $version));
498         else
499             $url = WikiURL($wikiword);
500
501         // Extra steps for dumping page to an html file.
502         // FIXME: shouldn't this be in WikiURL?
503         if ($this->HTML_DUMP_SUFFIX) {
504             // no action or sortby links
505             $url = preg_replace("/\?.*$/","",$url);
506             // urlencode for pagenames with accented letters
507             $url = rawurlencode($url);
508             $url = preg_replace('/^\./', '%2e', $url);
509             // fix url#anchor links (looks awful)
510             if (strstr($url,'%23'))
511                 $url = preg_replace("/%23/",$this->HTML_DUMP_SUFFIX."#",$url);
512             else
513                 $url .= $this->HTML_DUMP_SUFFIX;
514         }
515
516         $link = HTML::a(array('href' => $url));
517
518         if (isa($wikiword, 'WikiPageName'))
519             $default_text = $wikiword->shortName;
520         else
521             $default_text = $wikiword;
522         
523         if (!empty($linktext)) {
524             $link->pushContent($linktext);
525             $link->setAttr('class', 'named-wiki');
526             $link->setAttr('title', $this->maybeSplitWikiWord($default_text));
527         }
528         else {
529             $link->pushContent($this->maybeSplitWikiWord($default_text));
530             $link->setAttr('class', 'wiki');
531         }
532         if ($request->getArg('frame'))
533             $link->setAttr('target', '_top');
534         return $link;
535     }
536
537     function linkUnknownWikiWord($wikiword, $linktext = '') {
538         global $request;
539
540         // Get rid of anchors on unknown wikiwords
541         if (isa($wikiword, 'WikiPageName')) {
542             $default_text = $wikiword->shortName;
543             $wikiword = $wikiword->name;
544         }
545         else {
546             $default_text = $wikiword;
547         }
548         
549         if ($this->DUMP_MODE) { // HTML, PDF or XML
550             $link = HTML::u( empty($linktext) ? $wikiword : $linktext);
551             $link->addTooltip(sprintf(_("Empty link to: %s"), $wikiword));
552             $link->setAttr('class', empty($linktext) ? 'wikiunknown' : 'named-wikiunknown');
553             return $link;
554         } else {
555             // if AnonEditUnknownLinks show "?" only users which are allowed to edit this page
556             if (! $this->_anonEditUnknownLinks and ! mayAccessPage('edit', $request->getArg('pagename'))) {
557                 $text = HTML::span( empty($linktext) ? $wikiword : $linktext);
558                 $text->setAttr('class', empty($linktext) ? 'wikiunknown' : 'named-wikiunknown');
559                 return $text;
560             } else {
561                 $url = WikiURL($wikiword, array('action' => 'create'));
562                 $button = $this->makeButton('?', $url);
563                 $button->addTooltip(sprintf(_("Create: %s"), $wikiword));
564             }
565         }
566
567         $link = HTML::span();
568         if (!empty($linktext)) {
569             $link->pushContent(HTML::u($linktext));
570             $link->setAttr('class', 'named-wikiunknown');
571         }
572         else {
573             $link->pushContent(HTML::u($this->maybeSplitWikiWord($default_text)));
574             $link->setAttr('class', 'wikiunknown');
575         }
576         $link->pushContent($button);
577         if ($request->getPref('googleLink')) {
578             $gbutton = $this->makeButton('G', "http://www.google.com/search?q=$wikiword");
579             $gbutton->addTooltip(sprintf(_("Google:%s"), $wikiword));
580             $link->pushContent($gbutton);
581         }
582         if ($request->getArg('frame'))
583             $link->setAttr('target', '_top');
584         return $link;
585     }
586
587     function linkBadWikiWord($wikiword, $linktext = '') {
588         global $ErrorManager;
589         
590         if ($linktext) {
591             $text = $linktext;
592         }
593         elseif (isa($wikiword, 'WikiPageName')) {
594             $text = $wikiword->shortName;
595         }
596         else {
597             $text = $wikiword;
598         }
599
600         if (isa($wikiword, 'WikiPageName'))
601             $message = $wikiword->getWarnings();
602         else
603             $message = sprintf(_("'%s': Bad page name"), $wikiword);
604         $ErrorManager->warning($message);
605         
606         return HTML::span(array('class' => 'badwikiword'), $text);
607     }
608     
609     ////////////////////////////////////////////////////////////////
610     //
611     // Images and Icons
612     //
613     ////////////////////////////////////////////////////////////////
614     var $_imageAliases = array();
615     var $_imageAlt = array();
616
617     /**
618      *
619      * (To disable an image, alias the image to <code>false</code>.
620      */
621     function addImageAlias ($alias, $image_name) {
622         // fall back to the PhpWiki-supplied image if not found
623         if ($this->_findFile("images/$image_name", true))
624             $this->_imageAliases[$alias] = $image_name;
625     }
626
627     function addImageAlt ($alias, $alt_text) {
628         $this->_imageAlt[$alias] = $alt_text;
629     }
630     function getImageAlt ($alias) {
631         return $this->_imageAlt[$alias];
632     }
633
634     function getImageURL ($image) {
635         $aliases = &$this->_imageAliases;
636
637         if (isset($aliases[$image])) {
638             $image = $aliases[$image];
639             if (!$image)
640                 return false;
641         }
642
643         // If not extension, default to .png.
644         if (!preg_match('/\.\w+$/', $image))
645             $image .= '.png';
646
647         // FIXME: this should probably be made to fall back
648         //        automatically to .gif, .jpg.
649         //        Also try .gif before .png if browser doesn't like png.
650
651         $path = $this->_findData("images/$image", 'missing okay');
652         if (!$path) // search explicit images/ or button/ links also
653             $path = $this->_findData("$image", 'missing okay');
654
655         if ($this->DUMP_MODE) {
656             if (empty($this->dumped_images)) $this->dumped_images = array();
657             $path = "images/". basename($path);
658             if (!in_array($path,$this->dumped_images)) $this->dumped_images[] = $path;
659         }
660         return $path;   
661     }
662
663     function setLinkIcon($proto, $image = false) {
664         if (!$image)
665             $image = $proto;
666
667         $this->_linkIcons[$proto] = $image;
668     }
669
670     function getLinkIconURL ($proto) {
671         $icons = &$this->_linkIcons;
672         if (!empty($icons[$proto]))
673             return $this->getImageURL($icons[$proto]);
674         elseif (!empty($icons['*']))
675             return $this->getImageURL($icons['*']);
676         return false;
677     }
678
679     function addButtonAlias ($text, $alias = false) {
680         $aliases = &$this->_buttonAliases;
681
682         if (is_array($text))
683             $aliases = array_merge($aliases, $text);
684         elseif ($alias === false)
685             unset($aliases[$text]);
686         else
687             $aliases[$text] = $alias;
688     }
689
690     function getButtonURL ($text) {
691         $aliases = &$this->_buttonAliases;
692         if (isset($aliases[$text]))
693             $text = $aliases[$text];
694
695         $qtext = urlencode($text);
696         $url = $this->_findButton("$qtext.png");
697         if ($url && strstr($url, '%')) {
698             $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url);
699         }
700         if (!$url) {// Jeff complained about png not supported everywhere. This is not PC
701             $url = $this->_findButton("$qtext.gif");
702             if ($url && strstr($url, '%')) {
703                 $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url);
704             }
705         }
706         return $url;
707     }
708
709     function _findButton ($button_file) {
710         if (empty($this->_button_path))
711             $this->_button_path = $this->_getButtonPath();
712
713         foreach ($this->_button_path as $dir) {
714             if ($path = $this->_findData("$dir/$button_file", 1))
715                 return $path; 
716         }
717         return false;
718     }
719
720     function _getButtonPath () {
721         $button_dir = $this->_findFile("buttons");
722         $path_dir = $this->_path . $button_dir;
723         if (!file_exists($path_dir) || !is_dir($path_dir))
724             return array();
725         $path = array($button_dir);
726         
727         $dir = dir($path_dir);
728         while (($subdir = $dir->read()) !== false) {
729             if ($subdir[0] == '.')
730                 continue;
731             if ($subdir == 'CVS')
732                 continue;
733             if (is_dir("$path_dir/$subdir"))
734                 $path[] = "$button_dir/$subdir";
735         }
736         $dir->close();
737         // add default buttons
738         $path[] = "themes/default/buttons";
739         $path_dir = $this->_path . "themes/default/buttons";
740         $dir = dir($path_dir);
741         while (($subdir = $dir->read()) !== false) {
742             if ($subdir[0] == '.')
743                 continue;
744             if ($subdir == 'CVS')
745                 continue;
746             if (is_dir("$path_dir/$subdir"))
747                 $path[] = "themes/default/buttons/$subdir";
748         }
749         $dir->close();
750
751         return $path;
752     }
753
754     ////////////////////////////////////////////////////////////////
755     //
756     // Button style
757     //
758     ////////////////////////////////////////////////////////////////
759
760     function makeButton ($text, $url, $class = false) {
761         // FIXME: don't always try for image button?
762
763         // Special case: URLs like 'submit:preview' generate form
764         // submission buttons.
765         if (preg_match('/^submit:(.*)$/', $url, $m))
766             return $this->makeSubmitButton($text, $m[1], $class);
767
768         $imgurl = $this->getButtonURL($text);
769         if ($imgurl)
770             return new ImageButton($text, $url, $class, $imgurl);
771         else
772             return new Button($this->maybeSplitWikiWord($text), $url, $class);
773     }
774
775     function makeSubmitButton ($text, $name, $class = false) {
776         $imgurl = $this->getButtonURL($text);
777
778         if ($imgurl)
779             return new SubmitImageButton($text, $name, $class, $imgurl);
780         else
781             return new SubmitButton($text, $name, $class);
782     }
783
784     /**
785      * Make button to perform action.
786      *
787      * This constructs a button which performs an action on the
788      * currently selected version of the current page.
789      * (Or anotherpage or version, if you want...)
790      *
791      * @param $action string The action to perform (e.g. 'edit', 'lock').
792      * This can also be the name of an "action page" like 'LikePages'.
793      * Alternatively you can give a hash of query args to be applied
794      * to the page.
795      *
796      * @param $label string Textual label for the button.  If left empty,
797      * a suitable name will be guessed.
798      *
799      * @param $page_or_rev mixed  The page to link to.  This can be
800      * given as a string (the page name), a WikiDB_Page object, or as
801      * WikiDB_PageRevision object.  If given as a WikiDB_PageRevision
802      * object, the button will link to a specific version of the
803      * designated page, otherwise the button links to the most recent
804      * version of the page.
805      *
806      * @return object A Button object.
807      */
808     function makeActionButton ($action, $label = false, $page_or_rev = false) {
809         extract($this->_get_name_and_rev($page_or_rev));
810
811         if (is_array($action)) {
812             $attr = $action;
813             $action = isset($attr['action']) ? $attr['action'] : 'browse';
814         }
815         else
816             $attr['action'] = $action;
817
818         $class = is_safe_action($action) ? 'wikiaction' : 'wikiadmin';
819         if (!$label)
820             $label = $this->_labelForAction($action);
821
822         if ($version)
823             $attr['version'] = $version;
824
825         if ($action == 'browse')
826             unset($attr['action']);
827
828         return $this->makeButton($label, WikiURL($pagename, $attr), $class);
829     }
830
831     /**
832      * Make a "button" which links to a wiki-page.
833      *
834      * These are really just regular WikiLinks, possibly
835      * disguised (e.g. behind an image button) by the theme.
836      *
837      * This method should probably only be used for links
838      * which appear in page navigation bars, or similar places.
839      *
840      * Use linkExistingWikiWord, or LinkWikiWord for normal links.
841      *
842      * @param $page_or_rev mixed The page to link to.  This can be
843      * given as a string (the page name), a WikiDB_Page object, or as
844      * WikiDB_PageRevision object.  If given as a WikiDB_PageRevision
845      * object, the button will link to a specific version of the
846      * designated page, otherwise the button links to the most recent
847      * version of the page.
848      *
849      * @return object A Button object.
850      */
851     function makeLinkButton ($page_or_rev, $label = false, $action = false) {
852         extract($this->_get_name_and_rev($page_or_rev));
853
854         $args = $version ? array('version' => $version) : false;
855         if ($action) $args['action'] = $action;
856
857         return $this->makeButton($label ? $label : $pagename, 
858                                  WikiURL($pagename, $args), 'wiki');
859     }
860
861     function _get_name_and_rev ($page_or_rev) {
862         $version = false;
863
864         if (empty($page_or_rev)) {
865             global $request;
866             $pagename = $request->getArg("pagename");
867             $version = $request->getArg("version");
868         }
869         elseif (is_object($page_or_rev)) {
870             if (isa($page_or_rev, 'WikiDB_PageRevision')) {
871                 $rev = $page_or_rev;
872                 $page = $rev->getPage();
873                 if (!$rev->isCurrent()) $version = $rev->getVersion();
874             }
875             else {
876                 $page = $page_or_rev;
877             }
878             $pagename = $page->getName();
879         }
880         else {
881             $pagename = (string) $page_or_rev;
882         }
883         return compact('pagename', 'version');
884     }
885
886     function _labelForAction ($action) {
887         switch ($action) {
888             case 'edit':   return _("Edit");
889             case 'diff':   return _("Diff");
890             case 'logout': return _("Sign Out");
891             case 'login':  return _("Sign In");
892             case 'lock':   return _("Lock Page");
893             case 'unlock': return _("Unlock Page");
894             case 'remove': return _("Remove Page");
895             default:
896                 // I don't think the rest of these actually get used.
897                 // 'setprefs'
898                 // 'upload' 'dumpserial' 'loadfile' 'zip'
899                 // 'save' 'browse'
900                 return gettext(ucfirst($action));
901         }
902     }
903
904     //----------------------------------------------------------------
905     var $_buttonSeparator = "\n | ";
906
907     function setButtonSeparator($separator) {
908         $this->_buttonSeparator = $separator;
909     }
910
911     function getButtonSeparator() {
912         return $this->_buttonSeparator;
913     }
914
915
916     ////////////////////////////////////////////////////////////////
917     //
918     // CSS
919     //
920     // Notes:
921     //
922     // Based on testing with Galeon 1.2.7 (Mozilla 1.2):
923     // Automatic media-based style selection (via <link> tags) only
924     // seems to work for the default style, not for alternate styles.
925     //
926     // Doing
927     //
928     //  <link rel="stylesheet" type="text/css" href="phpwiki.css" />
929     //  <link rel="stylesheet" type="text/css" href="phpwiki-printer.css" media="print" />
930     //
931     // works to make it so that the printer style sheet get used
932     // automatically when printing (or print-previewing) a page
933     // (but when only when the default style is selected.)
934     //
935     // Attempts like:
936     //
937     //  <link rel="alternate stylesheet" title="Modern"
938     //        type="text/css" href="phpwiki-modern.css" />
939     //  <link rel="alternate stylesheet" title="Modern"
940     //        type="text/css" href="phpwiki-printer.css" media="print" />
941     //
942     // Result in two "Modern" choices when trying to select alternate style.
943     // If one selects the first of those choices, one gets phpwiki-modern
944     // both when browsing and printing.  If one selects the second "Modern",
945     // one gets no CSS when browsing, and phpwiki-printer when printing.
946     //
947     // The Real Fix?
948     // =============
949     //
950     // We should probably move to doing the media based style
951     // switching in the CSS files themselves using, e.g.:
952     //
953     //  @import url(print.css) print;
954     //
955     ////////////////////////////////////////////////////////////////
956
957     function _CSSlink($title, $css_file, $media, $is_alt = false) {
958         // Don't set title on default style.  This makes it clear to
959         // the user which is the default (i.e. most supported) style.
960         if ($is_alt and isBrowserKonqueror())
961             return HTML();
962         $link = HTML::link(array('rel'     => $is_alt ? 'alternate stylesheet' : 'stylesheet',
963                                  'type'    => 'text/css',
964                                  'charset' => $GLOBALS['charset'],
965                                  'href'    => $this->_findData($css_file)));
966         if ($is_alt)
967             $link->setAttr('title', $title);
968
969         if ($media) 
970             $link->setAttr('media', $media);
971         if ($this->DUMP_MODE) {
972             if (empty($this->dumped_css)) $this->dumped_css = array();
973             if (!in_array($css_file,$this->dumped_css)) $this->dumped_css[] = $css_file;
974             $link->setAttr('href', basename($link->getAttr('href')));
975         }
976         
977         return $link;
978     }
979
980     /** Set default CSS source for this theme.
981      *
982      * To set styles to be used for different media, pass a
983      * hash for the second argument, e.g.
984      *
985      * $theme->setDefaultCSS('default', array('' => 'normal.css',
986      *                                        'print' => 'printer.css'));
987      *
988      * If you call this more than once, the last one called takes
989      * precedence as the default style.
990      *
991      * @param string $title Name of style (currently ignored, unless
992      * you call this more than once, in which case, some of the style
993      * will become alternate (rather than default) styles, and then their
994      * titles will be used.
995      *
996      * @param mixed $css_files Name of CSS file, or hash containing a mapping
997      * between media types and CSS file names.  Use a key of '' (the empty string)
998      * to set the default CSS for non-specified media.  (See above for an example.)
999      */
1000     function setDefaultCSS ($title, $css_files) {
1001         if (!is_array($css_files))
1002             $css_files = array('' => $css_files);
1003         // Add to the front of $this->_css
1004         unset($this->_css[$title]);
1005         $this->_css = array_merge(array($title => $css_files), $this->_css);
1006     }
1007
1008     /** Set alternate CSS source for this theme.
1009      *
1010      * @param string $title Name of style.
1011      * @param string $css_files Name of CSS file.
1012      */
1013     function addAlternateCSS ($title, $css_files) {
1014         if (!is_array($css_files))
1015             $css_files = array('' => $css_files);
1016         $this->_css[$title] = $css_files;
1017     }
1018
1019     /**
1020      * @return string HTML for CSS.
1021      */
1022     function getCSS () {
1023         $css = array();
1024         $is_alt = false;
1025         foreach ($this->_css as $title => $css_files) {
1026             ksort($css_files); // move $css_files[''] to front.
1027             foreach ($css_files as $media => $css_file) {
1028                 $css[] = $this->_CSSlink($title, $css_file, $media, $is_alt);
1029                 if ($is_alt) break;
1030                 
1031             }
1032             $is_alt = true;
1033         }
1034         return HTML($css);
1035     }
1036     
1037
1038     function findTemplate ($name) {
1039         return $this->_path . $this->_findFile("templates/$name.tmpl");
1040     }
1041
1042     var $_MoreHeaders = array();
1043     function addMoreHeaders ($element) {
1044         array_push($this->_MoreHeaders,$element);
1045     }
1046     function getMoreHeaders () {
1047         if (empty($this->_MoreHeaders))
1048             return '';
1049         $out = '';
1050         //$out = "<!-- More Headers -->\n";
1051         foreach ($this->_MoreHeaders as $h) {
1052             if (is_object($h))
1053                 $out .= printXML($h);
1054             else
1055                 $out .= "$h\n";
1056         }
1057         return $out;
1058     }
1059
1060     var $_MoreAttr = array();
1061     function addMoreAttr ($id,$element) {
1062         if (empty($this->_MoreAttr) or !is_array($this->_MoreAttr[$id]))
1063             $this->_MoreAttr[$id] = array($element);
1064         else
1065             array_push($this->_MoreAttr[$id],$element);
1066     }
1067     function getMoreAttr ($id) {
1068         if (empty($this->_MoreAttr[$id]))
1069             return '';
1070         $out = '';
1071         foreach ($this->_MoreAttr[$id] as $h) {
1072             if (is_object($h))
1073                 $out .= printXML($h);
1074             else
1075                 $out .= "$h";
1076         }
1077         return $out;
1078     }
1079
1080     /**
1081      * Custom UserPreferences:
1082      * A list of name => _UserPreference class pairs.
1083      * Rationale: Certain themes should be able to extend the predefined list 
1084      * of preferences. Display/editing is done in the theme specific userprefs.tmpl
1085      * but storage/sanification/update/... must be extended to the Get/SetPreferences methods.
1086      * These values are just ignored if another theme is used.
1087      */
1088     function customUserPreferences($array) {
1089         global $customUserPreferenceColumns; // FIXME: really a global?
1090         if (empty($customUserPreferenceColumns)) $customUserPreferenceColumns = array();
1091         //array('wikilens' => new _UserPreference_wikilens());
1092         foreach ($array as $field => $prefobj) {
1093             $customUserPreferenceColumns[$field] = $prefobj;
1094         }
1095     }
1096
1097     /** addPageListColumn(array('rating' => new _PageList_Column_rating('rating', _("Rate"))))
1098      *  Register custom PageList types for special themes, like 
1099      *  'rating' for wikilens
1100      */
1101     function addPageListColumn ($array) {
1102         global $customPageListColumns;
1103         if (empty($customPageListColumns)) $customPageListColumns = array();
1104         foreach ($array as $column => $obj) {
1105             $customPageListColumns[$column] = $obj;
1106         }
1107     }
1108
1109 };
1110
1111
1112 /**
1113  * A class representing a clickable "button".
1114  *
1115  * In it's simplest (default) form, a "button" is just a link associated
1116  * with some sort of wiki-action.
1117  */
1118 class Button extends HtmlElement {
1119     /** Constructor
1120      *
1121      * @param $text string The text for the button.
1122      * @param $url string The url (href) for the button.
1123      * @param $class string The CSS class for the button.
1124      */
1125     function Button ($text, $url, $class = false) {
1126         global $request;
1127         //php5 workaround
1128         if (check_php_version(5)) {
1129             $this->_init('a', array('href' => $url));
1130         } else {
1131             $this->HtmlElement('a', array('href' => $url));
1132         }
1133         if ($class)
1134             $this->setAttr('class', $class);
1135         if ($request->getArg('frame'))
1136             $this->setAttr('target', '_top');
1137         $this->pushContent($GLOBALS['Theme']->maybeSplitWikiWord($text));
1138     }
1139
1140 };
1141
1142
1143 /**
1144  * A clickable image button.
1145  */
1146 class ImageButton extends Button {
1147     /** Constructor
1148      *
1149      * @param $text string The text for the button.
1150      * @param $url string The url (href) for the button.
1151      * @param $class string The CSS class for the button.
1152      * @param $img_url string URL for button's image.
1153      * @param $img_attr array Additional attributes for the &lt;img&gt; tag.
1154      */
1155     function ImageButton ($text, $url, $class, $img_url, $img_attr = false) {
1156         $this->HtmlElement('a', array('href' => $url));
1157         if ($class)
1158             $this->setAttr('class', $class);
1159
1160         if (!is_array($img_attr))
1161             $img_attr = array();
1162         $img_attr['src'] = $img_url;
1163         $img_attr['alt'] = $text;
1164         $img_attr['class'] = 'wiki-button';
1165         $img_attr['border'] = 0;
1166         $this->pushContent(HTML::img($img_attr));
1167     }
1168 };
1169
1170 /**
1171  * A class representing a form <samp>submit</samp> button.
1172  */
1173 class SubmitButton extends HtmlElement {
1174     /** Constructor
1175      *
1176      * @param $text string The text for the button.
1177      * @param $name string The name of the form field.
1178      * @param $class string The CSS class for the button.
1179      */
1180     function SubmitButton ($text, $name = false, $class = false) {
1181         $this->HtmlElement('input', array('type' => 'submit',
1182                                           'value' => $text));
1183         if ($name)
1184             $this->setAttr('name', $name);
1185         if ($class)
1186             $this->setAttr('class', $class);
1187     }
1188
1189 };
1190
1191
1192 /**
1193  * A class representing an image form <samp>submit</samp> button.
1194  */
1195 class SubmitImageButton extends SubmitButton {
1196     /** Constructor
1197      *
1198      * @param $text string The text for the button.
1199      * @param $name string The name of the form field.
1200      * @param $class string The CSS class for the button.
1201      * @param $img_url string URL for button's image.
1202      * @param $img_attr array Additional attributes for the &lt;img&gt; tag.
1203      */
1204     function SubmitImageButton ($text, $name = false, $class = false, $img_url) {
1205         $this->HtmlElement('input', array('type'  => 'image',
1206                                           'src'   => $img_url,
1207                                           'value' => $text,
1208                                           'alt'   => $text));
1209         if ($name)
1210             $this->setAttr('name', $name);
1211         if ($class)
1212             $this->setAttr('class', $class);
1213     }
1214
1215 };
1216
1217 /** 
1218  * A sidebar box with title and body, narrow fixed-width.
1219  * To represent abbrevated content of plugins, links or forms,
1220  * like "Getting Started", "Search", "Sarch Pagename", 
1221  * "Login", "Menu", "Recent Changes", "Last comments", "Last Blogs"
1222  * "Calendar"
1223  * ... See http://tikiwiki.org/
1224  *
1225  * Usage:
1226  * sidebar.tmpl:
1227  *   $menu = SidebarBox("Menu",HTML::dl(HTML::dt(...))); $menu->format();
1228  *   $menu = PluginSidebarBox("RecentChanges",array('limit'=>10)); $menu->format();
1229  */
1230 class SidebarBox {
1231
1232     function SidebarBox($title, $body) {
1233         $this->title = $title;
1234         $this->body = $body;
1235     }
1236     function format() {
1237         return WikiPlugin::makeBox($this->title, $this->body);
1238     }
1239 }
1240
1241 /** 
1242  * A sidebar box for plugins.
1243  * Any plugin may provide a box($args=false, $request=false, $basepage=false)
1244  * method, with the help of WikiPlugin::makeBox()
1245  */
1246 class PluginSidebarBox extends SidebarBox {
1247
1248     var $_plugin, $_args = false, $_basepage = false;
1249
1250     function PluginSidebarBox($name, $args = false, $basepage = false) {
1251         $loader = new WikiPluginLoader();
1252         $plugin = $loader->getPlugin($name);
1253         if (!method_exists($plugin,'box')) {
1254             return $loader->error(sprintf(_("%s: has no box method"),
1255                                           get_class($plugin)));
1256         }
1257         $this->_plugin   =& $plugin;
1258         $this->_args     = $args ? $args : array();
1259         $this->_basepage = $basepage;
1260     }
1261
1262     function format($args = false) {
1263         return $this->_plugin->box($args ? array_merge($this->_args,$args) : $this->_args,
1264                                    $GLOBALS['request'], 
1265                                    $this->_basepage);
1266     }
1267 }
1268
1269 // Various boxes which are no plugins
1270 class RelatedLinksBox extends SidebarBox {
1271     function RelatedLinksBox($title = false, $body = '', $limit = 20) {
1272         global $request;
1273         $this->title = $title ? $title : _("Related Links");
1274         $this->body = HTML($body);
1275         $page = $request->getPage($request->getArg('pagename'));
1276         $revision = $page->getCurrentRevision();
1277         $page_content = $revision->getTransformedContent();
1278         //$cache = &$page->_wikidb->_cache;
1279         $counter = 0;
1280         $sp = HTML::Raw('&middot; ');
1281         foreach ($page_content->getWikiPageLinks() as $link) {
1282             if (!$request->_dbi->isWikiPage($link)) continue;
1283             $this->body->pushContent($sp, WikiLink($link), HTML::br());
1284             $counter++;
1285             if ($limit and $counter > $limit) continue;
1286         }
1287     }
1288 }
1289
1290 class RelatedExternalLinksBox extends SidebarBox {
1291     function RelatedExternalLinksBox($title = false, $body = '', $limit = 20) {
1292         global $request;
1293         $this->title = $title ? $title : _("External Links");
1294         $this->body = HTML($body);
1295         $page = $request->getPage($request->getArg('pagename'));
1296         $cache = &$page->_wikidb->_cache;
1297         $counter = 0;
1298         $sp = HTML::Raw('&middot; ');
1299         foreach ($cache->getWikiPageLinks() as $link) {
1300             if ($link) {
1301                 $this->body->pushContent($sp, WikiLink($link), HTML::br());
1302                 $counter++;
1303                 if ($limit and $counter > $limit) continue;
1304             }
1305         }
1306     }
1307 }
1308
1309 function listAvailableThemes() {
1310     $available_themes = array(); 
1311     $dir_root = 'themes';
1312     if (defined('PHPWIKI_DIR'))
1313         $dir_root = PHPWIKI_DIR . "/$dir_root";
1314     $dir = dir($dir_root);
1315     if ($dir) {
1316         while($entry = $dir->read()) {
1317             if (is_dir($dir_root.'/'.$entry)
1318                 && (substr($entry,0,1) != '.')
1319                 && $entry != 'CVS') {
1320                 array_push($available_themes, $entry);
1321             }
1322         }
1323         $dir->close();
1324     }
1325     return $available_themes;
1326 }
1327
1328 function listAvailableLanguages() {
1329     $available_languages = array('en');
1330     $dir_root = 'locale';
1331     if (defined('PHPWIKI_DIR'))
1332         $dir_root = PHPWIKI_DIR . "/$dir_root";
1333     if ($dir = dir($dir_root)) {
1334         while($entry = $dir->read()) {
1335             if (is_dir($dir_root."/".$entry)
1336                 && (substr($entry,0,1) != '.')
1337                 && $entry != 'po'
1338                 && $entry != 'CVS') 
1339             {
1340                 array_push($available_languages, $entry);
1341             }
1342         }
1343         $dir->close();
1344     }
1345     return $available_languages;
1346 }
1347
1348 // $Log: not supported by cvs2svn $
1349 // Revision 1.99  2004/06/01 15:27:59  rurban
1350 // AdminUser only ADMIN_USER not member of Administrators
1351 // some RateIt improvements by dfrankow
1352 // edit_toolbar buttons
1353 //
1354 // Revision 1.98  2004/05/27 17:49:05  rurban
1355 // renamed DB_Session to DbSession (in CVS also)
1356 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
1357 // remove leading slash in error message
1358 // added force_unlock parameter to File_Passwd (no return on stale locks)
1359 // fixed adodb session AffectedRows
1360 // added FileFinder helpers to unify local filenames and DATA_PATH names
1361 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
1362 //
1363 // Revision 1.97  2004/05/18 16:23:39  rurban
1364 // rename split_pagename to SplitPagename
1365 //
1366 // Revision 1.96  2004/05/13 13:48:34  rurban
1367 // doc update for the new 1.3.10 release
1368 //
1369 // Revision 1.94  2004/05/13 11:52:34  rurban
1370 // search also default buttons
1371 //
1372 // Revision 1.93  2004/05/12 10:49:55  rurban
1373 // require_once fix for those libs which are loaded before FileFinder and
1374 //   its automatic include_path fix, and where require_once doesn't grok
1375 //   dirname(__FILE__) != './lib'
1376 // upgrade fix with PearDB
1377 // navbar.tmpl: remove spaces for IE &nbsp; button alignment
1378 //
1379 // Revision 1.92  2004/05/03 21:57:47  rurban
1380 // locale updates: we previously lost some words because of wrong strings in
1381 //   PhotoAlbum, german rewording.
1382 // fixed $_SESSION registering (lost session vars, esp. prefs)
1383 // fixed ending slash in listAvailableLanguages/Themes
1384 //
1385 // Revision 1.91  2004/05/03 11:40:42  rurban
1386 // put listAvailableLanguages() and listAvailableThemes() from SystemInfo and
1387 // UserPreferences into Themes.php
1388 //
1389 // Revision 1.90  2004/05/02 19:12:14  rurban
1390 // fix sf.net bug #945154 Konqueror alt css
1391 //
1392 // Revision 1.89  2004/04/29 21:25:45  rurban
1393 // default theme navbar consistency: linkButtons instead of action buttons
1394 //   3rd makeLinkButtin arg for action support
1395 //
1396 // Revision 1.88  2004/04/19 18:27:45  rurban
1397 // Prevent from some PHP5 warnings (ref args, no :: object init)
1398 //   php5 runs now through, just one wrong XmlElement object init missing
1399 // Removed unneccesary UpgradeUser lines
1400 // Changed WikiLink to omit version if current (RecentChanges)
1401 //
1402 // Revision 1.87  2004/04/19 09:13:23  rurban
1403 // new pref: googleLink
1404 //
1405 // Revision 1.86  2004/04/18 01:11:51  rurban
1406 // more numeric pagename fixes.
1407 // fixed action=upload with merge conflict warnings.
1408 // charset changed from constant to global (dynamic utf-8 switching)
1409 //
1410 // Revision 1.85  2004/04/12 13:04:50  rurban
1411 // added auth_create: self-registering Db users
1412 // fixed IMAP auth
1413 // removed rating recommendations
1414 // ziplib reformatting
1415 //
1416 // Revision 1.84  2004/04/10 02:30:49  rurban
1417 // Fixed gettext problem with VIRTUAL_PATH scripts (Windows only probably)
1418 // Fixed "cannot setlocale..." (sf.net problem)
1419 //
1420 // Revision 1.83  2004/04/09 17:49:03  rurban
1421 // Added PhpWiki RssFeed to Sidebar
1422 // sidebar formatting
1423 // some browser dependant fixes (old-browser support)
1424 //
1425 // Revision 1.82  2004/04/06 20:00:10  rurban
1426 // Cleanup of special PageList column types
1427 // Added support of plugin and theme specific Pagelist Types
1428 // Added support for theme specific UserPreferences
1429 // Added session support for ip-based throttling
1430 //   sql table schema change: ALTER TABLE session ADD sess_ip CHAR(15);
1431 // Enhanced postgres schema
1432 // Added DB_Session_dba support
1433 //
1434 // Revision 1.81  2004/04/01 15:57:10  rurban
1435 // simplified Sidebar theme: table, not absolute css positioning
1436 // added the new box methods.
1437 // remaining problems: large left margin, how to override _autosplitWikiWords in Template only
1438 //
1439 // Revision 1.80  2004/03/30 02:14:03  rurban
1440 // fixed yet another Prefs bug
1441 // added generic PearDb_iter
1442 // $request->appendValidators no so strict as before
1443 // added some box plugin methods
1444 // PageList commalist for condensed output
1445 //
1446 // Revision 1.79  2004/03/24 19:39:02  rurban
1447 // php5 workaround code (plus some interim debugging code in XmlElement)
1448 //   php5 doesn't work yet with the current XmlElement class constructors,
1449 //   WikiUserNew does work better than php4.
1450 // rewrote WikiUserNew user upgrading to ease php5 update
1451 // fixed pref handling in WikiUserNew
1452 // added Email Notification
1453 // added simple Email verification
1454 // removed emailVerify userpref subclass: just a email property
1455 // changed pref binary storage layout: numarray => hash of non default values
1456 // print optimize message only if really done.
1457 // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string.
1458 //   prefs should be stored in db or homepage, besides the current session.
1459 //
1460 // Revision 1.78  2004/03/18 22:32:33  rurban
1461 // work to make it php5 compatible
1462 //
1463 // Revision 1.77  2004/03/08 19:30:01  rurban
1464 // fixed Theme->getButtonURL
1465 // AllUsers uses now WikiGroup (also DB User and DB Pref users)
1466 // PageList fix for empty pagenames
1467 //
1468 // Revision 1.76  2004/03/08 18:17:09  rurban
1469 // added more WikiGroup::getMembersOf methods, esp. for special groups
1470 // fixed $LDAP_SET_OPTIONS
1471 // fixed _AuthInfo group methods
1472 //
1473 // Revision 1.75  2004/03/01 09:34:37  rurban
1474 // fixed button path logic: now fallback to default also
1475 //
1476 // Revision 1.74  2004/02/28 21:14:08  rurban
1477 // generally more PHPDOC docs
1478 //   see http://xarch.tu-graz.ac.at/home/rurban/phpwiki/xref/
1479 // fxied WikiUserNew pref handling: empty theme not stored, save only
1480 //   changed prefs, sql prefs improved, fixed password update,
1481 //   removed REPLACE sql (dangerous)
1482 // moved gettext init after the locale was guessed
1483 // + some minor changes
1484 //
1485 // Revision 1.73  2004/02/26 03:22:05  rurban
1486 // also copy css and images with XHTML Dump
1487 //
1488 // Revision 1.72  2004/02/26 02:25:53  rurban
1489 // fix empty and #-anchored links in XHTML Dumps
1490 //
1491 // Revision 1.71  2004/02/15 21:34:37  rurban
1492 // PageList enhanced and improved.
1493 // fixed new WikiAdmin... plugins
1494 // editpage, Theme with exp. htmlarea framework
1495 //   (htmlarea yet committed, this is really questionable)
1496 // WikiUser... code with better session handling for prefs
1497 // enhanced UserPreferences (again)
1498 // RecentChanges for show_deleted: how should pages be deleted then?
1499 //
1500 // Revision 1.70  2004/01/26 09:17:48  rurban
1501 // * changed stored pref representation as before.
1502 //   the array of objects is 1) bigger and 2)
1503 //   less portable. If we would import packed pref
1504 //   objects and the object definition was changed, PHP would fail.
1505 //   This doesn't happen with an simple array of non-default values.
1506 // * use $prefs->retrieve and $prefs->store methods, where retrieve
1507 //   understands the interim format of array of objects also.
1508 // * simplified $prefs->get() and fixed $prefs->set()
1509 // * added $user->_userid and class '_WikiUser' portability functions
1510 // * fixed $user object ->_level upgrading, mostly using sessions.
1511 //   this fixes yesterdays problems with loosing authorization level.
1512 // * fixed WikiUserNew::checkPass to return the _level
1513 // * fixed WikiUserNew::isSignedIn
1514 // * added explodePageList to class PageList, support sortby arg
1515 // * fixed UserPreferences for WikiUserNew
1516 // * fixed WikiPlugin for empty defaults array
1517 // * UnfoldSubpages: added pagename arg, renamed pages arg,
1518 //   removed sort arg, support sortby arg
1519 //
1520 // Revision 1.69  2003/12/05 01:32:28  carstenklapp
1521 // New feature: Easier to run multiple wiks off of one set of code. Name
1522 // your logo and signature image files "YourWikiNameLogo.png" and
1523 // "YourWikiNameSignature.png" and put them all into
1524 // themes/default/images. YourWikiName should match what is defined as
1525 // WIKI_NAME in index.php. In case the image is not found, the default
1526 // shipped with PhpWiki will be used.
1527 //
1528 // Revision 1.68  2003/03/04 01:53:30  dairiki
1529 // Inconsequential decrufting.
1530 //
1531 // Revision 1.67  2003/02/26 03:40:22  dairiki
1532 // New action=create.  Essentially the same as action=edit, except that if the
1533 // page already exists, it falls back to action=browse.
1534 //
1535 // This is for use in the "question mark" links for unknown wiki words
1536 // to avoid problems and confusion when following links from stale pages.
1537 // (If the "unknown page" has been created in the interim, the user probably
1538 // wants to view the page before editing it.)
1539 //
1540 // Revision 1.66  2003/02/26 00:10:26  dairiki
1541 // More/better/different checks for bad page names.
1542 //
1543 // Revision 1.65  2003/02/24 22:41:57  dairiki
1544 // Fix stupid typo.
1545 //
1546 // Revision 1.64  2003/02/24 22:06:14  dairiki
1547 // Attempts to fix auto-selection of printer CSS when printing.
1548 // See new comments lib/Theme.php for more details.
1549 // Also see SF patch #669563.
1550 //
1551 // Revision 1.63  2003/02/23 03:37:05  dairiki
1552 // Stupid typo/bug fix.
1553 //
1554 // Revision 1.62  2003/02/21 04:14:52  dairiki
1555 // New WikiLink type 'if_known'.  This gives linkified name if page
1556 // exists, otherwise, just plain text.
1557 //
1558 // Revision 1.61  2003/02/18 21:52:05  dairiki
1559 // Fix so that one can still link to wiki pages with # in their names.
1560 // (This was made difficult by the introduction of named tags, since
1561 // '[Page #1]' is now a link to anchor '1' in page 'Page'.
1562 //
1563 // Now the ~ escape for page names should work: [Page ~#1].
1564 //
1565 // Revision 1.60  2003/02/15 01:59:47  dairiki
1566 // Theme::getCSS():  Add Default-Style HTTP(-eqiv) header in attempt
1567 // to fix default stylesheet selection on some browsers.
1568 // For details on the Default-Style header, see:
1569 //  http://home.dairiki.org/docs/html4/present/styles.html#h-14.3.2
1570 //
1571 // Revision 1.59  2003/01/04 22:30:16  carstenklapp
1572 // New: display a "Never edited." message instead of an invalid epoch date.
1573 //
1574
1575 // (c-file-style: "gnu")
1576 // Local Variables:
1577 // mode: php
1578 // tab-width: 8
1579 // c-basic-offset: 4
1580 // c-hanging-comment-ender-p: nil
1581 // indent-tabs-mode: nil
1582 // End:
1583 ?>