summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Model
diff options
context:
space:
mode:
authorMark Pemberton <mpemberton5@gmail.com>2011-06-04 00:38:07 -0400
committerMark Pemberton <mpemberton5@gmail.com>2011-06-04 00:38:07 -0400
commitb628e63e015bc3b2eadc712feaa6c4d05cf75bbd (patch)
treeebdcec5c8133a3b6f86d06dc3f6fb3de46609f04 /src/SemanticScuttle/Model
parent84e603aa91a303a1419962ff3ff6086710a7b1a9 (diff)
parent4c8a53c5bc632302aaf8978e711eb53a03166db5 (diff)
downloadsemanticscuttle-b628e63e015bc3b2eadc712feaa6c4d05cf75bbd.tar.gz
semanticscuttle-b628e63e015bc3b2eadc712feaa6c4d05cf75bbd.tar.bz2
Merge branch 'master' into privatekey2
Conflicts: data/templates/default/bookmarks.tpl.php
Diffstat (limited to 'src/SemanticScuttle/Model')
-rw-r--r--src/SemanticScuttle/Model/Template.php3
-rw-r--r--src/SemanticScuttle/Model/Theme.php97
2 files changed, 100 insertions, 0 deletions
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 @@
+<?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