summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-07-28 20:40:28 +0800
committerTim Almdal <tnalmdal@shaw.ca>2009-07-28 21:00:25 +0800
commita7f4d7aced009007d36e48685648e9bc3382f8cb (patch)
treef5b13204b496414ccee0f9e997da0b811ef66559 /modules
parent2f969c80eb2e228f2c5729c6f4660c99555f9c9f (diff)
Revert commit 078c77a62b623322956457bfd7bfbdaf56203b00 and change the
tag_event:item_edit_form to use the new Form_Script library to inject script into a form. Signed-off-by: Tim Almdal <tnalmdal@shaw.ca>
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/controllers/albums.php5
-rw-r--r--modules/gallery/controllers/movies.php5
-rw-r--r--modules/gallery/controllers/photos.php5
-rw-r--r--modules/gallery/helpers/album.php14
-rw-r--r--modules/gallery/helpers/photo.php14
-rw-r--r--modules/gallery/tests/xss_data.txt2
-rw-r--r--modules/gallery/views/item_edit.html.php9
-rw-r--r--modules/tag/helpers/tag_event.php18
-rw-r--r--modules/tag/js/tag.js1
9 files changed, 26 insertions, 47 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 4fefd3a1..56b74cb1 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -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()));
}
}
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 1391c4b4..c8227d74 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -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()));
}
}
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 9d9b25a1..8ee24da8 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -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()));
}
}
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index f146bfb3..6065f580 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -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;
}
}
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index 299195e9..5cf37de1 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -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;
}
/**
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index cc9261e5..82b039d7 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -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
diff --git a/modules/gallery/views/item_edit.html.php b/modules/gallery/views/item_edit.html.php
deleted file mode 100644
index 9aa2fb64..00000000
--- a/modules/gallery/views/item_edit.html.php
+++ /dev/null
@@ -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> \ No newline at end of file
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index 0cb49ffa..0fe8a393 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -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);
}
diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js
index a5aaa3f8..765c2a35 100644
--- a/modules/tag/js/tag.js
+++ b/modules/tag/js/tag.js
@@ -66,3 +66,4 @@ function editInPlace(element) {
};
ajaxify_editInPlaceForm();
}
+