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;
 }
Example #2
0
 public function day($display_year, $display_user, $display_month, $display_day)
 {
     // Display all images for the specified day.
     // Figure out the total number of photos to display.
     if ($display_user == "-1") {
         $day_count = ORM::factory("item")->viewable()->where("type !=", "album")->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))->where("captured <", mktime(0, 0, 0, $display_month, $display_day + 1, $display_year))->find_all()->count();
     } else {
         $day_count = ORM::factory("item")->viewable()->where("owner_id", $display_user)->where("type !=", "album")->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))->where("captured <", mktime(0, 0, 0, $display_month, $display_day + 1, $display_year))->find_all()->count();
     }
     // Figure out paging stuff.
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = $this->input->get("page", "1");
     $offset = ($page - 1) * $page_size;
     $max_pages = ceil($day_count / $page_size);
     // Make sure that the page references a valid offset
     if ($page < 1 || $day_count && $page > ceil($day_count / $page_size)) {
         Kohana::show_404();
     }
     // Set up the page.
     $template = new Theme_View("page.html", "other", "CalendarDayView");
     $template->page_title = t("Gallery :: Calendar");
     $template->set_global("page_size", $page_size);
     // Figure out which photos go on this page.
     if ($display_user == "-1") {
         $template->set_global("children", ORM::factory("item")->viewable()->where("type !=", "album")->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))->where("captured <", mktime(0, 0, 0, $display_month, $display_day + 1, $display_year))->orderby("captured", "ASC")->find_all($page_size, $offset));
     } else {
         $template->set_global("children", ORM::factory("item")->viewable()->where("owner_id", $display_user)->where("type !=", "album")->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))->where("captured <", mktime(0, 0, 0, $display_month, $display_day + 1, $display_year))->orderby("captured", "ASC")->find_all($page_size, $offset));
     }
     // Finish setting up and then display the page.
     $template->set_global("children_count", $day_count);
     $template->content = new View("dynamic.html");
     $template->content->title = t("Photos From ") . date("d F Y", mktime(0, 0, 0, $display_month, $display_day, $display_year));
     print $template;
 }
Example #3
0
 public function index()
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $q = Input::instance()->get("q");
     $q_with_more_terms = search::add_query_terms($q);
     $show = Input::instance()->get("show");
     if ($show) {
         $child = ORM::factory("item", $show);
         $index = search::get_position($child, $q_with_more_terms);
         if ($index) {
             $page = ceil($index / $page_size);
             url::redirect(url::abs_site("search?q=" . urlencode($q) . ($page == 1 ? "" : "&page={$page}")));
         }
     }
     $page = Input::instance()->get("page", 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         $page = 1;
     }
     $offset = ($page - 1) * $page_size;
     list($count, $result) = search::search($q_with_more_terms, $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");
     $root = item::root();
     $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, "breadcrumbs" => array(Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance($q, url::abs_site("search?q=" . urlencode($q)))->set_last()), "children_count" => $count));
     $template->content = new View("search.html");
     $template->content->items = $result;
     $template->content->q = $q;
     print $template;
     item::set_display_context_callback("Search_Controller::get_display_context", $title, $q_with_more_terms, $q);
 }
Example #4
0
 private function _show($album)
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $album_defn = unserialize(module::get_var("dynamic", $album));
     $input = Input::instance();
     $show = $input->get("show");
     if ($show) {
         $child = ORM::factory("item", $show);
         $index = dynamic::get_position($album_defn, $child);
         if ($index) {
             $page = ceil($index / $page_size);
             url::redirect("dynamic/{$album}" . ($page == 1 ? "" : "?page={$page}"));
         }
     } else {
         $page = (int) $input->get("page", "1");
     }
     $children_count = dynamic::get_display_count($album_defn);
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect(url::merge(array("page" => 1)));
     } else {
         if ($page > $max_pages) {
             url::redirect(url::merge(array("page" => $max_pages)));
         }
     }
     $root = item::root();
     $template = new Theme_View("page.html", "collection", "dynamic");
     $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, "children" => dynamic::items($album_defn->key_field, $page_size, $offset), "breadcrumbs" => array(Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance($album_defn->title, url::site("dynamic/{$album}"))->set_last()), "children_count" => $children_count));
     $template->content = new View("dynamic.html");
     $template->content->title = t($album_defn->title);
     print $template;
     item::set_display_context_callback("Dynamic_Controller::get_display_context", $album_defn, $album);
 }
