From 5ba53394fcda4ae9cfa9af52b37fb67517deeb5a Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 25 May 2011 19:43:36 +0200 Subject: [PATCH] implement request #1989987: theme support. merge themes branch with --squash --- build.xml | 13 +-- data/config.default.php | 9 ++ data/templates/{ => default}/about.tpl.php | 0 data/templates/{ => default}/admin.tpl.php | 0 .../bookmarkcommondescriptionedit.tpl.php | 0 .../{ => default}/bookmarklet.inc.php | 0 .../bookmarks-thumbnail.inc.tpl.php | 0 .../bookmarks-vote-horizontal.inc.tpl.php | 0 .../{ => default}/bookmarks-vote.inc.tpl.php | 0 .../templates/{ => default}/bookmarks.tpl.php | 25 +++-- data/templates/{ => default}/bottom.inc.php | 0 data/templates/{ => default}/dojo.inc.php | 0 .../{ => default}/dynamictags.inc.php | 0 .../{ => default}/editbookmark.tpl.php | 0 .../editprofile-sslclientcerts.tpl.php | 0 .../{ => default}/editprofile.tpl.php | 0 .../templates/{ => default}/error.404.tpl.php | 0 .../templates/{ => default}/error.500.tpl.php | 0 .../{ => default}/importDelicious.tpl.php | 0 .../{ => default}/importNetscape.tpl.php | 0 .../{ => default}/importStructure.tpl.php | 0 data/templates/{ => default}/login.tpl.php | 0 data/templates/{ => default}/password.tpl.php | 0 data/templates/{ => default}/profile.tpl.php | 0 data/templates/{ => default}/register.tpl.php | 0 data/templates/{ => default}/rss.tpl.php | 0 data/templates/{ => default}/search.menu.php | 0 .../{ => default}/sidebar.block.common.php | 0 .../{ => default}/sidebar.block.linked.php | 0 .../{ => default}/sidebar.block.menu.php | 0 .../{ => default}/sidebar.block.menu2.php | 0 .../{ => default}/sidebar.block.popular.php | 0 .../{ => default}/sidebar.block.recent.php | 0 .../{ => default}/sidebar.block.related.php | 0 .../{ => default}/sidebar.block.search.php | 0 .../sidebar.block.tagactions.php | 0 .../{ => default}/sidebar.block.users.php | 0 .../{ => default}/sidebar.block.watchlist.php | 0 .../sidebar.block.watchstatus.php | 0 .../{ => default}/sidebar.linkedtags.inc.php | 0 data/templates/{ => default}/sidebar.tpl.php | 0 .../{ => default}/tag2tagadd.tpl.php | 0 .../{ => default}/tag2tagdelete.tpl.php | 0 .../{ => default}/tag2tagedit.tpl.php | 0 .../tagcommondescriptionedit.tpl.php | 0 .../templates/{ => default}/tagdelete.tpl.php | 0 data/templates/{ => default}/tagedit.tpl.php | 0 .../templates/{ => default}/tagrename.tpl.php | 0 data/templates/{ => default}/tags.tpl.php | 0 data/templates/{ => default}/toolbar.inc.php | 0 data/templates/{ => default}/top.inc.php | 4 +- data/templates/{ => default}/users.tpl.php | 0 data/templates/testdummy/top.inc.php | 66 ++++++++++++ doc/ChangeLog | 3 + doc/themes.rst | 48 +++++++++ src/SemanticScuttle/Model/Template.php | 3 + src/SemanticScuttle/Model/Theme.php | 97 ++++++++++++++++++ src/SemanticScuttle/Service/Template.php | 29 +++++- src/SemanticScuttle/header.php | 3 + www/jsScuttle.php | 5 +- www/{ => themes/default}/icon.png | Bin www/{ => themes/default}/images/b_edit.png | Bin www/{ => themes/default}/images/bg_admin.png | Bin www/{ => themes/default}/images/bg_bar.png | Bin www/{ => themes/default}/images/bg_header.png | Bin .../default}/images/bg_sidebar.png | Bin www/{ => themes/default}/images/loading.gif | Bin www/{ => themes/default}/images/logo.png | Bin www/{ => themes/default}/images/logo_24.gif | Bin www/{ => themes/default}/images/rss.gif | Bin .../default}/images/thumbs_up.orig.png | Bin .../default}/images/vote-against-voted.png | Bin .../default}/images/vote-against.png | Bin .../default}/images/vote-for-voted.png | Bin www/{ => themes/default}/images/vote-for.png | Bin www/{ => themes/default}/scuttle.css | 0 www/themes/testdummy/images/logo.png | Bin 0 -> 2890 bytes www/themes/testdummy/scuttle.css | 12 +++ 78 files changed, 298 insertions(+), 19 deletions(-) rename data/templates/{ => default}/about.tpl.php (100%) rename data/templates/{ => default}/admin.tpl.php (100%) rename data/templates/{ => default}/bookmarkcommondescriptionedit.tpl.php (100%) rename data/templates/{ => default}/bookmarklet.inc.php (100%) rename data/templates/{ => default}/bookmarks-thumbnail.inc.tpl.php (100%) rename data/templates/{ => default}/bookmarks-vote-horizontal.inc.tpl.php (100%) rename data/templates/{ => default}/bookmarks-vote.inc.tpl.php (100%) rename data/templates/{ => default}/bookmarks.tpl.php (92%) rename data/templates/{ => default}/bottom.inc.php (100%) rename data/templates/{ => default}/dojo.inc.php (100%) rename data/templates/{ => default}/dynamictags.inc.php (100%) rename data/templates/{ => default}/editbookmark.tpl.php (100%) rename data/templates/{ => default}/editprofile-sslclientcerts.tpl.php (100%) rename data/templates/{ => default}/editprofile.tpl.php (100%) rename data/templates/{ => default}/error.404.tpl.php (100%) rename data/templates/{ => default}/error.500.tpl.php (100%) rename data/templates/{ => default}/importDelicious.tpl.php (100%) rename data/templates/{ => default}/importNetscape.tpl.php (100%) rename data/templates/{ => default}/importStructure.tpl.php (100%) rename data/templates/{ => default}/login.tpl.php (100%) rename data/templates/{ => default}/password.tpl.php (100%) rename data/templates/{ => default}/profile.tpl.php (100%) rename data/templates/{ => default}/register.tpl.php (100%) rename data/templates/{ => default}/rss.tpl.php (100%) rename data/templates/{ => default}/search.menu.php (100%) rename data/templates/{ => default}/sidebar.block.common.php (100%) rename data/templates/{ => default}/sidebar.block.linked.php (100%) rename data/templates/{ => default}/sidebar.block.menu.php (100%) rename data/templates/{ => default}/sidebar.block.menu2.php (100%) rename data/templates/{ => default}/sidebar.block.popular.php (100%) rename data/templates/{ => default}/sidebar.block.recent.php (100%) rename data/templates/{ => default}/sidebar.block.related.php (100%) rename data/templates/{ => default}/sidebar.block.search.php (100%) rename data/templates/{ => default}/sidebar.block.tagactions.php (100%) rename data/templates/{ => default}/sidebar.block.users.php (100%) rename data/templates/{ => default}/sidebar.block.watchlist.php (100%) rename data/templates/{ => default}/sidebar.block.watchstatus.php (100%) rename data/templates/{ => default}/sidebar.linkedtags.inc.php (100%) rename data/templates/{ => default}/sidebar.tpl.php (100%) rename data/templates/{ => default}/tag2tagadd.tpl.php (100%) rename data/templates/{ => default}/tag2tagdelete.tpl.php (100%) rename data/templates/{ => default}/tag2tagedit.tpl.php (100%) rename data/templates/{ => default}/tagcommondescriptionedit.tpl.php (100%) rename data/templates/{ => default}/tagdelete.tpl.php (100%) rename data/templates/{ => default}/tagedit.tpl.php (100%) rename data/templates/{ => default}/tagrename.tpl.php (100%) rename data/templates/{ => default}/tags.tpl.php (100%) rename data/templates/{ => default}/toolbar.inc.php (100%) rename data/templates/{ => default}/top.inc.php (92%) rename data/templates/{ => default}/users.tpl.php (100%) create mode 100644 data/templates/testdummy/top.inc.php create mode 100644 doc/themes.rst create mode 100644 src/SemanticScuttle/Model/Theme.php rename www/{ => themes/default}/icon.png (100%) rename www/{ => themes/default}/images/b_edit.png (100%) rename www/{ => themes/default}/images/bg_admin.png (100%) rename www/{ => themes/default}/images/bg_bar.png (100%) rename www/{ => themes/default}/images/bg_header.png (100%) rename www/{ => themes/default}/images/bg_sidebar.png (100%) rename www/{ => themes/default}/images/loading.gif (100%) rename www/{ => themes/default}/images/logo.png (100%) rename www/{ => themes/default}/images/logo_24.gif (100%) rename www/{ => themes/default}/images/rss.gif (100%) rename www/{ => themes/default}/images/thumbs_up.orig.png (100%) rename www/{ => themes/default}/images/vote-against-voted.png (100%) rename www/{ => themes/default}/images/vote-against.png (100%) rename www/{ => themes/default}/images/vote-for-voted.png (100%) rename www/{ => themes/default}/images/vote-for.png (100%) rename www/{ => themes/default}/scuttle.css (100%) create mode 100644 www/themes/testdummy/images/logo.png create mode 100644 www/themes/testdummy/scuttle.css diff --git a/build.xml b/build.xml index 9773a63..7b3896b 100644 --- a/build.xml +++ b/build.xml @@ -121,18 +121,19 @@ + diff --git a/data/config.default.php b/data/config.default.php index 8c47e0b..c850521 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -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'; /*************************************************** diff --git a/data/templates/about.tpl.php b/data/templates/default/about.tpl.php similarity index 100% rename from data/templates/about.tpl.php rename to data/templates/default/about.tpl.php diff --git a/data/templates/admin.tpl.php b/data/templates/default/admin.tpl.php similarity index 100% rename from data/templates/admin.tpl.php rename to data/templates/default/admin.tpl.php diff --git a/data/templates/bookmarkcommondescriptionedit.tpl.php b/data/templates/default/bookmarkcommondescriptionedit.tpl.php similarity index 100% rename from data/templates/bookmarkcommondescriptionedit.tpl.php rename to data/templates/default/bookmarkcommondescriptionedit.tpl.php diff --git a/data/templates/bookmarklet.inc.php b/data/templates/default/bookmarklet.inc.php similarity index 100% rename from data/templates/bookmarklet.inc.php rename to data/templates/default/bookmarklet.inc.php diff --git a/data/templates/bookmarks-thumbnail.inc.tpl.php b/data/templates/default/bookmarks-thumbnail.inc.tpl.php similarity index 100% rename from data/templates/bookmarks-thumbnail.inc.tpl.php rename to data/templates/default/bookmarks-thumbnail.inc.tpl.php diff --git a/data/templates/bookmarks-vote-horizontal.inc.tpl.php b/data/templates/default/bookmarks-vote-horizontal.inc.tpl.php similarity index 100% rename from data/templates/bookmarks-vote-horizontal.inc.tpl.php rename to data/templates/default/bookmarks-vote-horizontal.inc.tpl.php diff --git a/data/templates/bookmarks-vote.inc.tpl.php b/data/templates/default/bookmarks-vote.inc.tpl.php similarity index 100% rename from data/templates/bookmarks-vote.inc.tpl.php rename to data/templates/default/bookmarks-vote.inc.tpl.php diff --git a/data/templates/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php similarity index 92% rename from data/templates/bookmarks.tpl.php rename to data/templates/default/bookmarks.tpl.php index 55d6a0f..91d50bf 100644 --- a/data/templates/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -39,7 +39,9 @@ include('search.menu.php'); isAdmin($userid) && $pageName != PAGE_WATCHLIST) : ?>
- + + +
@@ -70,7 +72,7 @@ if ($userservice->isLoggedOn()) { ) { echo ' '; echo !is_array($cDescription) || strlen($cDescription['cdDescription'])==0?T_('Edit the common description of this tag'):''; - echo ' '; + echo ' '; } else if (isset($hash)) { echo ' ('; echo T_('Edit the common description of this bookmark').')'; @@ -95,7 +97,7 @@ if($userservice->isLoggedOn()) { if($currenttag!= '') { echo ' '; echo strlen($pDescription['tDescription'])==0?T_('Edit your personal description of this tag'):''; - echo ' '; + echo ' '; } } ?>

@@ -219,9 +221,12 @@ if ($currenttag!= '') { $brss = ''; $size = count($rsschannels); for ($i = 0; $i < $size; $i++) { - $brss = '' - . '' . htmlspecialchars($rsschannels[$i][0]) .'' + . '' . htmlspecialchars($rsschannels[$i][0]) .'' . ''; } @@ -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 = ' '; + $adminStar = ' '; } else { $adminBgClass = ''; $adminStar = ''; diff --git a/data/templates/bottom.inc.php b/data/templates/default/bottom.inc.php similarity index 100% rename from data/templates/bottom.inc.php rename to data/templates/default/bottom.inc.php diff --git a/data/templates/dojo.inc.php b/data/templates/default/dojo.inc.php similarity index 100% rename from data/templates/dojo.inc.php rename to data/templates/default/dojo.inc.php diff --git a/data/templates/dynamictags.inc.php b/data/templates/default/dynamictags.inc.php similarity index 100% rename from data/templates/dynamictags.inc.php rename to data/templates/default/dynamictags.inc.php diff --git a/data/templates/editbookmark.tpl.php b/data/templates/default/editbookmark.tpl.php similarity index 100% rename from data/templates/editbookmark.tpl.php rename to data/templates/default/editbookmark.tpl.php diff --git a/data/templates/editprofile-sslclientcerts.tpl.php b/data/templates/default/editprofile-sslclientcerts.tpl.php similarity index 100% rename from data/templates/editprofile-sslclientcerts.tpl.php rename to data/templates/default/editprofile-sslclientcerts.tpl.php diff --git a/data/templates/editprofile.tpl.php b/data/templates/default/editprofile.tpl.php similarity index 100% rename from data/templates/editprofile.tpl.php rename to data/templates/default/editprofile.tpl.php diff --git a/data/templates/error.404.tpl.php b/data/templates/default/error.404.tpl.php similarity index 100% rename from data/templates/error.404.tpl.php rename to data/templates/default/error.404.tpl.php diff --git a/data/templates/error.500.tpl.php b/data/templates/default/error.500.tpl.php similarity index 100% rename from data/templates/error.500.tpl.php rename to data/templates/default/error.500.tpl.php diff --git a/data/templates/importDelicious.tpl.php b/data/templates/default/importDelicious.tpl.php similarity index 100% rename from data/templates/importDelicious.tpl.php rename to data/templates/default/importDelicious.tpl.php diff --git a/data/templates/importNetscape.tpl.php b/data/templates/default/importNetscape.tpl.php similarity index 100% rename from data/templates/importNetscape.tpl.php rename to data/templates/default/importNetscape.tpl.php diff --git a/data/templates/importStructure.tpl.php b/data/templates/default/importStructure.tpl.php similarity index 100% rename from data/templates/importStructure.tpl.php rename to data/templates/default/importStructure.tpl.php diff --git a/data/templates/login.tpl.php b/data/templates/default/login.tpl.php similarity index 100% rename from data/templates/login.tpl.php rename to data/templates/default/login.tpl.php diff --git a/data/templates/password.tpl.php b/data/templates/default/password.tpl.php similarity index 100% rename from data/templates/password.tpl.php rename to data/templates/default/password.tpl.php diff --git a/data/templates/profile.tpl.php b/data/templates/default/profile.tpl.php similarity index 100% rename from data/templates/profile.tpl.php rename to data/templates/default/profile.tpl.php diff --git a/data/templates/register.tpl.php b/data/templates/default/register.tpl.php similarity index 100% rename from data/templates/register.tpl.php rename to data/templates/default/register.tpl.php diff --git a/data/templates/rss.tpl.php b/data/templates/default/rss.tpl.php similarity index 100% rename from data/templates/rss.tpl.php rename to data/templates/default/rss.tpl.php diff --git a/data/templates/search.menu.php b/data/templates/default/search.menu.php similarity index 100% rename from data/templates/search.menu.php rename to data/templates/default/search.menu.php diff --git a/data/templates/sidebar.block.common.php b/data/templates/default/sidebar.block.common.php similarity index 100% rename from data/templates/sidebar.block.common.php rename to data/templates/default/sidebar.block.common.php diff --git a/data/templates/sidebar.block.linked.php b/data/templates/default/sidebar.block.linked.php similarity index 100% rename from data/templates/sidebar.block.linked.php rename to data/templates/default/sidebar.block.linked.php diff --git a/data/templates/sidebar.block.menu.php b/data/templates/default/sidebar.block.menu.php similarity index 100% rename from data/templates/sidebar.block.menu.php rename to data/templates/default/sidebar.block.menu.php diff --git a/data/templates/sidebar.block.menu2.php b/data/templates/default/sidebar.block.menu2.php similarity index 100% rename from data/templates/sidebar.block.menu2.php rename to data/templates/default/sidebar.block.menu2.php diff --git a/data/templates/sidebar.block.popular.php b/data/templates/default/sidebar.block.popular.php similarity index 100% rename from data/templates/sidebar.block.popular.php rename to data/templates/default/sidebar.block.popular.php diff --git a/data/templates/sidebar.block.recent.php b/data/templates/default/sidebar.block.recent.php similarity index 100% rename from data/templates/sidebar.block.recent.php rename to data/templates/default/sidebar.block.recent.php diff --git a/data/templates/sidebar.block.related.php b/data/templates/default/sidebar.block.related.php similarity index 100% rename from data/templates/sidebar.block.related.php rename to data/templates/default/sidebar.block.related.php diff --git a/data/templates/sidebar.block.search.php b/data/templates/default/sidebar.block.search.php similarity index 100% rename from data/templates/sidebar.block.search.php rename to data/templates/default/sidebar.block.search.php diff --git a/data/templates/sidebar.block.tagactions.php b/data/templates/default/sidebar.block.tagactions.php similarity index 100% rename from data/templates/sidebar.block.tagactions.php rename to data/templates/default/sidebar.block.tagactions.php diff --git a/data/templates/sidebar.block.users.php b/data/templates/default/sidebar.block.users.php similarity index 100% rename from data/templates/sidebar.block.users.php rename to data/templates/default/sidebar.block.users.php diff --git a/data/templates/sidebar.block.watchlist.php b/data/templates/default/sidebar.block.watchlist.php similarity index 100% rename from data/templates/sidebar.block.watchlist.php rename to data/templates/default/sidebar.block.watchlist.php diff --git a/data/templates/sidebar.block.watchstatus.php b/data/templates/default/sidebar.block.watchstatus.php similarity index 100% rename from data/templates/sidebar.block.watchstatus.php rename to data/templates/default/sidebar.block.watchstatus.php diff --git a/data/templates/sidebar.linkedtags.inc.php b/data/templates/default/sidebar.linkedtags.inc.php similarity index 100% rename from data/templates/sidebar.linkedtags.inc.php rename to data/templates/default/sidebar.linkedtags.inc.php diff --git a/data/templates/sidebar.tpl.php b/data/templates/default/sidebar.tpl.php similarity index 100% rename from data/templates/sidebar.tpl.php rename to data/templates/default/sidebar.tpl.php diff --git a/data/templates/tag2tagadd.tpl.php b/data/templates/default/tag2tagadd.tpl.php similarity index 100% rename from data/templates/tag2tagadd.tpl.php rename to data/templates/default/tag2tagadd.tpl.php diff --git a/data/templates/tag2tagdelete.tpl.php b/data/templates/default/tag2tagdelete.tpl.php similarity index 100% rename from data/templates/tag2tagdelete.tpl.php rename to data/templates/default/tag2tagdelete.tpl.php diff --git a/data/templates/tag2tagedit.tpl.php b/data/templates/default/tag2tagedit.tpl.php similarity index 100% rename from data/templates/tag2tagedit.tpl.php rename to data/templates/default/tag2tagedit.tpl.php diff --git a/data/templates/tagcommondescriptionedit.tpl.php b/data/templates/default/tagcommondescriptionedit.tpl.php similarity index 100% rename from data/templates/tagcommondescriptionedit.tpl.php rename to data/templates/default/tagcommondescriptionedit.tpl.php diff --git a/data/templates/tagdelete.tpl.php b/data/templates/default/tagdelete.tpl.php similarity index 100% rename from data/templates/tagdelete.tpl.php rename to data/templates/default/tagdelete.tpl.php diff --git a/data/templates/tagedit.tpl.php b/data/templates/default/tagedit.tpl.php similarity index 100% rename from data/templates/tagedit.tpl.php rename to data/templates/default/tagedit.tpl.php diff --git a/data/templates/tagrename.tpl.php b/data/templates/default/tagrename.tpl.php similarity index 100% rename from data/templates/tagrename.tpl.php rename to data/templates/default/tagrename.tpl.php diff --git a/data/templates/tags.tpl.php b/data/templates/default/tags.tpl.php similarity index 100% rename from data/templates/tags.tpl.php rename to data/templates/default/tags.tpl.php diff --git a/data/templates/toolbar.inc.php b/data/templates/default/toolbar.inc.php similarity index 100% rename from data/templates/toolbar.inc.php rename to data/templates/default/toolbar.inc.php diff --git a/data/templates/top.inc.php b/data/templates/default/top.inc.php similarity index 92% rename from data/templates/top.inc.php rename to data/templates/default/top.inc.php index bdd4b1a..9eed6ff 100644 --- a/data/templates/top.inc.php +++ b/data/templates/default/top.inc.php @@ -4,8 +4,8 @@ <?php echo filter($GLOBALS['sitename'] .(isset($pagetitle) ? ' » ' . $pagetitle : '')); ?> - - + + + + + + + <?php echo filter($GLOBALS['sitename'] .(isset($pagetitle) ? ' » ' . $pagetitle : '')); ?> + + + +'; + } +} +?> + + + + + + + + + + + + + + + + + + + +'. $subtitle ."\n"; +} +if(DEBUG_MODE) { + echo '

'. 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.') ."

\n"; +} +if (isset($error) && $error!='') { + echo '

'. $error ."

\n"; +} +if (isset($msg) && $msg!='') { + echo '

'. $msg ."

\n"; +} +if (isset($tipMsg) && $tipMsg!='') { + echo '

'. $tipMsg ."

\n"; +} +?> diff --git a/doc/ChangeLog b/doc/ChangeLog index 8fa208c..ade19af 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -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 index 0000000..6f34a36 --- /dev/null +++ b/doc/themes.rst @@ -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/ + diff --git a/src/SemanticScuttle/Model/Template.php b/src/SemanticScuttle/Model/Template.php index ff5fbbe..234e23f 100644 --- a/src/SemanticScuttle/Model/Template.php +++ b/src/SemanticScuttle/Model/Template.php @@ -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 index 0000000..65861b8 --- /dev/null +++ b/src/SemanticScuttle/Model/Theme.php @@ -0,0 +1,97 @@ + + * @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 + * @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 diff --git a/src/SemanticScuttle/Service/Template.php b/src/SemanticScuttle/Service/Template.php index efa8d28..b5d4cfa 100644 --- a/src/SemanticScuttle/Service/Template.php +++ b/src/SemanticScuttle/Service/Template.php @@ -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; } } diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php index 098e5c3..6c0d4df 100644 --- a/src/SemanticScuttle/header.php +++ b/src/SemanticScuttle/header.php @@ -18,9 +18,12 @@ 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')) { diff --git a/www/jsScuttle.php b/www/jsScuttle.php index c166755..5e5f31b 100644 --- a/www/jsScuttle.php +++ b/www/jsScuttle.php @@ -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(images/loading.gif)'; + usernameField.style.backgroundImage = 'url(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(images/loading.gif)'; + title.style.backgroundImage = 'url(resource('images/loading.gif');?>)'; if (response != null) { title.style.backgroundImage = 'none'; title.value = response; diff --git a/www/icon.png b/www/themes/default/icon.png similarity index 100% rename from www/icon.png rename to www/themes/default/icon.png diff --git a/www/images/b_edit.png b/www/themes/default/images/b_edit.png similarity index 100% rename from www/images/b_edit.png rename to www/themes/default/images/b_edit.png diff --git a/www/images/bg_admin.png b/www/themes/default/images/bg_admin.png similarity index 100% rename from www/images/bg_admin.png rename to www/themes/default/images/bg_admin.png diff --git a/www/images/bg_bar.png b/www/themes/default/images/bg_bar.png similarity index 100% rename from www/images/bg_bar.png rename to www/themes/default/images/bg_bar.png diff --git a/www/images/bg_header.png b/www/themes/default/images/bg_header.png similarity index 100% rename from www/images/bg_header.png rename to www/themes/default/images/bg_header.png diff --git a/www/images/bg_sidebar.png b/www/themes/default/images/bg_sidebar.png similarity index 100% rename from www/images/bg_sidebar.png rename to www/themes/default/images/bg_sidebar.png diff --git a/www/images/loading.gif b/www/themes/default/images/loading.gif similarity index 100% rename from www/images/loading.gif rename to www/themes/default/images/loading.gif diff --git a/www/images/logo.png b/www/themes/default/images/logo.png similarity index 100% rename from www/images/logo.png rename to www/themes/default/images/logo.png diff --git a/www/images/logo_24.gif b/www/themes/default/images/logo_24.gif similarity index 100% rename from www/images/logo_24.gif rename to www/themes/default/images/logo_24.gif diff --git a/www/images/rss.gif b/www/themes/default/images/rss.gif similarity index 100% rename from www/images/rss.gif rename to www/themes/default/images/rss.gif diff --git a/www/images/thumbs_up.orig.png b/www/themes/default/images/thumbs_up.orig.png similarity index 100% rename from www/images/thumbs_up.orig.png rename to www/themes/default/images/thumbs_up.orig.png diff --git a/www/images/vote-against-voted.png b/www/themes/default/images/vote-against-voted.png similarity index 100% rename from www/images/vote-against-voted.png rename to www/themes/default/images/vote-against-voted.png diff --git a/www/images/vote-against.png b/www/themes/default/images/vote-against.png similarity index 100% rename from www/images/vote-against.png rename to www/themes/default/images/vote-against.png diff --git a/www/images/vote-for-voted.png b/www/themes/default/images/vote-for-voted.png similarity index 100% rename from www/images/vote-for-voted.png rename to www/themes/default/images/vote-for-voted.png diff --git a/www/images/vote-for.png b/www/themes/default/images/vote-for.png similarity index 100% rename from www/images/vote-for.png rename to www/themes/default/images/vote-for.png diff --git a/www/scuttle.css b/www/themes/default/scuttle.css similarity index 100% rename from www/scuttle.css rename to www/themes/default/scuttle.css diff --git a/www/themes/testdummy/images/logo.png b/www/themes/testdummy/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..4a8f8bae36399e501555db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U(OeXR?W#BCl*|k~w|K~OWG#aDKxBvhE07*qoM6N<$f*Z1#g#Z8m literal 0 HcmV?d00001 diff --git a/www/themes/testdummy/scuttle.css b/www/themes/testdummy/scuttle.css new file mode 100644 index 0000000..c62cd19 --- /dev/null +++ b/www/themes/testdummy/scuttle.css @@ -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; +}