|
From: <ru...@us...> - 2009-01-16 09:41:09
|
Revision: 6405
http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6405&view=rev
Author: rurban
Date: 2009-01-16 09:41:04 +0000 (Fri, 16 Jan 2009)
Log Message:
-----------
Derive Sidebar now from Monobook.
Search all parent classes for theme files, not only default.
Modified Paths:
--------------
trunk/lib/WikiTheme.php
trunk/themes/Sidebar/themeinfo.php
Modified: trunk/lib/WikiTheme.php
===================================================================
--- trunk/lib/WikiTheme.php 2009-01-16 06:26:31 UTC (rev 6404)
+++ trunk/lib/WikiTheme.php 2009-01-16 09:41:04 UTC (rev 6405)
@@ -200,9 +200,21 @@
$this->_themes_dir = NormalizeLocalFileName("themes");
$this->_path = defined('PHPWIKI_DIR') ? NormalizeLocalFileName("") : "";
$this->_theme = "themes/$theme_name";
+ $this->_parents = array();
- if ($theme_name != 'default')
- $this->_default_theme = new WikiTheme('default',true);
+ if ($theme_name != 'default') {
+ $parent = $this;
+ /* derived classes should search all parent classes */
+ while ($parent = get_parent_class($parent)) {
+ if ($parent == 'WikiTheme') {
+ $this->_default_theme = new WikiTheme('default', true);
+ $this->_parents[] = $this->_default_theme;
+ } elseif ($parent) {
+ $this->_parents[] = new WikiTheme
+ (preg_replace("/^WikiTheme_/i", "", $parent), true);
+ }
+ }
+ }
if ($noinit) return;
$script_url = deduce_script_name();
@@ -242,14 +254,23 @@
if (file_exists($this->_path . $file))
return $file;
+ /* Derived classes should search all parent classes */
+ foreach ($this->_parents as $parent) {
+ $path = $parent->_findFile($file, 1);
+ if ($path) {
+ return $path;
+ } elseif (DEBUG & _DEBUG_VERBOSE) {
+ ; //trigger_error("$parent->_theme/$file: not found", E_USER_NOTICE);
+ }
+ }
if (isset($this->_default_theme)) {
return $this->_default_theme->_findFile($file, $missing_okay);
}
else if (!$missing_okay) {
- if (DEBUG & function_exists('debug_backtrace')) { // >= 4.3.0
+ trigger_error("$this->_theme/$file: not found", E_USER_NOTICE);
+ if (DEBUG & _DEBUG_TRACE && function_exists('debug_backtrace')) { // >= 4.3.0
echo "<pre>", printSimpleTrace(debug_backtrace()), "</pre>\n";
}
- trigger_error("$this->_theme/$file: not found", E_USER_NOTICE);
}
return false;
}
@@ -1143,12 +1164,11 @@
return $this->_path . $tmp;
else {
$f1 = $this->file("templates/$name.tmpl");
- //trigger_error("findTemplate($name) pwd: ".getcwd(), E_USER_ERROR);
- if (isset($this->_default_theme)) {
- $f2 = $this->_default_theme->file("templates/$name.tmpl");
- //trigger_error("$f1 nor $f2 found", E_USER_ERROR);
- } else
- trigger_error("$f1 not found", E_USER_ERROR);
+ foreach ($this->_parents as $parent) {
+ if ($tmp = $parent->_findFile("templates/$name.tmpl", 1))
+ return $this->_path . $tmp;
+ }
+ trigger_error("$f1 not found", E_USER_ERROR);
return false;
}
}
Modified: trunk/themes/Sidebar/themeinfo.php
===================================================================
--- trunk/themes/Sidebar/themeinfo.php 2009-01-16 06:26:31 UTC (rev 6404)
+++ trunk/themes/Sidebar/themeinfo.php 2009-01-16 09:41:04 UTC (rev 6405)
@@ -2,22 +2,52 @@
rcs_id('$Id$');
/*
- * This file defines the Sidebar appearance ("theme") of PhpWiki,
- * which can be used as parent class for all sidebar themes. See blog.
- * This use the dynamic jscalendar, which doesn't need extra requests
- * per month/year change.
+ * This file defines the Sidebar theme of PhpWiki,
+ * which can be used as parent class for all sidebar themes. See MonoBook and blog.
+ * It is now an extension of the MonoBook theme.
+ *
+ * This uses the dynamic jscalendar, which doesn't need extra requests per month/year change.
+ *
+ * Changes to MonoBook:
+ * makeActionButton
+ * folderArrow
+ * special login, search and tags
+ * CbNewUserEdit - when a new user creates or edits a page, a Userpage template is created
+ * CbUpload - uploads are virus checked
*/
+if (!defined("CLAMDSCAN_PATH"))
+ define("CLAMDSCAN_PATH","/usr/local/bin/clamdscan");
+if (!defined("CLAMDSCAN_VIRUS"))
+ define("CLAMDSCAN_VIRUS","/var/www/virus-found");
+
require_once('lib/WikiTheme.php');
-require_once('lib/WikiPlugin.php');
+require_once('themes/MonoBook/themeinfo.php');
+//require_once('lib/WikiPlugin.php');
-class WikiTheme_Sidebar extends WikiTheme {
+class WikiTheme_Sidebar extends WikiTheme_MonoBook {
function WikiTheme_Sidebar ($theme_name='Sidebar') {
$this->WikiTheme($theme_name);
$this->calendarInit(true);
}
+ /* Display up/down button with persistent state */
+ /* persistent state per block in cookie for 30 days */
+ function folderArrow ($id, $init='Open') {
+ global $request;
+ if ($cookie = $request->cookies->get("folder_".$id)) {
+ $init = $cookie;
+ }
+ $png = $this->_findData('images/folderArrow'.$init.'.png');
+ return HTML::img(array('id' => $id.'-img',
+ 'src' => $png,
+ //'align' => 'right',
+ 'onClick' => "showHideFolder('$id')",
+ 'title' => _("Click to hide/show")));
+ }
+
+ /*
function findTemplate ($name) {
// hack for navbar.tmpl to hide the buttonseparator
if ($name == "navbar") {
@@ -28,71 +58,44 @@
}
return parent::findTemplate($name);
}
+ */
- function load() {
- // CSS file defines fonts, colors and background images for this
- // style. The companion '*-heavy.css' file isn't defined, it's just
- // expected to be in the same directory that the base style is in.
+ /* Callback when a new user creates or edits a page */
+ function CbNewUserEdit (&$request, $userid) {
+ $userid = strtoupper($userid);
+ $content = "{{Template/UserPage}}";
+ $dbi =& $request->_dbi;
+ $page = $dbi->getPage($userid);
+ $page->save($content, WIKIDB_FORCE_CREATE, array('author' => $userid));
+ $dbi->touch();
+ }
- $this->setDefaultCSS(_("Sidebar"), 'sidebar.css');
- //$this->addAlternateCSS('PhpWiki', 'phpwiki.css');
- //$this->setDefaultCSS('PhpWiki', 'phpwiki.css');
- $this->addAlternateCSS(_("Printer"), 'phpwiki-printer.css', 'print, screen');
- $this->addAlternateCSS(_("Modern"), 'phpwiki-modern.css');
+ /** CbUpload (&$request, $pathname) => true or false
+ * Callback when a file is uploaded. virusscan, ...
+ * @param string $str
+ * @return bool true for success, false to abort gracefully.
+ * In case of false, the file is deleted by the caller, but the callback must
+ * inform the user why the file was deleted.
+ * Src:
+ * if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name))
+ * unlink($file_dir . $userfile_name);
+ */
+ function CbUpload (&$request, $pathname) {
+ $cmdline = CLAMDSCAN_PATH . " --nosummary --move=" . CLAMDSCAN_VIRUS;
+ $report = `$cmdline $pathname"`;
+ if (!$report) {
+ trigger_error("clamdscan failed", E_USER_WARNING);
+ return true;
+ }
+ if (!preg_match("/: OK$/", $report)) {
+ //preg_match("/: (.+)$/", $report, $m);
+ trigger_error("Upload failed. virus-scanner: $report", E_USER_WARNING);
+ return false;
+ } else {
+ return true;
+ }
+ }
- /**
- * The logo image appears on every page and links to the HomePage.
- */
- //$this->addImageAlias('logo', 'logo.png');
-
- /**
- * The Signature image is shown after saving an edited page. If this
- * is not set, any signature defined in index.php will be used. If it
- * is not defined by index.php or in here then the "Thank you for
- * editing..." screen will be omitted.
- */
-
- // Comment this next line out to enable signature.
- $this->addImageAlias('signature', false);
-
- $this->addImageAlias('search', 'search.png');
-
- /*
- * Link icons.
- */
- $this->setLinkIcon('http');
- $this->setLinkIcon('https');
- $this->setLinkIcon('ftp');
- $this->setLinkIcon('mailto');
- $this->setLinkIcon('interwiki');
- $this->setLinkIcon('*', 'url');
-
- //$this->setButtonSeparator(' | ');
-
- /**
- * WikiWords can automatically be split by inserting spaces between
- * the words. The default is to leave WordsSmashedTogetherLikeSo.
- */
- $this->setAutosplitWikiWords(true);
-
- /**
- * If true (default) show create '?' buttons on not existing pages, even if the
- * user is not signed in.
- * If false, anon users get no links and it looks cleaner, but then they
- * cannot easily fix missing pages.
- */
- $this->setAnonEditUnknownLinks(false);
-
- /*
- * You may adjust the formats used for formatting dates and times
- * below. (These examples give the default formats.)
- * Formats are given as format strings to PHP strftime() function See
- * http://www.php.net/manual/en/function.strftime.php for details.
- * Do not include the server's zone (%Z), times are converted to the
- * user's time zone.
- */
- //$this->setDateFormat("%B %d, %Y");
- }
}
$WikiTheme = new WikiTheme_Sidebar('Sidebar');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|