summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/config/upload.php2
-rw-r--r--modules/gallery/controllers/movies.php9
-rw-r--r--modules/gallery/controllers/photos.php9
-rw-r--r--modules/gallery/css/gallery.css39
-rw-r--r--modules/gallery/helpers/gallery_theme.php1
-rw-r--r--modules/gallery/libraries/InPlaceEdit.php88
-rw-r--r--modules/gallery/models/item.php34
-rw-r--r--modules/gallery/views/in_place_edit.html.php16
8 files changed, 147 insertions, 51 deletions
diff --git a/modules/gallery/config/upload.php b/modules/gallery/config/upload.php
index 897ecacf..69ea7768 100644
--- a/modules/gallery/config/upload.php
+++ b/modules/gallery/config/upload.php
@@ -33,4 +33,4 @@ $config['create_directories'] = FALSE;
/**
* Remove spaces from uploaded filenames.
*/
-$config['remove_spaces'] = TRUE; \ No newline at end of file
+$config['remove_spaces'] = FALSE; \ No newline at end of file
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 01a9fc8b..6200e8b4 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -25,13 +25,14 @@ class Movies_Controller extends Items_Controller {
public function _show($movie) {
access::required("view", $movie);
- $position = $movie->parent()->get_position($movie);
+ $where = 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);
+ $movie->parent()->children(3, $position - 2, $where);
} else {
$previous_item = null;
- list ($next_item) = $movie->parent()->viewable()->children(1, $position);
+ list ($next_item) = $movie->parent()->viewable()->children(1, $position, $where);
}
$template = new Theme_View("page.html", "movie");
@@ -41,7 +42,7 @@ class Movies_Controller extends Items_Controller {
$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());
+ $template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where));
$template->set_global("position", $position);
$template->content = new View("movie.html");
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 54cd63c6..b9adfd90 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -25,13 +25,14 @@ class Photos_Controller extends Items_Controller {
public function _show($photo) {
access::required("view", $photo);
- $position = $photo->parent()->get_position($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);
+ $photo->parent()->children(3, $position - 2, $where);
} else {
$previous_item = null;
- list ($next_item) = $photo->parent()->viewable()->children(1, $position);
+ list ($next_item) = $photo->parent()->viewable()->children(1, $position, $where);
}
$template = new Theme_View("page.html", "photo");
@@ -41,7 +42,7 @@ class Photos_Controller extends Items_Controller {
$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());
+ $template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where));
$template->set_global("position", $position);
$template->content = new View("photo.html");
diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css
index a4a52155..724c50d3 100644
--- a/modules/gallery/css/gallery.css
+++ b/modules/gallery/css/gallery.css
@@ -1,8 +1,3 @@
-/**
- * @todo Make #g-welcome-message p unecessary
- * @todo Review permissions dialog, find home
- */
-
/* Permissions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#g-edit-permissions-form {
@@ -15,7 +10,6 @@
#g-edit-permissions-form fieldset {
border: 1px solid #ccc;
- padding: 0;
}
#g-permissions .g-denied,
@@ -42,59 +36,52 @@
background: #999;
}
+/* In-place edit ~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+#g-inplace-edit-form ul {
+ margin: 0;
+}
+
/* Simple uploader ~~~~~~~~~~~~~~~~~~~~~~~ */
#g-add-photos #SWFUpload_0 {
+ left: 134px;
position: relative;
top: -200px;
- left: 134px;
-}
-
-#g-add-photos .g-breadcrumbs {
- border: 0;
- margin: 0;
- padding-left:10px;
}
#g-add-photos-canvas {
border: 1px solid #ccc;
- margin: .5em 0 .5em 0;
- width: 469px;
height: 325px;
+ margin: .5em 0;
overflow: auto;
+ width: 469px;
}
#g-add-photos button {
- margin-bottom: .5em;
float: right;
+ margin-bottom: .5em;
}
+
#g-uploadqueue-infobar {
clear: both;
}
#g-uploadqueue-infobar #g-cancelupload {
- display: none;
cursor: pointer;
-}
-
-#g-add-photos-canvas {
+ display: none;
}
#g-add-photos-queue .progressbar {
height: 4px;
}
-#g-add-photos-queue .title {
- font-size: 1.25em;
-}
-
#g-add-photos-queue .status {
font-size: .75em;
}
#g-add-photos-queue .box {
- margin-bottom: 8px;
- padding: 4px;
+ padding: .2em;
}
#g-add-photos-queue .pending {
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 3fcaca67..0682d4ae 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -61,6 +61,7 @@ class gallery_theme_Core {
}
static function admin_head($theme) {
+ $theme->css("gallery.css");
$theme->script("gallery.panel.js");
$session = Session::instance();
if ($session->get("debug")) {
diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php
new file mode 100644
index 00000000..057874e3
--- /dev/null
+++ b/modules/gallery/libraries/InPlaceEdit.php
@@ -0,0 +1,88 @@
+<?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 InPlaceEdit_Core {
+ private $rules = array();
+ private $messages = array();
+ private $callback = array();
+ private $initial_value;
+ private $action = "";
+ private $errors;
+ private $form;
+
+ static function factory($initial_value) {
+ $instance = new InPlaceEdit();
+ $instance->initial_value = $initial_value;
+ $instance->form = array("input" => $initial_value);
+ $instance->errors = array("input" => "");
+
+ return $instance;
+ }
+
+ public function add_action($action) {
+ $this->action = $action;
+ return $this;
+ }
+
+ public function add_rules($rules) {
+ $this->rules += $rules;
+ return $this;
+ }
+
+ public function add_messages($messages) {
+ $this->messages += $messages;
+ return $this;
+ }
+
+ public function add_callback($callback) {
+ $this->callback = $callback;
+ return $this;
+ }
+
+ public function validate() {
+ $post = Validation::factory($_POST)
+ ->add_callbacks("input", $this->callback);
+ foreach ($this->rules as $rule) {
+ $post->add_rules("input", $rule);
+ }
+
+ $valid = $post->validate();
+ $this->form = array_merge($this->form, $post->as_array());
+ $this->errors = array_merge($this->errors, $post->errors());
+ return $valid;
+ }
+
+ public function render() {
+ $v = new View("in_place_edit.html");
+ $v->hidden = array("csrf" => access::csrf_token());
+ $v->action = url::site($this->action);
+ $v->form = $this->form;
+ $v->errors = $this->errors;
+ foreach ($v->errors as $key => $error) {
+ if (!empty($error)) {
+ $v->errors[$key] = $this->messages[$error];
+ }
+ }
+ return $v->render();
+ }
+
+ public function value() {
+ return $this->form["input"];
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index fc0f0193..9735ed62 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -422,7 +422,7 @@ class Item_Model extends ORM_MPTT {
* 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.
*/
- public function get_position($child) {
+ public function get_position($child, $where=array()) {
if ($this->sort_order == "DESC") {
$comp = ">";
} else {
@@ -435,18 +435,20 @@ class Item_Model extends ORM_MPTT {
$count = $db->from("items")
->where("parent_id", $this->id)
->where($this->sort_column, NULL)
+ ->where($where)
->count_records();
if (empty($count)) {
// There are no NULLs in the sort column, so we can just use it directly.
- $position = $db->query("
- SELECT COUNT(*) AS position FROM {items}
- WHERE `parent_id` = {$this->id}
- AND `{$this->sort_column}` $comp (SELECT `{$this->sort_column}`
- FROM {items} WHERE `id` = $child->id)")
- ->current()->position;
-
- // We stopped short of our target value in the sort (notice that we're using a < comparator
+ $sort_column = $this->sort_column;
+
+ $position = $db->from("items")
+ ->where("parent_id", $this->id)
+ ->where("$sort_column < ", $child->$sort_column)
+ ->where($where)
+ ->count_records();
+
+ // We stopped short of our target value in the sort (notice that we're using a < comparator
// above) because it's possible that we have duplicate values in the sort column. An
// equality check would just arbitrarily pick one of those multiple possible equivalent
// columns, which would mean that if you choose a sort order that has duplicates, it'd pick
@@ -454,13 +456,12 @@ class Item_Model extends ORM_MPTT {
//
// Fix this by doing a 2nd query where we iterate over the equivalent columns and add them to
// our base value.
- $result = $db->query("
- SELECT id FROM {items}
- WHERE `parent_id` = {$this->id}
- AND `{$this->sort_column}` = (SELECT `{$this->sort_column}`
- FROM {items} WHERE `id` = $child->id)
- ORDER BY `id` ASC");
- foreach ($result as $row) {
+ foreach ($db->from("items")
+ ->where("parent_id", $this->id)
+ ->where($sort_column, $child->$sort_column)
+ ->where($where)
+ ->orderby(array("id" => "ASC"))
+ ->get() as $row) {
$position++;
if ($row->id == $child->id) {
break;
@@ -484,6 +485,7 @@ class Item_Model extends ORM_MPTT {
foreach ($db->select("id")
->from("items")
->where("parent_id", $this->id)
+ ->where($where)
->orderby($orderby)
->get() as $row) {
$position++;
diff --git a/modules/gallery/views/in_place_edit.html.php b/modules/gallery/views/in_place_edit.html.php
new file mode 100644
index 00000000..64671d57
--- /dev/null
+++ b/modules/gallery/views/in_place_edit.html.php
@@ -0,0 +1,16 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<?= form::open($action, array("method" => "post", "id" => "g-inplace-edit-form", "class" => "g-short-form"), $hidden) ?>
+ <ul>
+ <li <? if (!empty($errors["input"])): ?> class="g-error"<? endif ?>>
+ <?= form::input("input", $form["input"], " class='textbox'") ?>
+ </li>
+ <li>
+ <?= form::submit(array("class" => "submit ui-state-default"), t("Save")) ?>
+ </li>
+ <li><a href="#" class="g-cancel"><?= t("Cancel") ?></a></li>
+ </ul>
+<?= form::close() ?>
+<? if (!empty($errors["input"])): ?>
+<div id="g-inplace-edit-message" class="g-error"><?= $errors["input"] ?></div>
+<? endif ?>
+