summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/controllers/album.php20
-rw-r--r--core/helpers/core_installer.php2
-rw-r--r--core/libraries/Theme.php (renamed from core/helpers/theme.php)21
-rw-r--r--core/models/item.php18
-rw-r--r--core/tests/Theme_Test.php20
-rw-r--r--themes/default/views/album.html.php128
-rw-r--r--themes/default/views/footer.html.php7
-rw-r--r--themes/default/views/header.html.php53
-rw-r--r--themes/default/views/page_footer.html.php4
-rw-r--r--themes/default/views/page_header.html.php30
-rw-r--r--themes/default/views/sidebar.html.php (renamed from themes/default/views/page_sidebar.html.php)0
11 files changed, 178 insertions, 125 deletions
diff --git a/core/controllers/album.php b/core/controllers/album.php
index a22e5eeb..b1c7d205 100644
--- a/core/controllers/album.php
+++ b/core/controllers/album.php
@@ -18,28 +18,16 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Album_Controller extends Template_Controller {
- public $template = "page.html";
+ public $template = "album.html";
public function View($id) {
$item = ORM::factory("item")->where("id", $id)->find();
if (empty($item->id)) {
return Kohana::show_404();
}
- $this->template->item = $item;
-
- $this->template->header = new View("page_header.html");
- $this->template->header->item = $item;
-
- $this->template->footer = new View("page_footer.html");
- $this->template->footer->item = $item;
-
- $this->template->content = new View("album.html");
- $this->template->content->item = $item;
- $this->template->content->maxRows = 3;
- $this->template->content->maxColumns = 3;
-
- $this->template->sidebar = new View("page_sidebar.html");
- $this->template->sidebar->item = $item;
+ $this->template->set_global('item', $item);
+ $this->template->set_global('children', $item->get_children());
+ $this->template->set_global('theme', new Theme("default", $this->template));
}
}
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index 9dd5224c..ea01a0c0 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -43,6 +43,7 @@ class core_installer {
`id` int(9) NOT NULL auto_increment,
`type` char(32) default NULL,
`title` char(255) default NULL,
+ `description` char(255) default NULL,
`path` char(255) default NULL,
`left` int(9) default NULL,
`right` int(9) default NULL,
@@ -64,6 +65,7 @@ class core_installer {
$root = ORM::factory("item");
$root->title = "Gallery";
+ $root->description = "Welcome to your Gallery3";
$root->make_root();
}
}
diff --git a/core/helpers/theme.php b/core/libraries/Theme.php
index 5aa568c7..924e978c 100644
--- a/core/helpers/theme.php
+++ b/core/libraries/Theme.php
@@ -18,16 +18,17 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class theme_Core {
- public static $debug_backtrace = "debug_backtrace";
+ private $theme_name = null;
- public static function url($path) {
- // Using debug_backtrace() sucks. But I don't know of another way to get
- // the location of the caller without forcing them to pass it in as an argument, which
- // makes for a crappy API.
- $backtrace = call_user_func(theme::$debug_backtrace);
- $calling_file = $backtrace[1]['file'];
- $theme_name = substr($calling_file, strlen(THEMEPATH));
- $theme_name = substr($theme_name, 0, strcspn($theme_name, "/"));
- return url::base() . "themes/{$theme_name}/$path";
+ public function __construct($theme_name) {
+ $this->theme_name = $theme_name;
+ }
+
+ public function url($path) {
+ return url::base() . "themes/{$this->theme_name}/$path";
+ }
+
+ public function display($page_name, $view_class="View") {
+ return new $view_class($page_name);
}
}
diff --git a/core/models/item.php b/core/models/item.php
index b8957911..8b08b699 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -20,4 +20,22 @@
class Item_Model extends MPTT {
protected $left_column = "left";
protected $right_column = "right";
+
+ public function is_album() {
+ return $this->type == 'album';
+ }
+
+ public function is_photo() {
+ return $this->type == 'photo';
+ }
+
+ // MPTT::get_children returns null if there are no children; change that to an empty array for
+ // consistency.
+ public function get_children() {
+ $children = parent::get_children();
+ if (empty($children)) {
+ $children = array();
+ }
+ return $children;
+ }
}
diff --git a/core/tests/Theme_Test.php b/core/tests/Theme_Test.php
index 5b568b19..f73a98eb 100644
--- a/core/tests/Theme_Test.php
+++ b/core/tests/Theme_Test.php
@@ -19,16 +19,22 @@
*/
class Theme_Test extends Unit_Test_Case {
- public function teardown() {
- theme::$debug_backtrace = "debug_backtrace";
+ public function url_test() {
+ $theme = new Theme("fake_theme");
+ $this->assert_equal("http://./themes/fake_theme/file", $theme->url("file"));
}
- public function url_test() {
- theme::$debug_backtrace = array("Theme_Test", "_fake_debug_backtrace");
- $this->assert_equal("http://./themes/fake_theme/file", theme::url("file"));
+ public function display_test() {
+ $theme = new Theme("fake_theme");
+ $view = $theme->display("test_page", "Theme_Test_Mock_View");
+ $this->assert_equal("test_page", $view->page_name);
}
+}
+
+class Theme_Test_Mock_View {
+ public $page_name = null;
- public function _fake_debug_backtrace() {
- return array(array(), array('file' => THEMEPATH . "fake_theme/views/some_file.html.php"));
+ public function __construct($page_name) {
+ $this->page_name = $page_name;
}
} \ No newline at end of file
diff --git a/themes/default/views/album.html.php b/themes/default/views/album.html.php
index 10930daa..2abb810f 100644
--- a/themes/default/views/album.html.php
+++ b/themes/default/views/album.html.php
@@ -1,72 +1,84 @@
<? defined("SYSPATH") or die("No direct script access."); ?>
-<script type="text/javascript">
- myTooltip = new YAHOO.widget.Tooltip("myTooltip", {
- context:"photo-id-1",
- text:"<strong>Photo title</strong><br />taken December 24, 2007<br />Viewed 27 times<br /><br/>Tags: christmas, familiy, home, xmas",
- showDelay:500 } );
-</script>
+<?= $theme->display('header.html') ?>
-<div id="gAlbumGrid">
- <div id="gAlbumGridHeader">
- <h1>Christmas 2007</h1>
- <span class="understate">(interesting information about the Album)</span>
- <a href="#" id="gSlideshowLink" class="buttonlink">Slideshow</a>
- </div>
+<div id="bd">
+ <div id="yui-main">
+ <div id="gContent" class="yui-b">
+ <script type="text/javascript">
+ myTooltip = new YAHOO.widget.Tooltip("myTooltip", {
+ context:"photo-id-1",
+ text:"<strong>Photo title</strong><br />taken December 24, 2007<br />Viewed 27 times<br /><br/>Tags: christmas, familiy, home, xmas",
+ showDelay:500 } );
+ </script>
- <div class="gAlbumContainer first gAlbum">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Album title</h2>
- <ul class="gMetadata">
- <li>Views: 321</li>
- <li>By: <a href="#">username</a></li>
- </ul>
- </div>
+ <div id="gAlbumGrid">
+ <div id="gAlbumGridHeader">
+ <h1><?= $item->title ?></h1>
+ <span class="understate"><?= $item->description ?></span>
+ <a href="#" id="gSlideshowLink" class="buttonlink">Slideshow</a>
+ </div>
- <div class="gItemContainer">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gAlbumContainer first gAlbum">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Album title</h2>
+ <ul class="gMetadata">
+ <li>Views: 321</li>
+ <li>By: <a href="#">username</a></li>
+ </ul>
+ </div>
- <div class="gItemContainer">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gItemContainer">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
- <div class="gItemContainer first">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gItemContainer">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
- <div class="gItemContainer">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gItemContainer first">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
- <div class="gItemContainer">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gItemContainer">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
- <div class="gItemContainer first">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gItemContainer">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
- <div class="gItemContainer">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gItemContainer first">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
- <div class="gItemContainer">
- <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= theme::url("images/thumbnail.jpg") ?>" /></a>
- <h2>Photo title</h2>
- </div>
+ <div class="gItemContainer">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
- <div id="gPagination">
- Items 1-10 of 34
- <span class="first_inactive">first</span>
- <span class="previous_inactive">previous</span>
- <a href="#" class="next">next</a>
- <a href="#" class="last">last</a>
+ <div class="gItemContainer">
+ <a href="photo.html"><img id="photo-id-1" class="photo" alt="photo" src="<?= $theme->url("images/thumbnail.jpg") ?>" /></a>
+ <h2>Photo title</h2>
+ </div>
+
+ <div id="gPagination">
+ Items 1-10 of 34
+ <span class="first_inactive">first</span>
+ <span class="previous_inactive">previous</span>
+ <a href="#" class="next">next</a>
+ <a href="#" class="last">last</a>
+ </div>
+ </div>
+
+ </div>
</div>
+ <?= $theme->display('sidebar.html') ?>
</div>
+
+<?= $theme->display('footer.html') ?>
diff --git a/themes/default/views/footer.html.php b/themes/default/views/footer.html.php
new file mode 100644
index 00000000..ab40a417
--- /dev/null
+++ b/themes/default/views/footer.html.php
@@ -0,0 +1,7 @@
+<? defined("SYSPATH") or die("No direct script access."); ?>
+ <div id="gFooter">
+ Powered by <a href="#">GalleryX</a> | <a href="#">About this Gallery</a> | ...
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/themes/default/views/header.html.php b/themes/default/views/header.html.php
new file mode 100644
index 00000000..797dcb7c
--- /dev/null
+++ b/themes/default/views/header.html.php
@@ -0,0 +1,53 @@
+<? defined("SYSPATH") or die("No direct script access."); ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tranisitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <title>Browse Photos :: <?= $item->title ?></title>
+
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fonts-grids.css" />
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/base/base-min.css" />
+ <link rel="stylesheet" type="text/css" href="<?= $theme->url("css/styles.css") ?>" media="screen,projection" />
+
+ <!-- CSS -->
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/container/assets/container.css" />
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/animation/animation-min.js"></script>
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/container/container-min.js"></script>
+
+ <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/treeview/assets/skins/sam/treeview.css" />
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/treeview/treeview-min.js"></script>
+ </head>
+
+ <body class="yui-skin-sam">
+ <div id="doc2" class="yui-t5 gAlbumView">
+ <div id="gHeader">
+ <img id="gLogo" alt="<?= _("Logo") ?>" src="<?= $theme->url("images/logo.png") ?>" />
+
+ <h1><?= $item->title ?></h1>
+
+ <div id="gLoginMenu">
+ <a href="#"><?= _("Register") ?></a> |
+ <a href="#"><?= _("Login") ?>
+ </div>
+
+ <ul id="gSiteMenu">
+ <li><a href="index.html"><?= _("HOME") ?></a></li>
+ <li><a class="active" href="browse.html"><?= _("BROWSE") ?></a></li>
+ <li><a href="upload.html"><?= _("UPLOAD") ?></a></li>
+ <li><a href="upload.html"><?= _("MY GALLERY") ?></a></li>
+ <li><a href="#"><?= _("ADMIN") ?></a></li>
+ </ul>
+
+ <ul id="gBreadcrumbs">
+ <li class="root"><a href="#">Home</a></li>
+ <li><a href="#">Friends &amp; Family</a></li>
+ <li class="active"><span>Christmas 2007</span></li>
+ </ul>
+
+ <form id="gSearchForm">
+ <input type="text" class="text" value="<?= _("Search Gallery ...") ?>"/>
+ <input type="submit" class="submit" value="search" />
+ </form>
+ </div>
diff --git a/themes/default/views/page_footer.html.php b/themes/default/views/page_footer.html.php
deleted file mode 100644
index 4e15fbff..00000000
--- a/themes/default/views/page_footer.html.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<? defined("SYSPATH") or die("No direct script access."); ?>
-<div id="gFooter">
- Powered by <a href="#">GalleryX</a> | <a href="#">About this Gallery</a> | ...
-</div>
diff --git a/themes/default/views/page_header.html.php b/themes/default/views/page_header.html.php
deleted file mode 100644
index 58eb8847..00000000
--- a/themes/default/views/page_header.html.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<? defined("SYSPATH") or die("No direct script access."); ?>
-<div id="gHeader">
- <img id="gLogo" alt="<?= _("Logo") ?>" src="<?= theme::url("images/logo.png") ?>" />
-
- <h1><?= $item->title ?></h1>
-
- <div id="gLoginMenu">
- <a href="#"><?= _("Register") ?></a> |
- <a href="#"><?= _("Login") ?>
- </div>
-
- <ul id="gSiteMenu">
- <li><a href="index.html"><?= _("HOME") ?></a></li>
- <li><a class="active" href="browse.html"><?= _("BROWSE") ?></a></li>
- <li><a href="upload.html"><?= _("UPLOAD") ?></a></li>
- <li><a href="upload.html"><?= _("MY GALLERY") ?></a></li>
- <li><a href="#"><?= _("ADMIN") ?></a></li>
- </ul>
-
- <ul id="gBreadcrumbs">
- <li class="root"><a href="#">Home</a></li>
- <li><a href="#">Friends &amp; Family</a></li>
- <li class="active"><span>Christmas 2007</span></li>
- </ul>
-
- <form id="gSearchForm">
- <input type="text" class="text" value="<?= _("Search Gallery ...") ?>"/>
- <input type="submit" class="submit" value="search" />
- </form>
-</div>
diff --git a/themes/default/views/page_sidebar.html.php b/themes/default/views/sidebar.html.php
index 923b4e4e..923b4e4e 100644
--- a/themes/default/views/page_sidebar.html.php
+++ b/themes/default/views/sidebar.html.php