Example #5
0
 public function index()
 {
     $template = new Theme_View("page.html", "other", "About");
     $template->css("about.css");
     $template->page_title = t("Gallery :: About");
     $template->content = new View("about.html");
     print $template;
 }
Example #6
0
 /**
  *  @see REST_Controller::_show($resource)
  */
 public function _show($photo)
 {
     access::required("view", $photo);
     $where = array("type != " => "album");
     $position = $photo->parent()->get_position($photo, $where);
     if ($position > 1) {
         list($previous_item, $ignore, $next_item) = $photo->parent()->children(3, $position - 2, $where);
     } else {
         $previous_item = null;
         list($next_item) = $photo->parent()->viewable()->children(1, $position, $where);
     }
     $template = new Theme_View("page.html", "photo");
     $template->set_global("item", $photo);
     $template->set_global("children", array());
     $template->set_global("children_count", 0);
     $template->set_global("parents", $photo->parents());
     $template->set_global("next_item", $next_item);
     $template->set_global("previous_item", $previous_item);
     $template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where));
     $template->set_global("position", $position);
     $template->content = new View("photo.html");
     $photo->view_count++;
     $photo->save();
     print $template;
 }
Example #7
0
 public function show($movie)
 {
     if (!is_object($movie)) {
         // show() must be public because we route to it in url::parse_url(), so make
         // sure that we're actually receiving an object
         Kohana::show_404();
     }
     access::required("view", $movie);
     $where = array(array("type", "!=", "album"));
     $position = $movie->parent()->get_position($movie, $where);
     if ($position > 1) {
         list($previous_item, $ignore, $next_item) = $movie->parent()->children(3, $position - 2, $where);
     } else {
         $previous_item = null;
         list($next_item) = $movie->parent()->viewable()->children(1, $position, $where);
     }
     $template = new Theme_View("page.html", "item", "movie");
     $template->set_global("item", $movie);
     $template->set_global("children", array());
     $template->set_global("children_count", 0);
     $template->set_global("parents", $movie->parents());
     $template->set_global("next_item", $next_item);
     $template->set_global("previous_item", $previous_item);
     $template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where));
     $template->set_global("position", $position);
     $template->content = new View("movie.html");
     $movie->view_count++;
     $movie->save();
     print $template;
 }
Example #8
0
 public function show($movie)
 {
     if (!is_object($movie)) {
         // show() must be public because we route to it in url::parse_url(), so make
         // sure that we're actually receiving an object
         throw new Kohana_404_Exception();
     }
     access::required("view", $movie);
     $template = new Theme_View("page.html", "item", "movie");
     $template->set_global(array("item" => $movie, "children" => array(), "children_count" => 0));
     $template->set_global(item::get_display_context($movie));
     $template->content = new View("movie.html");
     $movie->increment_view_count();
     print $template;
 }
Example #9
0
 public function index()
 {
     $template = new Theme_View("page.html", "other", "All Tags");
     $template->css("all_tags.css");
     $template->page_title = t("Gallery :: All Tags");
     $template->content = new View("all_tags.html");
     $filter = Input::instance()->get("filter");
     $template->content->filter = $filter;
     $query = ORM::factory("tag");
     if ($filter) {
         $query->like("name", $filter);
     }
     $template->content->tags = $query->order_by("name", "ASC")->find_all();
     print $template;
 }
 public function showuser()
 {
     if (identity::active_user()->guest && !module::get_var("photoannotation", "allowguestsearch", false)) {
         message::error(t("You have to log in to perform a people search."));
         url::redirect(url::site());
         return;
     }
     $form = photoannotation::get_user_search_form("g-user-cloud-form");
     $user_id = Input::instance()->get("name", "");
     if ($user_id == "") {
         $user_id = Input::instance()->post("name", "");
     }
     $getuser = photoannotation::getuser($user_id);
     if ($getuser->found) {
         url::redirect(user_profile::url($getuser->user->id));
         return;
     }
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = Input::instance()->get("page", 1);
     $offset = ($page - 1) * $page_size;
     // Make sure that the page references a valid offset
     if ($page < 1) {
         $page = 1;
     }
     list($count, $result) = photoannotation::search_user($user_id, $page_size, $offset);
     $max_pages = max(ceil($count / $page_size), 1);
     if ($page > 1) {
         $previous_page_url = url::site("photoannotation/showuser?name=" . $user_id . "&amp;page=" . ($page - 1));
     }
     if ($page < $max_pages) {
         $next_page_url = url::site("photoannotation/showuser?name=" . $user_id . "&amp;page=" . ($page + 1));
     }
     if ($user_id == "") {
         $user_id = "*";
     }
     $template = new Theme_View("page.html", "other", "usersearch");
     $template->set_global("position", $page);
     $template->set_global("total", $max_pages);
     $template->content = new View("photoannotation_user_search.html");
     $template->content->search_form = photoannotation::get_user_search_form(g - user - search - form);
     $template->content->users = $result;
     $template->content->q = $user_id;
     $template->content->count = $count;
     $template->content->paginator = new View("paginator.html");
     $template->content->paginator->previous_page_url = $previous_page_url;
     $template->content->paginator->next_page_url = $next_page_url;
     print $template;
 }
