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