summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.htaccess16
-rw-r--r--modules/gallery/controllers/albums.php230
2 files changed, 122 insertions, 124 deletions
diff --git a/.htaccess b/.htaccess
index c3f94237..8c2e3793 100644
--- a/.htaccess
+++ b/.htaccess
@@ -29,13 +29,12 @@
# ExpiresByType text/html A1
# </IfModule>
-# You can use mod_rewrite to enable short urls in Gallery 3 (which
-# gets rid of the "index.php" from your urls). To do this, you must
-# uncomment the block below that starts with <IfModule> and ends with
-# </IfModule> then properly configure the RewriteBase line in the
-# block below. You just need to change RewriteBase line to match your
-# Gallery 3 URL. Here are some examples:
+# You can use the mod_rewrite Apache module to get rid of the
+# "index.php" from your Gallery 3 urls. Uncomment the block below
+# inside the <IfModule> ... </IfModule> lines and then edit the
+# RewriteBase line to match your Gallery 3 URL.
#
+# Here are some RewriteBase values:
# Gallery 3 URL RewriteBase line
# ============= ====================
# http://example.com/gallery3 RewriteBase /gallery3
@@ -45,9 +44,8 @@
# Then just use your Gallery 3 without the index.php in the url.
#
# NOTE: future upgrades of Gallery 3 will overwrite this file! If you
-# want these changes to be persistent, you should talk to your system
-# administrator about putting this block into your Apache config
-# files.
+# want these changes to be persistent, talk to your system admin about
+# putting this block into your Apache config files.
#
# <IfModule mod_rewrite.c>
# RewriteEngine On
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 8ceff0f9..5f62f798 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -1,118 +1,118 @@
- <?php defined("SYSPATH") or die("No direct script access.");
- /**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
- class Albums_Controller extends Items_Controller {
-
- /**
- * @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 = user::get_login_form("login/auth_html");
- print $view;
- return;
- } else {
- access::forbidden();
- }
- }
-
- $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;
- $max_pages = max(ceil($children_count / $page_size), 1);
-
- // Make sure that the page references a valid offset
- if ($page < 1) {
- url::redirect("albums/$album->id");
- } else if ($page > $max_pages) {
- url::redirect("albums/$album->id?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;
- }
-
- /**
- * @see REST_Controller::_create($resource)
- */
- public function _create($album) {
- access::verify_csrf();
- access::required("view", $album);
- access::required("add", $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("view", $album);
- access::required("add", $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::success("content", "Created an album",
- html::anchor("albums/$new_album->id", "view album"));
- message::success(t("Created album %album_title",
- array("album_title" => html::purify($new_album->title))));
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Albums_Controller extends Items_Controller {
+
+ /**
+ * @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 = user::get_login_form("login/auth_html");
+ print $view;
+ return;
+ } else {
+ access::forbidden();
+ }
+ }
+
+ $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;
+ $max_pages = max(ceil($children_count / $page_size), 1);
+
+ // Make sure that the page references a valid offset
+ if ($page < 1) {
+ url::redirect("albums/$album->id");
+ } else if ($page > $max_pages) {
+ url::redirect("albums/$album->id?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;
+ }
+
+ /**
+ * @see REST_Controller::_create($resource)
+ */
+ public function _create($album) {
+ access::verify_csrf();
+ access::required("view", $album);
+ access::required("add", $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("view", $album);
+ access::required("add", $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::success("content", "Created an album",
+ html::anchor("albums/$new_album->id", "view album"));
+ message::success(t("Created album %album_title",
+ array("album_title" => html::purify($new_album->title))));
print json_encode(
array("result" => "success",