]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/Sidebar/themeinfo.php
Harmonize file footer
[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 // rcs_id('$Id$');
10
11 /*
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.
15  *
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.
19  *
20  * Changes to MonoBook:
21  *  folderArrow
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
25  */
26
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");
31
32 require_once('lib/WikiTheme.php');
33 require_once('lib/WikiPlugin.php');
34 require_once('themes/MonoBook/themeinfo.php');
35
36 class WikiTheme_Sidebar extends WikiTheme_MonoBook {
37
38     function WikiTheme_Sidebar ($theme_name='Sidebar') {
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         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         $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));
69         $dbi->touch();
70     }
71
72     /** CbUpload (&$request, $pathname) => true or false
73      * Callback when a file is uploaded. virusscan, ...
74      * @param string $str
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.
78      * Src:
79      *   if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name))
80      *      unlink($file_dir . $userfile_name);
81      */
82     function CbUpload (&$request, $pathname) {
83         $cmdline = CLAMDSCAN_PATH . " --nosummary --move=" . CLAMDSCAN_VIRUS;
84         $report = `$cmdline "$pathname"`;
85         if (!$report) {
86             trigger_error("clamdscan failed", E_USER_WARNING);
87             return true;
88         }
89         if (!preg_match("/: OK$/", $report)) {
90             //preg_match("/: (.+)$/", $report, $m);
91             trigger_error("Upload failed. virus-scanner: $report", E_USER_WARNING);
92             return false;
93         } else {
94             return true;
95         }
96     }
97
98
99     function findTemplate ($name) {
100         // hack for navbar.tmpl to hide the buttonseparator
101         if ($name == "navbar") {
102             $this->setButtonSeparator(HTML::Raw("<br />\n&nbsp;&middot;&nbsp;"));
103         }
104         if ($name == "actionbar" || $name == "signin") {
105             $this->setButtonSeparator(" ");
106         }
107         return parent::findTemplate($name);
108     }
109
110     function load() {
111
112         $this->initGlobals();
113
114         // CSS file defines fonts, colors and background images for this
115         // style.  The companion '*-heavy.css' file isn't defined, it's just
116         // expected to be in the same directory that the base style is in.
117
118         $this->setDefaultCSS(_("Sidebar"), 'sidebar.css');
119         //$this->addAlternateCSS('PhpWiki', 'phpwiki.css');
120         //$this->setDefaultCSS('PhpWiki', 'phpwiki.css');
121         $this->addAlternateCSS(_("Printer"), 'phpwiki-printer.css', 'print, screen');
122         $this->addAlternateCSS(_("Modern"), 'phpwiki-modern.css');
123
124         /**
125          * The logo image appears on every page and links to the HomePage.
126          */
127         //$this->addImageAlias('logo', 'logo.png');
128
129         /**
130          * The Signature image is shown after saving an edited page. If this
131          * is not set, any signature defined in index.php will be used. If it
132          * is not defined by index.php or in here then the "Thank you for
133          * editing..." screen will be omitted.
134          */
135
136         // Comment this next line out to enable signature.
137         $this->addImageAlias('signature', false);
138
139         $this->addImageAlias('search', 'search.png');
140
141         /*
142          * Link icons.
143          */
144         $this->setLinkIcon('http');
145         $this->setLinkIcon('https');
146         $this->setLinkIcon('ftp');
147         $this->setLinkIcon('mailto');
148         $this->setLinkIcon('interwiki');
149         $this->setLinkIcon('*', 'url');
150
151         //$this->setButtonSeparator(' | ');
152
153         /**
154          * WikiWords can automatically be split by inserting spaces between
155          * the words. The default is to leave WordsSmashedTogetherLikeSo.
156          */
157         //$this->setAutosplitWikiWords(true);
158
159         /**
160          * If true (default) show create '?' buttons on not existing pages, even if the
161          * user is not signed in.
162          * If false, anon users get no links and it looks cleaner, but then they
163          * cannot easily fix missing pages.
164          */
165         $this->setAnonEditUnknownLinks(false);
166
167         /*
168          * You may adjust the formats used for formatting dates and times
169          * below.  (These examples give the default formats.)
170          * Formats are given as format strings to PHP strftime() function See
171          * http://www.php.net/manual/en/function.strftime.php for details.
172          * Do not include the server's zone (%Z), times are converted to the
173          * user's time zone.
174          */
175         //$this->setDateFormat("%B %d, %Y");
176
177         /**
178          * Custom UserPreferences:
179          * A list of name => _UserPreference class pairs.
180          * Rationale: Certain themes should be able to extend the predefined list
181          * of preferences. Display/editing is done in the theme specific userprefs.tmpl
182          * but storage/sanification/update/... must be extended to the Get/SetPreferences methods.
183          * See themes/wikilens/themeinfo.php
184          */
185         //$this->customUserPreference();
186
187         /**
188          * Register custom PageList type and define custom PageList classes.
189          * Rationale: Certain themes should be able to extend the predefined list
190          * of pagelist types. E.g. certain plugins, like MostPopular might use
191          * info=pagename,hits,rating
192          * which displays the rating column whenever the wikilens theme is active.
193          * See themes/wikilens/themeinfo.php
194          */
195         //$this->addPageListColumn();
196
197     }
198 }
199
200 $WikiTheme = new WikiTheme_Sidebar('Sidebar');
201 if (ENABLE_RATEIT) {
202   require_once("lib/wikilens/CustomPrefs.php");
203   require_once("lib/wikilens/PageListColumns.php");
204   //require_once("lib/plugin/RateIt.php");
205   $plugin = new WikiPlugin_RateIt;
206   // add parent to current theme to find the RateIt images
207   // $WikiTheme->addParent('wikilens', 'noinit');
208   $WikiTheme->_parents[] = new WikiTheme('wikilens', 'noinit');
209   $plugin->head();
210 }
211
212 // Local Variables:
213 // mode: php
214 // tab-width: 8
215 // c-basic-offset: 4
216 // c-hanging-comment-ender-p: nil
217 // indent-tabs-mode: nil
218 // End: 
219 ?>