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