2 rcs_id('$Id: themeinfo.php,v 1.21 2005-02-03 05:11:40 rurban Exp $');
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..
9 require_once('lib/Theme.php');
10 require_once('lib/WikiPlugin.php');
12 class Theme_Sidebar extends Theme {
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();
22 if ($theme_name != 'default')
23 $this->_default_theme = new Theme;
24 $this->_css = array();
26 $this->calendarInit();
28 if (defined("ENABLE_LIVESEARCH") and ENABLE_LIVESEARCH) { // by bitflux.ch. not yet enabled
29 $this->initLiveSearch();
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 /> · '));
38 //$this->setButtonSeparator("\n");
39 //$WikiTheme->setButtonSeparator($old);
41 if ($name == "actionbar" || $name == "signin") {
42 //$old = $WikiTheme->getButtonSeparator();
43 //$this->setButtonSeparator(HTML::br());
44 $this->setButtonSeparator(" ");
45 //$WikiTheme->setButtonSeparator($old);
47 return parent::findTemplate($name);
50 function calendarLink($date = false) {
51 return $this->calendarBase() . SUBPAGE_SEPARATOR .
52 strftime("%Y-%m-%d", $date ? $date : time());
55 function calendarBase() {
56 static $UserCalPageTitle = false;
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;
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'];
76 $this->_findFile('jscalendar/calendar-phpwiki.css'), 'all'));
77 $this->addMoreHeaders("\n");
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");
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));
95 while ($page = $iter->next()) {
97 $existing[] = basename($page->_pagename);
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();
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;
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
119 function dateStatusHandler(date, y, m, d) {
120 if (dateExists(date, y, m, d)) return "existing";
127 $WikiTheme = new Theme_Sidebar('Sidebar');
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.
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');
140 * The logo image appears on every page and links to the HomePage.
142 //$WikiTheme->addImageAlias('logo', 'logo.png');
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.
151 // Comment this next line out to enable signature.
152 $WikiTheme->addImageAlias('signature', false);
157 $WikiTheme->setLinkIcon('http');
158 $WikiTheme->setLinkIcon('https');
159 $WikiTheme->setLinkIcon('ftp');
160 $WikiTheme->setLinkIcon('mailto');
161 $WikiTheme->setLinkIcon('interwiki');
162 $WikiTheme->setLinkIcon('*', 'url');
164 //$WikiTheme->setButtonSeparator(' | ');
167 * WikiWords can automatically be split by inserting spaces between
168 * the words. The default is to leave WordsSmashedTogetherLikeSo.
170 $WikiTheme->setAutosplitWikiWords(true);
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.
178 $WikiTheme->setAnonEditUnknownLinks(false);
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
188 //$WikiTheme->setDateFormat("%B %d, %Y");
191 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
192 // (c-file-style: "gnu")
197 // c-hanging-comment-ender-p: nil
198 // indent-tabs-mode: nil