2 // Avoid direct call to this file.
3 // PHPWIKI_VERSION is defined in lib/prepend.php
4 if (!defined('PHPWIKI_VERSION')) {
10 * This file defines the Sidebar theme of PhpWiki,
11 * which can be used as parent class for all sidebar themes. See MonoBook and blog.
12 * It is now an extension of the MonoBook theme.
14 * This uses the dynamic jscalendar, which doesn't need extra requests per month/year change.
15 * This is a complete rewrite and not related to the old Sidebar theme.
16 * It is derived from MonoBook, includes the calendar and can derive from wikilens.
18 * Changes to MonoBook:
20 * special login, search and tags
21 * CbNewUserEdit - when a new user creates or edits a page, a Userpage template is created
22 * CbUpload - uploads are virus checked
25 if (!defined("CLAMDSCAN_PATH"))
26 define("CLAMDSCAN_PATH","/usr/local/bin/clamdscan");
27 if (!defined("CLAMDSCAN_VIRUS"))
28 define("CLAMDSCAN_VIRUS","/var/www/virus-found");
30 require_once 'lib/WikiTheme.php';
31 require_once 'lib/WikiPlugin.php';
32 require_once 'themes/MonoBook/themeinfo.php';
34 class WikiTheme_Sidebar extends WikiTheme_MonoBook {
36 function WikiTheme_Sidebar ($theme_name='Sidebar') {
37 $this->WikiTheme($theme_name);
38 //$this->calendarInit(true);
41 /* Display up/down button with persistent state */
42 /* persistent state per block in cookie for 30 days */
43 function folderArrow ($id, $init='Open') {
45 if ($cookie = $request->cookies->get("folder_".$id)) {
48 if ($init == 'Open' or $init == 'Closed')
49 $png = $this->_findData('images/folderArrow'.$init.'.png');
51 $png = $this->_findData('images/folderArrowOpen.png');
52 return HTML::img(array('id' => $id.'-img',
55 'onclick' => "showHideFolder('$id')",
56 'alt' => _("Click to hide/show"),
57 'title' => _("Click to hide/show")));
60 /* Callback when a new user creates or edits a page */
61 function CbNewUserEdit (&$request, $userid) {
62 $userid = strtoupper($userid);
63 $content = "{{Template/UserPage}}";
64 $dbi =& $request->_dbi;
65 $page = $dbi->getPage($userid);
66 $page->save($content, WIKIDB_FORCE_CREATE, array('author' => $userid));
70 /** CbUpload (&$request, $pathname) => true or false
71 * Callback when a file is uploaded. virusscan, ...
74 * @return bool true for success, false to abort gracefully.
75 * In case of false, the file is deleted by the caller, but the callback must
76 * inform the user why the file was deleted.
78 * if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name))
79 * unlink($file_dir . $userfile_name);
81 function CbUpload (&$request, $pathname) {
82 $cmdline = CLAMDSCAN_PATH . " --nosummary --move=" . CLAMDSCAN_VIRUS;
83 $report = `$cmdline "$pathname"`;
85 trigger_error("clamdscan failed", E_USER_WARNING);
88 if (!preg_match("/: OK$/", $report)) {
89 //preg_match("/: (.+)$/", $report, $m);
90 trigger_error("Upload failed. virus-scanner: $report", E_USER_WARNING);
98 function findTemplate ($name) {
99 // hack for navbar.tmpl to hide the buttonseparator
100 if ($name == "navbar") {
101 $this->setButtonSeparator(HTML::Raw("<br />\n · "));
103 if ($name == "actionbar" || $name == "signin") {
104 $this->setButtonSeparator(" ");
106 return parent::findTemplate($name);
111 $this->initGlobals();
113 // CSS file defines fonts, colors and background images for this
114 // style. The companion '*-heavy.css' file isn't defined, it's just
115 // expected to be in the same directory that the base style is in.
117 $this->setDefaultCSS(_("Sidebar"), array('' => 'sidebar.css',
118 'print' => 'phpwiki-printer.css'));
119 $this->addAlternateCSS(_("Printer"), 'phpwiki-printer.css', 'print, screen');
120 $this->addAlternateCSS(_("Modern"), 'phpwiki-modern.css');
123 * The logo image appears on every page and links to the HomePage.
125 //$this->addImageAlias('logo', 'logo.png');
128 * The Signature image is shown after saving an edited page. If this
129 * is not set, any signature defined in index.php will be used. If it
130 * is not defined by index.php or in here then the "Thank you for
131 * editing..." screen will be omitted.
134 // Comment this next line out to enable signature.
135 $this->addImageAlias('signature', false);
137 $this->addImageAlias('search', 'search.png');
142 $this->setLinkIcon('http');
143 $this->setLinkIcon('https');
144 $this->setLinkIcon('ftp');
145 $this->setLinkIcon('mailto');
146 $this->setLinkIcon('interwiki');
147 $this->setLinkIcon('*', 'url');
149 //$this->setButtonSeparator(' | ');
152 * WikiWords can automatically be split by inserting spaces between
153 * the words. The default is to leave WordsSmashedTogetherLikeSo.
155 //$this->setAutosplitWikiWords(true);
158 * If true (default) show create '?' buttons on not existing pages, even if the
159 * user is not signed in.
160 * If false, anon users get no links and it looks cleaner, but then they
161 * cannot easily fix missing pages.
163 $this->setAnonEditUnknownLinks(false);
166 * You may adjust the formats used for formatting dates and times
167 * below. (These examples give the default formats.)
168 * Formats are given as format strings to PHP strftime() function See
169 * http://www.php.net/manual/en/function.strftime.php for details.
170 * Do not include the server's zone (%Z), times are converted to the
173 //$this->setDateFormat("%B %d, %Y");
176 * Custom UserPreferences:
177 * A list of name => _UserPreference class pairs.
178 * Rationale: Certain themes should be able to extend the predefined list
179 * of preferences. Display/editing is done in the theme specific userprefs.tmpl
180 * but storage/sanification/update/... must be extended to the Get/SetPreferences methods.
181 * See themes/wikilens/themeinfo.php
183 //$this->customUserPreference();
186 * Register custom PageList type and define custom PageList classes.
187 * Rationale: Certain themes should be able to extend the predefined list
188 * of pagelist types. E.g. certain plugins, like MostPopular might use
189 * info=pagename,hits,rating
190 * which displays the rating column whenever the wikilens theme is active.
191 * See themes/wikilens/themeinfo.php
193 //$this->addPageListColumn();
198 $WikiTheme = new WikiTheme_Sidebar('Sidebar');
200 require_once 'lib/wikilens/CustomPrefs.php';
201 require_once 'lib/wikilens/PageListColumns.php';
202 //require_once("lib/plugin/RateIt.php");
203 $plugin = new WikiPlugin_RateIt;
204 // add parent to current theme to find the RateIt images
205 // $WikiTheme->addParent('wikilens', 'noinit');
206 $WikiTheme->_parents[] = new WikiTheme('wikilens', 'noinit');
214 // c-hanging-comment-ender-p: nil
215 // indent-tabs-mode: nil