2 rcs_id('$Id: themeinfo.php,v 1.24 2005-08-06 13:26:25 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 parent::Theme($theme_name);
19 $this->calendarInit(true);
22 function findTemplate ($name) {
23 // hack for navbar.tmpl to hide the buttonseparator
24 if ($name == "navbar") {
25 $this->setButtonSeparator(HTML::Raw("<br />\n · "));
27 if ($name == "actionbar" || $name == "signin") {
28 $this->setButtonSeparator(" ");
30 return parent::findTemplate($name);
33 function calendarLink($date = false) {
34 return $this->calendarBase() . SUBPAGE_SEPARATOR .
35 strftime("%Y-%m-%d", $date ? $date : time());
38 function calendarBase() {
39 static $UserCalPageTitle = false;
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;
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'];
59 $this->_findFile('jscalendar/calendar-phpwiki.css'), 'all'));
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)));
69 $this->_findData('jscalendar/calendar-setup'.(DEBUG?'':'_stripped').'.js'))));
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"));
75 while ($page = $iter->next()) {
77 $existing[] = basename($page->_pagename);
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();
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;
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";
106 $this->addMoreHeaders(JavaScript('
107 function dateStatusFunc(date, y, m, d) { return false;}'));
113 $WikiTheme = new Theme_Sidebar('Sidebar');
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.
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');
126 * The logo image appears on every page and links to the HomePage.
128 //$WikiTheme->addImageAlias('logo', 'logo.png');
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.
137 // Comment this next line out to enable signature.
138 $WikiTheme->addImageAlias('signature', false);
143 $WikiTheme->setLinkIcon('http');
144 $WikiTheme->setLinkIcon('https');
145 $WikiTheme->setLinkIcon('ftp');
146 $WikiTheme->setLinkIcon('mailto');
147 $WikiTheme->setLinkIcon('interwiki');
148 $WikiTheme->setLinkIcon('*', 'url');
150 //$WikiTheme->setButtonSeparator(' | ');
153 * WikiWords can automatically be split by inserting spaces between
154 * the words. The default is to leave WordsSmashedTogetherLikeSo.
156 $WikiTheme->setAutosplitWikiWords(true);
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.
164 $WikiTheme->setAnonEditUnknownLinks(false);
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
174 //$WikiTheme->setDateFormat("%B %d, %Y");
177 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
178 // (c-file-style: "gnu")
183 // c-hanging-comment-ender-p: nil
184 // indent-tabs-mode: nil