Example #11
0
 public function show($tag_id)
 {
     $tag = ORM::factory("tag", $tag_id);
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = (int) Input::instance()->get("page", "1");
     $children_count = $tag->items_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect($album->abs_url());
     } else {
         if ($page > $max_pages) {
             url::redirect($album->abs_url("page={$max_pages}"));
         }
     }
     $template = new Theme_View("page.html", "collection", "tag");
     $template->set_global("page", $page);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("page_size", $page_size);
     $template->set_global("tag", $tag);
     $template->set_global("children", $tag->items($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     $template->content->title = $tag->name;
     print $template;
 }
Example #12
0
 public function show($album)
 {
     if (!is_object($album)) {
         // show() must be public because we route to it in url::parse_url(), so make
         // sure that we're actually receiving an object
         throw new Kohana_404_Exception();
     }
     access::required("view", $album);
     $page_size = module::get_var("gallery", "page_size", 9);
     $input = Input::instance();
     $show = $input->get("show");
     if ($show) {
         $child = ORM::factory("item", $show);
         $index = $album->get_position($child);
         if ($index) {
             $page = ceil($index / $page_size);
             if ($page == 1) {
                 url::redirect($album->abs_url());
             } else {
                 url::redirect($album->abs_url("page={$page}"));
             }
         }
     }
     $page = $input->get("page", "1");
     $children_count = $album->viewable()->children_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect($album->abs_url());
     } else {
         if ($page > $max_pages) {
             url::redirect($album->abs_url("page={$max_pages}"));
         }
     }
     $template = new Theme_View("page.html", "collection", "album");
     $template->set_global("page", $page);
     $template->set_global("page_title", null);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("page_size", $page_size);
     $template->set_global("item", $album);
     $template->set_global("children", $album->viewable()->children($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->set_global("parents", $album->parents());
     $template->content = new View("album.html");
     // We can't use math in ORM or the query builder, so do this by hand.  It's important
     // that we do this with math, otherwise concurrent accesses will damage accuracy.
     db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = {$album->id}");
     print $template;
 }
Example #13
0
 public function _show($tag)
 {
     $page_size = module::get_var("core", "page_size", 9);
     $page = $this->input->get("page", "1");
     $children_count = $tag->items_count();
     $offset = ($page - 1) * $page_size;
     // Make sure that the page references a valid offset
     if ($page < 1 || $page > ceil($children_count / $page_size)) {
         Kohana::show_404();
     }
     $template = new Theme_View("page.html", "tag");
     $template->set_global('page_size', $page_size);
     $template->set_global('tag', $tag);
     $template->set_global('children', $tag->items($page_size, $offset));
     $template->set_global('children_count', $children_count);
     $template->content = new View("tag.html");
     print $template;
 }
Example #14
0
 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;
     }
 }
Example #15
0
 public function index()
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $q = $this->input->get("q");
     $page = $this->input->get("page", 1);
     $offset = ($page - 1) * $page_size;
     // Make sure that the page references a valid offset
     if ($page < 1) {
         $page = 1;
     }
     list($count, $result) = search::search($q, $page_size, $offset);
     $template = new Theme_View("page.html", "search");
     $template->set_global("page_size", $page_size);
     $template->set_global("children_count", $count);
     $template->content = new View("search.html");
     $template->content->items = $result;
     $template->content->q = $q;
     print $template;
 }
