diff options
-rw-r--r-- | .build_number | 2 | ||||
-rw-r--r-- | modules/g2_import/controllers/g2.php | 27 | ||||
-rw-r--r-- | modules/gallery/controllers/albums.php | 6 | ||||
-rw-r--r-- | modules/gallery/js/l10n_client.js | 6 | ||||
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 4 | ||||
-rw-r--r-- | modules/search/controllers/search.php | 24 | ||||
-rw-r--r-- | modules/tag/controllers/tag.php | 1 | ||||
-rw-r--r-- | modules/watermark/controllers/admin_watermarks.php | 2 |
8 files changed, 54 insertions, 18 deletions
diff --git a/.build_number b/.build_number index 5e7b340a..a0ca84e8 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=306 +build_number=311 diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 0645266b..3641b342 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -33,10 +33,30 @@ class G2_Controller extends Controller { $input = Input::instance(); $path = $input->get("path"); $id = $input->get("g2_itemId"); + $view = $input->get("g2_view"); - /* Tags are handled specially, since there's no mapping for them */ - if (($path && 0 === strpos($path, "tag/"))) { - url::redirect("tag_name/" . substr($path, 4)); + // Tags did not have mappings created, so we need to catch them first. However, if a g2_itemId was + // passed, we'll want to show lookup the mapping anyway + if (($path && 0 === strpos($path, "tag/")) || $view = "tags.VirtualAlbum") { + if (0 === strpos($path, "tag/")) { + $tag_name = substr($path, 4); + } + if ($view == "tags.VirtualAlbum") { + $tag_name = $input->get("g2_tagName"); + } + + if (!$id) { + url::redirect("tag_name/$tag_name"); + } + + $tag = ORM::factory("tag")->where("name", "=", $tag_name)->find(); + if ($tag->loaded()) { + item::set_display_context_callback("Tag_Controller::get_display_context", $tag->id); + // We want to show the item as part of the tag virtual album. Most of this code is below; we'll + // change $path and $view to let it fall through + $view = ""; + $path = ""; + } } if (($path && $path != 'index.php' && $path != 'main.php') || $id) { @@ -45,7 +65,6 @@ class G2_Controller extends Controller { // Gallery 2 don't specify g2_view if it's the default (core.ShowItem). And in some cases // (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled. $where = array(array("g2_id", "=", $id)); - $view = $input->get("g2_view"); if ($view == "core.DownloadItem") { $where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full")); } else if ($view) { diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index e14fe347..d545b415 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -93,10 +93,16 @@ class Albums_Controller extends Items_Controller { "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => $item->parent()->viewable()->children_count($where), + "siblings_callback" => array("Albums_Controller::get_siblings", array($item)), "parents" => $item->parents()->as_array(), "breadcrumbs" => Breadcrumb::array_from_item_parents($item)); } + static function get_siblings($item) { + // @todo consider creating Item_Model::siblings() if we use this more broadly. + return $item->parent()->viewable()->children(); + } + public function create($parent_id) { access::verify_csrf(); $album = ORM::factory("item", $parent_id); diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index a1b970e7..6d919c29 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -140,7 +140,11 @@ jQuery.extend(Gallery, { } else { if(search.length > 0) { $('#l10n-client-string-select li').hide(); - $('#l10n-client-string-select li:contains('+search+')').show(); + $('#l10n-client-string-select li').each(function() { + if ($(this).val().indexOf(search) != -1) { + $(this).show(); + } + }); $('#l10n-client #g-l10n-search').val(search); } } diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 8d69f23b..cf384109 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -86,6 +86,10 @@ class Theme_View_Core extends Gallery_View { return $this->item; } + public function siblings() { + return call_user_func_array($this->siblings_callback[0], $this->siblings_callback[1]); + } + public function tag() { return $this->tag; } diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index f7f1d981..673a281f 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -54,8 +54,6 @@ class Search_Controller extends Controller { list ($count, $result) = search::search_within_album($q_with_more_terms, $album, $page_size, $offset); - $title = t("Search: %q", array("q" => $q_with_more_terms)); - $max_pages = max(ceil($count / $page_size), 1); $template = new Theme_View("page.html", "collection", "search"); @@ -77,28 +75,27 @@ class Search_Controller extends Controller { print $template; - item::set_display_context_callback( - "Search_Controller::get_display_context", $album->id, $title, $q_with_more_terms, $q); + item::set_display_context_callback("Search_Controller::get_display_context", $album, $q); } - static function get_display_context($item, $album_id, $title, $query_terms, $q) { - $album = ORM::factory("item", $album_id); - $position = search::get_position_within_album($item, $query_terms, $album); + static function get_display_context($item, $album, $q) { + $q_with_more_terms = search::add_query_terms($q); + $position = search::get_position_within_album($item, $q_with_more_terms, $album); if ($position > 1) { list ($count, $result_data) = - search::search_within_album($query_terms, $album, 3, $position - 2); + search::search_within_album($q_with_more_terms, $album, 3, $position - 2); list ($previous_item, $ignore, $next_item) = $result_data; } else { $previous_item = null; list ($count, $result_data) = - search::search_within_album($query_terms, $album, 1, $position); + search::search_within_album($q_with_more_terms, $album, 1, $position); list ($next_item) = $result_data; } $search_url = url::abs_site("search" . "?q=" . urlencode($q) . - "&album=" . urlencode($album_id) . + "&album=" . urlencode($album->id) . "&show={$item->id}"); $root = item::root(); @@ -106,9 +103,14 @@ class Search_Controller extends Controller { "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => $count, + "siblings_callback" => array("Search_Controller::get_siblings", array($q, $album)), "breadcrumbs" => array( - Breadcrumb::instance($root->title, "/", $root->id)->set_first(), + Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance(t("Search: %q", array("q" => $q)), $search_url), Breadcrumb::instance($item->title, $item->url())->set_last())); } + + static function get_siblings($q, $album) { + return search::search_within_album(search::add_query_terms($q), $album, 1000, 1)[1]; + } } diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 6199c49b..bada9bac 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -86,6 +86,7 @@ class Tag_Controller extends Controller { "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => $tag->items_count($where), + "siblings_callback" => array(array($tag, "items"), array()), "breadcrumbs" => array( Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance(t("Tag: %tag_name", array("tag_name" => $tag->name)), diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php index 1cc0c392..2d656c9f 100644 --- a/modules/watermark/controllers/admin_watermarks.php +++ b/modules/watermark/controllers/admin_watermarks.php @@ -66,7 +66,7 @@ class Admin_Watermarks_Controller extends Admin_Controller { $form = watermark::get_delete_form(); if ($form->validate()) { - if ($name = module::get_var("watermark", "name")) { + if ($name = basename(module::get_var("watermark", "name"))) { @unlink(VARPATH . "modules/watermark/$name"); module::clear_var("watermark", "name"); |