summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-09-02 23:53:35 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-09-02 23:53:35 -0700
commit3dc7e2e78cab117726385e29d47bb1487b5d755d (patch)
tree1ffd4f0523a6c6b52b8a577dcddcf9fe9a7789d1 /modules
parentde61da5bfc9dac7d778f5ca3ff763125a212ec3f (diff)
parent640d84aba46f4dcd813d7c9ade320f665c1958c0 (diff)
Merge branch 'master' into talmdal
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/controllers/albums.php192
-rw-r--r--modules/gallery/views/admin_maintenance.html.php8
2 files changed, 100 insertions, 100 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 627ee052..5f62f798 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -17,102 +17,102 @@
* 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))));
+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",
diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php
index 4bca8653..ce693d73 100644
--- a/modules/gallery/views/admin_maintenance.html.php
+++ b/modules/gallery/views/admin_maintenance.html.php
@@ -7,7 +7,7 @@
<div id="gAvailableTasks">
<h2> <?= t("Available Tasks") ?> </h2>
- <table class="gMessages">
+ <table>
<tr>
<th>
<?= t("Name") ?>
@@ -21,7 +21,7 @@
</tr>
<? $i = 0; ?>
<? foreach ($task_definitions as $task): ?>
- <tr class="<?= log::severity_class($task->severity) ?> <?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>">
+ <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= log::severity_class($task->severity) ?>">
<td class="<?= log::severity_class($task->severity) ?>">
<?= $task->name ?>
</td>
@@ -69,7 +69,7 @@
</tr>
<? $i = 0; ?>
<? foreach ($running_tasks as $task): ?>
- <tr class="<?= $task->state == "stalled" ? "gWarning" : "" ?> <?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>">
+ <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= $task->state == "stalled" ? "gWarning" : "" ?>">
<td class="<?= $task->state == "stalled" ? "gWarning" : "" ?>">
<?= gallery::date_time($task->updated) ?>
</td>
@@ -142,7 +142,7 @@
</tr>
<? $i = 0; ?>
<? foreach ($finished_tasks as $task): ?>
- <tr class="<?= $task->state == "success" ? "gSuccess" : "gError" ?> <?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>">
+ <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= $task->state == "success" ? "gSuccess" : "gError" ?>">
<td class="<?= $task->state == "success" ? "gSuccess" : "gError" ?>">
<?= gallery::date_time($task->updated) ?>
</td>