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