]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/Sidebar/themeinfo.php
Remove CVS backend
[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 __construct($theme_name = 'Sidebar')
38     {
39         $this->WikiTheme($theme_name);
40     }
41
42     /* Display up/down button with persistent state */
43     /* persistent state per block in cookie for 30 days */
44     function folderArrow($id, $init = 'Open')
45     {
46         global $request;
47         if ($cookie = $request->cookies->get("folder_" . $id)) {
48             $init = $cookie;
49         }
50         if ($init == 'Open' or $init == 'Closed')
51             $png = $this->_findData('images/folderArrow' . $init . '.png');
52         else
53             $png = $this->_findData('images/folderArrowOpen.png');
54         return HTML::img(array('id' => $id . '-img',
55             'src' => $png,
56             //'align' => 'right',
57             'onclick' => "showHideFolder('$id')",
58             'alt' => _("Click to hide/show"),
59             'title' => _("Click to hide/show")));
60     }
61
62     /* Callback when a new user creates or edits a page */
63     function CbNewUserEdit(&$request, $userid)
64     {
65         $userid = strtoupper($userid);
66         $content = "{{Template/UserPage}}";
67         $dbi =& $request->_dbi;
68         $page = $dbi->getPage($userid);
69         $page->save($content, WIKIDB_FORCE_CREATE, array('author' => $userid));
70         $dbi->touch();
71     }
72
73     /** CbUpload (&$request, $pathname) => true or false
74      * Callback when a file is uploaded. virusscan, ...
75      * @param $request
76      * @param $pathname
77      * @return bool   true for success, false to abort gracefully.
78      * In case of false, the file is deleted by the caller, but the callback must
79      * inform the user why the file was deleted.
80      * Src:
81      *   if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name))
82      *      unlink($file_dir . $userfile_name);
83      */
84     function CbUpload(&$request, $pathname)
85     {
86         $cmdline = CLAMDSCAN_PATH . " --nosummary --move=" . CLAMDSCAN_VIRUS;
87         $report = `$cmdline "$pathname"`;
88         if (!$report) {
89             trigger_error("clamdscan failed", E_USER_WARNING);
90             return true;
91         }
92         if (!preg_match("/: OK$/", $report)) {
93             //preg_match("/: (.+)$/", $report, $m);
94             trigger_error("Upload failed. virus-scanner: $report", E_USER_WARNING);
95             return false;
96         } else {
97             return true;
98         }
99     }
100
101     function findTemplate($name)
102     {
103         // hack for navbar.tmpl to hide the button separator
104         if ($name == "navbar") {
105             $this->setButtonSeparator(HTML::raw("<br />\n&nbsp;&middot;&nbsp;"));
106         }
107         if ($name == "actionbar" || $name == "signin") {
108             $this->setButtonSeparator(" ");
109         }
110         return parent::findTemplate($name);
111     }
112
113     function load()
114     {
115
116         $this->initGlobals();
117
118         // CSS file defines fonts, colors and background images for this
119         // style.  The companion '*-heavy.css' file isn't defined, it's just
120         // expected to be in the same directory that the base style is in.
121
122         $this->setDefaultCSS(_("Sidebar"), array('' => 'sidebar.css',
123             'print' => 'phpwiki-printer.css'));
124         $this->addAlternateCSS(_("Printer"), 'phpwiki-printer.css', 'print, screen');
125         $this->addAlternateCSS(_("Modern"), 'phpwiki-modern.css');
126
127         /**
128          * The logo image appears on every page and links to the HomePage.
129          */
130         //$this->addImageAlias('logo', 'logo.png');
131
132         /**
133          * The Signature image is shown after saving an edited page. If this
134          * is not set, any signature defined in index.php will be used. If it
135          * is not defined by index.php or in here then the "Thank you for
136          * editing..." screen will be omitted.
137          */
138
139         // Comment this next line out to enable signature.
140         $this->addImageAlias('signature', false);
141
142         $this->addImageAlias('search', 'search.png');
143
144         /*
145          * Link icons.
146          */
147         $this->setLinkIcon('http');
148         $this->setLinkIcon('https');
149         $this->setLinkIcon('ftp');
150         $this->setLinkIcon('mailto');
151         $this->setLinkIcon('interwiki');
152         $this->setLinkIcon('*', 'url');
153
154         //$this->setButtonSeparator(' | ');
155
156         /**
157          * WikiWords can automatically be split by inserting spaces between
158          * the words. The default is to leave WordsSmashedTogetherLikeSo.
159          */
160         //$this->setAutosplitWikiWords(true);
161
162         /**
163          * If true (default) show create '?' buttons on not existing pages, even if the
164          * user is not signed in.
165          * If false, anon users get no links and it looks cleaner, but then they
166          * cannot easily fix missing pages.
167          */
168         $this->setAnonEditUnknownLinks(false);
169
170         /*
171          * You may adjust the formats used for formatting dates and times
172          * below.  (These examples give the default formats.)
173          * Formats are given as format strings to PHP strftime() function See
174          * http://www.php.net/manual/en/function.strftime.php for details.
175          * Do not include the server's zone (%Z), times are converted to the
176          * user's time zone.
177          */
178         //$this->setDateFormat("%B %d, %Y");
179
180         /**
181          * Custom UserPreferences:
182          * A list of name => _UserPreference class pairs.
183          * Rationale: Certain themes should be able to extend the predefined list
184          * of preferences. Display/editing is done in the theme specific userprefs.tmpl
185          * but storage/sanification/update/... must be extended to the Get/SetPreferences methods.
186          * See themes/wikilens/themeinfo.php
187          */
188         //$this->customUserPreference();
189
190         /**
191          * Register custom PageList type and define custom PageList classes.
192          * Rationale: Certain themes should be able to extend the predefined list
193          * of pagelist types. E.g. certain plugins, like MostPopular might use
194          * info=pagename,hits,rating
195          * which displays the rating column whenever the wikilens theme is active.
196          * See themes/wikilens/themeinfo.php
197          */
198         //$this->addPageListColumn();
199
200     }
201 }
202
203 $WikiTheme = new WikiTheme_Sidebar('Sidebar');
204 if (ENABLE_RATEIT) {
205     require_once 'lib/wikilens/CustomPrefs.php';
206     require_once 'lib/wikilens/PageListColumns.php';
207     //require_once("lib/plugin/RateIt.php");
208     $plugin = new WikiPlugin_RateIt;
209     // add parent to current theme to find the RateIt images
210     // $WikiTheme->addParent('wikilens', 'noinit');
211     $WikiTheme->_parents[] = new WikiTheme('wikilens', 'noinit');
212     $plugin->head();
213 }
214
215 // Local Variables:
216 // mode: php
217 // tab-width: 8
218 // c-basic-offset: 4
219 // c-hanging-comment-ender-p: nil
220 // indent-tabs-mode: nil
221 // End: