]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/Theme.php
renamed global $Theme to $WikiTheme (gforge nameclash)
[SourceForge/phpwiki.git] / lib / Theme.php
1 <?php rcs_id('$Id: Theme.php,v 1.105 2004-06-14 11:31:36 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 $WikiTheme, $request;
58
59     if ($type == 'button') {
60         return $WikiTheme->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 $WikiTheme->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 ($WikiTheme->_autosplitWikiWords)
124                 $part = " " . $part;
125             if ($part)
126                 $link->pushContent($WikiTheme->linkExistingWikiWord($parent, $sep . $part));
127             $sep = $WikiTheme->_autosplitWikiWords ? ' ' . SUBPAGE_SEPARATOR : SUBPAGE_SEPARATOR;
128         }
129         if ($exists)
130             $link->pushContent($WikiTheme->linkExistingWikiWord($wikipage, $sep . $last_part, $version));
131         else
132             $link->pushContent($WikiTheme->linkUnknownWikiWord($wikipage, $sep . $last_part));
133         return $link;
134     }
135
136     if ($exists) {
137         return $WikiTheme->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 $WikiTheme->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 $WikiTheme;
182
183     if (!is_array($action) && preg_match('/submit:(.*)/A', $action, $m))
184         return $WikiTheme->makeSubmitButton($label, $m[1], $class = $page_or_rev);
185     else
186         return $WikiTheme->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             /*
433             if ( mayAccessPage('change',$page->getName()) )
434                 return fmt("Owner: %s", $this->makeActionButton(array('action'=>_("chown"),
435                                                                       's' => $page->getName()),
436                                                                 $owner, $page));
437             */
438             if ( $dbi->isWikiPage($owner) )
439                 return fmt("Owner: %s", WikiLink($owner));
440             else
441                 return fmt("Owner: %s", '"'.$owner.'"');
442         }
443     }
444
445     function getAuthorMessage ($revision, $only_authenticated = true) {
446         $dbi =& $GLOBALS['request']->_dbi;
447         $author = $revision->get('author_id');
448         if ( $author or $only_authenticated ) {
449             if (!$author) $author = $revision->get('author');
450             if (!$author) return '';
451             if ( $dbi->isWikiPage($author) )
452                 return fmt("by %s", WikiLink($author));
453             else
454                 return fmt("by %s", '"'.$author.'"');
455         }
456     }
457
458     ////////////////////////////////////////////////////////////////
459     //
460     // Hooks for other formatting
461     //
462     ////////////////////////////////////////////////////////////////
463
464     //FIXME: PHP 4.1 Warnings
465     //lib/Theme.php:84: Notice[8]: The call_user_method() function is deprecated,
466     //use the call_user_func variety with the array(&$obj, "method") syntax instead
467
468     function getFormatter ($type, $format) {
469         $method = strtolower("get${type}Formatter");
470         if (method_exists($this, $method))
471             return $this->{$method}($format);
472         return false;
473     }
474
475     ////////////////////////////////////////////////////////////////
476     //
477     // Links
478     //
479     ////////////////////////////////////////////////////////////////
480
481     var $_autosplitWikiWords = false;
482
483     function setAutosplitWikiWords($autosplit=false) {
484         $this->_autosplitWikiWords = $autosplit ? true : false;
485     }
486
487     function maybeSplitWikiWord ($wikiword) {
488         if ($this->_autosplitWikiWords)
489             return SplitPagename($wikiword);
490         else
491             return $wikiword;
492     }
493
494     var $_anonEditUnknownLinks = true;
495     function setAnonEditUnknownLinks($anonedit=true) {
496         $this->_anonEditUnknownLinks = $anonedit ? true : false;
497     }
498
499     function linkExistingWikiWord($wikiword, $linktext = '', $version = false) {
500         global $request;
501
502         if ($version !== false)
503             $url = WikiURL($wikiword, array('version' => $version));
504         else
505             $url = WikiURL($wikiword);
506
507         // Extra steps for dumping page to an html file.
508         // FIXME: shouldn't this be in WikiURL?
509         if ($this->HTML_DUMP_SUFFIX) {
510             // no action or sortby links
511             $url = preg_replace("/\?.*$/","",$url);
512             // urlencode for pagenames with accented letters
513             $url = rawurlencode($url);
514             $url = preg_replace('/^\./', '%2e', $url);
515             // fix url#anchor links (looks awful)
516             if (strstr($url,'%23'))
517                 $url = preg_replace("/%23/",$this->HTML_DUMP_SUFFIX."#",$url);
518             else
519                 $url .= $this->HTML_DUMP_SUFFIX;
520         }
521
522         $link = HTML::a(array('href' => $url));
523
524         if (isa($wikiword, 'WikiPageName'))
525             $default_text = $wikiword->shortName;
526         else
527             $default_text = $wikiword;
528         
529         if (!empty($linktext)) {
530             $link->pushContent($linktext);
531             $link->setAttr('class', 'named-wiki');
532             $link->setAttr('title', $this->maybeSplitWikiWord($default_text));
533         }
534         else {
535             $link->pushContent($this->maybeSplitWikiWord($default_text));
536             $link->setAttr('class', 'wiki');
537         }
538         if ($request->getArg('frame'))
539             $link->setAttr('target', '_top');
540         return $link;
541     }
542
543     function linkUnknownWikiWord($wikiword, $linktext = '') {
544         global $request;
545
546         // Get rid of anchors on unknown wikiwords
547         if (isa($wikiword, 'WikiPageName')) {
548             $default_text = $wikiword->shortName;
549             $wikiword = $wikiword->name;
550         }
551         else {
552             $default_text = $wikiword;
553         }
554         
555         if ($this->DUMP_MODE) { // HTML, PDF or XML
556             $link = HTML::u( empty($linktext) ? $wikiword : $linktext);
557             $link->addTooltip(sprintf(_("Empty link to: %s"), $wikiword));
558             $link->setAttr('class', empty($linktext) ? 'wikiunknown' : 'named-wikiunknown');
559             return $link;
560         } else {
561             // if AnonEditUnknownLinks show "?" only users which are allowed to edit this page
562             if (! $this->_anonEditUnknownLinks and ! mayAccessPage('edit', $request->getArg('pagename'))) {
563                 $text = HTML::span( empty($linktext) ? $wikiword : $linktext);
564                 $text->setAttr('class', empty($linktext) ? 'wikiunknown' : 'named-wikiunknown');
565                 return $text;
566             } else {
567                 $url = WikiURL($wikiword, array('action' => 'create'));
568                 $button = $this->makeButton('?', $url);
569                 $button->addTooltip(sprintf(_("Create: %s"), $wikiword));
570             }
571         }
572
573         $link = HTML::span();
574         if (!empty($linktext)) {
575             $link->pushContent(HTML::u($linktext));
576             $link->setAttr('class', 'named-wikiunknown');
577         }
578         else {
579             $link->pushContent(HTML::u($this->maybeSplitWikiWord($default_text)));
580             $link->setAttr('class', 'wikiunknown');
581         }
582         $link->pushContent($button);
583         if ($request->getPref('googleLink')) {
584             $gbutton = $this->makeButton('G', "http://www.google.com/search?q=$wikiword");
585             $gbutton->addTooltip(sprintf(_("Google:%s"), $wikiword));
586             $link->pushContent($gbutton);
587         }
588         if ($request->getArg('frame'))
589             $link->setAttr('target', '_top');
590         return $link;
591     }
592
593     function linkBadWikiWord($wikiword, $linktext = '') {
594         global $ErrorManager;
595         
596         if ($linktext) {
597             $text = $linktext;
598         }
599         elseif (isa($wikiword, 'WikiPageName')) {
600             $text = $wikiword->shortName;
601         }
602         else {
603             $text = $wikiword;
604         }
605
606         if (isa($wikiword, 'WikiPageName'))
607             $message = $wikiword->getWarnings();
608         else
609             $message = sprintf(_("'%s': Bad page name"), $wikiword);
610         $ErrorManager->warning($message);
611         
612         return HTML::span(array('class' => 'badwikiword'), $text);
613     }
614     
615     ////////////////////////////////////////////////////////////////
616     //
617     // Images and Icons
618     //
619     ////////////////////////////////////////////////////////////////
620     var $_imageAliases = array();
621     var $_imageAlt = array();
622
623     /**
624      *
625      * (To disable an image, alias the image to <code>false</code>.
626      */
627     function addImageAlias ($alias, $image_name) {
628         // fall back to the PhpWiki-supplied image if not found
629         if ($this->_findFile("images/$image_name", true))
630             $this->_imageAliases[$alias] = $image_name;
631     }
632
633     function addImageAlt ($alias, $alt_text) {
634         $this->_imageAlt[$alias] = $alt_text;
635     }
636     function getImageAlt ($alias) {
637         return $this->_imageAlt[$alias];
638     }
639
640     function getImageURL ($image) {
641         $aliases = &$this->_imageAliases;
642
643         if (isset($aliases[$image])) {
644             $image = $aliases[$image];
645             if (!$image)
646                 return false;
647         }
648
649         // If not extension, default to .png.
650         if (!preg_match('/\.\w+$/', $image))
651             $image .= '.png';
652
653         // FIXME: this should probably be made to fall back
654         //        automatically to .gif, .jpg.
655         //        Also try .gif before .png if browser doesn't like png.
656
657         $path = $this->_findData("images/$image", 'missing okay');
658         if (!$path) // search explicit images/ or button/ links also
659             $path = $this->_findData("$image", 'missing okay');
660
661         if ($this->DUMP_MODE) {
662             if (empty($this->dumped_images)) $this->dumped_images = array();
663             $path = "images/". basename($path);
664             if (!in_array($path,$this->dumped_images)) $this->dumped_images[] = $path;
665         }
666         return $path;   
667     }
668
669     function setLinkIcon($proto, $image = false) {
670         if (!$image)
671             $image = $proto;
672
673         $this->_linkIcons[$proto] = $image;
674     }
675
676     function getLinkIconURL ($proto) {
677         $icons = &$this->_linkIcons;
678         if (!empty($icons[$proto]))
679             return $this->getImageURL($icons[$proto]);
680         elseif (!empty($icons['*']))
681             return $this->getImageURL($icons['*']);
682         return false;
683     }
684
685     var $_linkIcon = 'front'; // or 'after' or 'no'. 
686     // maybe also 'spanall': there is a scheme currently in effect with front, which 
687     // spans the icon only to the first, to let the next words wrap on line breaks
688     // see stdlib.php:PossiblyGlueIconToText()
689     function getLinkIconAttr () {
690         return $this->_linkIcon;
691     }
692     function setLinkIconAttr ($where) {
693         $this->_linkIcon = $where;
694     }
695
696     function addButtonAlias ($text, $alias = false) {
697         $aliases = &$this->_buttonAliases;
698
699         if (is_array($text))
700             $aliases = array_merge($aliases, $text);
701         elseif ($alias === false)
702             unset($aliases[$text]);
703         else
704             $aliases[$text] = $alias;
705     }
706
707     function getButtonURL ($text) {
708         $aliases = &$this->_buttonAliases;
709         if (isset($aliases[$text]))
710             $text = $aliases[$text];
711
712         $qtext = urlencode($text);
713         $url = $this->_findButton("$qtext.png");
714         if ($url && strstr($url, '%')) {
715             $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url);
716         }
717         if (!$url) {// Jeff complained about png not supported everywhere. This is not PC
718             $url = $this->_findButton("$qtext.gif");
719             if ($url && strstr($url, '%')) {
720                 $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url);
721             }
722         }
723         return $url;
724     }
725
726     function _findButton ($button_file) {
727         if (empty($this->_button_path))
728             $this->_button_path = $this->_getButtonPath();
729
730         foreach ($this->_button_path as $dir) {
731             if ($path = $this->_findData("$dir/$button_file", 1))
732                 return $path; 
733         }
734         return false;
735     }
736
737     function _getButtonPath () {
738         $button_dir = $this->_findFile("buttons");
739         $path_dir = $this->_path . $button_dir;
740         if (!file_exists($path_dir) || !is_dir($path_dir))
741             return array();
742         $path = array($button_dir);
743         
744         $dir = dir($path_dir);
745         while (($subdir = $dir->read()) !== false) {
746             if ($subdir[0] == '.')
747                 continue;
748             if ($subdir == 'CVS')
749                 continue;
750             if (is_dir("$path_dir/$subdir"))
751                 $path[] = "$button_dir/$subdir";
752         }
753         $dir->close();
754         // add default buttons
755         $path[] = "themes/default/buttons";
756         $path_dir = $this->_path . "themes/default/buttons";
757         $dir = dir($path_dir);
758         while (($subdir = $dir->read()) !== false) {
759             if ($subdir[0] == '.')
760                 continue;
761             if ($subdir == 'CVS')
762                 continue;
763             if (is_dir("$path_dir/$subdir"))
764                 $path[] = "themes/default/buttons/$subdir";
765         }
766         $dir->close();
767
768         return $path;
769     }
770
771     ////////////////////////////////////////////////////////////////
772     //
773     // Button style
774     //
775     ////////////////////////////////////////////////////////////////
776
777     function makeButton ($text, $url, $class = false) {
778         // FIXME: don't always try for image button?
779
780         // Special case: URLs like 'submit:preview' generate form
781         // submission buttons.
782         if (preg_match('/^submit:(.*)$/', $url, $m))
783             return $this->makeSubmitButton($text, $m[1], $class);
784
785         $imgurl = $this->getButtonURL($text);
786         if ($imgurl)
787             return new ImageButton($text, $url, $class, $imgurl);
788         else
789             return new Button($this->maybeSplitWikiWord($text), $url, $class);
790     }
791
792     function makeSubmitButton ($text, $name, $class = false) {
793         $imgurl = $this->getButtonURL($text);
794
795         if ($imgurl)
796             return new SubmitImageButton($text, $name, $class, $imgurl);
797         else
798             return new SubmitButton($text, $name, $class);
799     }
800
801     /**
802      * Make button to perform action.
803      *
804      * This constructs a button which performs an action on the
805      * currently selected version of the current page.
806      * (Or anotherpage or version, if you want...)
807      *
808      * @param $action string The action to perform (e.g. 'edit', 'lock').
809      * This can also be the name of an "action page" like 'LikePages'.
810      * Alternatively you can give a hash of query args to be applied
811      * to the page.
812      *
813      * @param $label string Textual label for the button.  If left empty,
814      * a suitable name will be guessed.
815      *
816      * @param $page_or_rev mixed  The page to link to.  This can be
817      * given as a string (the page name), a WikiDB_Page object, or as
818      * WikiDB_PageRevision object.  If given as a WikiDB_PageRevision
819      * object, the button will link to a specific version of the
820      * designated page, otherwise the button links to the most recent
821      * version of the page.
822      *
823      * @return object A Button object.
824      */
825     function makeActionButton ($action, $label = false, $page_or_rev = false) {
826         extract($this->_get_name_and_rev($page_or_rev));
827
828         if (is_array($action)) {
829             $attr = $action;
830             $action = isset($attr['action']) ? $attr['action'] : 'browse';
831         }
832         else
833             $attr['action'] = $action;
834
835         $class = is_safe_action($action) ? 'wikiaction' : 'wikiadmin';
836         if (!$label)
837             $label = $this->_labelForAction($action);
838
839         if ($version)
840             $attr['version'] = $version;
841
842         if ($action == 'browse')
843             unset($attr['action']);
844
845         return $this->makeButton($label, WikiURL($pagename, $attr), $class);
846     }
847
848     /**
849      * Make a "button" which links to a wiki-page.
850      *
851      * These are really just regular WikiLinks, possibly
852      * disguised (e.g. behind an image button) by the theme.
853      *
854      * This method should probably only be used for links
855      * which appear in page navigation bars, or similar places.
856      *
857      * Use linkExistingWikiWord, or LinkWikiWord for normal links.
858      *
859      * @param $page_or_rev mixed The page to link to.  This can be
860      * given as a string (the page name), a WikiDB_Page object, or as
861      * WikiDB_PageRevision object.  If given as a WikiDB_PageRevision
862      * object, the button will link to a specific version of the
863      * designated page, otherwise the button links to the most recent
864      * version of the page.
865      *
866      * @return object A Button object.
867      */
868     function makeLinkButton ($page_or_rev, $label = false, $action = false) {
869         extract($this->_get_name_and_rev($page_or_rev));
870
871         $args = $version ? array('version' => $version) : false;
872         if ($action) $args['action'] = $action;
873
874         return $this->makeButton($label ? $label : $pagename, 
875                                  WikiURL($pagename, $args), 'wiki');
876     }
877
878     function _get_name_and_rev ($page_or_rev) {
879         $version = false;
880
881         if (empty($page_or_rev)) {
882             global $request;
883             $pagename = $request->getArg("pagename");
884             $version = $request->getArg("version");
885         }
886         elseif (is_object($page_or_rev)) {
887             if (isa($page_or_rev, 'WikiDB_PageRevision')) {
888                 $rev = $page_or_rev;
889                 $page = $rev->getPage();
890                 if (!$rev->isCurrent()) $version = $rev->getVersion();
891             }
892             else {
893                 $page = $page_or_rev;
894             }
895             $pagename = $page->getName();
896         }
897         else {
898             $pagename = (string) $page_or_rev;
899         }
900         return compact('pagename', 'version');
901     }
902
903     function _labelForAction ($action) {
904         switch ($action) {
905             case 'edit':   return _("Edit");
906             case 'diff':   return _("Diff");
907             case 'logout': return _("Sign Out");
908             case 'login':  return _("Sign In");
909             case 'lock':   return _("Lock Page");
910             case 'unlock': return _("Unlock Page");
911             case 'remove': return _("Remove Page");
912             default:
913                 // I don't think the rest of these actually get used.
914                 // 'setprefs'
915                 // 'upload' 'dumpserial' 'loadfile' 'zip'
916                 // 'save' 'browse'
917                 return gettext(ucfirst($action));
918         }
919     }
920
921     //----------------------------------------------------------------
922     var $_buttonSeparator = "\n | ";
923
924     function setButtonSeparator($separator) {
925         $this->_buttonSeparator = $separator;
926     }
927
928     function getButtonSeparator() {
929         return $this->_buttonSeparator;
930     }
931
932
933     ////////////////////////////////////////////////////////////////
934     //
935     // CSS
936     //
937     // Notes:
938     //
939     // Based on testing with Galeon 1.2.7 (Mozilla 1.2):
940     // Automatic media-based style selection (via <link> tags) only
941     // seems to work for the default style, not for alternate styles.
942     //
943     // Doing
944     //
945     //  <link rel="stylesheet" type="text/css" href="phpwiki.css" />
946     //  <link rel="stylesheet" type="text/css" href="phpwiki-printer.css" media="print" />
947     //
948     // works to make it so that the printer style sheet get used
949     // automatically when printing (or print-previewing) a page
950     // (but when only when the default style is selected.)
951     //
952     // Attempts like:
953     //
954     //  <link rel="alternate stylesheet" title="Modern"
955     //        type="text/css" href="phpwiki-modern.css" />
956     //  <link rel="alternate stylesheet" title="Modern"
957     //        type="text/css" href="phpwiki-printer.css" media="print" />
958     //
959     // Result in two "Modern" choices when trying to select alternate style.
960     // If one selects the first of those choices, one gets phpwiki-modern
961     // both when browsing and printing.  If one selects the second "Modern",
962     // one gets no CSS when browsing, and phpwiki-printer when printing.
963     //
964     // The Real Fix?
965     // =============
966     //
967     // We should probably move to doing the media based style
968     // switching in the CSS files themselves using, e.g.:
969     //
970     //  @import url(print.css) print;
971     //
972     ////////////////////////////////////////////////////////////////
973
974     function _CSSlink($title, $css_file, $media, $is_alt = false) {
975         // Don't set title on default style.  This makes it clear to
976         // the user which is the default (i.e. most supported) style.
977         if ($is_alt and isBrowserKonqueror())
978             return HTML();
979         $link = HTML::link(array('rel'     => $is_alt ? 'alternate stylesheet' : 'stylesheet',
980                                  'type'    => 'text/css',
981                                  'charset' => $GLOBALS['charset'],
982                                  'href'    => $this->_findData($css_file)));
983         if ($is_alt)
984             $link->setAttr('title', $title);
985
986         if ($media) 
987             $link->setAttr('media', $media);
988         if ($this->DUMP_MODE) {
989             if (empty($this->dumped_css)) $this->dumped_css = array();
990             if (!in_array($css_file,$this->dumped_css)) $this->dumped_css[] = $css_file;
991             $link->setAttr('href', basename($link->getAttr('href')));
992         }
993         
994         return $link;
995     }
996
997     /** Set default CSS source for this theme.
998      *
999      * To set styles to be used for different media, pass a
1000      * hash for the second argument, e.g.
1001      *
1002      * $theme->setDefaultCSS('default', array('' => 'normal.css',
1003      *                                        'print' => 'printer.css'));
1004      *
1005      * If you call this more than once, the last one called takes
1006      * precedence as the default style.
1007      *
1008      * @param string $title Name of style (currently ignored, unless
1009      * you call this more than once, in which case, some of the style
1010      * will become alternate (rather than default) styles, and then their
1011      * titles will be used.
1012      *
1013      * @param mixed $css_files Name of CSS file, or hash containing a mapping
1014      * between media types and CSS file names.  Use a key of '' (the empty string)
1015      * to set the default CSS for non-specified media.  (See above for an example.)
1016      */
1017     function setDefaultCSS ($title, $css_files) {
1018         if (!is_array($css_files))
1019             $css_files = array('' => $css_files);
1020         // Add to the front of $this->_css
1021         unset($this->_css[$title]);
1022         $this->_css = array_merge(array($title => $css_files), $this->_css);
1023     }
1024
1025     /** Set alternate CSS source for this theme.
1026      *
1027      * @param string $title Name of style.
1028      * @param string $css_files Name of CSS file.
1029      */
1030     function addAlternateCSS ($title, $css_files) {
1031         if (!is_array($css_files))
1032             $css_files = array('' => $css_files);
1033         $this->_css[$title] = $css_files;
1034     }
1035
1036     /**
1037      * @return string HTML for CSS.
1038      */
1039     function getCSS () {
1040         $css = array();
1041         $is_alt = false;
1042         foreach ($this->_css as $title => $css_files) {
1043             ksort($css_files); // move $css_files[''] to front.
1044             foreach ($css_files as $media => $css_file) {
1045                 $css[] = $this->_CSSlink($title, $css_file, $media, $is_alt);
1046                 if ($is_alt) break;
1047                 
1048             }
1049             $is_alt = true;
1050         }
1051         return HTML($css);
1052     }
1053     
1054
1055     function findTemplate ($name) {
1056         return $this->_path . $this->_findFile("templates/$name.tmpl");
1057     }
1058
1059     var $_MoreHeaders = array();
1060     function addMoreHeaders ($element) {
1061         array_push($this->_MoreHeaders,$element);
1062     }
1063     function getMoreHeaders () {
1064         if (empty($this->_MoreHeaders))
1065             return '';
1066         $out = '';
1067         //$out = "<!-- More Headers -->\n";
1068         foreach ($this->_MoreHeaders as $h) {
1069             if (is_object($h))
1070                 $out .= printXML($h);
1071             else
1072                 $out .= "$h\n";
1073         }
1074         return $out;
1075     }
1076
1077     var $_MoreAttr = array();
1078     function addMoreAttr ($id,$element) {
1079         if (empty($this->_MoreAttr) or !is_array($this->_MoreAttr[$id]))
1080             $this->_MoreAttr[$id] = array($element);
1081         else
1082             array_push($this->_MoreAttr[$id],$element);
1083     }
1084     function getMoreAttr ($id) {
1085         if (empty($this->_MoreAttr[$id]))
1086             return '';
1087         $out = '';
1088         foreach ($this->_MoreAttr[$id] as $h) {
1089             if (is_object($h))
1090                 $out .= printXML($h);
1091             else
1092                 $out .= "$h";
1093         }
1094         return $out;
1095     }
1096
1097     /**
1098      * Custom UserPreferences:
1099      * A list of name => _UserPreference class pairs.
1100      * Rationale: Certain themes should be able to extend the predefined list 
1101      * of preferences. Display/editing is done in the theme specific userprefs.tmpl
1102      * but storage/sanification/update/... must be extended to the Get/SetPreferences methods.
1103      * These values are just ignored if another theme is used.
1104      */
1105     function customUserPreferences($array) {
1106         global $customUserPreferenceColumns; // FIXME: really a global?
1107         if (empty($customUserPreferenceColumns)) $customUserPreferenceColumns = array();
1108         //array('wikilens' => new _UserPreference_wikilens());
1109         foreach ($array as $field => $prefobj) {
1110             $customUserPreferenceColumns[$field] = $prefobj;
1111         }
1112     }
1113
1114     /** addPageListColumn(array('rating' => new _PageList_Column_rating('rating', _("Rate"))))
1115      *  Register custom PageList types for special themes, like 
1116      *  'rating' for wikilens
1117      */
1118     function addPageListColumn ($array) {
1119         global $customPageListColumns;
1120         if (empty($customPageListColumns)) $customPageListColumns = array();
1121         foreach ($array as $column => $obj) {
1122             $customPageListColumns[$column] = $obj;
1123         }
1124     }
1125
1126 };
1127
1128
1129 /**
1130  * A class representing a clickable "button".
1131  *
1132  * In it's simplest (default) form, a "button" is just a link associated
1133  * with some sort of wiki-action.
1134  */
1135 class Button extends HtmlElement {
1136     /** Constructor
1137      *
1138      * @param $text string The text for the button.
1139      * @param $url string The url (href) for the button.
1140      * @param $class string The CSS class for the button.
1141      */
1142     function Button ($text, $url, $class = false) {
1143         global $request;
1144         //php5 workaround
1145         if (check_php_version(5)) {
1146             $this->_init('a', array('href' => $url));
1147         } else {
1148             $this->HtmlElement('a', array('href' => $url));
1149         }
1150         if ($class)
1151             $this->setAttr('class', $class);
1152         if ($request->getArg('frame'))
1153             $this->setAttr('target', '_top');
1154         $this->pushContent($GLOBALS['WikiTheme']->maybeSplitWikiWord($text));
1155     }
1156
1157 };
1158
1159
1160 /**
1161  * A clickable image button.
1162  */
1163 class ImageButton extends Button {
1164     /** Constructor
1165      *
1166      * @param $text string The text for the button.
1167      * @param $url string The url (href) for the button.
1168      * @param $class string The CSS class for the button.
1169      * @param $img_url string URL for button's image.
1170      * @param $img_attr array Additional attributes for the &lt;img&gt; tag.
1171      */
1172     function ImageButton ($text, $url, $class, $img_url, $img_attr = false) {
1173         $this->HtmlElement('a', array('href' => $url));
1174         if ($class)
1175             $this->setAttr('class', $class);
1176
1177         if (!is_array($img_attr))
1178             $img_attr = array();
1179         $img_attr['src'] = $img_url;
1180         $img_attr['alt'] = $text;
1181         $img_attr['class'] = 'wiki-button';
1182         $img_attr['border'] = 0;
1183         $this->pushContent(HTML::img($img_attr));
1184     }
1185 };
1186
1187 /**
1188  * A class representing a form <samp>submit</samp> button.
1189  */
1190 class SubmitButton extends HtmlElement {
1191     /** Constructor
1192      *
1193      * @param $text string The text for the button.
1194      * @param $name string The name of the form field.
1195      * @param $class string The CSS class for the button.
1196      */
1197     function SubmitButton ($text, $name = false, $class = false) {
1198         $this->HtmlElement('input', array('type' => 'submit',
1199                                           'value' => $text));
1200         if ($name)
1201             $this->setAttr('name', $name);
1202         if ($class)
1203             $this->setAttr('class', $class);
1204     }
1205
1206 };
1207
1208
1209 /**
1210  * A class representing an image form <samp>submit</samp> button.
1211  */
1212 class SubmitImageButton extends SubmitButton {
1213     /** Constructor
1214      *
1215      * @param $text string The text for the button.
1216      * @param $name string The name of the form field.
1217      * @param $class string The CSS class for the button.
1218      * @param $img_url string URL for button's image.
1219      * @param $img_attr array Additional attributes for the &lt;img&gt; tag.
1220      */
1221     function SubmitImageButton ($text, $name = false, $class = false, $img_url) {
1222         $this->HtmlElement('input', array('type'  => 'image',
1223                                           'src'   => $img_url,
1224                                           'value' => $text,
1225                                           'alt'   => $text));
1226         if ($name)
1227             $this->setAttr('name', $name);
1228         if ($class)
1229             $this->setAttr('class', $class);
1230     }
1231
1232 };
1233
1234 /** 
1235  * A sidebar box with title and body, narrow fixed-width.
1236  * To represent abbrevated content of plugins, links or forms,
1237  * like "Getting Started", "Search", "Sarch Pagename", 
1238  * "Login", "Menu", "Recent Changes", "Last comments", "Last Blogs"
1239  * "Calendar"
1240  * ... See http://tikiwiki.org/
1241  *
1242  * Usage:
1243  * sidebar.tmpl:
1244  *   $menu = SidebarBox("Menu",HTML::dl(HTML::dt(...))); $menu->format();
1245  *   $menu = PluginSidebarBox("RecentChanges",array('limit'=>10)); $menu->format();
1246  */
1247 class SidebarBox {
1248
1249     function SidebarBox($title, $body) {
1250         $this->title = $title;
1251         $this->body = $body;
1252     }
1253     function format() {
1254         return WikiPlugin::makeBox($this->title, $this->body);
1255     }
1256 }
1257
1258 /** 
1259  * A sidebar box for plugins.
1260  * Any plugin may provide a box($args=false, $request=false, $basepage=false)
1261  * method, with the help of WikiPlugin::makeBox()
1262  */
1263 class PluginSidebarBox extends SidebarBox {
1264
1265     var $_plugin, $_args = false, $_basepage = false;
1266
1267     function PluginSidebarBox($name, $args = false, $basepage = false) {
1268         $loader = new WikiPluginLoader();
1269         $plugin = $loader->getPlugin($name);
1270         if (!method_exists($plugin,'box')) {
1271             return $loader->error(sprintf(_("%s: has no box method"),
1272                                           get_class($plugin)));
1273         }
1274         $this->_plugin   =& $plugin;
1275         $this->_args     = $args ? $args : array();
1276         $this->_basepage = $basepage;
1277     }
1278
1279     function format($args = false) {
1280         return $this->_plugin->box($args ? array_merge($this->_args,$args) : $this->_args,
1281                                    $GLOBALS['request'], 
1282                                    $this->_basepage);
1283     }
1284 }
1285
1286 // Various boxes which are no plugins
1287 class RelatedLinksBox extends SidebarBox {
1288     function RelatedLinksBox($title = false, $body = '', $limit = 20) {
1289         global $request;
1290         $this->title = $title ? $title : _("Related Links");
1291         $this->body = HTML($body);
1292         $page = $request->getPage($request->getArg('pagename'));
1293         $revision = $page->getCurrentRevision();
1294         $page_content = $revision->getTransformedContent();
1295         //$cache = &$page->_wikidb->_cache;
1296         $counter = 0;
1297         $sp = HTML::Raw('&middot; ');
1298         foreach ($page_content->getWikiPageLinks() as $link) {
1299             if (!$request->_dbi->isWikiPage($link)) continue;
1300             $this->body->pushContent($sp, WikiLink($link), HTML::br());
1301             $counter++;
1302             if ($limit and $counter > $limit) continue;
1303         }
1304     }
1305 }
1306
1307 class RelatedExternalLinksBox extends SidebarBox {
1308     function RelatedExternalLinksBox($title = false, $body = '', $limit = 20) {
1309         global $request;
1310         $this->title = $title ? $title : _("External Links");
1311         $this->body = HTML($body);
1312         $page = $request->getPage($request->getArg('pagename'));
1313         $cache = &$page->_wikidb->_cache;
1314         $counter = 0;
1315         $sp = HTML::Raw('&middot; ');
1316         foreach ($cache->getWikiPageLinks() as $link) {
1317             if ($link) {
1318                 $this->body->pushContent($sp, WikiLink($link), HTML::br());
1319                 $counter++;
1320                 if ($limit and $counter > $limit) continue;
1321             }
1322         }
1323     }
1324 }
1325
1326 function listAvailableThemes() {
1327     $available_themes = array(); 
1328     $dir_root = 'themes';
1329     if (defined('PHPWIKI_DIR'))
1330         $dir_root = PHPWIKI_DIR . "/$dir_root";
1331     $dir = dir($dir_root);
1332     if ($dir) {
1333         while($entry = $dir->read()) {
1334             if (is_dir($dir_root.'/'.$entry)
1335                 && (substr($entry,0,1) != '.')
1336                 && $entry != 'CVS') {
1337                 array_push($available_themes, $entry);
1338             }
1339         }
1340         $dir->close();
1341     }
1342     return $available_themes;
1343 }
1344
1345 function listAvailableLanguages() {
1346     $available_languages = array('en');
1347     $dir_root = 'locale';
1348     if (defined('PHPWIKI_DIR'))
1349         $dir_root = PHPWIKI_DIR . "/$dir_root";
1350     if ($dir = dir($dir_root)) {
1351         while($entry = $dir->read()) {
1352             if (is_dir($dir_root."/".$entry)
1353                 && (substr($entry,0,1) != '.')
1354                 && $entry != 'po'
1355                 && $entry != 'CVS') 
1356             {
1357                 array_push($available_languages, $entry);
1358             }
1359         }
1360         $dir->close();
1361     }
1362     return $available_languages;
1363 }
1364
1365 // $Log: not supported by cvs2svn $
1366 // Revision 1.104  2004/06/11 09:07:30  rurban
1367 // support theme-specific LinkIconAttr: front or after or none
1368 //
1369 // Revision 1.103  2004/06/07 22:44:14  rurban
1370 // added simplified chown, setacl actions
1371 //
1372 // Revision 1.102  2004/06/07 18:59:28  rurban
1373 // added Chown link to Owner in statusbar
1374 //
1375 // Revision 1.101  2004/06/03 12:59:40  rurban
1376 // simplify translation
1377 // NS4 wrap=virtual only
1378 //
1379 // Revision 1.100  2004/06/03 10:18:19  rurban
1380 // fix FileUser locking issues, new config ENABLE_PAGEPERM
1381 //
1382 // Revision 1.99  2004/06/01 15:27:59  rurban
1383 // AdminUser only ADMIN_USER not member of Administrators
1384 // some RateIt improvements by dfrankow
1385 // edit_toolbar buttons
1386 //
1387 // Revision 1.98  2004/05/27 17:49:05  rurban
1388 // renamed DB_Session to DbSession (in CVS also)
1389 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
1390 // remove leading slash in error message
1391 // added force_unlock parameter to File_Passwd (no return on stale locks)
1392 // fixed adodb session AffectedRows
1393 // added FileFinder helpers to unify local filenames and DATA_PATH names
1394 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
1395 //
1396 // Revision 1.97  2004/05/18 16:23:39  rurban
1397 // rename split_pagename to SplitPagename
1398 //
1399 // Revision 1.96  2004/05/13 13:48:34  rurban
1400 // doc update for the new 1.3.10 release
1401 //
1402 // Revision 1.94  2004/05/13 11:52:34  rurban
1403 // search also default buttons
1404 //
1405 // Revision 1.93  2004/05/12 10:49:55  rurban
1406 // require_once fix for those libs which are loaded before FileFinder and
1407 //   its automatic include_path fix, and where require_once doesn't grok
1408 //   dirname(__FILE__) != './lib'
1409 // upgrade fix with PearDB
1410 // navbar.tmpl: remove spaces for IE &nbsp; button alignment
1411 //
1412 // Revision 1.92  2004/05/03 21:57:47  rurban
1413 // locale updates: we previously lost some words because of wrong strings in
1414 //   PhotoAlbum, german rewording.
1415 // fixed $_SESSION registering (lost session vars, esp. prefs)
1416 // fixed ending slash in listAvailableLanguages/Themes
1417 //
1418 // Revision 1.91  2004/05/03 11:40:42  rurban
1419 // put listAvailableLanguages() and listAvailableThemes() from SystemInfo and
1420 // UserPreferences into Themes.php
1421 //
1422 // Revision 1.90  2004/05/02 19:12:14  rurban
1423 // fix sf.net bug #945154 Konqueror alt css
1424 //
1425 // Revision 1.89  2004/04/29 21:25:45  rurban
1426 // default theme navbar consistency: linkButtons instead of action buttons
1427 //   3rd makeLinkButtin arg for action support
1428 //
1429 // Revision 1.88  2004/04/19 18:27:45  rurban
1430 // Prevent from some PHP5 warnings (ref args, no :: object init)
1431 //   php5 runs now through, just one wrong XmlElement object init missing
1432 // Removed unneccesary UpgradeUser lines
1433 // Changed WikiLink to omit version if current (RecentChanges)
1434 //
1435 // Revision 1.87  2004/04/19 09:13:23  rurban
1436 // new pref: googleLink
1437 //
1438 // Revision 1.86  2004/04/18 01:11:51  rurban
1439 // more numeric pagename fixes.
1440 // fixed action=upload with merge conflict warnings.
1441 // charset changed from constant to global (dynamic utf-8 switching)
1442 //
1443 // Revision 1.85  2004/04/12 13:04:50  rurban
1444 // added auth_create: self-registering Db users
1445 // fixed IMAP auth
1446 // removed rating recommendations
1447 // ziplib reformatting
1448 //
1449 // Revision 1.84  2004/04/10 02:30:49  rurban
1450 // Fixed gettext problem with VIRTUAL_PATH scripts (Windows only probably)
1451 // Fixed "cannot setlocale..." (sf.net problem)
1452 //
1453 // Revision 1.83  2004/04/09 17:49:03  rurban
1454 // Added PhpWiki RssFeed to Sidebar
1455 // sidebar formatting
1456 // some browser dependant fixes (old-browser support)
1457 //
1458 // Revision 1.82  2004/04/06 20:00:10  rurban
1459 // Cleanup of special PageList column types
1460 // Added support of plugin and theme specific Pagelist Types
1461 // Added support for theme specific UserPreferences
1462 // Added session support for ip-based throttling
1463 //   sql table schema change: ALTER TABLE session ADD sess_ip CHAR(15);
1464 // Enhanced postgres schema
1465 // Added DB_Session_dba support
1466 //
1467 // Revision 1.81  2004/04/01 15:57:10  rurban
1468 // simplified Sidebar theme: table, not absolute css positioning
1469 // added the new box methods.
1470 // remaining problems: large left margin, how to override _autosplitWikiWords in Template only
1471 //
1472 // Revision 1.80  2004/03/30 02:14:03  rurban
1473 // fixed yet another Prefs bug
1474 // added generic PearDb_iter
1475 // $request->appendValidators no so strict as before
1476 // added some box plugin methods
1477 // PageList commalist for condensed output
1478 //
1479 // Revision 1.79  2004/03/24 19:39:02  rurban
1480 // php5 workaround code (plus some interim debugging code in XmlElement)
1481 //   php5 doesn't work yet with the current XmlElement class constructors,
1482 //   WikiUserNew does work better than php4.
1483 // rewrote WikiUserNew user upgrading to ease php5 update
1484 // fixed pref handling in WikiUserNew
1485 // added Email Notification
1486 // added simple Email verification
1487 // removed emailVerify userpref subclass: just a email property
1488 // changed pref binary storage layout: numarray => hash of non default values
1489 // print optimize message only if really done.
1490 // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string.
1491 //   prefs should be stored in db or homepage, besides the current session.
1492 //
1493 // Revision 1.78  2004/03/18 22:32:33  rurban
1494 // work to make it php5 compatible
1495 //
1496 // Revision 1.77  2004/03/08 19:30:01  rurban
1497 // fixed Theme->getButtonURL
1498 // AllUsers uses now WikiGroup (also DB User and DB Pref users)
1499 // PageList fix for empty pagenames
1500 //
1501 // Revision 1.76  2004/03/08 18:17:09  rurban
1502 // added more WikiGroup::getMembersOf methods, esp. for special groups
1503 // fixed $LDAP_SET_OPTIONS
1504 // fixed _AuthInfo group methods
1505 //
1506 // Revision 1.75  2004/03/01 09:34:37  rurban
1507 // fixed button path logic: now fallback to default also
1508 //
1509 // Revision 1.74  2004/02/28 21:14:08  rurban
1510 // generally more PHPDOC docs
1511 //   see http://xarch.tu-graz.ac.at/home/rurban/phpwiki/xref/
1512 // fxied WikiUserNew pref handling: empty theme not stored, save only
1513 //   changed prefs, sql prefs improved, fixed password update,
1514 //   removed REPLACE sql (dangerous)
1515 // moved gettext init after the locale was guessed
1516 // + some minor changes
1517 //
1518 // Revision 1.73  2004/02/26 03:22:05  rurban
1519 // also copy css and images with XHTML Dump
1520 //
1521 // Revision 1.72  2004/02/26 02:25:53  rurban
1522 // fix empty and #-anchored links in XHTML Dumps
1523 //
1524 // Revision 1.71  2004/02/15 21:34:37  rurban
1525 // PageList enhanced and improved.
1526 // fixed new WikiAdmin... plugins
1527 // editpage, Theme with exp. htmlarea framework
1528 //   (htmlarea yet committed, this is really questionable)
1529 // WikiUser... code with better session handling for prefs
1530 // enhanced UserPreferences (again)
1531 // RecentChanges for show_deleted: how should pages be deleted then?
1532 //
1533 // Revision 1.70  2004/01/26 09:17:48  rurban
1534 // * changed stored pref representation as before.
1535 //   the array of objects is 1) bigger and 2)
1536 //   less portable. If we would import packed pref
1537 //   objects and the object definition was changed, PHP would fail.
1538 //   This doesn't happen with an simple array of non-default values.
1539 // * use $prefs->retrieve and $prefs->store methods, where retrieve
1540 //   understands the interim format of array of objects also.
1541 // * simplified $prefs->get() and fixed $prefs->set()
1542 // * added $user->_userid and class '_WikiUser' portability functions
1543 // * fixed $user object ->_level upgrading, mostly using sessions.
1544 //   this fixes yesterdays problems with loosing authorization level.
1545 // * fixed WikiUserNew::checkPass to return the _level
1546 // * fixed WikiUserNew::isSignedIn
1547 // * added explodePageList to class PageList, support sortby arg
1548 // * fixed UserPreferences for WikiUserNew
1549 // * fixed WikiPlugin for empty defaults array
1550 // * UnfoldSubpages: added pagename arg, renamed pages arg,
1551 //   removed sort arg, support sortby arg
1552 //
1553 // Revision 1.69  2003/12/05 01:32:28  carstenklapp
1554 // New feature: Easier to run multiple wiks off of one set of code. Name
1555 // your logo and signature image files "YourWikiNameLogo.png" and
1556 // "YourWikiNameSignature.png" and put them all into
1557 // themes/default/images. YourWikiName should match what is defined as
1558 // WIKI_NAME in index.php. In case the image is not found, the default
1559 // shipped with PhpWiki will be used.
1560 //
1561 // Revision 1.68  2003/03/04 01:53:30  dairiki
1562 // Inconsequential decrufting.
1563 //
1564 // Revision 1.67  2003/02/26 03:40:22  dairiki
1565 // New action=create.  Essentially the same as action=edit, except that if the
1566 // page already exists, it falls back to action=browse.
1567 //
1568 // This is for use in the "question mark" links for unknown wiki words
1569 // to avoid problems and confusion when following links from stale pages.
1570 // (If the "unknown page" has been created in the interim, the user probably
1571 // wants to view the page before editing it.)
1572 //
1573 // Revision 1.66  2003/02/26 00:10:26  dairiki
1574 // More/better/different checks for bad page names.
1575 //
1576 // Revision 1.65  2003/02/24 22:41:57  dairiki
1577 // Fix stupid typo.
1578 //
1579 // Revision 1.64  2003/02/24 22:06:14  dairiki
1580 // Attempts to fix auto-selection of printer CSS when printing.
1581 // See new comments lib/Theme.php for more details.
1582 // Also see SF patch #669563.
1583 //
1584 // Revision 1.63  2003/02/23 03:37:05  dairiki
1585 // Stupid typo/bug fix.
1586 //
1587 // Revision 1.62  2003/02/21 04:14:52  dairiki
1588 // New WikiLink type 'if_known'.  This gives linkified name if page
1589 // exists, otherwise, just plain text.
1590 //
1591 // Revision 1.61  2003/02/18 21:52:05  dairiki
1592 // Fix so that one can still link to wiki pages with # in their names.
1593 // (This was made difficult by the introduction of named tags, since
1594 // '[Page #1]' is now a link to anchor '1' in page 'Page'.
1595 //
1596 // Now the ~ escape for page names should work: [Page ~#1].
1597 //
1598 // Revision 1.60  2003/02/15 01:59:47  dairiki
1599 // Theme::getCSS():  Add Default-Style HTTP(-eqiv) header in attempt
1600 // to fix default stylesheet selection on some browsers.
1601 // For details on the Default-Style header, see:
1602 //  http://home.dairiki.org/docs/html4/present/styles.html#h-14.3.2
1603 //
1604 // Revision 1.59  2003/01/04 22:30:16  carstenklapp
1605 // New: display a "Never edited." message instead of an invalid epoch date.
1606 //
1607
1608 // (c-file-style: "gnu")
1609 // Local Variables:
1610 // mode: php
1611 // tab-width: 8
1612 // c-basic-offset: 4
1613 // c-hanging-comment-ender-p: nil
1614 // indent-tabs-mode: nil
1615 // End:
1616 ?>