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