]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/Sidebar/themeinfo.php
livesearch.js support, fix calendar init
[SourceForge/phpwiki.git] / themes / Sidebar / themeinfo.php
1 <?php
2 rcs_id('$Id: themeinfo.php,v 1.21 2005-02-03 05:11:40 rurban Exp $');
3
4 /*
5  * This file defines the Sidebar appearance ("theme") of PhpWiki.
6  * This use the dynamic jscalendar, which doesn't need extra requests per month/year change..
7  */
8
9 require_once('lib/Theme.php');
10 require_once('lib/WikiPlugin.php');
11
12 class Theme_Sidebar extends Theme {
13
14     function Theme_Sidebar ($theme_name='Sidebar') {
15         $this->_name = $theme_name;
16         $this->_themes_dir = NormalizeLocalFileName("themes");
17         $this->_path  = defined('PHPWIKI_DIR') ? NormalizeLocalFileName("") : "";
18         $this->_theme = "themes/$theme_name";
19         if (ENABLE_DOUBLECLICKEDIT) // by pixels
20             $this->initDoubleClickEdit();
21
22         if ($theme_name != 'default')
23             $this->_default_theme = new Theme;
24         $this->_css = array();
25
26         $this->calendarInit();
27
28         if (defined("ENABLE_LIVESEARCH") and ENABLE_LIVESEARCH) { // by bitflux.ch. not yet enabled
29             $this->initLiveSearch();
30         }
31     }
32
33     function findTemplate ($name) {
34         // hack for navbar.tmpl to hide the buttonseparator
35         if ($name == "navbar") {
36             //$old = $WikiTheme->getButtonSeparator();
37             $this->setButtonSeparator(HTML::Raw('<br /> &middot; '));
38             //$this->setButtonSeparator("\n");
39             //$WikiTheme->setButtonSeparator($old);
40         }
41         if ($name == "actionbar" || $name == "signin") {
42             //$old = $WikiTheme->getButtonSeparator();
43             //$this->setButtonSeparator(HTML::br());
44             $this->setButtonSeparator(" ");
45             //$WikiTheme->setButtonSeparator($old);
46         }
47         return parent::findTemplate($name);
48     }
49
50     function calendarLink($date = false) {
51         return $this->calendarBase() . SUBPAGE_SEPARATOR . 
52                strftime("%Y-%m-%d", $date ? $date : time());
53     }
54
55     function calendarBase() {
56         static $UserCalPageTitle = false;
57         global $request;
58
59         if (!$UserCalPageTitle) 
60             $UserCalPageTitle = $request->_user->getId() . 
61                                 SUBPAGE_SEPARATOR . _("Calendar");
62         if (!$UserCalPageTitle)
63             $UserCalPageTitle = (BLOG_EMPTY_DEFAULT_PREFIX ? '' 
64                                  : ($request->_user->getId() . SUBPAGE_SEPARATOR)) . "Blog";
65         return $UserCalPageTitle;
66     }
67
68     function calendarInit() {
69         $dbi = $GLOBALS['request']->getDbh();
70         // display flat calender dhtml under the clock
71         if ($dbi->isWikiPage($this->calendarBase())) {
72             $jslang = @$GLOBALS['LANG'];
73             $this->addMoreHeaders
74                 (
75                  $this->_CSSlink(0, 
76                                  $this->_findFile('jscalendar/calendar-phpwiki.css'), 'all'));
77             $this->addMoreHeaders("\n");
78             $this->addMoreHeaders
79                 (JavaScript('',
80                             array('src' => $this->_findData('jscalendar/calendar_stripped.js'))));
81             $this->addMoreHeaders("\n");
82             if (!($langfile = $this->_findData("jscalendar/lang/calendar-$jslang.js")))
83                 $langfile = $this->_findData("jscalendar/lang/calendar-en.js");
84             $this->addMoreHeaders(JavaScript('',array('src' => $langfile)));
85             $this->addMoreHeaders("\n");
86             $this->addMoreHeaders
87                 (JavaScript('',
88                             array('src' => 
89                                   $this->_findData('jscalendar/calendar-setup_stripped.js'))));
90             $this->addMoreHeaders("\n");
91             require_once("lib/TextSearchQuery.php");
92             // get existing date entries for the current user:
93             $iter = $dbi->titleSearch(new TextSearchQuery("^".$this->calendarBase().SUBPAGE_SEPARATOR, true));
94             $existing = array();
95             while ($page = $iter->next()) {
96                 if ($page->exists())
97                     $existing[] = basename($page->_pagename);
98             }
99             $js_exist = '{"'.join('":1,"',$existing).'":1}';
100             //var SPECIAL_DAYS = {"2004-05-11":1,"2004-05-12":1,"2004-06-01":1}
101             $this->addMoreHeaders(JavaScript('
102 // this table holds the existing calender entries for the current user
103 // calculated from the database
104 var SPECIAL_DAYS = '.$js_exist.';
105 // this function returns true if the date exists
106 function dateExists(date, y, m, d) {
107     var year = date.getFullYear();
108     m = m + 1;
109     m = m < 10 ? "0" + m : m;  // integer, 0..11
110     d = d < 10 ? "0" + d : d;  // integer, 1..31
111     var date = year+"-"+m+"-"+d;
112     var exists = SPECIAL_DAYS[date];
113     if (!exists) return false;
114     else return true;
115 }
116 // this is the actual date status handler.  Note that it receives the
117 // date object as well as separate values of year, month and date, for
118 // your confort.
119 function dateStatusHandler(date, y, m, d) {
120     if (dateExists(date, y, m, d)) return "existing";
121     else return false;
122 }'));
123         }
124     }
125 }
126
127 $WikiTheme = new Theme_Sidebar('Sidebar');
128
129 // CSS file defines fonts, colors and background images for this
130 // style.  The companion '*-heavy.css' file isn't defined, it's just
131 // expected to be in the same directory that the base style is in.
132
133 $WikiTheme->setDefaultCSS(_("Sidebar"), 'sidebar.css');
134 //$WikiTheme->addAlternateCSS('PhpWiki', 'phpwiki.css');
135 //$WikiTheme->setDefaultCSS('PhpWiki', 'phpwiki.css');
136 $WikiTheme->addAlternateCSS(_("Printer"), 'phpwiki-printer.css', 'print, screen');
137 $WikiTheme->addAlternateCSS(_("Modern"), 'phpwiki-modern.css');
138
139 /**
140  * The logo image appears on every page and links to the HomePage.
141  */
142 //$WikiTheme->addImageAlias('logo', 'logo.png');
143
144 /**
145  * The Signature image is shown after saving an edited page. If this
146  * is not set, any signature defined in index.php will be used. If it
147  * is not defined by index.php or in here then the "Thank you for
148  * editing..." screen will be omitted.
149  */
150
151 // Comment this next line out to enable signature.
152 $WikiTheme->addImageAlias('signature', false);
153
154 /*
155  * Link icons.
156  */
157 $WikiTheme->setLinkIcon('http');
158 $WikiTheme->setLinkIcon('https');
159 $WikiTheme->setLinkIcon('ftp');
160 $WikiTheme->setLinkIcon('mailto');
161 $WikiTheme->setLinkIcon('interwiki');
162 $WikiTheme->setLinkIcon('*', 'url');
163
164 //$WikiTheme->setButtonSeparator(' | ');
165
166 /**
167  * WikiWords can automatically be split by inserting spaces between
168  * the words. The default is to leave WordsSmashedTogetherLikeSo.
169  */
170 $WikiTheme->setAutosplitWikiWords(true);
171
172 /**
173  * If true (default) show create '?' buttons on not existing pages, even if the 
174  * user is not signed in.
175  * If false, anon users get no links and it looks cleaner, but then they 
176  * cannot easily fix missing pages.
177  */
178 $WikiTheme->setAnonEditUnknownLinks(false);
179
180 /*
181  * You may adjust the formats used for formatting dates and times
182  * below.  (These examples give the default formats.)
183  * Formats are given as format strings to PHP strftime() function See
184  * http://www.php.net/manual/en/function.strftime.php for details.
185  * Do not include the server's zone (%Z), times are converted to the
186  * user's time zone.
187  */
188 //$WikiTheme->setDateFormat("%B %d, %Y");
189
190
191 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
192 // (c-file-style: "gnu")
193 // Local Variables:
194 // mode: php
195 // tab-width: 8
196 // c-basic-offset: 4
197 // c-hanging-comment-ender-p: nil
198 // indent-tabs-mode: nil
199 // End:   
200 ?>