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