public function show($page_name) { // Display the page specified by $page_name, or a 404 error if it doesn't exist. // Run a database search to look up the page. $existing_page = ORM::factory("px_static_page")->where("name", "=", $page_name)->find_all(); // If it doesn't exist, display a 404 error. if (count($existing_page) == 0) { throw new Kohana_404_Exception(); } // Set up breadcrumbs. $breadcrumbs = array(); $root = item::root(); $breadcrumbs[] = Breadcrumb::instance($root->title, $root->url())->set_first(); $breadcrumbs[] = Breadcrumb::instance(t($existing_page[0]->title), url::site("pages_xtra/show/{$page_name}"))->set_last(); // Display the page. $template = new Theme_View("page.html", "other", "Pages"); $template->set_global(array("breadcrumbs" => $breadcrumbs)); // Call database variables into page header (off-page content). $site_title = module::get_var("pages_xtra", "site_title"); // Next line can be used as alternative to the following line // $template->page_title = t("Gallery :: ") . t($existing_page[0]->title); $template->page_title = t($existing_page[0]->title) . t(" :: {$site_title}"); $template->page_tags = $existing_page[0]->tags; $page_tags = trim(nl2br(html::purify($existing_page[0]->tags))); $template->page_description = $existing_page[0]->description; $page_description = trim(nl2br(html::purify($existing_page[0]->description))); // Set a new View and call database variables into page (on-page content). $template->content = new View("pages_xtra_display.html"); $template->content->title = $existing_page[0]->title; $template->content->body = $existing_page[0]->html_code; print $template; }
public function build_breadcrumbs_for_item_test() { $album = test::random_album(); $item = test::random_photo($album); $expected = array(); $expected[] = Breadcrumb::instance(item::root()->title, item::root()->url("show={$album->id}"))->set_first(); $expected[] = Breadcrumb::instance($album->title, $album->url("show={$item->id}")); $expected[] = Breadcrumb::instance($item->title, $item->url())->set_last(); $this->assert_equal($expected, Breadcrumb::array_from_item_parents($item)); }
static function get_display_context($item, $album_defn, $path) { $where = array(array("type", "!=", "album")); $position = dynamic::get_position($album_defn, $item, $where); if ($position > 1) { list($previous_item, $ignore, $next_item) = dynamic::items($album_defn->key_field, 3, $position - 2); } else { $previous_item = null; list($next_item) = dynamic::items($album_defn->key_field, 1, $position); } $root = item::root(); return array("position" => $position, "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => dynamic::get_display_count($album_defn), "siblings_callback" => array("dynamic::items", array($album_defn->key_field)), "breadcrumbs" => array(Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance($album_defn->title, url::site("dynamic/{$path}?show={$item->id}")), Breadcrumb::instance($item->title, $item->url())->set_last())); }
static function get_display_context($item, $tag_id) { $tag = ORM::factory("tag", $tag_id); $where = array(array("type", "!=", "album")); $position = tag::get_position($tag, $item, $where); if ($position > 1) { list($previous_item, $ignore, $next_item) = $tag->items(3, $position - 2, $where); } else { $previous_item = null; list($next_item) = $tag->items(1, $position, $where); } $root = item::root(); return array("position" => $position, "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => $tag->items_count($where), "breadcrumbs" => array(Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance(t("Tag: %tag_name", array("tag_name" => $tag->name)), $tag->url("show={$item->id}")), Breadcrumb::instance($item->title, $item->url())->set_last())); }
static function get_display_context($item, $title, $query_terms, $q) { $position = search::get_position($item, $query_terms); if ($position > 1) { list($count, $result_data) = search::search($query_terms, 3, $position - 2); list($previous_item, $ignore, $next_item) = $result_data; } else { $previous_item = null; list($count, $result_data) = search::search($query_terms, 1, $position); list($next_item) = $result_data; } $search_url = url::abs_site("search?q=" . urlencode($q) . "&show={$item->id}"); $root = item::root(); return array("position" => $position, "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => $count, "breadcrumbs" => array(Breadcrumb::instance($root->title, "/", $root->id)->set_first(), Breadcrumb::instance(t("Search: %q", array("q" => $q)), $search_url), Breadcrumb::instance($item->title, $item->url())->set_last())); }
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($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($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) . "&show={$item->id}"); $root = item::root(); return array("position" => $position, "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->url())->set_first(), Breadcrumb::instance(t("Search: %q", array("q" => $q)), $search_url), Breadcrumb::instance($item->title, $item->url())->set_last())); }
public function googlemap($fullsize) { // Display all tags with GPS coordinates on a google map. // If the user can't view maps, throw a 404 error. if (module::get_var("tagsmap", "restrict_maps") == true && identity::active_user()->guest) { throw new Kohana_404_Exception(); } // Generate a list of GPS coordinates. $tagsGPS = ORM::factory("tags_gps")->find_all(); // Set up and display the actual page. // If fullsize is true, allow the map to take up the entire browser window, // if not, then display the map in the gallery theme. if ($fullsize == true) { $view = new View("tagsmap_googlemap.html"); $view->map_fullsize = true; // Load in module preferences. $view->tags_gps = $tagsGPS; $view->google_map_key = module::get_var("tagsmap", "googlemap_api_key"); $view->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude"); $view->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude"); $view->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom"); $view->google_map_type = module::get_var("tagsmap", "googlemap_type"); print $view; } else { // Set up breadcrumbs. $breadcrumbs = array(); $root = item::root(); $breadcrumbs[] = Breadcrumb::instance($root->title, $root->url())->set_first(); $breadcrumbs[] = Breadcrumb::instance(t("Tag Map"), url::site("tagsmap/googlemap/"))->set_last(); $template = new Theme_View("page.html", "other", "tag"); $template->page_title = t("Gallery :: Map"); $template->set_global(array("breadcrumbs" => $breadcrumbs)); $template->content = new View("tagsmap_googlemap.html"); // Load in module preferences. $template->content->tags_gps = $tagsGPS; $template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key"); $template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude"); $template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude"); $template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom"); $template->content->google_map_type = module::get_var("tagsmap", "googlemap_type"); print $template; } }
public function show($page_name) { // Display the page specified by $page_name, or a 404 error if it doesn't exist. // Run a database search to look up the page. $existing_page = ORM::factory("static_page")->where("name", "=", $page_name)->find_all(); // If it doesn't exist, display a 404 error. if (count($existing_page) == 0) { throw new Kohana_404_Exception(); } // Set up breadcrumbs. $breadcrumbs = array(); $root = item::root(); $breadcrumbs[] = Breadcrumb::instance($root->title, $root->url())->set_first(); $breadcrumbs[] = Breadcrumb::instance(t($existing_page[0]->title), url::site("pages/show/{$page_name}"))->set_last(); // Display the page. $template = new Theme_View("page.html", "other", "Pages"); $template->set_global(array("breadcrumbs" => $breadcrumbs)); $template->page_title = t("Gallery :: ") . t($existing_page[0]->title); $template->content = new View("pages_display.html"); $template->content->title = $existing_page[0]->title; $template->content->body = $existing_page[0]->html_code; print $template; }
static function get_display_context($item, $tag_id, $album_id) { // Make sure #album_id is valid, clear it out if it isn't. // Note: $dynamic_siblings is used exclusively for Grey Dragon. $album_tags = ORM::factory("tags_album_id")->where("id", "=", $album_id)->find_all(); if (count($album_tags) == 0) { $album_id = 0; } // Load the tag and item, make sure the user has access to the item. $display_tag = ORM::factory("tag", $tag_id); // Figure out sort order from module preferences. $sort_page_field = ""; $sort_page_direction = ""; if ($tag_id > 0 || count($album_tags) == 0) { $sort_page_field = module::get_var("tag_albums", "subalbum_sort_by", "title"); $sort_page_direction = module::get_var("tag_albums", "subalbum_sort_direction", "ASC"); } else { $parent_album = ORM::factory("item", $album_tags[0]->album_id); $sort_page_field = $parent_album->sort_column; $sort_page_direction = $parent_album->sort_order; } // Load the number of items in the parent album, and determine previous and next items. $sibling_count = ""; $tag_children = ""; $previous_item = ""; $next_item = ""; $position = 0; $dynamic_siblings = ""; $siblings_callback_param = array(); if ($tag_id > 0) { $album_tags_search_type = ""; $sibling_count = tag_albums_Controller::_count_records(array($tag_id), "OR", false); $position = tag_albums_Controller::_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) { $previous_item_object = tag_albums_Controller::_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 = $previous_item_object[0]; } } $next_item_object = tag_albums_Controller::_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 = $next_item_object[0]; } $dynamic_siblings = tag_albums_Controller::_get_records(array($tag_id), $sibling_count, 0, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false); $siblings_callback_param = array(array($tag_id), $sibling_count, 0, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false); } else { $tag_ids = array(); foreach (explode(",", $album_tags[0]->tags) as $tag_name) { $tag = ORM::factory("tag")->where("name", "=", trim($tag_name))->find(); if ($tag->loaded()) { $tag_ids[] = $tag->id; } } $album_tags_search_type = $album_tags[0]->search_type; $sibling_count = tag_albums_Controller::_count_records($tag_ids, $album_tags_search_type, false); $position = tag_albums_Controller::_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) { $previous_item_object = tag_albums_Controller::_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) { $previous_item = $previous_item_object[0]; } } $next_item_object = tag_albums_Controller::_get_records($tag_ids, 1, $position, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false); if (count($next_item_object) > 0) { $next_item = $next_item_object[0]; } $dynamic_siblings = tag_albums_Controller::_get_records($tag_ids, $sibling_count, 0, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false); $siblings_callback_param = array($tag_ids, $sibling_count, 0, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false); } // Set up breadcrumbs $tag_album_breadcrumbs = array(); if ($album_id > 0) { $counter = 0; $tag_album_breadcrumbs[] = Breadcrumb::instance($item->title, $item->url())->set_last(); if ($album_tags[0]->tags == "*") { $tag_album_breadcrumbs[] = Breadcrumb::instance($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id . "/" . $album_id . "/" . urlencode($display_tag->name))); } $parent_item = ORM::factory("item", $album_tags[0]->album_id); $tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, url::site("tag_albums/album/" . $album_id . "/" . urlencode($parent_item->name))); $parent_item = ORM::factory("item", $parent_item->parent_id); while ($parent_item->id != 1) { $tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url()); $parent_item = ORM::factory("item", $parent_item->parent_id); } $tag_album_breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url())->set_first(); $tag_album_breadcrumbs[1]->url .= "?show=" . $item->id; $tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true); } else { $tag_album_breadcrumbs[] = Breadcrumb::instance(item::root()->title, item::root()->url())->set_first(); $tag_album_breadcrumbs[] = Breadcrumb::instance(module::get_var("tag_albums", "tag_page_title", "All Tags"), url::site("tag_albums/")); $tag_album_breadcrumbs[] = Breadcrumb::instance($display_tag->name, url::site("tag_albums/tag/" . $display_tag->id . "/" . urlencode($display_tag->name)) . "?show=" . $item->id); $tag_album_breadcrumbs[] = Breadcrumb::instance($item->title, $item->url())->set_last(); } return array("position" => $position, "previous_item" => $previous_item, "next_item" => $next_item, "tag_id" => $tag_id, "album_id" => $album_id, "is_tagalbum_page" => true, "dynamic_siblings" => $dynamic_siblings, "sibling_count" => $sibling_count, "siblings_callback" => array("tag_albums_Controller::get_siblings", $siblings_callback_param), "breadcrumbs" => $tag_album_breadcrumbs); }
static function get_display_month_context($item, $display_user, $display_year, $display_month) { // Set up default search conditions for retrieving all photos from the specified month. $where = array(array("type", "!=", "album")); if ($display_user != "-1") { $where[] = array("owner_id", "=", $display_user); } $where[] = array("captured", ">=", mktime(0, 0, 0, $display_month, 1, $display_year)); $where[] = array("captured", "<", mktime(0, 0, 0, $display_month + 1, 1, $display_year)); // Generate breadcrumbs for the photo page. $root = item::root(); $breadcrumbs = array(Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance($display_year, url::site("calendarview/calendar/" . $display_year . "/" . $display_user)), Breadcrumb::instance(t(date("F", mktime(0, 0, 0, $display_month, 1, $display_year))), url::site("calendarview/month/" . $display_year . "/" . $display_user . "/" . $display_month)), Breadcrumb::instance($item->title, $item->url())->set_last()); return CalendarView_Controller::get_display_context($item, $where, $breadcrumbs); }
public function map($map_type, $type_id) { // Map all items in the specified album or user. // Valid values for $map_type are "album" or "user", $type_id is either an // album id# or a user id#. // If the user can't view maps, throw a 404 error. if (module::get_var("exif_gps", "restrict_maps") == true && identity::active_user()->guest) { throw new Kohana_404_Exception(); } // Figure out what to display for the page title and how many items to display. $map_title = ""; $items_count = 0; if ($map_type == "album") { $curr_album = ORM::factory("item")->where("id", "=", $type_id)->find_all(); $map_title = $curr_album[0]->title; $items_count = ORM::factory("item", $type_id)->join("exif_coordinates", "items.id", "exif_coordinates.item_id")->viewable()->order_by("exif_coordinates.latitude", "ASC")->descendants_count(); } elseif ($map_type == "user") { $curr_user = ORM::factory("user")->where("id", "=", $type_id)->find_all(); $map_title = $curr_user[0]->full_name . "'s " . t("Photos"); $items_count = ORM::factory("item")->join("exif_coordinates", "items.id", "exif_coordinates.item_id")->where("items.owner_id", "=", $type_id)->viewable()->order_by("exif_coordinates.latitude", "ASC")->count_all(); } // Set up breadcrumbs. $breadcrumbs = array(); if ($map_type == "album") { $counter = 0; $breadcrumbs[] = Breadcrumb::instance(t("Map"), url::site("exif_gps/map/album/{$type_id}"))->set_last(); $parent_item = ORM::factory("item", $type_id); while ($parent_item->id != 1) { $breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url()); $parent_item = ORM::factory("item", $parent_item->parent_id); } $breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url())->set_first(); $breadcrumbs = array_reverse($breadcrumbs, true); } else { $root = item::root(); $breadcrumbs[] = Breadcrumb::instance($root->title, $root->url())->set_first(); $breadcrumbs[] = Breadcrumb::instance(t("Photo Map"), url::site("exif_gps/map/{$map_type}/{$type_id}"))->set_last(); } // Set up and display the actual page. $template = new Theme_View("page.html", "other", "EXIF_GPS_MAP"); $template->page_title = t("Gallery :: Map"); $template->set_global(array("breadcrumbs" => $breadcrumbs)); $template->content = new View("exif_gps_map.html"); if ($map_title == "") { $template->content->title = t("Map"); } else { $template->content->title = t("Map of") . " " . $map_title; } // Figure out default map type. $int_map_type = module::get_var("exif_gps", "largemap_maptype"); if ($int_map_type == 0) { $map_display_type = "ROADMAP"; } if ($int_map_type == 1) { $map_display_type = "SATELLITE"; } if ($int_map_type == 2) { $map_display_type = "HYBRID"; } if ($int_map_type == 3) { $map_display_type = "TERRAIN"; } $template->content->map_type = $map_display_type; // These are used to set up the URL to the xml file. $template->content->query_type = $map_type; $template->content->query_id = $type_id; $template->content->items_count = $items_count; // Load in module preferences. $template->content->google_map_key = module::get_var("exif_gps", "googlemap_api_key"); // Display the page. print $template; }
static function get_display_context($item, $str_display_type, $user_id) { // Set up display elements on the photo page to link to the virtual album. // Valid $str_display_type values are popular, recent, albums and descendants. // $user_id can be set to "0" to search site wide. // For "descendants", $user_id should be the album id #. // Figure out page title. $str_page_title = ""; if ($str_display_type == "recent") { $str_page_title = t("Recent Uploads"); } elseif ($str_display_type == "albums") { $str_page_title = t("Recent Albums"); } elseif ($str_display_type == "descendants") { $str_page_title = t("Recent Uploads"); } else { $str_page_title = t("Most Viewed"); } // Figure out item position. $position = latestupdates_Controller::_get_position($item, $str_display_type, $user_id); // Figure out which items are the previous and next items with the virtual album. if ($position > 1) { list($previous_item, $ignore, $next_item) = latestupdates_Controller::items($str_display_type, $user_id, 3, $position - 2); } else { $previous_item = null; list($next_item) = latestupdates_Controller::items($str_display_type, $user_id, 1, $position); } // Figure out total number of items (excluding albums). $count = latestupdates_Controller::items_count($str_display_type, $user_id); // Set up breadcrumbs. $root = item::root(); $breadcrumbs = array(); if ($user_id == 0) { $breadcrumbs[0] = Breadcrumb::instance($root->title, $root->url())->set_first(); $breadcrumbs[1] = Breadcrumb::instance($str_page_title, url::site("latestupdates/updates?show={$item->id}")); $breadcrumbs[2] = Breadcrumb::instance($item->title, $item->url())->set_last(); } else { if ($str_display_type == "descendants") { $counter = 0; $breadcrumbs[] = Breadcrumb::instance($item->title, $item->url())->set_last(); $breadcrumbs[] = Breadcrumb::instance(t("Recent Uploads"), url::site("latestupdates/albums/{$user_id}?show={$item->id}")); $parent_item = ORM::factory("item", $user_id); while ($parent_item->id != 1) { $breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url()); $parent_item = ORM::factory("item", $parent_item->parent_id); } $breadcrumbs[] = Breadcrumb::instance($parent_item->title, $parent_item->url())->set_first(); $breadcrumbs = array_reverse($breadcrumbs, true); } else { $current_user = ORM::factory("user", $user_id); $breadcrumbs[0] = Breadcrumb::instance($root->title, $root->url())->set_first(); $breadcrumbs[1] = Breadcrumb::instance(t("User profile: %name", array("name" => $current_user->display_name())), url::site("user_profile/show/{$user_id}")); $breadcrumbs[2] = Breadcrumb::instance($str_page_title, url::site("latestupdates/users/{$str_display_type}/{$user_id}?show={$item->id}")); $breadcrumbs[3] = Breadcrumb::instance($item->title, $item->url())->set_last(); } } // Return the display elements. return array("position" => $position, "previous_item" => $previous_item, "next_item" => $next_item, "sibling_count" => $count, "siblings_callback" => array("latestupdates_Controller::items", array($str_display_type, $user_id)), "breadcrumbs" => $breadcrumbs); }