2 rcs_id('$Id: themeinfo.php,v 1.23 2005-02-04 13:25:07 rurban Exp $');
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.
11 require_once('lib/Theme.php');
12 require_once('lib/WikiPlugin.php');
14 class Theme_Sidebar extends Theme {
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();
24 if ($theme_name != 'default')
25 $this->_default_theme = new Theme;
26 $this->_css = array();
28 $this->calendarInit();
30 if (defined("ENABLE_LIVESEARCH") and ENABLE_LIVESEARCH) { // by bitflux.ch
31 $this->initLiveSearch();
35 function findTemplate ($name) {
36 // hack for navbar.tmpl to hide the buttonseparator
37 if ($name == "navbar") {
38 $this->setButtonSeparator(HTML::Raw("<br />\n · "));
40 if ($name == "actionbar" || $name == "signin") {
41 $this->setButtonSeparator(" ");
43 return parent::findTemplate($name);
46 function calendarLink($date = false) {
47 return $this->calendarBase() . SUBPAGE_SEPARATOR .
48 strftime("%Y-%m-%d", $date ? $date : time());
51 function calendarBase() {
52 static $UserCalPageTitle = false;
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;
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'];
72 $this->_findFile('jscalendar/calendar-phpwiki.css'), 'all'));
73 $this->addMoreHeaders("\n");
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");
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));
91 while ($page = $iter->next()) {
93 $existing[] = basename($page->_pagename);
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();
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;
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
115 function dateStatusHandler(date, y, m, d) {
116 if (dateExists(date, y, m, d)) return "existing";
123 $WikiTheme = new Theme_Sidebar('Sidebar');
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.
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');
136 * The logo image appears on every page and links to the HomePage.
138 //$WikiTheme->addImageAlias('logo', 'logo.png');
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.
147 // Comment this next line out to enable signature.
148 $WikiTheme->addImageAlias('signature', false);
153 $WikiTheme->setLinkIcon('http');
154 $WikiTheme->setLinkIcon('https');
155 $WikiTheme->setLinkIcon('ftp');
156 $WikiTheme->setLinkIcon('mailto');
157 $WikiTheme->setLinkIcon('interwiki');
158 $WikiTheme->setLinkIcon('*', 'url');
160 //$WikiTheme->setButtonSeparator(' | ');
163 * WikiWords can automatically be split by inserting spaces between
164 * the words. The default is to leave WordsSmashedTogetherLikeSo.
166 $WikiTheme->setAutosplitWikiWords(true);
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.
174 $WikiTheme->setAnonEditUnknownLinks(false);
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
184 //$WikiTheme->setDateFormat("%B %d, %Y");
187 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
188 // (c-file-style: "gnu")
193 // c-hanging-comment-ender-p: nil
194 // indent-tabs-mode: nil