Add filter support, plus other bug fixes and improvements.
This commit is contained in:
parent
93f2974783
commit
dea88b79c4
@ -34,7 +34,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// If it does exist, and is set to *, load a list of all tags.
|
// If it does exist, and is set to *, load a list of all tags.
|
||||||
if ($album_tags[0]->tags == "*") {
|
if ($album_tags[0]->tags == "*") {
|
||||||
$this->index($id);
|
$this->index($id, "");
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, populate this page with the specified items.
|
// Otherwise, populate this page with the specified items.
|
||||||
|
|
||||||
@ -58,12 +58,23 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
$album_tags_search_type = $album_tags[0]->search_type;
|
$album_tags_search_type = $album_tags[0]->search_type;
|
||||||
|
|
||||||
// Figure out how many items are in this "virtual album"
|
|
||||||
$count = $this->_count_records($tag_ids, $album_tags_search_type, true);
|
|
||||||
|
|
||||||
// Figure out how many items to display on each page.
|
// Figure out how many items to display on each page.
|
||||||
$page_size = module::get_var("gallery", "page_size", 9);
|
$page_size = module::get_var("gallery", "page_size", 9);
|
||||||
|
|
||||||
|
// If this page was reached from a breadcrumb, figure out what page to load from the show id.
|
||||||
|
$show = Input::instance()->get("show");
|
||||||
|
if ($show) {
|
||||||
|
$child = ORM::factory("item", $show);
|
||||||
|
$index = $this->_get_position($child->$sort_page_field, $child->id, $tag_ids, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
|
||||||
|
if ($index) {
|
||||||
|
$page = ceil($index / $page_size);
|
||||||
|
url::redirect("tag_albums/album/" . $id . "?page=$page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Figure out how many items are in this "virtual album"
|
||||||
|
$count = $this->_count_records($tag_ids, $album_tags_search_type, true);
|
||||||
|
|
||||||
// Figure out which page # the visitor is on and
|
// Figure out which page # the visitor is on and
|
||||||
// don't allow the visitor to go below page 1.
|
// don't allow the visitor to go below page 1.
|
||||||
$page = Input::instance()->get("page", 1);
|
$page = Input::instance()->get("page", 1);
|
||||||
@ -86,8 +97,10 @@ class tag_albums_Controller extends Controller {
|
|||||||
$tag_children = $this->_get_records($tag_ids, $page_size, $offset, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
|
$tag_children = $this->_get_records($tag_ids, $page_size, $offset, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
|
||||||
$children = Array();
|
$children = Array();
|
||||||
foreach ($tag_children as $one_child) {
|
foreach ($tag_children as $one_child) {
|
||||||
$child_tag = new Tag_Albums_Item($one_child->name, url::site("tag_albums/show/" . $one_child->id . "/0/" . $id), $one_child->type);
|
$child_tag = new Tag_Albums_Item($one_child->title, url::site("tag_albums/show/" . $one_child->id . "/0/" . $id), $one_child->type);
|
||||||
$child_tag->id = $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()) {
|
if ($one_child->has_thumb()) {
|
||||||
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
||||||
}
|
}
|
||||||
@ -114,17 +127,20 @@ class tag_albums_Controller extends Controller {
|
|||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url .= "?show=" . $album->id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
|
|
||||||
// Set up and display the actual page.
|
// Set up and display the actual page.
|
||||||
$template = new Theme_View("page.html", "collection", "Tag Albums");
|
$parent_album = ORM::factory("item", $album->parent_id);
|
||||||
|
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
|
||||||
$template->page_title = $page_title;
|
$template->page_title = $page_title;
|
||||||
$template->set_global("page", $page);
|
$template->set_global("page", $page);
|
||||||
$template->set_global("page_size", $page_size);
|
$template->set_global("page_size", $page_size);
|
||||||
$template->set_global("max_pages", $max_pages);
|
$template->set_global("max_pages", $max_pages);
|
||||||
$template->set_global("children", $children);
|
$template->set_global("children", $children);
|
||||||
$template->set_global("children_count", $count);
|
$template->set_global("children_count", $count);
|
||||||
$template->content = new View("tag_albums.html");
|
$template->set_global("parent_url", $parent_album->url()); // Used by Grey Dragon.
|
||||||
|
$template->content = new View("tag_albums_album.html");
|
||||||
$template->content->title = $page_title;
|
$template->content->title = $page_title;
|
||||||
$template->content->description = $page_description;
|
$template->content->description = $page_description;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
@ -132,9 +148,27 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index($id) {
|
public function filter($id, $filter) {
|
||||||
|
// Display the index page, but only show albums for
|
||||||
|
// tags whose name begins with $filter.
|
||||||
|
$this->index($id, $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index($id, $filter) {
|
||||||
// Load a page containing sub-albums for each tag in the gallery.
|
// Load a page containing sub-albums for each tag in the gallery.
|
||||||
|
|
||||||
|
// Check to see if the user has overridden default behavior, and act accordingly.
|
||||||
|
if ((module::get_var("tag_albums", "tag_index_scope", "false")) || ($id == "")) {
|
||||||
|
$tag_album_index_type = module::get_var("tag_albums", "tag_index", "default");
|
||||||
|
if (($tag_album_index_type == "tagcloudpage") && (module::is_active("tag_cloud_page"))) {
|
||||||
|
Tag_Cloud_Page_Controller::index();
|
||||||
|
return;
|
||||||
|
} elseif (($tag_album_index_type == "alltags") && (module::is_active("all_tags"))) {
|
||||||
|
All_Tags_Controller::index();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If an ID was specified, make sure it's valid.
|
// If an ID was specified, make sure it's valid.
|
||||||
$album_tags = ORM::factory("tags_album_id")
|
$album_tags = ORM::factory("tags_album_id")
|
||||||
->where("id", "=", $id)
|
->where("id", "=", $id)
|
||||||
@ -165,6 +199,40 @@ class tag_albums_Controller extends Controller {
|
|||||||
// Figure out how many items to display on each page.
|
// Figure out how many items to display on each page.
|
||||||
$page_size = module::get_var("gallery", "page_size", 9);
|
$page_size = module::get_var("gallery", "page_size", 9);
|
||||||
|
|
||||||
|
// If this page was reached from a breadcrumb, figure out what page to load from the show id.
|
||||||
|
$show = Input::instance()->get("show");
|
||||||
|
if ($show) {
|
||||||
|
$child = ORM::factory("tag", $show);
|
||||||
|
$comp = "";
|
||||||
|
if (!strcasecmp($sort_page_direction, "DESC")) {
|
||||||
|
$comp = ">";
|
||||||
|
} else {
|
||||||
|
$comp = "<";
|
||||||
|
}
|
||||||
|
$index = ORM::factory("tag")
|
||||||
|
->where($sort_page_field, $comp, $child->$sort_page_field)
|
||||||
|
->order_by("tags." . $sort_page_field, $sort_page_direction)
|
||||||
|
->count_all();
|
||||||
|
$tag_model = ORM::factory("tag")
|
||||||
|
->where($sort_page_field, "=", $child->$sort_page_field)
|
||||||
|
->order_by("tags." . $sort_page_field, $sort_page_direction)
|
||||||
|
->find_all();
|
||||||
|
foreach ($tag_model as $one_tag) {
|
||||||
|
$index++;
|
||||||
|
if ($one_tag->id == $show) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($index) {
|
||||||
|
$page = ceil($index / $page_size);
|
||||||
|
if ($id == "") {
|
||||||
|
url::redirect("tag_albums/?page=$page");
|
||||||
|
} else {
|
||||||
|
url::redirect("tag_albums/album/" . $id . "?page=$page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out which page # the visitor is on and
|
// Figure out which page # the visitor is on and
|
||||||
// don't allow the visitor to go below page 1.
|
// don't allow the visitor to go below page 1.
|
||||||
$page = Input::instance()->get("page", 1);
|
$page = Input::instance()->get("page", 1);
|
||||||
@ -177,8 +245,21 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// Determine the total number of items,
|
// Determine the total number of items,
|
||||||
// for page numbering purposes.
|
// for page numbering purposes.
|
||||||
$all_tags_count = ORM::factory("tag")
|
$all_tags_count_model = ORM::factory("tag");
|
||||||
->count_all();
|
if ($filter != "") {
|
||||||
|
if ($filter == "NUM") {
|
||||||
|
$all_tags_count_model->open();
|
||||||
|
$all_tags_count_model->where("tags.name", "LIKE", "0%");
|
||||||
|
$counter = 1;
|
||||||
|
while ($counter < 10) {
|
||||||
|
$all_tags_count_model->or_where("tags.name", "LIKE", ($counter++) . "%");
|
||||||
|
}
|
||||||
|
$all_tags_count_model->close();
|
||||||
|
} else {
|
||||||
|
$all_tags_count_model->where("tags.name", "LIKE", $filter . "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$all_tags_count = $all_tags_count_model->count_all();
|
||||||
|
|
||||||
// Figure out what the highest page number is.
|
// Figure out what the highest page number is.
|
||||||
$max_pages = ceil($all_tags_count / $page_size);
|
$max_pages = ceil($all_tags_count / $page_size);
|
||||||
@ -189,9 +270,22 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Figure out which items to display on this page.
|
// Figure out which items to display on this page.
|
||||||
$display_tags = ORM::factory("tag")
|
$display_tags_model = ORM::factory("tag");
|
||||||
->order_by("tags." . $sort_page_field, $sort_page_direction)
|
if ($filter != "") {
|
||||||
->find_all($page_size, $offset);
|
if ($filter == "NUM") {
|
||||||
|
$display_tags_model->open();
|
||||||
|
$display_tags_model->where("tags.name", "LIKE", "0%");
|
||||||
|
$counter = 1;
|
||||||
|
while ($counter < 10) {
|
||||||
|
$display_tags_model->or_where("tags.name", "LIKE", ($counter++) . "%");
|
||||||
|
}
|
||||||
|
$display_tags_model->close();
|
||||||
|
} else {
|
||||||
|
$display_tags_model->where("tags.name", "LIKE", $filter . "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$display_tags_model->order_by("tags." . $sort_page_field, $sort_page_direction);
|
||||||
|
$display_tags = $display_tags_model->find_all($page_size, $offset);
|
||||||
|
|
||||||
// Set up the previous and next page buttons.
|
// Set up the previous and next page buttons.
|
||||||
if ($page > 1) {
|
if ($page > 1) {
|
||||||
@ -224,32 +318,38 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// Set up breadcrumbs.
|
// Set up breadcrumbs.
|
||||||
$tag_album_breadcrumbs = Array();
|
$tag_album_breadcrumbs = Array();
|
||||||
|
$parent_url = "";
|
||||||
if ($id != "") {
|
if ($id != "") {
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($album->title, "");
|
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($album->title, "");
|
||||||
$parent_item = ORM::factory("item", $album->parent_id);
|
$parent_item = ORM::factory("item", $album->parent_id);
|
||||||
|
$parent_url = $parent_item->url();
|
||||||
while ($parent_item->id != 1) {
|
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());
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url .= "?show=" . $album->id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
} else {
|
} else {
|
||||||
|
$parent_url = item::root()->url();
|
||||||
$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[1] = new Tag_Albums_Breadcrumb($page_title, "");
|
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb($page_title, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up and display the actual page.
|
// Set up and display the actual page.
|
||||||
$template = new Theme_View("page.html", "collection", "Tag Albums");
|
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
|
||||||
$template->page_title = $page_title;
|
$template->page_title = $page_title;
|
||||||
$template->set_global("page", $page);
|
$template->set_global("page", $page);
|
||||||
$template->set_global("page_size", $page_size);
|
$template->set_global("page_size", $page_size);
|
||||||
$template->set_global("max_pages", $max_pages);
|
$template->set_global("max_pages", $max_pages);
|
||||||
$template->set_global("children", $children);
|
$template->set_global("children", $children);
|
||||||
$template->set_global("children_count", $all_tags_count);
|
$template->set_global("children_count", $all_tags_count);
|
||||||
$template->content = new View("tag_albums.html");
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->content = new View("tag_albums_album.html");
|
||||||
$template->content->title = $page_title;
|
$template->content->title = $page_title;
|
||||||
$template->content->description = $page_description;
|
$template->content->description = $page_description;
|
||||||
|
$template->content->filter_text = $this->_get_filter_html($id, $filter);
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
}
|
}
|
||||||
@ -275,6 +375,17 @@ class tag_albums_Controller extends Controller {
|
|||||||
// Figure out how many items to display on each page.
|
// Figure out how many items to display on each page.
|
||||||
$page_size = module::get_var("gallery", "page_size", 9);
|
$page_size = module::get_var("gallery", "page_size", 9);
|
||||||
|
|
||||||
|
// If this page was reached from a breadcrumb, figure out what page to load from the show id.
|
||||||
|
$show = Input::instance()->get("show");
|
||||||
|
if ($show) {
|
||||||
|
$child = ORM::factory("item", $show);
|
||||||
|
$index = $this->_get_position($child->$sort_page_field, $child->id, Array($id), "items." . $sort_page_field, $sort_page_direction, "OR", true);
|
||||||
|
if ($index) {
|
||||||
|
$page = ceil($index / $page_size);
|
||||||
|
url::redirect("tag_albums/tag/" . $id . "/" . $album_id . "?page=$page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out which page # the visitor is on and
|
// Figure out which page # the visitor is on and
|
||||||
// don't allow the visitor to go below page 1.
|
// don't allow the visitor to go below page 1.
|
||||||
$page = Input::instance()->get("page", 1);
|
$page = Input::instance()->get("page", 1);
|
||||||
@ -303,8 +414,10 @@ class tag_albums_Controller extends Controller {
|
|||||||
// Create an array of "fake" items to display on the page.
|
// Create an array of "fake" items to display on the page.
|
||||||
$children = Array();
|
$children = Array();
|
||||||
foreach ($tag_children as $one_child) {
|
foreach ($tag_children as $one_child) {
|
||||||
$child_tag = new Tag_Albums_Item($one_child->name, url::site("tag_albums/show/" . $one_child->id . "/" . $id . "/" . $album_id), $one_child->type);
|
$child_tag = new Tag_Albums_Item($one_child->title, url::site("tag_albums/show/" . $one_child->id . "/" . $id . "/" . $album_id), $one_child->type);
|
||||||
$child_tag->id = $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()) {
|
if ($one_child->has_thumb()) {
|
||||||
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
||||||
}
|
}
|
||||||
@ -326,6 +439,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// Set up breadcrumbs for the page.
|
// Set up breadcrumbs for the page.
|
||||||
$tag_album_breadcrumbs = Array();
|
$tag_album_breadcrumbs = Array();
|
||||||
|
$parent_url = "";
|
||||||
if ($album_id != "") {
|
if ($album_id != "") {
|
||||||
$counter = 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, "");
|
||||||
@ -333,27 +447,31 @@ class tag_albums_Controller extends Controller {
|
|||||||
if ($album_tags[0]->tags != "*") {
|
if ($album_tags[0]->tags != "*") {
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
||||||
}
|
}
|
||||||
|
$parent_url = $parent_item->url(); // Used by Grey Dragon.
|
||||||
while ($parent_item->id != 1) {
|
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());
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url = url::site("tag_albums/album/" . $album_id) . "?show=" . $id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
} else {
|
} 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[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/"));
|
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/") . "?show=" . $id);
|
||||||
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, "");
|
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up and display the actual page.
|
// Set up and display the actual page.
|
||||||
$template = new Theme_View("page.html", "collection", "Tag Albums");
|
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
|
||||||
$template->page_title = $display_tag->name;
|
$template->page_title = $display_tag->name;
|
||||||
$template->set_global("page", $page);
|
$template->set_global("page", $page);
|
||||||
$template->set_global("page_size", $page_size);
|
$template->set_global("page_size", $page_size);
|
||||||
$template->set_global("max_pages", $max_pages);
|
$template->set_global("max_pages", $max_pages);
|
||||||
$template->set_global("children", $children);
|
$template->set_global("children", $children);
|
||||||
$template->set_global("children_count", $count);
|
$template->set_global("children_count", $count);
|
||||||
$template->content = new View("tag_albums.html");
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->content = new View("tag_albums_album.html");
|
||||||
$template->content->title = $display_tag->name;
|
$template->content->title = $display_tag->name;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
@ -375,6 +493,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
$display_tag = ORM::factory("tag", $tag_id);
|
$display_tag = ORM::factory("tag", $tag_id);
|
||||||
$item = ORM::factory("item", $item_id);
|
$item = ORM::factory("item", $item_id);
|
||||||
access::required("view", $item);
|
access::required("view", $item);
|
||||||
|
$parent_url = "";
|
||||||
|
|
||||||
// Figure out sort order from module preferences.
|
// Figure out sort order from module preferences.
|
||||||
$sort_page_field = "";
|
$sort_page_field = "";
|
||||||
@ -394,19 +513,21 @@ class tag_albums_Controller extends Controller {
|
|||||||
$previous_item = "";
|
$previous_item = "";
|
||||||
$next_item = "";
|
$next_item = "";
|
||||||
$position = 0;
|
$position = 0;
|
||||||
|
$dynamic_siblings = "";
|
||||||
if ($tag_id > 0) {
|
if ($tag_id > 0) {
|
||||||
$sibling_count = $this->_count_records(Array($tag_id), "OR", false);
|
$sibling_count = $this->_count_records(Array($tag_id), "OR", false);
|
||||||
$position = $this->_get_position($item->$sort_page_field, $item->id, Array($tag_id), "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type);
|
$position = $this->_get_position($item->$sort_page_field, $item->id, Array($tag_id), "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if ($position > 1) {
|
if ($position > 1) {
|
||||||
$previous_item_object = $this->_get_records(Array($tag_id), 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$previous_item_object = $this->_get_records(Array($tag_id), 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($previous_item_object) > 0) {
|
if (count($previous_item_object) > 0) {
|
||||||
$previous_item = new Tag_Albums_Item($previous_item_object[0]->name, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
$previous_item = new Tag_Albums_Item($previous_item_object[0]->title, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$next_item_object = $this->_get_records(Array($tag_id), 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$next_item_object = $this->_get_records(Array($tag_id), 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($next_item_object) > 0) {
|
if (count($next_item_object) > 0) {
|
||||||
$next_item = new Tag_Albums_Item($next_item_object[0]->name, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
$next_item = new Tag_Albums_Item($next_item_object[0]->title, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
||||||
}
|
}
|
||||||
|
$dynamic_siblings = $this->_get_records(Array($tag_id), null, null, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
} else {
|
} else {
|
||||||
$tag_ids = Array();
|
$tag_ids = Array();
|
||||||
foreach (explode(",", $album_tags[0]->tags) as $tag_name) {
|
foreach (explode(",", $album_tags[0]->tags) as $tag_name) {
|
||||||
@ -417,17 +538,18 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
$album_tags_search_type = $album_tags[0]->search_type;
|
$album_tags_search_type = $album_tags[0]->search_type;
|
||||||
$sibling_count = $this->_count_records($tag_ids, $album_tags_search_type, false);
|
$sibling_count = $this->_count_records($tag_ids, $album_tags_search_type, false);
|
||||||
$position = $this->_get_position($item->$sort_page_field, $item->id, $tag_ids, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type);
|
$position = $this->_get_position($item->$sort_page_field, $item->id, $tag_ids, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if ($position > 1) {
|
if ($position > 1) {
|
||||||
$previous_item_object = $this->_get_records($tag_ids, 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$previous_item_object = $this->_get_records($tag_ids, 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($previous_item_object) > 0) {
|
if (count($previous_item_object) > 0) {
|
||||||
$previous_item = new Tag_Albums_Item($previous_item_object[0]->name, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
$previous_item = new Tag_Albums_Item($previous_item_object[0]->title, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$next_item_object = $this->_get_records($tag_ids, 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$next_item_object = $this->_get_records($tag_ids, 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($next_item_object) > 0) {
|
if (count($next_item_object) > 0) {
|
||||||
$next_item = new Tag_Albums_Item($next_item_object[0]->name, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
$next_item = new Tag_Albums_Item($next_item_object[0]->title, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
||||||
}
|
}
|
||||||
|
$dynamic_siblings = $this->_get_records($tag_ids, null, null, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up breadcrumbs
|
// Set up breadcrumbs
|
||||||
@ -439,45 +561,67 @@ class tag_albums_Controller extends Controller {
|
|||||||
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id . "/" . $album_id));
|
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id . "/" . $album_id));
|
||||||
}
|
}
|
||||||
$parent_item = ORM::factory("item", $album_tags[0]->album_id);
|
$parent_item = ORM::factory("item", $album_tags[0]->album_id);
|
||||||
|
if ($album_tags[0]->tags == "*") {
|
||||||
|
$parent_url = url::site("tag_albums/tag/" . $display_tag->id . "/" . $album_id);
|
||||||
|
} else {
|
||||||
|
$parent_url = $parent_item->url();
|
||||||
|
}
|
||||||
|
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, url::site("tag_albums/album/" . $album_id));
|
||||||
|
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
||||||
while ($parent_item->id != 1) {
|
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());
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url .= "?show=" . $item->id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
} else {
|
} else {
|
||||||
$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[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/"));
|
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/"));
|
||||||
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id));
|
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id) . "?show=" . $item->id);
|
||||||
$tag_album_breadcrumbs[3] = new Tag_Albums_Breadcrumb($item->title, "");
|
$tag_album_breadcrumbs[3] = new Tag_Albums_Breadcrumb($item->title, "");
|
||||||
|
$parent_url = url::site("tag_albums/tag/" . $display_tag->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Increase the items view count.
|
||||||
|
$item->increment_view_count();
|
||||||
|
|
||||||
// Load the page.
|
// Load the page.
|
||||||
if ($item->is_photo()) {
|
if ($item->is_photo()) {
|
||||||
$template = new Theme_View("page.html", "item", "photo");
|
$template = new Theme_View("calpage.html", "item", "photo");
|
||||||
$template->page_title = $item->title;
|
$template->page_title = $item->title;
|
||||||
$template->set_global("children", Array());
|
$template->set_global("children", Array());
|
||||||
$template->set_global("item", $item);
|
$template->set_global("item", $item);
|
||||||
$template->set_global("previous_item", $previous_item);
|
$template->set_global("previous_item", $previous_item);
|
||||||
$template->set_global("next_item", $next_item);
|
$template->set_global("next_item", $next_item);
|
||||||
|
$template->set_global("is_tagalbum_page", true); // used for grey dragon
|
||||||
|
$template->set_global("tag_id", $tag_id); // used for grey dragon
|
||||||
|
$template->set_global("album_id", $album_id); // used for grey dragon
|
||||||
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->set_global("dynamic_siblings", $dynamic_siblings); // Used by Grey Dragon.
|
||||||
$template->set_global("children_count", 0);
|
$template->set_global("children_count", 0);
|
||||||
$template->set_global("position", $position);
|
$template->set_global("position", $position);
|
||||||
$template->set_global("sibling_count", $sibling_count);
|
$template->set_global("sibling_count", $sibling_count);
|
||||||
$template->content = new View("tag_albums_photo.html");
|
$template->content = new View("photo.html");
|
||||||
$template->content->title = $item->title;
|
$template->content->title = $item->title;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
} elseif ($item->is_movie()) {
|
} elseif ($item->is_movie()) {
|
||||||
$template = new Theme_View("page.html", "item", "movie");
|
$template = new Theme_View("calpage.html", "item", "movie");
|
||||||
$template->page_title = $item->title;
|
$template->page_title = $item->title;
|
||||||
$template->set_global("children", Array());
|
$template->set_global("children", Array());
|
||||||
$template->set_global("item", $item);
|
$template->set_global("item", $item);
|
||||||
$template->set_global("previous_item", $previous_item);
|
$template->set_global("previous_item", $previous_item);
|
||||||
$template->set_global("next_item", $next_item);
|
$template->set_global("next_item", $next_item);
|
||||||
|
$template->set_global("is_tagalbum_page", true); // used for grey dragon
|
||||||
|
$template->set_global("tag_id", $tag_id); // used for grey dragon
|
||||||
|
$template->set_global("album_id", $album_id); // used for grey dragon
|
||||||
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->set_global("dynamic_siblings", $dynamic_siblings); // Used by Grey Dragon.
|
||||||
$template->set_global("children_count", 0);
|
$template->set_global("children_count", 0);
|
||||||
$template->set_global("position", $position);
|
$template->set_global("position", $position);
|
||||||
$template->set_global("sibling_count", $sibling_count);
|
$template->set_global("sibling_count", $sibling_count);
|
||||||
$template->content = new View("tag_albums_movie.html");
|
$template->content = new View("movie.html");
|
||||||
$template->content->title = $item->title;
|
$template->content->title = $item->title;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
@ -487,7 +631,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _get_position($item_title, $item_id, $tag_ids, $sort_field, $sort_direction, $search_type) {
|
private function _get_position($item_title, $item_id, $tag_ids, $sort_field, $sort_direction, $search_type, $include_albums) {
|
||||||
// Determine an item's position within a virtual album.
|
// Determine an item's position within a virtual album.
|
||||||
|
|
||||||
// Convert ASC/DESC to < or > characters.
|
// Convert ASC/DESC to < or > characters.
|
||||||
@ -514,7 +658,9 @@ class tag_albums_Controller extends Controller {
|
|||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
$items_model->close();
|
$items_model->close();
|
||||||
$items_model->and_where("items.type", "!=", "album");
|
if ($include_albums == false) {
|
||||||
|
$items_model->and_where("items.type", "!=", "album");
|
||||||
|
}
|
||||||
$items_model->and_where($sort_field, $comp, $item_title);
|
$items_model->and_where($sort_field, $comp, $item_title);
|
||||||
$items_model->order_by($sort_field, $sort_direction);
|
$items_model->order_by($sort_field, $sort_direction);
|
||||||
$items_model->group_by("items.id");
|
$items_model->group_by("items.id");
|
||||||
@ -543,7 +689,9 @@ class tag_albums_Controller extends Controller {
|
|||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
$items_model->close();
|
$items_model->close();
|
||||||
$items_model->and_where("items.type", "!=", "album");
|
if ($include_albums == false) {
|
||||||
|
$items_model->and_where("items.type", "!=", "album");
|
||||||
|
}
|
||||||
$items_model->and_where($sort_field, "=", $item_title);
|
$items_model->and_where($sort_field, "=", $item_title);
|
||||||
$items_model->order_by($sort_field, $sort_direction);
|
$items_model->order_by($sort_field, $sort_direction);
|
||||||
$items_model->group_by("items.id");
|
$items_model->group_by("items.id");
|
||||||
@ -570,6 +718,9 @@ class tag_albums_Controller extends Controller {
|
|||||||
// higher then they should be. So instead, I'm manually selecting each column that I need.
|
// higher then they should be. So instead, I'm manually selecting each column that I need.
|
||||||
$items_model->select("items.id");
|
$items_model->select("items.id");
|
||||||
$items_model->select("items.name");
|
$items_model->select("items.name");
|
||||||
|
$items_model->select("items.title");
|
||||||
|
$items_model->select("items.view_count");
|
||||||
|
$items_model->select("items.owner_id");
|
||||||
$items_model->select("items.type");
|
$items_model->select("items.type");
|
||||||
$items_model->select("items.thumb_width");
|
$items_model->select("items.thumb_width");
|
||||||
$items_model->select("items.thumb_height");
|
$items_model->select("items.thumb_height");
|
||||||
@ -599,6 +750,41 @@ class tag_albums_Controller extends Controller {
|
|||||||
return $items_model->find_all($page_size, $offset);
|
return $items_model->find_all($page_size, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _get_filter_html($album_id, $str_filter) {
|
||||||
|
// Generate HTML to display filter links on the index page.
|
||||||
|
|
||||||
|
// Make sure $album_id is set.
|
||||||
|
if ($album_id == "") {
|
||||||
|
$album_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the links.
|
||||||
|
$str_html = "Filter: ";
|
||||||
|
if ($str_filter != "") {
|
||||||
|
if ($album_id > 0) {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/album/" . $album_id) . "\">(All)</a> ";
|
||||||
|
} else {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/") . "\">(All)</a> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($str_filter == "NUM") {
|
||||||
|
$str_html .= "# ";
|
||||||
|
} else {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/filter/" . $album_id . "/NUM") . "\">#</a> ";
|
||||||
|
}
|
||||||
|
foreach(range('A','Z') as $letter) {
|
||||||
|
if ($letter == $str_filter) {
|
||||||
|
$str_html .= $letter . " ";
|
||||||
|
} else {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/filter/" . $album_id . "/" . $letter) . "\">";
|
||||||
|
$str_html .= $letter . "</a> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the HTML.
|
||||||
|
return $str_html;
|
||||||
|
}
|
||||||
|
|
||||||
private function _count_records($tag_ids, $search_type, $include_albums) {
|
private function _count_records($tag_ids, $search_type, $include_albums) {
|
||||||
// Count the number of viewable items for the designated tag(s)
|
// Count the number of viewable items for the designated tag(s)
|
||||||
// and return that number.
|
// and return that number.
|
||||||
|
@ -34,7 +34,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// If it does exist, and is set to *, load a list of all tags.
|
// If it does exist, and is set to *, load a list of all tags.
|
||||||
if ($album_tags[0]->tags == "*") {
|
if ($album_tags[0]->tags == "*") {
|
||||||
$this->index($id);
|
$this->index($id, "");
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, populate this page with the specified items.
|
// Otherwise, populate this page with the specified items.
|
||||||
|
|
||||||
@ -58,12 +58,23 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
$album_tags_search_type = $album_tags[0]->search_type;
|
$album_tags_search_type = $album_tags[0]->search_type;
|
||||||
|
|
||||||
// Figure out how many items are in this "virtual album"
|
|
||||||
$count = $this->_count_records($tag_ids, $album_tags_search_type, true);
|
|
||||||
|
|
||||||
// Figure out how many items to display on each page.
|
// Figure out how many items to display on each page.
|
||||||
$page_size = module::get_var("gallery", "page_size", 9);
|
$page_size = module::get_var("gallery", "page_size", 9);
|
||||||
|
|
||||||
|
// If this page was reached from a breadcrumb, figure out what page to load from the show id.
|
||||||
|
$show = Input::instance()->get("show");
|
||||||
|
if ($show) {
|
||||||
|
$child = ORM::factory("item", $show);
|
||||||
|
$index = $this->_get_position($child->$sort_page_field, $child->id, $tag_ids, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
|
||||||
|
if ($index) {
|
||||||
|
$page = ceil($index / $page_size);
|
||||||
|
url::redirect("tag_albums/album/" . $id . "?page=$page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Figure out how many items are in this "virtual album"
|
||||||
|
$count = $this->_count_records($tag_ids, $album_tags_search_type, true);
|
||||||
|
|
||||||
// Figure out which page # the visitor is on and
|
// Figure out which page # the visitor is on and
|
||||||
// don't allow the visitor to go below page 1.
|
// don't allow the visitor to go below page 1.
|
||||||
$page = Input::instance()->get("page", 1);
|
$page = Input::instance()->get("page", 1);
|
||||||
@ -86,8 +97,10 @@ class tag_albums_Controller extends Controller {
|
|||||||
$tag_children = $this->_get_records($tag_ids, $page_size, $offset, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
|
$tag_children = $this->_get_records($tag_ids, $page_size, $offset, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
|
||||||
$children = Array();
|
$children = Array();
|
||||||
foreach ($tag_children as $one_child) {
|
foreach ($tag_children as $one_child) {
|
||||||
$child_tag = new Tag_Albums_Item($one_child->name, url::site("tag_albums/show/" . $one_child->id . "/0/" . $id), $one_child->type);
|
$child_tag = new Tag_Albums_Item($one_child->title, url::site("tag_albums/show/" . $one_child->id . "/0/" . $id), $one_child->type);
|
||||||
$child_tag->id = $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()) {
|
if ($one_child->has_thumb()) {
|
||||||
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
||||||
}
|
}
|
||||||
@ -114,17 +127,20 @@ class tag_albums_Controller extends Controller {
|
|||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url .= "?show=" . $album->id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
|
|
||||||
// Set up and display the actual page.
|
// Set up and display the actual page.
|
||||||
$template = new Theme_View("page.html", "collection", "Tag Albums");
|
$parent_album = ORM::factory("item", $album->parent_id);
|
||||||
|
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
|
||||||
$template->page_title = $page_title;
|
$template->page_title = $page_title;
|
||||||
$template->set_global("page", $page);
|
$template->set_global("page", $page);
|
||||||
$template->set_global("page_size", $page_size);
|
$template->set_global("page_size", $page_size);
|
||||||
$template->set_global("max_pages", $max_pages);
|
$template->set_global("max_pages", $max_pages);
|
||||||
$template->set_global("children", $children);
|
$template->set_global("children", $children);
|
||||||
$template->set_global("children_count", $count);
|
$template->set_global("children_count", $count);
|
||||||
$template->content = new View("tag_albums.html");
|
$template->set_global("parent_url", $parent_album->url()); // Used by Grey Dragon.
|
||||||
|
$template->content = new View("tag_albums_album.html");
|
||||||
$template->content->title = $page_title;
|
$template->content->title = $page_title;
|
||||||
$template->content->description = $page_description;
|
$template->content->description = $page_description;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
@ -132,9 +148,27 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index($id) {
|
public function filter($id, $filter) {
|
||||||
|
// Display the index page, but only show albums for
|
||||||
|
// tags whose name begins with $filter.
|
||||||
|
$this->index($id, $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index($id, $filter) {
|
||||||
// Load a page containing sub-albums for each tag in the gallery.
|
// Load a page containing sub-albums for each tag in the gallery.
|
||||||
|
|
||||||
|
// Check to see if the user has overridden default behavior, and act accordingly.
|
||||||
|
if ((module::get_var("tag_albums", "tag_index_scope", "false")) || ($id == "")) {
|
||||||
|
$tag_album_index_type = module::get_var("tag_albums", "tag_index", "default");
|
||||||
|
if (($tag_album_index_type == "tagcloudpage") && (module::is_active("tag_cloud_page"))) {
|
||||||
|
Tag_Cloud_Page_Controller::index();
|
||||||
|
return;
|
||||||
|
} elseif (($tag_album_index_type == "alltags") && (module::is_active("all_tags"))) {
|
||||||
|
All_Tags_Controller::index();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If an ID was specified, make sure it's valid.
|
// If an ID was specified, make sure it's valid.
|
||||||
$album_tags = ORM::factory("tags_album_id")
|
$album_tags = ORM::factory("tags_album_id")
|
||||||
->where("id", "=", $id)
|
->where("id", "=", $id)
|
||||||
@ -165,6 +199,40 @@ class tag_albums_Controller extends Controller {
|
|||||||
// Figure out how many items to display on each page.
|
// Figure out how many items to display on each page.
|
||||||
$page_size = module::get_var("gallery", "page_size", 9);
|
$page_size = module::get_var("gallery", "page_size", 9);
|
||||||
|
|
||||||
|
// If this page was reached from a breadcrumb, figure out what page to load from the show id.
|
||||||
|
$show = Input::instance()->get("show");
|
||||||
|
if ($show) {
|
||||||
|
$child = ORM::factory("tag", $show);
|
||||||
|
$comp = "";
|
||||||
|
if (!strcasecmp($sort_page_direction, "DESC")) {
|
||||||
|
$comp = ">";
|
||||||
|
} else {
|
||||||
|
$comp = "<";
|
||||||
|
}
|
||||||
|
$index = ORM::factory("tag")
|
||||||
|
->where($sort_page_field, $comp, $child->$sort_page_field)
|
||||||
|
->order_by("tags." . $sort_page_field, $sort_page_direction)
|
||||||
|
->count_all();
|
||||||
|
$tag_model = ORM::factory("tag")
|
||||||
|
->where($sort_page_field, "=", $child->$sort_page_field)
|
||||||
|
->order_by("tags." . $sort_page_field, $sort_page_direction)
|
||||||
|
->find_all();
|
||||||
|
foreach ($tag_model as $one_tag) {
|
||||||
|
$index++;
|
||||||
|
if ($one_tag->id == $show) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($index) {
|
||||||
|
$page = ceil($index / $page_size);
|
||||||
|
if ($id == "") {
|
||||||
|
url::redirect("tag_albums/?page=$page");
|
||||||
|
} else {
|
||||||
|
url::redirect("tag_albums/album/" . $id . "?page=$page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out which page # the visitor is on and
|
// Figure out which page # the visitor is on and
|
||||||
// don't allow the visitor to go below page 1.
|
// don't allow the visitor to go below page 1.
|
||||||
$page = Input::instance()->get("page", 1);
|
$page = Input::instance()->get("page", 1);
|
||||||
@ -177,8 +245,21 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// Determine the total number of items,
|
// Determine the total number of items,
|
||||||
// for page numbering purposes.
|
// for page numbering purposes.
|
||||||
$all_tags_count = ORM::factory("tag")
|
$all_tags_count_model = ORM::factory("tag");
|
||||||
->count_all();
|
if ($filter != "") {
|
||||||
|
if ($filter == "NUM") {
|
||||||
|
$all_tags_count_model->open();
|
||||||
|
$all_tags_count_model->where("tags.name", "LIKE", "0%");
|
||||||
|
$counter = 1;
|
||||||
|
while ($counter < 10) {
|
||||||
|
$all_tags_count_model->or_where("tags.name", "LIKE", ($counter++) . "%");
|
||||||
|
}
|
||||||
|
$all_tags_count_model->close();
|
||||||
|
} else {
|
||||||
|
$all_tags_count_model->where("tags.name", "LIKE", $filter . "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$all_tags_count = $all_tags_count_model->count_all();
|
||||||
|
|
||||||
// Figure out what the highest page number is.
|
// Figure out what the highest page number is.
|
||||||
$max_pages = ceil($all_tags_count / $page_size);
|
$max_pages = ceil($all_tags_count / $page_size);
|
||||||
@ -189,9 +270,22 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Figure out which items to display on this page.
|
// Figure out which items to display on this page.
|
||||||
$display_tags = ORM::factory("tag")
|
$display_tags_model = ORM::factory("tag");
|
||||||
->order_by("tags." . $sort_page_field, $sort_page_direction)
|
if ($filter != "") {
|
||||||
->find_all($page_size, $offset);
|
if ($filter == "NUM") {
|
||||||
|
$display_tags_model->open();
|
||||||
|
$display_tags_model->where("tags.name", "LIKE", "0%");
|
||||||
|
$counter = 1;
|
||||||
|
while ($counter < 10) {
|
||||||
|
$display_tags_model->or_where("tags.name", "LIKE", ($counter++) . "%");
|
||||||
|
}
|
||||||
|
$display_tags_model->close();
|
||||||
|
} else {
|
||||||
|
$display_tags_model->where("tags.name", "LIKE", $filter . "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$display_tags_model->order_by("tags." . $sort_page_field, $sort_page_direction);
|
||||||
|
$display_tags = $display_tags_model->find_all($page_size, $offset);
|
||||||
|
|
||||||
// Set up the previous and next page buttons.
|
// Set up the previous and next page buttons.
|
||||||
if ($page > 1) {
|
if ($page > 1) {
|
||||||
@ -224,32 +318,38 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// Set up breadcrumbs.
|
// Set up breadcrumbs.
|
||||||
$tag_album_breadcrumbs = Array();
|
$tag_album_breadcrumbs = Array();
|
||||||
|
$parent_url = "";
|
||||||
if ($id != "") {
|
if ($id != "") {
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($album->title, "");
|
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($album->title, "");
|
||||||
$parent_item = ORM::factory("item", $album->parent_id);
|
$parent_item = ORM::factory("item", $album->parent_id);
|
||||||
|
$parent_url = $parent_item->url();
|
||||||
while ($parent_item->id != 1) {
|
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());
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url .= "?show=" . $album->id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
} else {
|
} else {
|
||||||
|
$parent_url = item::root()->url();
|
||||||
$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[1] = new Tag_Albums_Breadcrumb($page_title, "");
|
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb($page_title, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up and display the actual page.
|
// Set up and display the actual page.
|
||||||
$template = new Theme_View("page.html", "collection", "Tag Albums");
|
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
|
||||||
$template->page_title = $page_title;
|
$template->page_title = $page_title;
|
||||||
$template->set_global("page", $page);
|
$template->set_global("page", $page);
|
||||||
$template->set_global("page_size", $page_size);
|
$template->set_global("page_size", $page_size);
|
||||||
$template->set_global("max_pages", $max_pages);
|
$template->set_global("max_pages", $max_pages);
|
||||||
$template->set_global("children", $children);
|
$template->set_global("children", $children);
|
||||||
$template->set_global("children_count", $all_tags_count);
|
$template->set_global("children_count", $all_tags_count);
|
||||||
$template->content = new View("tag_albums.html");
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->content = new View("tag_albums_album.html");
|
||||||
$template->content->title = $page_title;
|
$template->content->title = $page_title;
|
||||||
$template->content->description = $page_description;
|
$template->content->description = $page_description;
|
||||||
|
$template->content->filter_text = $this->_get_filter_html($id, $filter);
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
}
|
}
|
||||||
@ -275,6 +375,17 @@ class tag_albums_Controller extends Controller {
|
|||||||
// Figure out how many items to display on each page.
|
// Figure out how many items to display on each page.
|
||||||
$page_size = module::get_var("gallery", "page_size", 9);
|
$page_size = module::get_var("gallery", "page_size", 9);
|
||||||
|
|
||||||
|
// If this page was reached from a breadcrumb, figure out what page to load from the show id.
|
||||||
|
$show = Input::instance()->get("show");
|
||||||
|
if ($show) {
|
||||||
|
$child = ORM::factory("item", $show);
|
||||||
|
$index = $this->_get_position($child->$sort_page_field, $child->id, Array($id), "items." . $sort_page_field, $sort_page_direction, "OR", true);
|
||||||
|
if ($index) {
|
||||||
|
$page = ceil($index / $page_size);
|
||||||
|
url::redirect("tag_albums/tag/" . $id . "/" . $album_id . "?page=$page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out which page # the visitor is on and
|
// Figure out which page # the visitor is on and
|
||||||
// don't allow the visitor to go below page 1.
|
// don't allow the visitor to go below page 1.
|
||||||
$page = Input::instance()->get("page", 1);
|
$page = Input::instance()->get("page", 1);
|
||||||
@ -303,8 +414,10 @@ class tag_albums_Controller extends Controller {
|
|||||||
// Create an array of "fake" items to display on the page.
|
// Create an array of "fake" items to display on the page.
|
||||||
$children = Array();
|
$children = Array();
|
||||||
foreach ($tag_children as $one_child) {
|
foreach ($tag_children as $one_child) {
|
||||||
$child_tag = new Tag_Albums_Item($one_child->name, url::site("tag_albums/show/" . $one_child->id . "/" . $id . "/" . $album_id), $one_child->type);
|
$child_tag = new Tag_Albums_Item($one_child->title, url::site("tag_albums/show/" . $one_child->id . "/" . $id . "/" . $album_id), $one_child->type);
|
||||||
$child_tag->id = $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()) {
|
if ($one_child->has_thumb()) {
|
||||||
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
$child_tag->set_thumb($one_child->thumb_url(), $one_child->thumb_width, $one_child->thumb_height);
|
||||||
}
|
}
|
||||||
@ -326,6 +439,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
|
|
||||||
// Set up breadcrumbs for the page.
|
// Set up breadcrumbs for the page.
|
||||||
$tag_album_breadcrumbs = Array();
|
$tag_album_breadcrumbs = Array();
|
||||||
|
$parent_url = "";
|
||||||
if ($album_id != "") {
|
if ($album_id != "") {
|
||||||
$counter = 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, "");
|
||||||
@ -333,27 +447,31 @@ class tag_albums_Controller extends Controller {
|
|||||||
if ($album_tags[0]->tags != "*") {
|
if ($album_tags[0]->tags != "*") {
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
||||||
}
|
}
|
||||||
|
$parent_url = $parent_item->url(); // Used by Grey Dragon.
|
||||||
while ($parent_item->id != 1) {
|
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());
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url = url::site("tag_albums/album/" . $album_id) . "?show=" . $id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
} else {
|
} 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[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/"));
|
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/") . "?show=" . $id);
|
||||||
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, "");
|
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up and display the actual page.
|
// Set up and display the actual page.
|
||||||
$template = new Theme_View("page.html", "collection", "Tag Albums");
|
$template = new Theme_View("calpage.html", "collection", "Tag Albums");
|
||||||
$template->page_title = $display_tag->name;
|
$template->page_title = $display_tag->name;
|
||||||
$template->set_global("page", $page);
|
$template->set_global("page", $page);
|
||||||
$template->set_global("page_size", $page_size);
|
$template->set_global("page_size", $page_size);
|
||||||
$template->set_global("max_pages", $max_pages);
|
$template->set_global("max_pages", $max_pages);
|
||||||
$template->set_global("children", $children);
|
$template->set_global("children", $children);
|
||||||
$template->set_global("children_count", $count);
|
$template->set_global("children_count", $count);
|
||||||
$template->content = new View("tag_albums.html");
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->content = new View("tag_albums_album.html");
|
||||||
$template->content->title = $display_tag->name;
|
$template->content->title = $display_tag->name;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
@ -375,6 +493,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
$display_tag = ORM::factory("tag", $tag_id);
|
$display_tag = ORM::factory("tag", $tag_id);
|
||||||
$item = ORM::factory("item", $item_id);
|
$item = ORM::factory("item", $item_id);
|
||||||
access::required("view", $item);
|
access::required("view", $item);
|
||||||
|
$parent_url = "";
|
||||||
|
|
||||||
// Figure out sort order from module preferences.
|
// Figure out sort order from module preferences.
|
||||||
$sort_page_field = "";
|
$sort_page_field = "";
|
||||||
@ -394,19 +513,21 @@ class tag_albums_Controller extends Controller {
|
|||||||
$previous_item = "";
|
$previous_item = "";
|
||||||
$next_item = "";
|
$next_item = "";
|
||||||
$position = 0;
|
$position = 0;
|
||||||
|
$dynamic_siblings = "";
|
||||||
if ($tag_id > 0) {
|
if ($tag_id > 0) {
|
||||||
$sibling_count = $this->_count_records(Array($tag_id), "OR", false);
|
$sibling_count = $this->_count_records(Array($tag_id), "OR", false);
|
||||||
$position = $this->_get_position($item->$sort_page_field, $item->id, Array($tag_id), "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type);
|
$position = $this->_get_position($item->$sort_page_field, $item->id, Array($tag_id), "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if ($position > 1) {
|
if ($position > 1) {
|
||||||
$previous_item_object = $this->_get_records(Array($tag_id), 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$previous_item_object = $this->_get_records(Array($tag_id), 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($previous_item_object) > 0) {
|
if (count($previous_item_object) > 0) {
|
||||||
$previous_item = new Tag_Albums_Item($previous_item_object[0]->name, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
$previous_item = new Tag_Albums_Item($previous_item_object[0]->title, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$next_item_object = $this->_get_records(Array($tag_id), 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$next_item_object = $this->_get_records(Array($tag_id), 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($next_item_object) > 0) {
|
if (count($next_item_object) > 0) {
|
||||||
$next_item = new Tag_Albums_Item($next_item_object[0]->name, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
$next_item = new Tag_Albums_Item($next_item_object[0]->title, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
||||||
}
|
}
|
||||||
|
$dynamic_siblings = $this->_get_records(Array($tag_id), null, null, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
} else {
|
} else {
|
||||||
$tag_ids = Array();
|
$tag_ids = Array();
|
||||||
foreach (explode(",", $album_tags[0]->tags) as $tag_name) {
|
foreach (explode(",", $album_tags[0]->tags) as $tag_name) {
|
||||||
@ -417,17 +538,18 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
$album_tags_search_type = $album_tags[0]->search_type;
|
$album_tags_search_type = $album_tags[0]->search_type;
|
||||||
$sibling_count = $this->_count_records($tag_ids, $album_tags_search_type, false);
|
$sibling_count = $this->_count_records($tag_ids, $album_tags_search_type, false);
|
||||||
$position = $this->_get_position($item->$sort_page_field, $item->id, $tag_ids, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type);
|
$position = $this->_get_position($item->$sort_page_field, $item->id, $tag_ids, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if ($position > 1) {
|
if ($position > 1) {
|
||||||
$previous_item_object = $this->_get_records($tag_ids, 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$previous_item_object = $this->_get_records($tag_ids, 1, $position-2, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($previous_item_object) > 0) {
|
if (count($previous_item_object) > 0) {
|
||||||
$previous_item = new Tag_Albums_Item($previous_item_object[0]->name, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
$previous_item = new Tag_Albums_Item($previous_item_object[0]->title, url::site("tag_albums/show/" . $previous_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $previous_item_object[0]->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$next_item_object = $this->_get_records($tag_ids, 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
$next_item_object = $this->_get_records($tag_ids, 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
if (count($next_item_object) > 0) {
|
if (count($next_item_object) > 0) {
|
||||||
$next_item = new Tag_Albums_Item($next_item_object[0]->name, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
$next_item = new Tag_Albums_Item($next_item_object[0]->title, url::site("tag_albums/show/" . $next_item_object[0]->id . "/" . $tag_id . "/" . $album_id), $next_item_object[0]->type);
|
||||||
}
|
}
|
||||||
|
$dynamic_siblings = $this->_get_records($tag_ids, null, null, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up breadcrumbs
|
// Set up breadcrumbs
|
||||||
@ -439,45 +561,67 @@ class tag_albums_Controller extends Controller {
|
|||||||
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id . "/" . $album_id));
|
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id . "/" . $album_id));
|
||||||
}
|
}
|
||||||
$parent_item = ORM::factory("item", $album_tags[0]->album_id);
|
$parent_item = ORM::factory("item", $album_tags[0]->album_id);
|
||||||
|
if ($album_tags[0]->tags == "*") {
|
||||||
|
$parent_url = url::site("tag_albums/tag/" . $display_tag->id . "/" . $album_id);
|
||||||
|
} else {
|
||||||
|
$parent_url = $parent_item->url();
|
||||||
|
}
|
||||||
|
$tag_album_breadcrumbs[$counter++] = new Tag_Albums_Breadcrumb($parent_item->title, url::site("tag_albums/album/" . $album_id));
|
||||||
|
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
||||||
while ($parent_item->id != 1) {
|
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());
|
||||||
$parent_item = ORM::factory("item", $parent_item->parent_id);
|
$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[1]->url .= "?show=" . $item->id;
|
||||||
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
$tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
|
||||||
} else {
|
} else {
|
||||||
$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[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/"));
|
$tag_album_breadcrumbs[1] = new Tag_Albums_Breadcrumb("All Tags", url::site("tag_albums/"));
|
||||||
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id));
|
$tag_album_breadcrumbs[2] = new Tag_Albums_Breadcrumb($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id) . "?show=" . $item->id);
|
||||||
$tag_album_breadcrumbs[3] = new Tag_Albums_Breadcrumb($item->title, "");
|
$tag_album_breadcrumbs[3] = new Tag_Albums_Breadcrumb($item->title, "");
|
||||||
|
$parent_url = url::site("tag_albums/tag/" . $display_tag->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Increase the items view count.
|
||||||
|
$item->increment_view_count();
|
||||||
|
|
||||||
// Load the page.
|
// Load the page.
|
||||||
if ($item->is_photo()) {
|
if ($item->is_photo()) {
|
||||||
$template = new Theme_View("page.html", "item", "photo");
|
$template = new Theme_View("calpage.html", "item", "photo");
|
||||||
$template->page_title = $item->title;
|
$template->page_title = $item->title;
|
||||||
$template->set_global("children", Array());
|
$template->set_global("children", Array());
|
||||||
$template->set_global("item", $item);
|
$template->set_global("item", $item);
|
||||||
$template->set_global("previous_item", $previous_item);
|
$template->set_global("previous_item", $previous_item);
|
||||||
$template->set_global("next_item", $next_item);
|
$template->set_global("next_item", $next_item);
|
||||||
|
$template->set_global("is_tagalbum_page", true); // used for grey dragon
|
||||||
|
$template->set_global("tag_id", $tag_id); // used for grey dragon
|
||||||
|
$template->set_global("album_id", $album_id); // used for grey dragon
|
||||||
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->set_global("dynamic_siblings", $dynamic_siblings); // Used by Grey Dragon.
|
||||||
$template->set_global("children_count", 0);
|
$template->set_global("children_count", 0);
|
||||||
$template->set_global("position", $position);
|
$template->set_global("position", $position);
|
||||||
$template->set_global("sibling_count", $sibling_count);
|
$template->set_global("sibling_count", $sibling_count);
|
||||||
$template->content = new View("tag_albums_photo.html");
|
$template->content = new View("photo.html");
|
||||||
$template->content->title = $item->title;
|
$template->content->title = $item->title;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
} elseif ($item->is_movie()) {
|
} elseif ($item->is_movie()) {
|
||||||
$template = new Theme_View("page.html", "item", "movie");
|
$template = new Theme_View("calpage.html", "item", "movie");
|
||||||
$template->page_title = $item->title;
|
$template->page_title = $item->title;
|
||||||
$template->set_global("children", Array());
|
$template->set_global("children", Array());
|
||||||
$template->set_global("item", $item);
|
$template->set_global("item", $item);
|
||||||
$template->set_global("previous_item", $previous_item);
|
$template->set_global("previous_item", $previous_item);
|
||||||
$template->set_global("next_item", $next_item);
|
$template->set_global("next_item", $next_item);
|
||||||
|
$template->set_global("is_tagalbum_page", true); // used for grey dragon
|
||||||
|
$template->set_global("tag_id", $tag_id); // used for grey dragon
|
||||||
|
$template->set_global("album_id", $album_id); // used for grey dragon
|
||||||
|
$template->set_global("parent_url", $parent_url); // Used by Grey Dragon.
|
||||||
|
$template->set_global("dynamic_siblings", $dynamic_siblings); // Used by Grey Dragon.
|
||||||
$template->set_global("children_count", 0);
|
$template->set_global("children_count", 0);
|
||||||
$template->set_global("position", $position);
|
$template->set_global("position", $position);
|
||||||
$template->set_global("sibling_count", $sibling_count);
|
$template->set_global("sibling_count", $sibling_count);
|
||||||
$template->content = new View("tag_albums_movie.html");
|
$template->content = new View("movie.html");
|
||||||
$template->content->title = $item->title;
|
$template->content->title = $item->title;
|
||||||
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
$template->set_global("breadcrumbs", $tag_album_breadcrumbs);
|
||||||
print $template;
|
print $template;
|
||||||
@ -487,7 +631,7 @@ class tag_albums_Controller extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _get_position($item_title, $item_id, $tag_ids, $sort_field, $sort_direction, $search_type) {
|
private function _get_position($item_title, $item_id, $tag_ids, $sort_field, $sort_direction, $search_type, $include_albums) {
|
||||||
// Determine an item's position within a virtual album.
|
// Determine an item's position within a virtual album.
|
||||||
|
|
||||||
// Convert ASC/DESC to < or > characters.
|
// Convert ASC/DESC to < or > characters.
|
||||||
@ -514,7 +658,9 @@ class tag_albums_Controller extends Controller {
|
|||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
$items_model->close();
|
$items_model->close();
|
||||||
$items_model->and_where("items.type", "!=", "album");
|
if ($include_albums == false) {
|
||||||
|
$items_model->and_where("items.type", "!=", "album");
|
||||||
|
}
|
||||||
$items_model->and_where($sort_field, $comp, $item_title);
|
$items_model->and_where($sort_field, $comp, $item_title);
|
||||||
$items_model->order_by($sort_field, $sort_direction);
|
$items_model->order_by($sort_field, $sort_direction);
|
||||||
$items_model->group_by("items.id");
|
$items_model->group_by("items.id");
|
||||||
@ -543,7 +689,9 @@ class tag_albums_Controller extends Controller {
|
|||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
$items_model->close();
|
$items_model->close();
|
||||||
$items_model->and_where("items.type", "!=", "album");
|
if ($include_albums == false) {
|
||||||
|
$items_model->and_where("items.type", "!=", "album");
|
||||||
|
}
|
||||||
$items_model->and_where($sort_field, "=", $item_title);
|
$items_model->and_where($sort_field, "=", $item_title);
|
||||||
$items_model->order_by($sort_field, $sort_direction);
|
$items_model->order_by($sort_field, $sort_direction);
|
||||||
$items_model->group_by("items.id");
|
$items_model->group_by("items.id");
|
||||||
@ -570,6 +718,9 @@ class tag_albums_Controller extends Controller {
|
|||||||
// higher then they should be. So instead, I'm manually selecting each column that I need.
|
// higher then they should be. So instead, I'm manually selecting each column that I need.
|
||||||
$items_model->select("items.id");
|
$items_model->select("items.id");
|
||||||
$items_model->select("items.name");
|
$items_model->select("items.name");
|
||||||
|
$items_model->select("items.title");
|
||||||
|
$items_model->select("items.view_count");
|
||||||
|
$items_model->select("items.owner_id");
|
||||||
$items_model->select("items.type");
|
$items_model->select("items.type");
|
||||||
$items_model->select("items.thumb_width");
|
$items_model->select("items.thumb_width");
|
||||||
$items_model->select("items.thumb_height");
|
$items_model->select("items.thumb_height");
|
||||||
@ -599,6 +750,41 @@ class tag_albums_Controller extends Controller {
|
|||||||
return $items_model->find_all($page_size, $offset);
|
return $items_model->find_all($page_size, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _get_filter_html($album_id, $str_filter) {
|
||||||
|
// Generate HTML to display filter links on the index page.
|
||||||
|
|
||||||
|
// Make sure $album_id is set.
|
||||||
|
if ($album_id == "") {
|
||||||
|
$album_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the links.
|
||||||
|
$str_html = "Filter: ";
|
||||||
|
if ($str_filter != "") {
|
||||||
|
if ($album_id > 0) {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/album/" . $album_id) . "\">(All)</a> ";
|
||||||
|
} else {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/") . "\">(All)</a> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($str_filter == "NUM") {
|
||||||
|
$str_html .= "# ";
|
||||||
|
} else {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/filter/" . $album_id . "/NUM") . "\">#</a> ";
|
||||||
|
}
|
||||||
|
foreach(range('A','Z') as $letter) {
|
||||||
|
if ($letter == $str_filter) {
|
||||||
|
$str_html .= $letter . " ";
|
||||||
|
} else {
|
||||||
|
$str_html .= "<a href=\"" . url::site("tag_albums/filter/" . $album_id . "/" . $letter) . "\">";
|
||||||
|
$str_html .= $letter . "</a> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the HTML.
|
||||||
|
return $str_html;
|
||||||
|
}
|
||||||
|
|
||||||
private function _count_records($tag_ids, $search_type, $include_albums) {
|
private function _count_records($tag_ids, $search_type, $include_albums) {
|
||||||
// Count the number of viewable items for the designated tag(s)
|
// Count the number of viewable items for the designated tag(s)
|
||||||
// and return that number.
|
// and return that number.
|
||||||
|
Reference in New Issue
Block a user