]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/Sidebar/themeinfo.php
Reformat code
[SourceForge/phpwiki.git] / themes / Sidebar / themeinfo.php
1 <?php
2 // Avoid direct call to this file.
3 // PHPWIKI_VERSION is defined in lib/prepend.php
4 if (!defined('PHPWIKI_VERSION')) {
5     header("Location: /");
6     exit;
7 }
8
9 /*
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.
13  *
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.
17  *
18  * Changes to MonoBook:
19  *  folderArrow
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
23  */
24
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");
29
30 require_once 'lib/WikiTheme.php';
31 require_once 'lib/WikiPlugin.php';
32 require_once 'themes/MonoBook/themeinfo.php';
33
34 class WikiTheme_Sidebar extends WikiTheme_MonoBook
35 {
36
37     function WikiTheme_Sidebar($theme_name = 'Sidebar')
38     {
39         $this->WikiTheme($theme_name);
40         //$this->calendarInit(true);
41     }
42
43     /* Display up/down button with persistent state */
44     /* persistent state per block in cookie for 30 days */
45     function folderArrow($id, $init = 'Open')
46     {
47         global $request;
48         if ($cookie = $request->cookies->get("folder_" . $id)) {
49             $init = $cookie;
50         }
51         if ($init == 'Open' or $init == 'Closed')
52             $png = $this->_findData('images/folderArrow' . $init . '.png');
53         else
54             $png = $this->_findData('images/folderArrowOpen.png');
55         return HTML::img(array('id' => $id . '-img',
56             'src' => $png,
57             //'align' => 'right',
58             'onclick' => "showHideFolder('$id')",
59             'alt' => _("Click to hide/show"),
60             'title' => _("Click to hide/show")));
61     }
62
63     /* Callback when a new user creates or edits a page */
64     function CbNewUserEdit(&$request, $userid)
65     {
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));
71         $dbi->touch();
72     }
73
74     /** CbUpload (&$request, $pathname) => true or false
75      * Callback when a file is uploaded. virusscan, ...
76      * @param $request
77      * @param $pathname
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.
81      * Src:
82      *   if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name))
83      *      unlink($file_dir . $userfile_name);
84      */
85     function CbUpload(&$request, $pathname)
86     {
87         $cmdline = CLAMDSCAN_PATH . " --nosummary --move=" . CLAMDSCAN_VIRUS;
88         $report = `$cmdline "$pathname"`;
89         if (!$report) {
90             trigger_error("clamdscan failed", E_USER_WARNING);
91             return true;
92         }
93         if (!preg_match("/: OK$/", $report)) {
94             //preg_match("/: (.+)$/", $report, $m);
95             trigger_error("Upload failed. virus-scanner: $report", E_USER_WARNING);
96             return false;
97         } else {
98             return true;
99         }
100     }
101
102
103     function findTemplate($name)
104     {
105         // hack for navbar.tmpl to hide the buttonseparator
106         if ($name == "navbar") {
107             $this->setButtonSeparator(HTML::Raw("<br />\n&nbsp;&middot;&nbsp;"));
108         }
109         if ($name == "actionbar" || $name == "signin") {
110             $this->setButtonSeparator(" ");
111         }
112         return parent::findTemplate($name);
113     }
114
115     function load()
116     {
117
118         $this->initGlobals();
119
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.
123
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');
128
129         /**
130          * The logo image appears on every page and links to the HomePage.
131          */
132         //$this->addImageAlias('logo', 'logo.png');
133
134         /**
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.
139          */
140
141         // Comment this next line out to enable signature.
142         $this->addImageAlias('signature', false);
143
144         $this->addImageAlias('search', 'search.png');
145
146         /*
147          * Link icons.
148          */
149         $this->setLinkIcon('http');
150         $this->setLinkIcon('https');
151         $this->setLinkIcon('ftp');
152         $this->setLinkIcon('mailto');
153         $this->setLinkIcon('interwiki');
154         $this->setLinkIcon('*', 'url');
155
156         //$this->setButtonSeparator(' | ');
157
158         /**
159          * WikiWords can automatically be split by inserting spaces between
160          * the words. The default is to leave WordsSmashedTogetherLikeSo.
161          */
162         //$this->setAutosplitWikiWords(true);
163
164         /**
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.
169          */
170         $this->setAnonEditUnknownLinks(false);
171
172         /*
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
178          * user's time zone.
179          */
180         //$this->setDateFormat("%B %d, %Y");
181
182         /**
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
189          */
190         //$this->customUserPreference();
191
192         /**
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
199          */
200         //$this->addPageListColumn();
201
202     }
203 }
204
205 $WikiTheme = new WikiTheme_Sidebar('Sidebar');
206 if (ENABLE_RATEIT) {
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');
214     $plugin->head();
215 }
216
217 // Local Variables:
218 // mode: php
219 // tab-width: 8
220 // c-basic-offset: 4
221 // c-hanging-comment-ender-p: nil
222 // indent-tabs-mode: nil
223 // End: