1
0

Create all_siblings variable and full_or_resize_url() function for Shadowbox album view w/ Grey Dragon.

This commit is contained in:
rWatcher 2011-10-12 20:13:49 -04:00
parent 04d195787b
commit 891097f1d6
4 changed files with 46 additions and 12 deletions

View File

@ -100,7 +100,7 @@ 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);
$children = 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);
$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);
@ -141,6 +141,7 @@ class tag_albums_Controller extends Controller {
$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");
@ -317,7 +318,7 @@ class tag_albums_Controller extends Controller {
->where("items_tags.tag_id", "=", $one_tag->id)
->order_by("items.id", "DESC")
->find_all(1, 0);
$child_tag = new Tag_Albums_Item($one_tag->name, url::site("tag_albums/tag/" . $one_tag->id . "/" . $id . "/" . urlencode($one_tag->name)), "album");
$child_tag = new Tag_Albums_Item($one_tag->name, url::site("tag_albums/tag/" . $one_tag->id . "/" . $id . "/" . urlencode($one_tag->name)), "album", 0);
if (count($tag_item) > 0) {
if ($tag_item[0]->has_thumb()) {
$child_tag->set_thumb($tag_item[0]->thumb_url(), $tag_item[0]->thumb_width, $tag_item[0]->thumb_height);
@ -430,7 +431,7 @@ class tag_albums_Controller extends Controller {
// Create an array of "fake" items to display on the page.
$children = 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);
$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);
@ -491,6 +492,7 @@ class tag_albums_Controller extends Controller {
$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");
@ -542,12 +544,12 @@ class tag_albums_Controller extends Controller {
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);
if (count($previous_item_object) > 0) {
$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 . "/" . urlencode($previous_item_object[0]->name)), $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 . "/" . urlencode($previous_item_object[0]->name)), $previous_item_object[0]->type, $previous_item_object[0]->id);
}
}
$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) {
$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 . "/" . urlencode($next_item_object[0]->name)), $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 . "/" . urlencode($next_item_object[0]->name)), $next_item_object[0]->type, $next_item_object[0]->id);
}
$dynamic_siblings = $this->_get_records(Array($tag_id), null, null, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
} else {

View File

@ -20,6 +20,7 @@
class Tag_Albums_Item_Core {
public $title = "";
public $id = -1;
public $item_id = 0;
public $url = "#";
public $thumb_url = "";
public $thumb_width = 0;
@ -45,6 +46,19 @@ class Tag_Albums_Item_Core {
}
}
public function full_or_resize_url() {
if ($this->item_id > 0) {
$item = ORM::factory("item", $this->item_id);
if (access::can("view_full", $item)) {
return $item->file_url();
} else {
return $item->resize_url();
}
} else {
return "";
}
}
public function thumb_img($extra_attrs=array(), $max=null, $center_vertically=false) {
list ($height, $width) = $this->scale_dimensions($max);
if ($center_vertically && $max) {
@ -105,10 +119,11 @@ class Tag_Albums_Item_Core {
$this->thumb_height = $new_height;
}
public function __construct($new_title, $new_url, $new_type) {
public function __construct($new_title, $new_url, $new_type, $new_id) {
$this->title = $new_title;
$this->url = $new_url;
$this->item_type = $new_type;
$this->type = $new_type;
$this->item_id = $new_id;
}
}

View File

@ -100,7 +100,7 @@ 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);
$children = 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);
$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);
@ -141,6 +141,7 @@ class tag_albums_Controller extends Controller {
$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");
@ -317,7 +318,7 @@ class tag_albums_Controller extends Controller {
->where("items_tags.tag_id", "=", $one_tag->id)
->order_by("items.id", "DESC")
->find_all(1, 0);
$child_tag = new Tag_Albums_Item($one_tag->name, url::site("tag_albums/tag/" . $one_tag->id . "/" . $id . "/" . urlencode($one_tag->name)), "album");
$child_tag = new Tag_Albums_Item($one_tag->name, url::site("tag_albums/tag/" . $one_tag->id . "/" . $id . "/" . urlencode($one_tag->name)), "album", 0);
if (count($tag_item) > 0) {
if ($tag_item[0]->has_thumb()) {
$child_tag->set_thumb($tag_item[0]->thumb_url(), $tag_item[0]->thumb_width, $tag_item[0]->thumb_height);
@ -430,7 +431,7 @@ class tag_albums_Controller extends Controller {
// Create an array of "fake" items to display on the page.
$children = 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);
$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);
@ -491,6 +492,7 @@ class tag_albums_Controller extends Controller {
$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");
@ -542,12 +544,12 @@ class tag_albums_Controller extends Controller {
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);
if (count($previous_item_object) > 0) {
$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 . "/" . urlencode($previous_item_object[0]->name)), $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 . "/" . urlencode($previous_item_object[0]->name)), $previous_item_object[0]->type, $previous_item_object[0]->id);
}
}
$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) {
$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 . "/" . urlencode($next_item_object[0]->name)), $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 . "/" . urlencode($next_item_object[0]->name)), $next_item_object[0]->type, $next_item_object[0]->id);
}
$dynamic_siblings = $this->_get_records(Array($tag_id), null, null, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false);
} else {

View File

@ -20,6 +20,7 @@
class Tag_Albums_Item_Core {
public $title = "";
public $id = -1;
public $item_id = 0;
public $url = "#";
public $thumb_url = "";
public $thumb_width = 0;
@ -45,6 +46,19 @@ class Tag_Albums_Item_Core {
}
}
public function full_or_resize_url() {
if ($this->item_id > 0) {
$item = ORM::factory("item", $this->item_id);
if (access::can("view_full", $item)) {
return $item->file_url();
} else {
return $item->resize_url();
}
} else {
return "";
}
}
public function thumb_img($extra_attrs=array(), $max=null, $center_vertically=false) {
list ($height, $width) = $this->scale_dimensions($max);
if ($center_vertically && $max) {
@ -105,10 +119,11 @@ class Tag_Albums_Item_Core {
$this->thumb_height = $new_height;
}
public function __construct($new_title, $new_url, $new_type) {
public function __construct($new_title, $new_url, $new_type, $new_id) {
$this->title = $new_title;
$this->url = $new_url;
$this->item_type = $new_type;
$this->type = $new_type;
$this->item_id = $new_id;
}
}