Example #16
0
 public function drawfaces($id)
 {
     // Generate the page that allows the user to draw boxes over a photo.
     // Make sure user has access to view and edit the photo.
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     // Create the page.
     $template = new Theme_View("page.html", "drawfaces");
     $template->set_global("item_id", $id);
     $template->set_global("page_title", t("Draw Faces"));
     $template->set_global("page_type", "photoface");
     $template->content = new View("drawfaces.html");
     $template->content->title = t("Tag Faces");
     $template->content->form = $this->_get_faces_form($id);
     $template->content->delete_form = $this->_get_delfaces_form($id);
     // Display the page.
     print $template;
 }
Example #17
0
 public function index()
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $q = Input::instance()->get("q");
     $page = Input::instance()->get("page", 1);
     $offset = ($page - 1) * $page_size;
     // Make sure that the page references a valid offset
     if ($page < 1) {
         $page = 1;
     }
     list($count, $result) = search::search($q, $page_size, $offset);
     $max_pages = max(ceil($count / $page_size), 1);
     $template = new Theme_View("page.html", "collection", "search");
     $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, "children_count" => $count));
     $template->content = new View("search.html");
     $template->content->items = $result;
     $template->content->q = $q;
     print $template;
 }
Example #18
0
 public function show($album)
 {
     if (!is_object($album)) {
         // show() must be public because we route to it in url::parse_url(), so make
         // sure that we're actually receiving an object
         throw new Kohana_404_Exception();
     }
     access::required("view", $album);
     $page_size = module::get_var("gallery", "page_size", 9);
     $input = Input::instance();
     $show = $input->get("show");
     if ($show) {
         $child = ORM::factory("item", $show);
         $index = item::get_position($child);
         if ($index) {
             $page = ceil($index / $page_size);
             if ($page == 1) {
                 url::redirect($album->abs_url());
             } else {
                 url::redirect($album->abs_url("page={$page}"));
             }
         }
     }
     $page = $input->get("page", "1");
     $children_count = $album->viewable()->children_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect($album->abs_url());
     } else {
         if ($page > $max_pages) {
             url::redirect($album->abs_url("page={$max_pages}"));
         }
     }
     $five_items = $album->viewable()->children(5, 0);
     $template = new Theme_View("page.html", "collection", "album");
     $template->set_global(array("page" => $page, "page_title" => null, "max_pages" => $max_pages, "page_size" => $page_size, "item" => $album, "fiveitems" => $five_items, "children" => $album->viewable()->children($page_size, $offset), "parents" => $album->parents()->as_array(), "breadcrumbs" => Breadcrumb::array_from_item_parents($album), "children_count" => $children_count));
     $template->content = new View("album.html");
     $album->increment_view_count();
     print $template;
     item::set_display_context_callback("Albums_Controller::get_display_context");
 }
