1
0

Swith views to page.html and dynamic.html and use Gallery's breadcrumb object.

This commit is contained in:
rWatcher 2012-05-16 21:11:06 -04:00
parent 341e062c53
commit c72024db1d
4 changed files with 71 additions and 320 deletions

View File

@ -144,19 +144,7 @@ class tag_albums_Controller extends Controller {
// Figure out which items to display on this page and store their details in $children.
$tag_children = $this->_get_records($tag_ids, $page_size, $offset, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
$children_array = Array();
foreach ($tag_children as $one_child) {
$child_tag = new Tag_Albums_Item($one_child->title, url::site("tag_albums/show/" . $one_child->id . "/0/" . $id . "/" . urlencode($one_child->name)), $one_child->type, $one_child->id);
$child_tag->id = $one_child->id;
$child_tag->view_count = $one_child->view_count;
$child_tag->owner = identity::lookup_user($one_child->owner_id);
if ($one_child->has_thumb()) {
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
}
$children_array[] = $child_tag;
}
$children = new Tag_Albums_Children($children_array);
// Set up the previous and next page buttons.
if ($page > 1) {
$previous_page = $page - 1;
@ -168,34 +156,41 @@ class tag_albums_Controller extends Controller {
}
// Set up breadcrumbs.
$tag_album_breadcrumbs = Array();
$tag_album_breadcrumbs = array();
$counter = 0;
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($album->title, "");
$tag_album_breadcrumbs[] = Breadcrumb::instance($album->title, $album->url())->set_last();
$parent_item = ORM::factory("item", $album->parent_id);
while ($parent_item->id != 1) {
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
$tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url());
$parent_item = ORM::factory("item", $parent_item->parent_id);
}
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
$tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url())->set_first();
$tag_album_breadcrumbs[1]->url .= "?show=" . $album->id;
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
// Set up and display the actual page.
$parent_album = ORM::factory("item", $album->parent_id);
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
//$template = new Theme_View("calpage.html", "collection", "Tag Albums");
$template = new Theme_View("page.html", "collection", "Tag Albums");
$template->set_global(
array("page" => $page,
"max_pages" => $max_pages,
"page_size" => $page_size,
"children" => $tag_children,
"breadcrumbs" => $tag_album_breadcrumbs,
"children_count" => $count));
$template->page_title = $page_title;
$template->set_global("page", $page);
$template->set_global("page_size", $page_size);
$template->set_global("max_pages", $max_pages);
$template->set_global("children", $children);
$template->set_global("all_siblings", $this->_get_records($tag_ids, $count, 0, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false));
$template->set_global("children_count", $count);
$template->set_global("parent_url", $parent_album->url()); // Used by Grey Dragon.
$template->content = new View("tag_albums_album.html");
$template->content = new View("dynamic.html");
$template->content->title = $page_title;
$template->content->description = $page_description;
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
$template->set_global("all_siblings", $this->_get_records($tag_ids, $count, 0, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false));
$template->set_global("parent_url", $parent_album->url()); // Used by Grey Dragon.
print $template;
// Set breadcrumbs on the photo pages to point back to the calendar day view.
//item::set_display_context_callback("CalendarView_Controller::get_display_day_context", $display_user, $display_year, $display_month, $display_day);
}
}
@ -411,36 +406,38 @@ class tag_albums_Controller extends Controller {
$parent_url = "";
if ($id > 0) {
$counter = 0;
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($album->title, "");
$tag_album_breadcrumbs[] = Breadcrumb::instance($album->title, $album->url())->set_last();
$parent_item = ORM::factory("item", $album->parent_id);
$parent_url = $parent_item->url();
while ($parent_item->id != 1) {
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
$tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url());
$parent_item = ORM::factory("item", $parent_item->parent_id);
}
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
$tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url())->set_first();
$tag_album_breadcrumbs[1]->url .= "?show=" . $album->id;
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
} else {
$parent_url = item::root()->url();
$tag_album_breadcrumbs[0] = new Tag_Albums_Breadcrumb(item::root()->title, item::root()->url());
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb($page_title, "");
$tag_album_breadcrumbs[] = Breadcrumb::instance(item::root()->title, item::root()->url())->set_first();
$tag_album_breadcrumbs[] = Breadcrumb::instance($page_title, $str_page_url)->set_first();
}
// Set up and display the actual page.
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
$template = new Theme_View("page.html", "collection", "Tag Albums");
$template->set_global(
array("page" => $page,
"max_pages" => $max_pages,
"page_size" => $page_size,
"children" => $children,
"breadcrumbs" => $tag_album_breadcrumbs,
"children_count" => $all_tags_count));
$template->page_title = $page_title;
$template->set_global("page", $page);
$template->set_global("page_size", $page_size);
$template->set_global("max_pages", $max_pages);
$template->set_global("children", $children);
$template->set_global("children_count", $all_tags_count);
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
$template->content = new View("tag_albums_album.html");
$template->content = new View("dynamic.html");
$template->content->title = $page_title;
$template->content->description = $page_description;
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
$template->content->filter_text = $this->_get_filter_html($id, $filter);
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
print $template;
}
@ -510,20 +507,6 @@ class tag_albums_Controller extends Controller {
// Figure out which items to display on this page.
$tag_children = $this->_get_records(Array($id), $page_size, $offset, "items." . $sort_page_field, $sort_page_direction, "OR", true);
// Create an array of "fake" items to display on the page.
$children_array = Array();
foreach ($tag_children as $one_child) {
$child_tag = new Tag_Albums_Item($one_child->title, url::site("tag_albums/show/" . $one_child->id . "/" . $id . "/" . $album_id . "/" . urlencode($one_child->name)), $one_child->type, $one_child->id);
$child_tag->id = $one_child->id;
$child_tag->view_count = $one_child->view_count;
$child_tag->owner = identity::lookup_user($one_child->owner_id);
if ($one_child->has_thumb()) {
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
}
$children_array[] = $child_tag;
}
$children = new Tag_Albums_Children($children_array);
// Set up the previous and next page buttons.
if ($page > 1) {
@ -540,52 +523,68 @@ class tag_albums_Controller extends Controller {
$parent_url = "";
if ($album_id > 0) {
$counter = 0;
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($display_tag->name, "");
//$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($display_tag->name, "");
$tag_album_breadcrumbs[] = Breadcrumb::instance($display_tag->name, $str_page_url)->set_last();
$parent_item = ORM::factory("item", $album_tags[0]->album_id);
if ($album_tags[0]->tags != "*") {
$parent_item = ORM::factory("item", $parent_item->parent_id);
}
$parent_url = $parent_item->url(); // Used by Grey Dragon.
while ($parent_item->id != 1) {
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
//$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
$tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url());
$parent_item = ORM::factory("item", $parent_item->parent_id);
}
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
//$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, $parent_item->url());
$tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url())->set_first();
$parent_item = ORM::factory("item", $album_tags[0]->album_id);
/*
if ((module::get_var("tag_albums", "tag_index_scope", "false")) && (module::get_var("tag_albums", "tag_index", "default") != "default")) {
$tag_album_breadcrumbs[1]->url = url::site("tag_albums/album/" . $album_id . "/" . urlencode($parent_item->name));
} else {
$tag_album_breadcrumbs[1]->url = url::site("tag_albums/album/" . $album_id . "/" . urlencode($parent_item->name)) . "?show=" . $id;
}
*/
$tag_album_breadcrumbs[1]->url .= "?show=" . $id;
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
} else {
$parent_url = url::site("tag_albums/");
$tag_album_breadcrumbs[0] = new Tag_Albums_Breadcrumb(item::root()->title, item::root()->url());
//$tag_album_breadcrumbs[0] = new Tag_Albums_Breadcrumb(item::root()->title, item::root()->url());
$tag_album_breadcrumbs[] = Breadcrumb::instance(item::root()->title, item::root()->url())->set_first();
if (module::get_var("tag_albums", "tag_index", "default") == "default") {
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb(module::get_var("tag_albums", "tag_page_title", "All Tags"), url::site("tag_albums/") . "?show=" . $id);
//$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb(module::get_var("tag_albums", "tag_page_title", "All Tags"), url::site("tag_albums/") . "?show=" . $id);
$tag_album_breadcrumbs[] = Breadcrumb::instance(module::get_var("tag_albums", "tag_page_title", "All Tags"), url::site("tag_albums/") . "?show=" . $id);
} else {
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb(module::get_var("tag_albums", "tag_page_title", "All Tags"), url::site("tag_albums/"));
//$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb(module::get_var("tag_albums", "tag_page_title", "All Tags"), url::site("tag_albums/"));
$tag_album_breadcrumbs[] = Breadcrumb::instance(module::get_var("tag_albums", "tag_page_title", "All Tags"), url::site("tag_albums/"));
}
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, "");
//$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, "");
$tag_album_breadcrumbs[] = Breadcrumb::instance($display_tag->name, $str_page_url)->set_last();
}
// Set up and display the actual page.
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
$template = new Theme_View("page.html", "collection", "Tag Albums");
$template->set_global(
array("page" => $page,
"max_pages" => $max_pages,
"page_size" => $page_size,
"children" => $tag_children,
"breadcrumbs" => $tag_album_breadcrumbs,
"children_count" => $count));
$template->page_title = $display_tag->name;
$template->set_global("page", $page);
$template->set_global("page_size", $page_size);
$template->set_global("max_pages", $max_pages);
$template->set_global("children", $children);
$template->set_global("all_siblings", $this->_get_records(Array($id), $count, 0, "items." . $sort_page_field, $sort_page_direction, "OR", false));
$template->set_global("children_count", $count);
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
$template->content = new View("tag_albums_album.html");
$template->content = new View("dynamic.html");
$template->content->title = $display_tag->name;
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
//$template->content->description = $page_description;
$template->set_global("all_siblings", $this->_get_records(Array($id), $count, 0, "items." . $sort_page_field, $sort_page_direction, "OR", false));
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
print $template;
}
public function show($item_id, $tag_id, $album_id) {
$item = ORM::factory("item", $item_id);
url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
// Display the specified photo or video ($item_id) with breadcrumbs
// that point back to a virtual album ($tag_id / $album_id).

View File

@ -1,31 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2012 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Tag_Albums_Breadcrumb_Core {
// Creates a class to maintain a single breadcrumb.
// Multiple breadcrumbs can be achieved by createing an array of this class type.
public $title = "";
public $id = 1;
public $url = "";
public function __construct($new_title, $new_url) {
$this->title = $new_title;
$this->url = $new_url;
}
}

View File

@ -1,167 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?= $theme->html_attributes() ?> xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<? $theme->start_combining("script,css") ?>
<title>
<? if ($page_title): ?>
<?= $page_title ?>
<? else: ?>
<? if ($theme->item()): ?>
<?= $theme->item()->title ?>
<? elseif ($theme->tag()): ?>
<?= t("Photos tagged with %tag_title", array("tag_title" => $theme->tag()->name)) ?>
<? else: /* Not an item, not a tag, no page_title specified. Help! */ ?>
<?= item::root()->title ?>
<? endif ?>
<? endif ?>
</title>
<link rel="shortcut icon"
href="<?= url::file(module::get_var("gallery", "favicon_url")) ?>"
type="image/x-icon" />
<link rel="apple-touch-icon-precomposed"
href="<?= url::file(module::get_var("gallery", "apple_touch_icon_url")) ?>" />
<? if ($theme->page_type == "collection"): ?>
<? if (($thumb_proportion = $theme->thumb_proportion($theme->item())) != 1): ?>
<? $new_width = round($thumb_proportion * 213) ?>
<? $new_height = round($thumb_proportion * 240) ?>
<style type="text/css">
.g-view #g-content #g-album-grid .g-item {
width: <?= $new_width ?>px;
height: <?= $new_height ?>px;
/* <?= $thumb_proportion ?> */
}
</style>
<? endif ?>
<? endif ?>
<?= $theme->script("json2-min.js") ?>
<?= $theme->script("jquery.js") ?>
<?= $theme->script("jquery.form.js") ?>
<?= $theme->script("jquery-ui.js") ?>
<?= $theme->script("gallery.common.js") ?>
<? /* MSG_CANCEL is required by gallery.dialog.js */ ?>
<script type="text/javascript">
var MSG_CANCEL = <?= t('Cancel')->for_js() ?>;
</script>
<?= $theme->script("gallery.ajax.js") ?>
<?= $theme->script("gallery.dialog.js") ?>
<?= $theme->script("superfish/js/superfish.js") ?>
<?= $theme->script("jquery.localscroll.js") ?>
<? /* These are page specific but they get combined */ ?>
<? if ($theme->page_subtype == "photo"): ?>
<?= $theme->script("jquery.scrollTo.js") ?>
<?= $theme->script("gallery.show_full_size.js") ?>
<? elseif ($theme->page_subtype == "movie"): ?>
<?= $theme->script("flowplayer.js") ?>
<? endif ?>
<?= $theme->head() ?>
<? /* Theme specific CSS/JS goes last so that it can override module CSS/JS */ ?>
<?= $theme->script("ui.init.js") ?>
<?= $theme->css("yui/reset-fonts-grids.css") ?>
<?= $theme->css("superfish/css/superfish.css") ?>
<?= $theme->css("themeroller/ui.base.css") ?>
<?= $theme->css("screen.css") ?>
<? if (locales::is_rtl()): ?>
<?= $theme->css("screen-rtl.css") ?>
<? endif; ?>
<!--[if lte IE 8]>
<link rel="stylesheet" type="text/css" href="<?= $theme->url("css/fix-ie.css") ?>"
media="screen,print,projection" />
<![endif]-->
<!-- LOOKING FOR YOUR CSS? It's all been combined into the link below -->
<?= $theme->get_combined("css") ?>
<!-- LOOKING FOR YOUR JAVASCRIPT? It's all been combined into the link below -->
<?= $theme->get_combined("script") ?>
</head>
<body <?= $theme->body_attributes() ?>>
<?= $theme->page_top() ?>
<div id="doc4" class="yui-t5 g-view">
<?= $theme->site_status() ?>
<div id="g-header" class="ui-helper-clearfix">
<div id="g-banner">
<? if ($header_text = module::get_var("gallery", "header_text")): ?>
<?= $header_text ?>
<? else: ?>
<a id="g-logo" class="g-left" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>">
<img width="107" height="48" alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= url::file("lib/images/logo.png") ?>" />
</a>
<? endif ?>
<?= $theme->user_menu() ?>
<?= $theme->header_top() ?>
<!-- hide the menu until after the page has loaded, to minimize menu flicker -->
<div id="g-site-menu" style="visibility: hidden">
<?= $theme->site_menu($theme->item() ? "#g-item-id-{$theme->item()->id}" : "") ?>
</div>
<script type="text/javascript"> $(document).ready(function() { $("#g-site-menu").css("visibility", "visible"); }) </script>
<?= $theme->header_bottom() ?>
</div>
<? // rWatcher Edit: The following code was modifed to allow module-defined breadcrumbs.
// Everything else in this file is a copy of the default page.html.php file.
?>
<? if (!empty($breadcrumbs)): ?>
<ul class="g-breadcrumbs">
<? $i = 0 ?>
<? foreach ($breadcrumbs as $breadcrumb): ?>
<li<? if ($i == 0) print " class=\"g-first\"" ?>>
<!-- Adding ?show=<id> causes Gallery3 to display the page
containing that photo. For now, we just do it for
the immediate parent so that when you go back up a
level you're on the right page. -->
<? if ($breadcrumb->url) : ?>
<a href="<?= $breadcrumb->url ?>">
<?= html::purify(text::limit_chars($breadcrumb->title, module::get_var("gallery", "visible_title_length"))) ?>
</a>
<? else : ?>
<?= html::purify(text::limit_chars($breadcrumb->title, module::get_var("gallery", "visible_title_length"))) ?>
<? endif ?>
</li>
<? $i++ ?>
<? endforeach ?>
</ul>
<? endif ?>
<? // End modified code ?>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<div id="g-content" class="yui-g">
<?= $theme->messages() ?>
<?= $content ?>
</div>
</div>
</div>
<div id="g-sidebar" class="yui-b">
<? if ($theme->page_subtype != "login"): ?>
<?= new View("sidebar.html") ?>
<? endif ?>
</div>
</div>
<div id="g-footer" class="ui-helper-clearfix">
<?= $theme->footer() ?>
<? if ($footer_text = module::get_var("gallery", "footer_text")): ?>
<?= $footer_text ?>
<? endif ?>
<? if (module::get_var("gallery", "show_credits")): ?>
<ul id="g-credits" class="g-inline">
<?= $theme->credits() ?>
</ul>
<? endif ?>
</div>
</div>
<?= $theme->page_bottom() ?>
</body>
</html>

