mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-06-02 01:39:21 -04:00
Revert commit 078c77a62b and change the
tag_event:item_edit_form to use the new Form_Script library to inject script into a form.
This commit is contained in:
@@ -166,8 +166,7 @@ class Albums_Controller extends Items_Controller {
|
||||
access::required("view", $album);
|
||||
access::required("edit", $album);
|
||||
|
||||
$view = album::get_edit_form($album);
|
||||
$form = $view->form;
|
||||
$form = album::get_edit_form($album);
|
||||
if ($valid = $form->validate()) {
|
||||
// Make sure that there's not a conflict
|
||||
if ($album->id != 1 &&
|
||||
@@ -203,7 +202,7 @@ class Albums_Controller extends Items_Controller {
|
||||
} else {
|
||||
print json_encode(
|
||||
array("result" => "error",
|
||||
"form" => $view->__toString()));
|
||||
"form" => $form->__toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ class Movies_Controller extends Items_Controller {
|
||||
access::required("view", $photo);
|
||||
access::required("edit", $photo);
|
||||
|
||||
$view = photo::get_edit_form($photo);
|
||||
$form = $view->form;
|
||||
$form = photo::get_edit_form($photo);
|
||||
if ($valid = $form->validate()) {
|
||||
// Make sure that there's not a conflict
|
||||
if (Database::instance()
|
||||
@@ -102,7 +101,7 @@ class Movies_Controller extends Items_Controller {
|
||||
} else {
|
||||
print json_encode(
|
||||
array("result" => "error",
|
||||
"form" => $view->__toString()));
|
||||
"form" => $form->__toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ class Photos_Controller extends Items_Controller {
|
||||
access::required("view", $photo);
|
||||
access::required("edit", $photo);
|
||||
|
||||
$view = photo::get_edit_form($photo);
|
||||
$form = $view->form;
|
||||
$form = photo::get_edit_form($photo);
|
||||
if ($valid = $form->validate()) {
|
||||
if ($form->edit_item->filename->value != $photo->name) {
|
||||
// Make sure that there's not a conflict
|
||||
@@ -95,7 +94,7 @@ class Photos_Controller extends Items_Controller {
|
||||
} else {
|
||||
print json_encode(
|
||||
array("result" => "error",
|
||||
"form" => $view->__toString()));
|
||||
"form" => $form->__toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,11 +94,9 @@ class album_Core {
|
||||
}
|
||||
|
||||
static function get_edit_form($parent) {
|
||||
$view = new View("item_edit.html");
|
||||
$view->script = array();
|
||||
$view->form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gEditAlbumForm"));
|
||||
$view->form->hidden("_method")->value("put");
|
||||
$group = $view->form->group("edit_item")->label(t("Edit Album"));
|
||||
$form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gEditAlbumForm"));
|
||||
$form->hidden("_method")->value("put");
|
||||
$group = $form->group("edit_item")->label(t("Edit Album"));
|
||||
|
||||
$group->input("title")->label(t("Title"))->value($parent->title);
|
||||
$group->textarea("description")->label(t("Description"))->value($parent->description);
|
||||
@@ -130,11 +128,11 @@ class album_Core {
|
||||
"DESC" => t("Descending")))
|
||||
->selected($parent->sort_order);
|
||||
|
||||
module::event("item_edit_form", $parent, $view);
|
||||
module::event("item_edit_form", $parent, $form);
|
||||
|
||||
$group->hidden("type")->value("album");
|
||||
$group->submit("")->value(t("Modify"));
|
||||
$view->form->add_rules_from(ORM::factory("item"));
|
||||
return $view;
|
||||
$form->add_rules_from(ORM::factory("item"));
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,11 +135,9 @@ class photo_Core {
|
||||
}
|
||||
|
||||
static function get_edit_form($photo) {
|
||||
$view = new View("item_edit.html");
|
||||
$view->script = array();
|
||||
$view->form = new Forge("photos/$photo->id", "", "post", array("id" => "gEditPhotoForm"));
|
||||
$view->form->hidden("_method")->value("put");
|
||||
$group = $view->form->group("edit_item")->label(t("Edit Photo"));
|
||||
$form = new Forge("photos/$photo->id", "", "post", array("id" => "gEditPhotoForm"));
|
||||
$form->hidden("_method")->value("put");
|
||||
$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);
|
||||
$group->input("filename")->label(t("Filename"))->value($photo->name)
|
||||
@@ -149,11 +147,11 @@ class photo_Core {
|
||||
->callback("item::validate_no_trailing_period")
|
||||
->error_messages("no_trailing_period", t("The photo name can't end in \".\""));
|
||||
|
||||
module::event("item_edit_form", $photo, $view);
|
||||
module::event("item_edit_form", $photo, $form);
|
||||
|
||||
$group->submit("")->value(t("Modify"));
|
||||
$view->form->add_rules_from(ORM::factory("item"));
|
||||
return $view;
|
||||
$form->add_rules_from(ORM::factory("item"));
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -207,8 +207,6 @@ modules/gallery/views/admin_themes_preview.html.php 4 DIRTY $info->na
|
||||
modules/gallery/views/admin_themes_preview.html.php 7 DIRTY $url
|
||||
modules/gallery/views/after_install.html.php 11 $user->name
|
||||
modules/gallery/views/after_install.html.php 15 DIRTY $user->id
|
||||
modules/gallery/views/item_edit.html.php 4 DIRTY $script
|
||||
modules/gallery/views/item_edit.html.php 8 DIRTY $form
|
||||
modules/gallery/views/kohana_error_page.php 102 DIRTY $message
|
||||
modules/gallery/views/kohana_error_page.php 104 DIRTY $file
|
||||
modules/gallery/views/kohana_error_page.php 104 DIRTY $line
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<? if (!empty($script)): ?>
|
||||
<script>
|
||||
<?= implode("\n", $script) ?>
|
||||
</script>
|
||||
<? endif ?>
|
||||
<div id="gEditFormContainer">
|
||||
<?= $form ?>
|
||||
</div>
|
||||
@@ -64,19 +64,15 @@ class tag_event_Core {
|
||||
tag::compact();
|
||||
}
|
||||
|
||||
static function item_edit_form($item, $view) {
|
||||
static function item_edit_form($item, $form) {
|
||||
$url = url::site("tags/autocomplete");
|
||||
$view->script[] = "$('#gEditFormContainer form').ready(function() {
|
||||
$('#gEditFormContainer form input[id=tags]').autocomplete(
|
||||
'$url',
|
||||
{max: 30,
|
||||
multiple: true,
|
||||
multipleSeparator: ',',
|
||||
cacheLength: 1}
|
||||
);
|
||||
});";
|
||||
$form->script("")
|
||||
->text("$('form input[id=tags]').ready(function() {
|
||||
$('form input[id=tags]').autocomplete(
|
||||
'$url', {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1});
|
||||
});");
|
||||
$tag_value = implode(", ", tag::item_tags($item));
|
||||
$view->form->edit_item->input("tags")->label(t("Tags (comma separated)"))
|
||||
$form->edit_item->input("tags")->label(t("Tags (comma separated)"))
|
||||
->value($tag_value);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,3 +66,4 @@ function editInPlace(element) {
|
||||
};
|
||||
ajaxify_editInPlaceForm();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user