]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
implement request #1989987: theme support. merge themes branch with --squash
authorChristian Weiske <cweiske@cweiske.de>
Wed, 25 May 2011 17:43:36 +0000 (19:43 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 25 May 2011 17:43:36 +0000 (19:43 +0200)
78 files changed:
build.xml
data/config.default.php
data/templates/default/about.tpl.php [moved from data/templates/about.tpl.php with 100% similarity]
data/templates/default/admin.tpl.php [moved from data/templates/admin.tpl.php with 100% similarity]
data/templates/default/bookmarkcommondescriptionedit.tpl.php [moved from data/templates/bookmarkcommondescriptionedit.tpl.php with 100% similarity]
data/templates/default/bookmarklet.inc.php [moved from data/templates/bookmarklet.inc.php with 100% similarity]
data/templates/default/bookmarks-thumbnail.inc.tpl.php [moved from data/templates/bookmarks-thumbnail.inc.tpl.php with 100% similarity]
data/templates/default/bookmarks-vote-horizontal.inc.tpl.php [moved from data/templates/bookmarks-vote-horizontal.inc.tpl.php with 100% similarity]
data/templates/default/bookmarks-vote.inc.tpl.php [moved from data/templates/bookmarks-vote.inc.tpl.php with 100% similarity]
data/templates/default/bookmarks.tpl.php [moved from data/templates/bookmarks.tpl.php with 92% similarity]
data/templates/default/bottom.inc.php [moved from data/templates/bottom.inc.php with 100% similarity]
data/templates/default/dojo.inc.php [moved from data/templates/dojo.inc.php with 100% similarity]
data/templates/default/dynamictags.inc.php [moved from data/templates/dynamictags.inc.php with 100% similarity]
data/templates/default/editbookmark.tpl.php [moved from data/templates/editbookmark.tpl.php with 100% similarity]
data/templates/default/editprofile-sslclientcerts.tpl.php [moved from data/templates/editprofile-sslclientcerts.tpl.php with 100% similarity]
data/templates/default/editprofile.tpl.php [moved from data/templates/editprofile.tpl.php with 100% similarity]
data/templates/default/error.404.tpl.php [moved from data/templates/error.404.tpl.php with 100% similarity]
data/templates/default/error.500.tpl.php [moved from data/templates/error.500.tpl.php with 100% similarity]
data/templates/default/importDelicious.tpl.php [moved from data/templates/importDelicious.tpl.php with 100% similarity]
data/templates/default/importNetscape.tpl.php [moved from data/templates/importNetscape.tpl.php with 100% similarity]
data/templates/default/importStructure.tpl.php [moved from data/templates/importStructure.tpl.php with 100% similarity]
data/templates/default/login.tpl.php [moved from data/templates/login.tpl.php with 100% similarity]
data/templates/default/password.tpl.php [moved from data/templates/password.tpl.php with 100% similarity]
data/templates/default/profile.tpl.php [moved from data/templates/profile.tpl.php with 100% similarity]
data/templates/default/register.tpl.php [moved from data/templates/register.tpl.php with 100% similarity]
data/templates/default/rss.tpl.php [moved from data/templates/rss.tpl.php with 100% similarity]
data/templates/default/search.menu.php [moved from data/templates/search.menu.php with 100% similarity]
data/templates/default/sidebar.block.common.php [moved from data/templates/sidebar.block.common.php with 100% similarity]
data/templates/default/sidebar.block.linked.php [moved from data/templates/sidebar.block.linked.php with 100% similarity]
data/templates/default/sidebar.block.menu.php [moved from data/templates/sidebar.block.menu.php with 100% similarity]
data/templates/default/sidebar.block.menu2.php [moved from data/templates/sidebar.block.menu2.php with 100% similarity]
data/templates/default/sidebar.block.popular.php [moved from data/templates/sidebar.block.popular.php with 100% similarity]
data/templates/default/sidebar.block.recent.php [moved from data/templates/sidebar.block.recent.php with 100% similarity]
data/templates/default/sidebar.block.related.php [moved from data/templates/sidebar.block.related.php with 100% similarity]
data/templates/default/sidebar.block.search.php [moved from data/templates/sidebar.block.search.php with 100% similarity]
data/templates/default/sidebar.block.tagactions.php [moved from data/templates/sidebar.block.tagactions.php with 100% similarity]
data/templates/default/sidebar.block.users.php [moved from data/templates/sidebar.block.users.php with 100% similarity]
data/templates/default/sidebar.block.watchlist.php [moved from data/templates/sidebar.block.watchlist.php with 100% similarity]
data/templates/default/sidebar.block.watchstatus.php [moved from data/templates/sidebar.block.watchstatus.php with 100% similarity]
data/templates/default/sidebar.linkedtags.inc.php [moved from data/templates/sidebar.linkedtags.inc.php with 100% similarity]
data/templates/default/sidebar.tpl.php [moved from data/templates/sidebar.tpl.php with 100% similarity]
data/templates/default/tag2tagadd.tpl.php [moved from data/templates/tag2tagadd.tpl.php with 100% similarity]
data/templates/default/tag2tagdelete.tpl.php [moved from data/templates/tag2tagdelete.tpl.php with 100% similarity]
data/templates/default/tag2tagedit.tpl.php [moved from data/templates/tag2tagedit.tpl.php with 100% similarity]
data/templates/default/tagcommondescriptionedit.tpl.php [moved from data/templates/tagcommondescriptionedit.tpl.php with 100% similarity]
data/templates/default/tagdelete.tpl.php [moved from data/templates/tagdelete.tpl.php with 100% similarity]
data/templates/default/tagedit.tpl.php [moved from data/templates/tagedit.tpl.php with 100% similarity]
data/templates/default/tagrename.tpl.php [moved from data/templates/tagrename.tpl.php with 100% similarity]
data/templates/default/tags.tpl.php [moved from data/templates/tags.tpl.php with 100% similarity]
data/templates/default/toolbar.inc.php [moved from data/templates/toolbar.inc.php with 100% similarity]
data/templates/default/top.inc.php [moved from data/templates/top.inc.php with 92% similarity]
data/templates/default/users.tpl.php [moved from data/templates/users.tpl.php with 100% similarity]
data/templates/testdummy/top.inc.php [new file with mode: 0644]
doc/ChangeLog
doc/themes.rst [new file with mode: 0644]
src/SemanticScuttle/Model/Template.php
src/SemanticScuttle/Model/Theme.php [new file with mode: 0644]
src/SemanticScuttle/Service/Template.php
src/SemanticScuttle/header.php
www/jsScuttle.php
www/themes/default/icon.png [moved from www/icon.png with 100% similarity]
www/themes/default/images/b_edit.png [moved from www/images/b_edit.png with 100% similarity]
www/themes/default/images/bg_admin.png [moved from www/images/bg_admin.png with 100% similarity]
www/themes/default/images/bg_bar.png [moved from www/images/bg_bar.png with 100% similarity]
www/themes/default/images/bg_header.png [moved from www/images/bg_header.png with 100% similarity]
www/themes/default/images/bg_sidebar.png [moved from www/images/bg_sidebar.png with 100% similarity]
www/themes/default/images/loading.gif [moved from www/images/loading.gif with 100% similarity]
www/themes/default/images/logo.png [moved from www/images/logo.png with 100% similarity]
www/themes/default/images/logo_24.gif [moved from www/images/logo_24.gif with 100% similarity]
www/themes/default/images/rss.gif [moved from www/images/rss.gif with 100% similarity]
www/themes/default/images/thumbs_up.orig.png [moved from www/images/thumbs_up.orig.png with 100% similarity]
www/themes/default/images/vote-against-voted.png [moved from www/images/vote-against-voted.png with 100% similarity]
www/themes/default/images/vote-against.png [moved from www/images/vote-against.png with 100% similarity]
www/themes/default/images/vote-for-voted.png [moved from www/images/vote-for-voted.png with 100% similarity]
www/themes/default/images/vote-for.png [moved from www/images/vote-for.png with 100% similarity]
www/themes/default/scuttle.css [moved from www/scuttle.css with 100% similarity]
www/themes/testdummy/images/logo.png [new file with mode: 0644]
www/themes/testdummy/scuttle.css [new file with mode: 0644]

index 9773a6309360a649f8c6c10acdbd04d95232827f..7b3896b4af1526fecb2126c51282bac62312dcf0 100644 (file)
--- a/build.xml
+++ b/build.xml
 
      <replacement
       path="src/SemanticScuttle/header.php"
-      type="pear-config"
-      from="@data_dir@" to="data_dir"
+      type="pear-config" from="@data_dir@" to="data_dir"
+      />
+     <replacement
+      path="src/SemanticScuttle/header.php"
+      type="pear-config" from="@www_dir@" to="www_dir"
       />
      <replacement
       path="www/www-header.php"
-      type="pear-config"
-      from="@data_dir@" to="data_dir"
+      type="pear-config" from="@data_dir@" to="data_dir"
       />
      <replacement
       path="tests/prepare.php"
-      type="pear-config"
-      from="@data_dir@" to="data_dir"
+      type="pear-config" from="@data_dir@" to="data_dir"
       />
 
      <changelog version="0.97" date="2010-06-09" license="GPL">
index 8c47e0b0cbf2fa9627009ce8603b221a55735372..c850521a9c8d7105e7f586eb83dc9a492f308ae9 100644 (file)
@@ -63,6 +63,15 @@ $sidebarTopMessage  = '';
  */
 $sidebarBottomMessage = '';
 
+/**
+ * The HTML theme to use. With themes, you can give your semanticscuttle
+ * installation a new look.
+ *
+ * Themes are the folders in data/templates/
+ *
+ * @var string
+ */
+$theme = 'default';
 
 
 /***************************************************
similarity index 92%
rename from data/templates/bookmarks.tpl.php
rename to data/templates/default/bookmarks.tpl.php
index 55d6a0f6e862e4914a71c284f3b697dc34148db8..91d50bf0ce064c6c35bcd7bb372afc24bca4cb60 100644 (file)
@@ -39,7 +39,9 @@ include('search.menu.php');
 
 <?php if($GLOBALS['enableAdminColors']!=false && isset($userid) && $userservice->isAdmin($userid) && $pageName != PAGE_WATCHLIST) : ?>
 <div style="width:70%;text-align:center;">
-<img src="<?php echo ROOT ?>images/logo_24.gif" width="12px"/> <?php echo T_('Bookmarks on this page are managed by an admin user.'); ?><img src="<?php echo ROOT ?>images/logo_24.gif" width="12px"/>
+ <img src="<?php $theme->resource('images/logo_24.gif'); ?>" width="12px"/>
+ <?php echo T_('Bookmarks on this page are managed by an admin user.'); ?>
+ <img src="<?php $theme->resource('images/logo_24.gif'); ?>" width="12px"/>
 </div>
 <?php endif?>
 
@@ -70,7 +72,7 @@ if ($userservice->isLoggedOn()) {
     ) {
                echo ' <a href="'. createURL('tagcommondescriptionedit', $currenttag).'" title="'.T_('Edit the common description of this tag').'">';
                echo !is_array($cDescription) || strlen($cDescription['cdDescription'])==0?T_('Edit the common description of this tag'):'';
-               echo ' <img src="'.ROOT.'images/b_edit.png" /></a>';
+               echo ' <img src="' . $theme->resource('images/b_edit.png') . '" /></a>';
        } else if (isset($hash)) {
                echo ' (<a href="'.createURL('bookmarkcommondescriptionedit', $hash).'" title="'.T_('Edit the common description of this bookmark').'">';
                echo T_('Edit the common description of this bookmark').'</a>)';
@@ -95,7 +97,7 @@ if($userservice->isLoggedOn()) {
        if($currenttag!= '') {
                echo ' <a href="'. createURL('tagedit', $currenttag).'" title="'.T_('Edit your personal description of this tag').'" >';
                echo strlen($pDescription['tDescription'])==0?T_('Edit your personal description of this tag'):'';
-               echo ' <img src="'.ROOT.'images/b_edit.png" /></a>';
+               echo ' <img src="' . $theme->resource('images/b_edit.png') . '" /></a>';
        }
 }
 ?></p>
@@ -219,9 +221,12 @@ if ($currenttag!= '') {
        $brss = '';
        $size = count($rsschannels);
        for ($i = 0; $i < $size; $i++) {
-               $brss =  '<a style="background:#FFFFFF" href="'. htmlspecialchars($rsschannels[$i][1]) . '"'
+               $brss =  '<a style="background:#FFFFFF"'
+            . ' href="'. htmlspecialchars($rsschannels[$i][1]) . '"'
             . ' title="' . htmlspecialchars($rsschannels[$i][0]) . '">'
-            . '<img src="' . ROOT . 'images/rss.gif" width="16" height="16" alt="' . htmlspecialchars($rsschannels[$i][0]) .'"/>'
+            . '<img src="' . $theme->resource('images/rss.gif') . '"'
+            . ' width="16" height="16"'
+            . ' alt="' . htmlspecialchars($rsschannels[$i][0]) .'"/>'
             . '</a>';
        }
 
@@ -361,9 +366,15 @@ if ($currenttag!= '') {
                }
 
                // Admin specific design
-               if ($userservice->isAdmin($row['username']) && $GLOBALS['enableAdminColors']) {
+               if ($userservice->isAdmin($row['username'])
+            && $GLOBALS['enableAdminColors']
+        ) {
                        $adminBgClass = ' class="adminBackground"';
-                       $adminStar    = ' <img src="'. ROOT .'images/logo_24.gif" width="12px" title="'. T_('This bookmark is certified by an admin user.') .'" />';
+                       $adminStar    = ' <img'
+                . ' src="' . $theme->resource('images/logo_24.gif') . '"'
+                . ' width="12px"'
+                . ' title="' . T_('This bookmark is certified by an admin user.') . '"'
+                . '/>';
                } else {
                        $adminBgClass = '';
                        $adminStar    = '';
similarity index 92%
rename from data/templates/top.inc.php
rename to data/templates/default/top.inc.php
index bdd4b1a9a53d68623f2b6f23aa1b1c5db54b799d..9eed6ff265b9eb9a738c5ae5b4f7cd20c4c20fe6 100644 (file)
@@ -4,8 +4,8 @@
  <head>
   <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
   <title><?php echo filter($GLOBALS['sitename'] .(isset($pagetitle) ? ' ยป ' . $pagetitle : '')); ?></title>
-  <link rel="icon" type="image/png" href="<?php echo ROOT ?>icon.png" />
-  <link rel="stylesheet" type="text/css" href="<?php echo ROOT ?>scuttle.css" />
+  <link rel="icon" type="image/png" href="<?php echo $theme->resource('icon.png');?>" />
+  <link rel="stylesheet" type="text/css" href="<?php echo $theme->resource('scuttle.css');?>" />
   <link rel="search" type="application/opensearchdescription+xml" href="<?php echo ROOT ?>api/opensearch.php" title="<?php echo htmlspecialchars($GLOBALS['sitename']) ?>"/>
 <?php
 if (isset($rsschannels)) {
diff --git a/data/templates/testdummy/top.inc.php b/data/templates/testdummy/top.inc.php
new file mode 100644 (file)
index 0000000..7b0874c
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+  <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
+  <title><?php echo filter($GLOBALS['sitename'] .(isset($pagetitle) ? ' ยป ' . $pagetitle : '')); ?></title>
+  <link rel="icon" type="image/png" href="<?php echo $theme->resource('icon.png');?>" />
+  <link rel="stylesheet" type="text/css" href="<?php echo $theme->resource('scuttle.css');?>" />
+  <link rel="search" type="application/opensearchdescription+xml" href="<?php echo ROOT ?>api/opensearch.php" title="<?php echo htmlspecialchars($GLOBALS['sitename']) ?>"/>
+<?php
+if (isset($rsschannels)) {
+       $size = count($rsschannels);
+       for ($i = 0; $i < $size; $i++) {
+               echo '  <link rel="alternate" type="application/rss+xml" title="'
+            . htmlspecialchars($rsschannels[$i][0]) . '"'
+            . ' href="'. $rsschannels[$i][1] .'" />';
+       }
+}
+?>
+
+<?php if (isset($loadjs)) :?>
+<?php if (DEBUG_MODE) : ?>
+  <script type="text/javascript" src="<?php echo ROOT_JS ?>jquery-1.4.2.js"></script>
+  <script type="text/javascript" src="<?php echo ROOT_JS ?>jquery.jstree.js"></script>
+<?php else: ?>
+  <script type="text/javascript" src="<?php echo ROOT_JS ?>jquery-1.4.2.min.js"></script>
+  <script type="text/javascript" src="<?php echo ROOT_JS ?>jquery.jstree.min.js"></script>
+<?php endif ?>
+  <script type="text/javascript" src="<?php echo ROOT ?>jsScuttle.php"></script>
+<?php endif ?>
+
+ </head>
+ <body>
+
+<?php
+$headerstyle = '';
+if(isset($_GET['popup'])) {
+       $headerstyle = ' class="popup"';
+}
+?>
+
+<div id="header" <?php echo $headerstyle; ?>>
+<h1><a href="<?php echo ROOT ?>">.</a></h1>
+<?php
+if(!isset($_GET['popup'])) {
+       $this->includeTemplate('toolbar.inc');
+}
+?></div>
+
+<?php
+if (isset($subtitle)) {
+       echo '<h2>'. $subtitle ."</h2>\n";
+}
+if(DEBUG_MODE) {
+       echo '<p class="error">'. T_('Admins, your installation is in "Debug Mode" ($debugMode = true). To go in "Normal Mode" and hide debugging messages, change $debugMode to false into config.php.') ."</p>\n";
+}
+if (isset($error) && $error!='') {
+       echo '<p class="error">'. $error ."</p>\n";
+}
+if (isset($msg) && $msg!='') {
+       echo '<p class="success">'. $msg ."</p>\n";
+}
+if (isset($tipMsg) && $tipMsg!='') {
+       echo '<p class="tipMsg">'. $tipMsg ."</p>\n";
+}
+?>
index 8fa208c0a573d7e4493ba29e0a89646b878d5703..ade19afd5414b07970d07def77718a91d209c5fd 100644 (file)
@@ -1,6 +1,9 @@
 ChangeLog for SemantiScuttle
 ============================
 
+- Implement request #1989987: Theming support
+
+
 0.98.0 - 2011-XX-XX
 -------------------
 - Switch to jQuery and drop dojo
diff --git a/doc/themes.rst b/doc/themes.rst
new file mode 100644 (file)
index 0000000..6f34a36
--- /dev/null
@@ -0,0 +1,48 @@
+======================
+SemanticScuttle Themes
+======================
+SemanticScuttle may be changed visually by supplying custom "themes" (skins)
+that modify the visual appearance.
+
+
+Changing the current theme
+==========================
+In ``data/config.php``, set your theme like this: ::
+
+    $theme = 'darkmood';
+
+The available themes are the folders in ``www/themes/``.
+By default, SemanticScuttle ships only one usable theme ("default") and one
+to demonstrate how to create your own theme ("testdummy").
+
+
+Creating your own theme
+=======================
+Have a look at the "testdummy" theme in ``www/themes/testdummy/``.
+
+CSS and image files
+-------------------
+Since both file types need to be accessible via the web server directly,
+they are located in the ``www/`` folder: ::
+
+    www/themes/$themename/
+
+The main CSS file that automatically gets included is ::
+
+    www/themes/$themename/scuttle.css
+
+Several template files in SemanticScuttle include image files. If they do not
+exist in your theme, the default ones are used automatically.
+Note that this is not true for images that are specified in the CSS files.
+
+
+Template files
+--------------
+The templates of the default file are located in ::
+
+    data/templates/default/
+
+You may put your theme template files into ::
+
+    data/templates/$themename/
+
index ff5fbbe8c1de762eb9a7f22d0fdbf6079f4f9c3f..234e23f2d9ce5950f73ac4b6d88a8bb1227e89a3 100644 (file)
@@ -76,6 +76,9 @@ class SemanticScuttle_Model_Template
      * Sets variables and includes the template file,
      * causing it to be rendered.
      *
+     * Does not take care of themes and so.
+     * The include path must be set so the correct theme is used.
+     *
      * @return void
      */
     public function parse()
diff --git a/src/SemanticScuttle/Model/Theme.php b/src/SemanticScuttle/Model/Theme.php
new file mode 100644 (file)
index 0000000..65861b8
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+/**
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package  SemanticScuttle
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @license  AGPL v3 or later http://www.gnu.org/licenses/agpl.html
+ * @link     http://sourceforge.net/projects/semanticscuttle
+ */
+
+/**
+ * A theme, the visual representation of SemanticScuttle.
+ *
+ * @category Bookmarking
+ * @package  SemanticScuttle
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @license  AGPL v3 or later http://www.gnu.org/licenses/agpl.html
+ * @link     http://sourceforge.net/projects/semanticscuttle
+ */
+class SemanticScuttle_Model_Theme
+{
+    /**
+     * Theme name. Also the path part of template and resource files
+     *
+     * @var string
+     */
+    protected $name = null;
+
+    /**
+     * Local path to the www themes directory.
+     * Needs to have a trailing slash.
+     *
+     * @var string
+     */
+    protected $wwwThemeDir = null;
+
+
+
+    /**
+     * Create a new theme instance.
+     *
+     * @param string $name Theme name "data/templates/(*)/"
+     */
+    public function __construct($name = 'default')
+    {
+        $this->name = $name;
+        $this->wwwThemeDir = $GLOBALS['wwwdir'] . '/themes/';
+        //TODO: implement theme hierarchies with parent fallback
+    }
+
+
+
+    /**
+     * Returns the URL path to a resource file (www/themes/$name/$file).
+     * Automatically falls back to the parent theme if the file does not exist
+     * in the theme.
+     *
+     * Must always be used when adding i.e. images to the output.
+     *
+     * @param string $file File name to find the path for, i.e. "scuttle.css".
+     *
+     * @return string Full path
+     */
+    public function resource($file)
+    {
+        $themeFile = $this->wwwThemeDir . $this->name . '/' . $file;
+        if (file_exists($themeFile)) {
+            return ROOT . 'themes/' . $this->name . '/' . $file;
+        }
+
+        $defaultFile = $this->wwwThemeDir . 'default/' . $file;
+        if (file_exists($defaultFile)) {
+            return ROOT . 'themes/default/' . $file;
+        }
+
+        //file does not exist. fall back to the theme file
+        // to guide the theme author a bit.
+        // TODO: logging. in admin mode, there should be a message
+        return ROOT . 'themes/' . $this->name . '/' . $file;
+    }
+
+
+
+    /**
+     * Returns the theme name.
+     *
+     * @return string Theme name
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+}
+?>
\ No newline at end of file
index efa8d2854c937a2276dba363869ea03f0514cd79..b5d4cfacf14d5cdc2ccebb333e50deb4662d0bc6 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 require_once 'SemanticScuttle/Model/Template.php';
+require_once 'SemanticScuttle/Model/Theme.php';
 
 /**
  * SemanticScuttle template service.
@@ -38,6 +39,14 @@ class SemanticScuttle_Service_Template extends SemanticScuttle_Service
      */
     protected $basedir;
 
+    /**
+     * The template theme to use.
+     * Set in constructor based on $GLOBALS['theme']
+     *
+     * @var SemanticScuttle_Model_Theme
+     */
+    protected $theme;
+
 
 
     /**
@@ -64,6 +73,8 @@ class SemanticScuttle_Service_Template extends SemanticScuttle_Service
     protected function __construct()
     {
         $this->basedir = $GLOBALS['TEMPLATES_DIR'];
+        $this->theme   = new SemanticScuttle_Model_Theme($GLOBALS['theme']);
+        //FIXME: verify the theme exists
     }
 
 
@@ -74,19 +85,33 @@ class SemanticScuttle_Service_Template extends SemanticScuttle_Service
      * @param string $template Template filename relative
      *                         to template dir
      * @param array  $vars     Array of template variables.
+     *                         The current theme object will be added
+     *                         automatically with name "theme".
      *
      * @return SemanticScuttle_Model_Template Template object
      */
-    function loadTemplate($template, $vars = null)
+    public function loadTemplate($template, $vars = null)
     {
         if (substr($template, -4) != '.php') {
             $template .= '.php';
         }
+
+        $oldIncPath = get_include_path();
+        set_include_path(
+            $this->basedir . $this->theme->getName()
+            . PATH_SEPARATOR . $this->basedir . 'default'
+            //needed since services are instantiated in templates
+            . PATH_SEPARATOR . $oldIncPath
+        );
+
+        $vars['theme'] = $this->theme;
         $tpl = new SemanticScuttle_Model_Template(
-            $this->basedir .'/'. $template, $vars, $this
+            $template, $vars, $this
         );
         $tpl->parse();
 
+        set_include_path($oldIncPath);
+
         return $tpl;
     }
 }
index 098e5c39fad82be5afc7ecd07b7a39f778f297a6..6c0d4dff71f3c247326b06461b2ab51274ffe3e1 100644 (file)
 if ('@data_dir@' == '@' . 'data_dir@') {
     //non pear-install
     $datadir = dirname(__FILE__) . '/../../data/';
+    $wwwdir  = dirname(__FILE__) . '/../../www/';
 } else {
     //pear installation; files are in include path
     $datadir = '@data_dir@/SemanticScuttle/';
+    //FIXME: when you have multiple installations, the www_dir will be wrong
+    $wwwdir  = '@www_dir@/SemanticScuttle/';
 }
 
 if (!file_exists($datadir . '/config.php')) {
index c16675535b2c9769620f4ed679b27f9f2549ae70..5e5f31b84a30709fc4c7438983bb26ccd6005f8f 100644 (file)
@@ -3,6 +3,7 @@ $GLOBALS['saveInLastUrl'] = false;
 $httpContentType = 'text/javascript';
 require_once 'www-header.php';
 require_once 'SemanticScuttle/functions.php';
+$theme = new SemanticScuttle_Model_Theme($GLOBALS['theme']);
 $player_root = ROOT .'includes/player/';
 ?>
 
@@ -62,7 +63,7 @@ function isAvailable(input, response){
     username = username.trim();
     var availability = document.getElementById("availability");
     if (username != '') {
-        usernameField.style.backgroundImage = 'url(<?php echo ROOT; ?>images/loading.gif)';
+        usernameField.style.backgroundImage = 'url(<?php echo $theme->resource('images/loading.gif'); ?>)';
         if (response != '') {
             usernameField.style.backgroundImage = 'none';
             if (response == 'true') {
@@ -92,7 +93,7 @@ function useAddress(ele) {
 function getTitle(input, response){
     var title = document.getElementById('titleField');
     if (title.value == '') {
-        title.style.backgroundImage = 'url(<?php echo ROOT; ?>images/loading.gif)';
+        title.style.backgroundImage = 'url(<?php echo $theme->resource('images/loading.gif');?>)';
         if (response != null) {
             title.style.backgroundImage = 'none';
             title.value = response;
similarity index 100%
rename from www/icon.png
rename to www/themes/default/icon.png
diff --git a/www/themes/testdummy/images/logo.png b/www/themes/testdummy/images/logo.png
new file mode 100644 (file)
index 0000000..4a8f8ba
Binary files /dev/null and b/www/themes/testdummy/images/logo.png differ
diff --git a/www/themes/testdummy/scuttle.css b/www/themes/testdummy/scuttle.css
new file mode 100644 (file)
index 0000000..c62cd19
--- /dev/null
@@ -0,0 +1,12 @@
+@import url(../default/scuttle.css);
+
+body {
+    background-color: #FEA;
+}
+
+html > body h1 {
+    background: url('images/logo.png') no-repeat 10px;
+}
+div#header {
+    background: #FEA;
+}