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
37 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')
48 if ($cookie = $request->cookies->get("folder_" . $id)) {
51 if ($init == 'Open' or $init == 'Closed')
52 $png = $this->_findData('images/folderArrow' . $init . '.png');
54 $png = $this->_findData('images/folderArrowOpen.png');
55 return HTML::img(array('id' => $id . '-img',
58 'onclick' => "showHideFolder('$id')",
59 'alt' => _("Click to hide/show"),
60 'title' => _("Click to hide/show")));
63 /* Callback when a new user creates or edits a page */
64 function CbNewUserEdit(&$request, $userid)
66 $userid = strtoupper($userid);
67 $content = "{{Template/UserPage}}";
68 $dbi =& $request->_dbi;
69 $page = $dbi->getPage($userid);
70 $page->save($content, WIKIDB_FORCE_CREATE, array('author' => $userid));
74 /** CbUpload (&$request, $pathname) => true or false
75 * Callback when a file is uploaded. virusscan, ...
78 * @return bool true for success, false to abort gracefully.
79 * In case of false, the file is deleted by the caller, but the callback must
80 * inform the user why the file was deleted.
82 * if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name))
83 * unlink($file_dir . $userfile_name);
85 function CbUpload(&$request, $pathname)
87 $cmdline = CLAMDSCAN_PATH . " --nosummary --move=" . CLAMDSCAN_VIRUS;
88 $report = `$cmdline "$pathname"`;
90 trigger_error("clamdscan failed", E_USER_WARNING);
93 if (!preg_match("/: OK$/", $report)) {
94 //preg_match("/: (.+)$/", $report, $m);
95 trigger_error("Upload failed. virus-scanner: $report", E_USER_WARNING);
103 function findTemplate($name)
105 // hack for navbar.tmpl to hide the buttonseparator
106 if ($name == "navbar") {
107 $this->setButtonSeparator(HTML::Raw("<br />\n · "));
109 if ($name == "actionbar" || $name == "signin") {
110 $this->setButtonSeparator(" ");
112 return parent::findTemplate($name);
118 $this->initGlobals();
120 // CSS file defines fonts, colors and background images for this
121 // style. The companion '*-heavy.css' file isn't defined, it's just
122 // expected to be in the same directory that the base style is in.
124 $this->setDefaultCSS(_("Sidebar"), array('' => 'sidebar.css',
125 'print' => 'phpwiki-printer.css'));
126 $this->addAlternateCSS(_("Printer"), 'phpwiki-printer.css', 'print, screen');
127 $this->addAlternateCSS(_("Modern"), 'phpwiki-modern.css');
130 * The logo image appears on every page and links to the HomePage.
132 //$this->addImageAlias('logo', 'logo.png');
135 * The Signature image is shown after saving an edited page. If this
136 * is not set, any signature defined in index.php will be used. If it
137 * is not defined by index.php or in here then the "Thank you for
138 * editing..." screen will be omitted.
141 // Comment this next line out to enable signature.
142 $this->addImageAlias('signature', false);
144 $this->addImageAlias('search', 'search.png');
149 $this->setLinkIcon('http');
150 $this->setLinkIcon('https');
151 $this->setLinkIcon('ftp');
152 $this->setLinkIcon('mailto');
153 $this->setLinkIcon('interwiki');
154 $this->setLinkIcon('*', 'url');
156 //$this->setButtonSeparator(' | ');
159 * WikiWords can automatically be split by inserting spaces between
160 * the words. The default is to leave WordsSmashedTogetherLikeSo.
162 //$this->setAutosplitWikiWords(true);
165 * If true (default) show create '?' buttons on not existing pages, even if the
166 * user is not signed in.
167 * If false, anon users get no links and it looks cleaner, but then they
168 * cannot easily fix missing pages.
170 $this->setAnonEditUnknownLinks(false);
173 * You may adjust the formats used for formatting dates and times
174 * below. (These examples give the default formats.)
175 * Formats are given as format strings to PHP strftime() function See
176 * http://www.php.net/manual/en/function.strftime.php for details.
177 * Do not include the server's zone (%Z), times are converted to the
180 //$this->setDateFormat("%B %d, %Y");
183 * Custom UserPreferences:
184 * A list of name => _UserPreference class pairs.
185 * Rationale: Certain themes should be able to extend the predefined list
186 * of preferences. Display/editing is done in the theme specific userprefs.tmpl
187 * but storage/sanification/update/... must be extended to the Get/SetPreferences methods.
188 * See themes/wikilens/themeinfo.php
190 //$this->customUserPreference();
193 * Register custom PageList type and define custom PageList classes.
194 * Rationale: Certain themes should be able to extend the predefined list
195 * of pagelist types. E.g. certain plugins, like MostPopular might use
196 * info=pagename,hits,rating
197 * which displays the rating column whenever the wikilens theme is active.
198 * See themes/wikilens/themeinfo.php
200 //$this->addPageListColumn();
205 $WikiTheme = new WikiTheme_Sidebar('Sidebar');
207 require_once 'lib/wikilens/CustomPrefs.php';
208 require_once 'lib/wikilens/PageListColumns.php';
209 //require_once("lib/plugin/RateIt.php");
210 $plugin = new WikiPlugin_RateIt;
211 // add parent to current theme to find the RateIt images
212 // $WikiTheme->addParent('wikilens', 'noinit');
213 $WikiTheme->_parents[] = new WikiTheme('wikilens', 'noinit');
221 // c-hanging-comment-ender-p: nil
222 // indent-tabs-mode: nil