2 // Avoid direct call to this file.
3 // PHPWIKI_VERSION is defined in lib/prepend.php
4 if (!defined('PHPWIKI_VERSION')) {
12 * This file defines the Sidebar theme of PhpWiki,
13 * which can be used as parent class for all sidebar themes. See MonoBook and blog.
14 * It is now an extension of the MonoBook theme.
16 * This uses the dynamic jscalendar, which doesn't need extra requests per month/year change.
17 * This is a complete rewrite and not related to the old Sidebar theme.
18 * It is derived from MonoBook, includes the calendar and can derive from wikilens.
20 * Changes to MonoBook:
22 * special login, search and tags
23 * CbNewUserEdit - when a new user creates or edits a page, a Userpage template is created
24 * CbUpload - uploads are virus checked
27 if (!defined("CLAMDSCAN_PATH"))
28 define("CLAMDSCAN_PATH","/usr/local/bin/clamdscan");
29 if (!defined("CLAMDSCAN_VIRUS"))
30 define("CLAMDSCAN_VIRUS","/var/www/virus-found");
32 require_once('lib/WikiTheme.php');
33 require_once('lib/WikiPlugin.php');
34 require_once('themes/MonoBook/themeinfo.php');
36 class WikiTheme_Sidebar extends WikiTheme_MonoBook {
38 function WikiTheme_Sidebar ($theme_name='Sidebar') {
39 $this->WikiTheme($theme_name);
40 //$this->calendarInit(true);
43 /* Display up/down button with persistent state */
44 /* persistent state per block in cookie for 30 days */
45 function folderArrow ($id, $init='Open') {
47 if ($cookie = $request->cookies->get("folder_".$id)) {
50 if ($init == 'Open' or $init == 'Closed')
51 $png = $this->_findData('images/folderArrow'.$init.'.png');
53 $png = $this->_findData('images/folderArrowOpen.png');
54 return HTML::img(array('id' => $id.'-img',
57 'onclick' => "showHideFolder('$id')",
58 'alt' => _("Click to hide/show"),
59 'title' => _("Click to hide/show")));
62 /* Callback when a new user creates or edits a page */
63 function CbNewUserEdit (&$request, $userid) {
64 $userid = strtoupper($userid);
65 $content = "{{Template/UserPage}}";
66 $dbi =& $request->_dbi;
67 $page = $dbi->getPage($userid);
68 $page->save($content, WIKIDB_FORCE_CREATE, array('author' => $userid));
72 /** CbUpload (&$request, $pathname) => true or false
73 * Callback when a file is uploaded. virusscan, ...
75 * @return bool true for success, false to abort gracefully.
76 * In case of false, the file is deleted by the caller, but the callback must
77 * inform the user why the file was deleted.
79 * if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name))
80 * unlink($file_dir . $userfile_name);
82 function CbUpload (&$request, $pathname) {
83 $cmdline = CLAMDSCAN_PATH . " --nosummary --move=" . CLAMDSCAN_VIRUS;
84 $report = `$cmdline "$pathname"`;
86 trigger_error("clamdscan failed", E_USER_WARNING);
89 if (!preg_match("/: OK$/", $report)) {
90 //preg_match("/: (.+)$/", $report, $m);
91 trigger_error("Upload failed. virus-scanner: $report", E_USER_WARNING);
99 function findTemplate ($name) {
100 // hack for navbar.tmpl to hide the buttonseparator
101 if ($name == "navbar") {
102 $this->setButtonSeparator(HTML::Raw("<br />\n · "));
104 if ($name == "actionbar" || $name == "signin") {
105 $this->setButtonSeparator(" ");
107 return parent::findTemplate($name);
111 // CSS file defines fonts, colors and background images for this
112 // style. The companion '*-heavy.css' file isn't defined, it's just
113 // expected to be in the same directory that the base style is in.
115 $this->setDefaultCSS(_("Sidebar"), 'sidebar.css');
116 //$this->addAlternateCSS('PhpWiki', 'phpwiki.css');
117 //$this->setDefaultCSS('PhpWiki', 'phpwiki.css');
118 $this->addAlternateCSS(_("Printer"), 'phpwiki-printer.css', 'print, screen');
119 $this->addAlternateCSS(_("Modern"), 'phpwiki-modern.css');
122 * The logo image appears on every page and links to the HomePage.
124 //$this->addImageAlias('logo', 'logo.png');
127 * The Signature image is shown after saving an edited page. If this
128 * is not set, any signature defined in index.php will be used. If it
129 * is not defined by index.php or in here then the "Thank you for
130 * editing..." screen will be omitted.
133 // Comment this next line out to enable signature.
134 $this->addImageAlias('signature', false);
136 $this->addImageAlias('search', 'search.png');
141 $this->setLinkIcon('http');
142 $this->setLinkIcon('https');
143 $this->setLinkIcon('ftp');
144 $this->setLinkIcon('mailto');
145 $this->setLinkIcon('interwiki');
146 $this->setLinkIcon('*', 'url');
148 //$this->setButtonSeparator(' | ');
151 * WikiWords can automatically be split by inserting spaces between
152 * the words. The default is to leave WordsSmashedTogetherLikeSo.
154 $this->setAutosplitWikiWords(true);
157 * If true (default) show create '?' buttons on not existing pages, even if the
158 * user is not signed in.
159 * If false, anon users get no links and it looks cleaner, but then they
160 * cannot easily fix missing pages.
162 $this->setAnonEditUnknownLinks(false);
165 * You may adjust the formats used for formatting dates and times
166 * below. (These examples give the default formats.)
167 * Formats are given as format strings to PHP strftime() function See
168 * http://www.php.net/manual/en/function.strftime.php for details.
169 * Do not include the server's zone (%Z), times are converted to the
172 //$this->setDateFormat("%B %d, %Y");
176 $WikiTheme = new WikiTheme_Sidebar('Sidebar');
178 require_once("lib/wikilens/CustomPrefs.php");
179 require_once("lib/wikilens/PageListColumns.php");
180 //require_once("lib/plugin/RateIt.php");
181 $plugin = new WikiPlugin_RateIt;
185 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
186 // (c-file-style: "gnu")
191 // c-hanging-comment-ender-p: nil
192 // indent-tabs-mode: nil