mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-02 13:10:48 -04:00
Merge branch 'master' into talmdal_dev
This commit is contained in:
@@ -88,8 +88,8 @@
|
||||
* @return object
|
||||
*/
|
||||
$.fn.gallery_get_photo = function() {
|
||||
var photo = $(this).find("img").filter(function() {
|
||||
return this.id.match(/g-photo-id-\d+/);
|
||||
var photo = $(this).find("img,object").filter(function() {
|
||||
return this.id.match(/g-(photo|movie)-id-\d+/);
|
||||
});
|
||||
return photo;
|
||||
};
|
||||
|
||||
@@ -299,7 +299,10 @@ class Forge_Core {
|
||||
}
|
||||
|
||||
// Set the form open and close
|
||||
$form->open = form::$form_type(arr::remove('action', $this->attr), $this->attr, $hidden);
|
||||
$form->open = form::$form_type(arr::remove('action', $this->attr), $this->attr);
|
||||
foreach ($this->hidden as $hidden) {
|
||||
$form->open .= form::hidden($hidden->name, $hidden->value);
|
||||
}
|
||||
$form->close = "</form>";
|
||||
|
||||
// Set the inputs
|
||||
|
||||
@@ -157,8 +157,6 @@ class Albums_Controller extends Items_Controller {
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$watching_album = $album->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH));
|
||||
|
||||
$album->title = $form->edit_item->title->value;
|
||||
$album->description = $form->edit_item->description->value;
|
||||
$album->sort_column = $form->edit_item->sort_order->column->value;
|
||||
@@ -174,9 +172,13 @@ class Albums_Controller extends Items_Controller {
|
||||
message::success(t("Saved album %album_title",
|
||||
array("album_title" => html::purify($album->title))));
|
||||
|
||||
print json_encode(
|
||||
array("result" => "success",
|
||||
"location" => $watching_album ? $location : $album->url()));
|
||||
if ($form->from_id->value == $album->id) {
|
||||
// Use the new url; it might have changed.
|
||||
print json_encode(array("result" => "success", "location" => $album->url()));
|
||||
} else {
|
||||
// Stay on the same page
|
||||
print json_encode(array("result" => "success"));
|
||||
}
|
||||
} else {
|
||||
print json_encode(
|
||||
array("result" => "error",
|
||||
|
||||
@@ -110,8 +110,13 @@ class Movies_Controller extends Items_Controller {
|
||||
message::success(
|
||||
t("Saved movie %movie_title", array("movie_title" => $movie->title)));
|
||||
|
||||
print json_encode(
|
||||
array("result" => "success"));
|
||||
if ($form->from_id->value == $movie->id) {
|
||||
// Use the new url; it might have changed.
|
||||
print json_encode(array("result" => "success", "location" => $movie->url()));
|
||||
} else {
|
||||
// Stay on the same page
|
||||
print json_encode(array("result" => "success"));
|
||||
}
|
||||
} else {
|
||||
print json_encode(
|
||||
array("result" => "error",
|
||||
@@ -123,6 +128,7 @@ class Movies_Controller extends Items_Controller {
|
||||
$movie = ORM::factory("item", $movie_id);
|
||||
access::required("view", $movie);
|
||||
access::required("edit", $movie);
|
||||
|
||||
print movie::get_edit_form($movie);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,6 @@ class Photos_Controller extends Items_Controller {
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$watching_album = $photo->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH));
|
||||
|
||||
$photo->title = $form->edit_item->title->value;
|
||||
$photo->description = $form->edit_item->description->value;
|
||||
$photo->slug = $form->edit_item->slug->value;
|
||||
@@ -110,12 +108,15 @@ class Photos_Controller extends Items_Controller {
|
||||
|
||||
log::success("content", "Updated photo", "<a href=\"{$photo->url()}\">view</a>");
|
||||
message::success(
|
||||
t("Saved photo %photo_title",
|
||||
array("photo_title" => html::purify($photo->title))));
|
||||
t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title))));
|
||||
|
||||
print json_encode(
|
||||
array("result" => "success",
|
||||
"location" => $watching_album ? $location : $photo->url()));
|
||||
if ($form->from_id->value == $photo->id) {
|
||||
// Use the new url; it might have changed.
|
||||
print json_encode(array("result" => "success", "location" => $photo->url()));
|
||||
} else {
|
||||
// Stay on the same page
|
||||
print json_encode(array("result" => "success"));
|
||||
}
|
||||
} else {
|
||||
print json_encode(
|
||||
array("result" => "error",
|
||||
|
||||
@@ -133,13 +133,21 @@ class Quick_Controller extends Controller {
|
||||
|
||||
switch ($item->type) {
|
||||
case "album":
|
||||
return print album::get_edit_form($item);
|
||||
$form = album::get_edit_form($item);
|
||||
break;
|
||||
|
||||
case "photo":
|
||||
return print photo::get_edit_form($item);
|
||||
$form = photo::get_edit_form($item);
|
||||
break;
|
||||
|
||||
case "movie":
|
||||
return print movie::get_edit_form($item);
|
||||
$form = movie::get_edit_form($item);
|
||||
break;
|
||||
}
|
||||
|
||||
// Pass on the source item where this form was generated, so we have an idea where to return to.
|
||||
$form->hidden("from_id")->value((int)Input::instance()->get("from_id", 0));
|
||||
|
||||
print $form;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ class album_Core {
|
||||
|
||||
static function get_edit_form($parent) {
|
||||
$form = new Forge("albums/update/{$parent->id}", "", "post", array("id" => "g-edit-album-form"));
|
||||
$form->hidden("from_id");
|
||||
$group = $form->group("edit_item")->label(t("Edit Album"));
|
||||
|
||||
$group->input("title")->label(t("Title"))->value($parent->title);
|
||||
|
||||
@@ -272,8 +272,6 @@ class gallery_event_Core {
|
||||
->css_class("ui-icon-carat-1-n"));
|
||||
|
||||
if (access::can("edit", $item)) {
|
||||
$page_type = $theme->page_type();
|
||||
$page_subtype = $theme->page_subtype();
|
||||
switch ($item->type) {
|
||||
case "movie":
|
||||
$edit_title = t("Edit this movie");
|
||||
@@ -295,11 +293,12 @@ class gallery_event_Core {
|
||||
|
||||
$csrf = access::csrf_token();
|
||||
|
||||
$theme_item = $theme->item();
|
||||
$options_menu->append(Menu::factory("dialog")
|
||||
->id("edit")
|
||||
->label($edit_title)
|
||||
->css_class("ui-icon-pencil")
|
||||
->url(url::site("quick/form_edit/$item->id?page_type=$page_type")));
|
||||
->url(url::site("quick/form_edit/$item->id?from_id=$theme_item->id")));
|
||||
|
||||
if ($item->is_photo() && graphics::can("rotate")) {
|
||||
$options_menu
|
||||
@@ -310,7 +309,7 @@ class gallery_event_Core {
|
||||
->css_class("ui-icon-rotate-ccw")
|
||||
->ajax_handler("function(data) { " .
|
||||
"\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
|
||||
->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type")))
|
||||
->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&from_id=$theme_item->id")))
|
||||
->append(
|
||||
Menu::factory("ajax_link")
|
||||
->id("rotate_cw")
|
||||
@@ -318,12 +317,12 @@ class gallery_event_Core {
|
||||
->css_class("ui-icon-rotate-cw")
|
||||
->ajax_handler("function(data) { " .
|
||||
"\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
|
||||
->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type")));
|
||||
->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&from_id=$theme_item->id")));
|
||||
}
|
||||
|
||||
// @todo Don't move photos from the photo page; we don't yet have a good way of redirecting
|
||||
// after move
|
||||
if ($page_subtype == "album") {
|
||||
if ($theme->page_subtype() == "album") {
|
||||
$options_menu
|
||||
->append(Menu::factory("dialog")
|
||||
->id("move")
|
||||
@@ -358,7 +357,7 @@ class gallery_event_Core {
|
||||
->label($delete_title)
|
||||
->css_class("ui-icon-trash")
|
||||
->css_id("g-quick-delete")
|
||||
->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")));
|
||||
->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id")));
|
||||
}
|
||||
|
||||
if ($item->is_album()) {
|
||||
|
||||
@@ -130,6 +130,7 @@ class movie_Core {
|
||||
|
||||
static function get_edit_form($movie) {
|
||||
$form = new Forge("movies/update/$movie->id", "", "post", array("id" => "g-edit-movie-form"));
|
||||
$form->hidden("from_id");
|
||||
$group = $form->group("edit_item")->label(t("Edit Movie"));
|
||||
$group->input("title")->label(t("Title"))->value($movie->title);
|
||||
$group->textarea("description")->label(t("Description"))->value($movie->description);
|
||||
|
||||
@@ -139,6 +139,7 @@ class photo_Core {
|
||||
|
||||
static function get_edit_form($photo) {
|
||||
$form = new Forge("photos/update/$photo->id", "", "post", array("id" => "g-edit-photo-form"));
|
||||
$form->hidden("from_id");
|
||||
$group = $form->group("edit_item")->label(t("Edit Photo"));
|
||||
$group->input("title")->label(t("Title"))->value($photo->title);
|
||||
$group->textarea("description")->label(t("Description"))->value($photo->description);
|
||||
|
||||
@@ -23,7 +23,6 @@ class DrawForm_Test extends Unit_Test_Case {
|
||||
$form->input("title")->label(t("Title"));
|
||||
$form->textarea("description")->label(t("Text Area"));
|
||||
$form->submit("")->value(t("Submit"));
|
||||
$rendered = $form->__toString();
|
||||
|
||||
$csrf = access::csrf_token();
|
||||
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
|
||||
@@ -45,7 +44,7 @@ class DrawForm_Test extends Unit_Test_Case {
|
||||
" </li>\n" .
|
||||
" </ul>\n" .
|
||||
"</form>";
|
||||
$this->assert_same($expected, $rendered);
|
||||
$this->assert_same($expected, (string) $form);
|
||||
}
|
||||
|
||||
function group_test() {
|
||||
@@ -54,7 +53,6 @@ class DrawForm_Test extends Unit_Test_Case {
|
||||
$group->input("title")->label(t("Title"));
|
||||
$group->textarea("description")->label(t("Text Area"));
|
||||
$group->submit("")->value(t("Submit"));
|
||||
$rendered = $form->__toString();
|
||||
|
||||
$csrf = access::csrf_token();
|
||||
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
|
||||
@@ -79,7 +77,7 @@ class DrawForm_Test extends Unit_Test_Case {
|
||||
" </ul>\n" .
|
||||
" </fieldset>\n" .
|
||||
"</form>";
|
||||
$this->assert_same($expected, $rendered);
|
||||
$this->assert_same($expected, (string) $form);
|
||||
}
|
||||
|
||||
function form_script_test() {
|
||||
@@ -91,7 +89,6 @@ class DrawForm_Test extends Unit_Test_Case {
|
||||
->url(url::file("test.js"))
|
||||
->text("alert('Test Javascript');");
|
||||
$group->submit("")->value(t("Submit"));
|
||||
$rendered = $form->__toString();
|
||||
|
||||
$csrf = access::csrf_token();
|
||||
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
|
||||
@@ -120,7 +117,21 @@ class DrawForm_Test extends Unit_Test_Case {
|
||||
"alert('Test Javascript');\n" .
|
||||
"</script>\n" .
|
||||
"</form>";
|
||||
$this->assert_same($expected, $rendered);
|
||||
$this->assert_same($expected, (string) $form);
|
||||
}
|
||||
|
||||
function two_hiddens_test() {
|
||||
$form = new Forge("test/controller", "", "post");
|
||||
$form->hidden("HIDDEN_NAME")->value("HIDDEN_VALUE");
|
||||
|
||||
$csrf = access::csrf_token();
|
||||
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" class=\"form\">\n" .
|
||||
"<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" .
|
||||
"<input type=\"hidden\" name=\"HIDDEN_NAME\" value=\"HIDDEN_VALUE\" />" .
|
||||
" <ul>\n" .
|
||||
" </ul>\n" .
|
||||
"</form>";
|
||||
$this->assert_same($expected, (string) $form);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ $(document).ready(function() {
|
||||
// Set the hover item's height
|
||||
$(this).height("auto");
|
||||
var context_menu = $(this).find(".g-context-menu");
|
||||
var adj_height = $(this).height() + context_menu.height();
|
||||
$(this).height(adj_height);
|
||||
var adj_height = $(this).height() + context_menu.height();
|
||||
$(this).height(adj_height);
|
||||
},
|
||||
function() {
|
||||
// Reset item height and position
|
||||
@@ -87,12 +87,12 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
// Photo/Item item view
|
||||
if ($("#g-photo").length) {
|
||||
if ($("#g-photo,#g-movie").length) {
|
||||
// Ensure the resized image fits within its container
|
||||
$("#g-photo").gallery_fit_photo();
|
||||
$("#g-photo,#g-movie").gallery_fit_photo();
|
||||
|
||||
// Initialize context menus
|
||||
var resize = $("#g-photo").gallery_get_photo();
|
||||
var resize = $("#g-photo,#g-movie").gallery_get_photo();
|
||||
$(resize).hover(function(){
|
||||
$(this).gallery_context_menu();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user