コード例 #1
0
ファイル: albums.php プロジェクト: qboy1987/mooiyou
 static function get_display_context($item)
 {
     $where = array(array("type", "!=", "album"));
     $position = item::get_position($item, $where);
     if ($position > 1) {
         list($previous_item, $ignore, $next_item) = $item->parent()->viewable()->children(3, $position - 2, $where);
     } else {
         $previous_item = null;
         list($next_item) = $item->parent()->viewable()->children(1, $position, $where);
     }
     return array("position" => $position, "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));
 }
コード例 #2
0
ファイル: albums.php プロジェクト: kandsten/gallery3
 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}"));
         }
     }
     $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, "children" => $album->viewable()->children($page_size, $offset), "parents" => $album->parents()->as_array(), "children_count" => $children_count));
     $template->content = new View("album.html");
     $album->increment_view_count();
     print $template;
 }
コード例 #3
0
ファイル: photos.php プロジェクト: Joe7/gallery3
 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;
 }
コード例 #4
0
ファイル: item.php プロジェクト: assad2012/gallery3-appfog
 /**
  * Find the position of the given child id in this album.  The resulting value is 1-indexed, so
  * the first child in the album is at position 1.
  *
  * This method stands as a backward compatibility for gallery 3.0, and will
  * be deprecated in version 3.1.
  */
 public function get_position($child, $where = array())
 {
     return item::get_position($child, $where);
 }
コード例 #5
0
ファイル: quick.php プロジェクト: HarriLu/gallery3
 public function delete($id)
 {
     access::verify_csrf();
     $item = model_cache::get("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     if ($item->is_album()) {
         $msg = t("Deleted album <b>%title</b>", array("title" => html::purify($item->title)));
     } else {
         $msg = t("Deleted photo <b>%title</b>", array("title" => html::purify($item->title)));
     }
     $redirect = $item->parent();
     // redirect to this item, if current item was deleted
     if ($item->is_album()) {
         // Album delete will trigger deletes for all children.  Do this in a batch so that we can be
         // smart about notifications, album cover updates, etc.
         batch::start();
         $item->delete();
         batch::stop();
     } else {
         $where = array(array("type", "!=", "album"));
         // evaluate redirect item before delete of current item
         $position = item::get_position($item, $where);
         if ($position > 1) {
             list($previous_item, $ignore, $next_item) = $item->parent()->viewable()->children(3, $position - 2, $where);
         } else {
             $previous_item = null;
             list($next_item) = $item->parent()->viewable()->children(1, $position, $where);
         }
         if ($next_item) {
             $redirect = $next_item;
         } else {
             if ($previous_item) {
                 $redirect = $previous_item;
             }
         }
         $item->delete();
     }
     message::success($msg);
     $from_id = Input::instance()->get("from_id");
     if (Input::instance()->get("page_type") == "collection" && $from_id != $id) {
         json::reply(array("result" => "success", "reload" => 1));
     } else {
         json::reply(array("result" => "success", "location" => $redirect->url()));
     }
 }