View File

@ -1,50 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
// The g-info block was taken from album.html.php and $theme->album_top() was changed to $theme->dynamic_top().
// $item->title and $item->description have been changed to $title and $description.
//
// The g-album-grid block was also taken from album.html.php. The section for uploading new photos to an empty album
// has been removed. Also, $theme->context_menu has been removed as well (it was crashing the page).
?>
<div id="g-info">
<?= $theme->dynamic_top() ?>
<h1><?= html::purify($title) ?></h1>
<div class="g-description"><?= nl2br(html::purify($description)) ?></div>
</div>
<? if (isset($filter_text) && (module::get_var("tag_albums", "tag_index_filter"))): ?>
<div id="g-tags-filter">
<br/ >
<center><?= $filter_text; ?></center>
</div>
<? endif ?>
<ul id="g-album-grid" class="ui-helper-clearfix">
<? if (count($children)): ?>
<? foreach ($children as $i => $child): ?>
<? $item_class = "g-photo"; ?>
<? if ($child->is_album()): ?>
<? $item_class = "g-album"; ?>
<? endif ?>
<li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">
<?= $theme->thumb_top($child) ?>
<a href="<?= $child->url() ?>">
<? if ($child->has_thumb()): ?>
<?= $child->thumb_img(array("class" => "g-thumbnail")) ?>
<? endif ?>
</a>
<?= $theme->thumb_bottom($child) ?>
<h2><span class="<?= $item_class ?>"></span>
<a href="<?= $child->url() ?>"><?= html::purify($child->title) ?></a></h2>
<ul class="g-metadata">
<?= $theme->thumb_info($child) ?>
</ul>
</li>
<? endforeach ?>
<? else: ?>
<li><?= t("There aren't any photos here yet!") ?></li>
<? endif; ?>
</ul>
<?= $theme->dynamic_bottom() ?>
<?= $theme->paginator() ?>