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; } /** * @see Rest_Controller::_create($resource) */ public function _create($album) { access::required("edit", $album); switch ($this->input->post("type")) { case "album": return $this->_create_album($album); case "photo": return $this->_create_photo($album); default: access::forbidden(); } } private function _create_album($album) { access::required("edit", $album); $form = album::get_add_form($album); if ($form->validate()) { $new_album = album::create( $album, $this->input->post("name"), $this->input->post("title", $this->input->post("name")), $this->input->post("description"), user::active()->id); log::add("content", "Created an album", log::INFO, html::anchor("albums/$new_album->id", "view album")); message::add(_("Successfully created album")); rest::http_status(rest::CREATED); rest::http_location(url::site("albums/$new_album->id")); } else { print $form; } } private function _create_photo($album) { access::required("edit", $album); $form = photo::get_add_form($album); if ($form->validate()) { $photo = photo::create( $album, $this->input->post("file"), $_FILES["file"]["name"], $this->input->post("title", $this->input->post("name")), $this->input->post("description"), user::active()->id); log::add("content", "Added a photo", log::INFO, html::anchor("photos/$photo->id", "view photo")); message::add(_("Successfully added photo")); //rest::http_status(rest::CREATED); //rest::http_location(url::site("photos/$photo->id")); print "