Example #19
0
 /**
  *  @see REST_Controller::_show($resource)
  */
 public function _show($album)
 {
     access::required("view", $album);
     $page_size = module::get_var("core", "page_size", 9);
     $show = $this->input->get("show");
     if ($show) {
         $index = $album->get_position($show);
         $page = ceil($index / $page_size);
         if ($page == 1) {
             url::redirect("albums/{$album->id}");
         } else {
             url::redirect("albums/{$album->id}?page={$page}");
         }
     }
     $page = $this->input->get("page", "1");
     $children_count = $album->viewable()->children_count();
     $offset = ($page - 1) * $page_size;
     // Make sure that the page references a valid offset
     if ($page < 1 || $page > max(ceil($children_count / $page_size), 1)) {
         Kohana::show_404();
     }
     $template = new Theme_View("page.html", "album");
     $template->set_global("page_size", $page_size);
     $template->set_global("item", $album);
     $template->set_global("children", $album->viewable()->children($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->set_global("parents", $album->parents());
     $template->content = new View("album.html");
     $album->view_count++;
     $album->save();
     print $template;
 }
Example #20
0
 private function _show($album)
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = Input::instance()->get("page", "1");
     $album_defn = unserialize(module::get_var("dynamic", $album));
     $children_count = $album_defn->limit;
     if (empty($children_count)) {
         $children_count = ORM::factory("item")->viewable()->where("type", "!=", "album")->count_all();
     }
     $offset = ($page - 1) * $page_size;
     $max_pages = ceil($children_count / $page_size);
     // Make sure that the page references a valid offset
     if ($page < 1 || $children_count && $page > ceil($children_count / $page_size)) {
         throw new Kohana_404_Exception();
     }
     $template = new Theme_View("page.html", "collection", "dynamic");
     $template->set_global("page", $page);
     $template->set_global("page_size", $page_size);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("children", ORM::factory("item")->viewable()->where("type", "!=", "album")->order_by($album_defn->key_field, "DESC")->find_all($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     $template->content->title = t($album_defn->title);
     print $template;
 }
Example #21
0
 public function show($photo)
 {
     if (!is_object($photo)) {
         // show() must be public because we route to it in url::parse_url(), so make
         // sure that we're actually receiving an object
         throw new Kohana_404_Exception();
     }
     access::required("view", $photo);
     $where = array(array("type", "!=", "album"));
     $position = item::get_position($photo, $where);
     if ($position > 1) {
         list($previous_item, $ignore, $next_item) = $photo->parent()->viewable()->children(3, $position - 2, $where);
     } else {
         $previous_item = null;
         list($next_item) = $photo->parent()->viewable()->children(1, $position, $where);
     }
     $template = new Theme_View("page.html", "item", "photo");
     $template->set_global(array("item" => $photo, "children" => array(), "children_count" => 0, "parents" => $photo->parents()->as_array(), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $photo->parent()->viewable()->children_count($where), "position" => $position));
     $template->content = new View("photo.html");
     $photo->increment_view_count();
     print $template;
 }
Example #22
0
 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;
 }
Example #23
0
 public function __call($function, $args)
 {
     $tag_name = $function;
     $tag = ORM::factory("tag")->where("name", "=", $tag_name)->find();
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = (int) Input::instance()->get("page", "1");
     $children_count = $tag->items_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect(url::merge(array("page" => 1)));
     } else {
         if ($page > $max_pages) {
             url::redirect(url::merge(array("page" => $max_pages)));
         }
     }
     $template = new Theme_View("page.html", "collection", "tag");
     $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, "tag" => $tag, "children" => $tag->items($page_size, $offset), "children_count" => $children_count));
     $template->content = new View("dynamic.html");
     $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name));
     print $template;
 }
Example #24
0
 public function __call($function, $args)
 {
     $tag_id = $function;
     $tag = ORM::factory("tag")->where("id", "=", $tag_id)->find();
     $page_size = module::get_var("gallery", "page_size", 9);
     $input = Input::instance();
     $show = $input->get("show");
     if ($show) {
         $child = ORM::factory("item", $show);
         $index = tag::get_position($tag, $child);
         if ($index) {
             $page = ceil($index / $page_size);
             $uri = "tag/{$tag_id}/" . urlencode($tag->name);
             url::redirect($uri . ($page == 1 ? "" : "?page={$page}"));
         }
     } else {
         $page = (int) $input->get("page", "1");
     }
     $children_count = $tag->items_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect(url::merge(array("page" => 1)));
     } else {
         if ($page > $max_pages) {
             url::redirect(url::merge(array("page" => $max_pages)));
         }
     }
     $root = item::root();
     $template = new Theme_View("page.html", "collection", "tag");
     $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, "tag" => $tag, "children" => $tag->items($page_size, $offset), "breadcrumbs" => array(Breadcrumb::instance($root->title, $root->url())->set_first(), Breadcrumb::instance(t("Tag: %tag_name", array("tag_name" => $tag->name)), $tag->url())->set_last()), "children_count" => $children_count));
     $template->content = new View("dynamic.html");
     $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name));
     print $template;
     item::set_display_context_callback("Tag_Controller::get_display_context", $tag->id);
 }
Example #25
0
 /**
  * Add a new comment to the collection.
  */
 public function create($id)
 {
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     $form = comment::get_add_form($item);
     $valid = $form->validate();
     if ($valid) {
         if (identity::active_user()->guest && !$form->add_comment->inputs["name"]->value) {
             $form->add_comment->inputs["name"]->add_error("missing", 1);
             $valid = false;
         }
         if (!$form->add_comment->text->value) {
             $form->add_comment->text->add_error("missing", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $comment = comment::create($item, identity::active_user(), $form->add_comment->text->value, $form->add_comment->inputs["name"]->value, $form->add_comment->email->value, $form->add_comment->url->value);
         $active = identity::active_user();
         if ($active->guest) {
             $form->add_comment->inputs["name"]->value("");
             $form->add_comment->email->value("");
             $form->add_comment->url->value("");
         } else {
             $form->add_comment->inputs["name"]->value($active->full_name);
             $form->add_comment->email->value($active->email);
             $form->add_comment->url->value($active->url);
         }
         $form->add_comment->text->value("");
         $view = new Theme_View("comment.html", "other", "comment-fragment");
         $view->comment = $comment;
         print json_encode(array("result" => "success", "view" => $view->__toString(), "form" => $form->__toString()));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
Example #26
0
 /**
  *  @see REST_Controller::_show($resource)
  */
 public function _show($photo)
 {
     access::required("view", $photo);
     // We sort by id ascending so for now, find sibling info by doing id based queries.
     $next_item = ORM::factory("item")->viewable()->where("parent_id", $photo->parent_id)->where("id >", $photo->id)->orderby("id", "ASC")->find();
     $previous_item = ORM::factory("item")->viewable()->where("parent_id", $photo->parent_id)->where("id <", $photo->id)->orderby("id", "DESC")->find();
     $position = ORM::factory("item")->viewable()->where("parent_id", $photo->parent_id)->where("id <=", $photo->id)->count_all();
     $template = new Theme_View("page.html", "movie");
     $template->set_global("item", $photo);
     $template->set_global("children", array());
     $template->set_global("children_count", $photo->children_count());
     $template->set_global("parents", $photo->parents());
     $template->set_global("next_item", $next_item->loaded ? $next_item : null);
     $template->set_global("previous_item", $previous_item->loaded ? $previous_item : null);
     $template->set_global("sibling_count", $photo->parent()->children_count());
     $template->set_global("position", $position);
     $template->content = new View("movie.html");
     $photo->view_count++;
     $photo->save();
     print $template;
 }
Example #27
0
 /**
  *  @see REST_Controller::_show($resource)
  */
 public function _show($album)
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     if (!access::can("view", $album)) {
         if ($album->id == 1) {
             $view = new Theme_View("page.html", "login");
             $view->page_title = t("Log in to Gallery");
             $view->content = new View("login_ajax.html");
             $view->content->form = auth::get_login_form("login/auth_html");
             print $view;
             return;
         } else {
             access::forbidden();
         }
     }
     $show = $this->input->get("show");
     if ($show) {
         $child = ORM::factory("item", $show);
         $index = $album->get_position($child);
         if ($index) {
             $page = ceil($index / $page_size);
             if ($page == 1) {
                 url::redirect($album->abs_url());
             } else {
                 url::redirect($album->abs_url("page={$page}"));
             }
         }
     }
     $page = $this->input->get("page", "1");
     $children_count = $album->viewable()->children_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect($album->abs_url());
     } else {
         if ($page > $max_pages) {
             url::redirect($album->abs_url("page={$max_pages}"));
         }
     }
     $template = new Theme_View("page.html", "album");
     $template->set_global("page_size", $page_size);
     $template->set_global("item", $album);
     $template->set_global("children", $album->viewable()->children($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->set_global("parents", $album->parents());
     $template->content = new View("album.html");
     // We can't use math in ORM or the query builder, so do this by hand.  It's important
     // that we do this with math, otherwise concurrent accesses will damage accuracy.
     Database::instance()->query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = {$album->id}");
     print $template;
 }
Example #28
0
 public function index()
 {
     if (favourites_configuration::isUsersOnly() && identity::active_user()->name == "guest") {
         //login required.
         url::redirect("login/html");
         return;
     }
     $album = Favourites::getOrCreate()->get_as_album();
     $page_size = module::get_var("gallery", "page_size", 9);
     $input = Input::instance();
     $show = $input->get("show");
     if ($show) {
         $child = ORM::factory("item", $show);
         $index = $album->get_position($child);
         if ($index) {
             $page = ceil($index / $page_size);
             if ($page == 1) {
                 //url::redirect("favourites");
             } else {
                 //url::redirect("favourites?page=$page");
             }
         }
     }
     $page = $input->get("page", "1");
     $children_count = $album->viewable()->children_count();
     $offset = ($page - 1) * $page_size;
     $max_pages = max(ceil($children_count / $page_size), 1);
     // Make sure that the page references a valid offset
     if ($page < 1) {
         //url::redirect($album->abs_url());
     } else {
         if ($page > $max_pages) {
             //url::redirect($album->abs_url("page=$max_pages"));
         }
     }
     $template = new Theme_View("page.html", "collection", "favourites");
     $template->set_global("page", $page);
     $template->set_global("page_title", null);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("page_size", $page_size);
     $template->set_global("children", $album->viewable()->children($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     print $template;
 }
Example #29
0
 public function _show($tag)
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = $this->input->get("page", "1");
     $children_count = $tag->items_count();
     $offset = ($page - 1) * $page_size;
     // Make sure that the page references a valid offset
     if ($page < 1 || $children_count && $page > ceil($children_count / $page_size)) {
         Kohana::show_404();
     }
     $template = new Theme_View("page.html", "tag");
     $template->set_global("page_size", $page_size);
     $template->set_global("page_title", t("Browse Tag::%name", array("name" => $tag->name)));
     $template->set_global("tag", $tag);
     $template->set_global("children", $tag->items($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     print $template;
 }
Example #30
0
 public function album($id)
 {
     // Displays a dynamic page containing items that have been
     //  tagged with one or more tags.
     // Load the specified ID to make sure it exists.
     $album_tags = ORM::factory("tags_album_id")->where("id", "=", $id)->find_all();
     // If it doesn't exist, redirect to the modules root page.
     if (count($album_tags) == 0) {
         url::redirect("tag_albums/");
     }
     // If it does exist, and is set to *, load a list of all tags.
     if ($album_tags[0]->tags == "*") {
         $this->index($id, "");
     } else {
         // Otherwise, populate this page with the specified items.
         // Inherit permissions, title and description from the album that linked to this page.
         $album = ORM::factory("item", $album_tags[0]->album_id);
         access::required("view", $album);
         $page_title = $album->title;
         $page_description = $album->description;
         // URL to this page
         $str_page_url = "tag_albums/album/" . $id . "/" . urlencode($album->name);
         // Determine page sort order.
         $sort_page_field = $album->sort_column;
         $sort_page_direction = $album->sort_order;
         // Determine search type (AND/OR) and generate an array of the tag ids.
         $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;
         // Figure out how many items to display on each page.
         $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);
                 if ($page == 1) {
                     url::redirect($str_page_url);
                 } else {
                     url::redirect($str_page_url . "?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
         //   don't allow the visitor to go below page 1.
         $page = Input::instance()->get("page", 1);
         if ($page < 1) {
             url::redirect($str_page_url);
         }
         // First item to display.
         $offset = ($page - 1) * $page_size;
         // Figure out what the highest page number is.
         $max_pages = ceil($count / $page_size);
         // Don't let the visitor go past the last page.
         if ($max_pages && $page > $max_pages) {
             url::redirect($str_page_url . "/?page={$max_pages}");
         }
         // Figure out which items to display on this page and store their details in $children.
         $tag_children = $this->_get_records($tag_ids, $page_size, $offset, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, true);
         // Set up the previous and next page buttons.
         if ($page > 1) {
             $previous_page = $page - 1;
             $view->previous_page_link = url::site($str_page_url . "/?page={$previous_page}");
         }
         if ($page < $max_pages) {
             $next_page = $page + 1;
             $view->next_page_link = url::site($str_page_url . "/?page={$next_page}");
         }
         // Set up breadcrumbs.
         $tag_album_breadcrumbs = array();
         $counter = 0;
         $tag_album_breadcrumbs[] = Breadcrumb::instance($album->title, $album->url())->set_last();
         $parent_item = ORM::factory("item", $album->parent_id);
         while ($parent_item->id != 1) {
             $tag_album_breadcrumbs[] = 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=" . $album->id;
         $tag_album_breadcrumbs = array_reverse($tag_album_breadcrumbs, true);
         // Set up and display the actual page.
         $template = new Theme_View("page.html", "collection", "Tag Albums");
         $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, "children" => $tag_children, "breadcrumbs" => $tag_album_breadcrumbs, "children_count" => $count));
         $template->page_title = $page_title;
         $template->content = new View("dynamic.html");
         $template->content->title = $page_title;
         $template->content->description = $page_description;
         $template->set_global("all_siblings", $this->_get_records($tag_ids, $count, 0, "items." . $sort_page_field, $sort_page_direction, $album_tags_search_type, false));
         print $template;
         // Set breadcrumbs on the photo pages to point back to the calendar day view.
         item::set_display_context_callback("tag_albums_Controller::get_display_context", 0, $id);
     }
 }