1
0

Change json::reply calls to use "html" instead of "form" and not JSON

encode HTML payloads when we don't need to.

This is follow on for:
7607e1f932
This commit is contained in:
Bharat Mediratta 2010-07-31 21:32:59 -07:00
parent e87c6a2832
commit 8eec328a06
9 changed files with 33 additions and 42 deletions

View File

@ -62,7 +62,7 @@ class Admin_Postage_Bands_Controller extends Controller
"postage_name" => html::clean($postage_band->name)))); "postage_name" => html::clean($postage_band->name))));
json::reply(array("result" => "success")); json::reply(array("result" => "success"));
} else { } else {
json::reply(array("result" => "error", "form" => (string)$form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
} }
@ -91,7 +91,7 @@ class Admin_Postage_Bands_Controller extends Controller
$name = $postage->name; $name = $postage->name;
$postage->delete(); $postage->delete();
} else { } else {
json::reply(array("result" => "error", "form" => (string)$form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
$message = t("Deleted user %postage_band", array("postage_band" => html::clean($name))); $message = t("Deleted user %postage_band", array("postage_band" => html::clean($name)));
@ -129,7 +129,7 @@ class Admin_Postage_Bands_Controller extends Controller
array("postage_name" => html::clean($postage->name)))); array("postage_name" => html::clean($postage->name))));
json::reply(array("result" => "success")); json::reply(array("result" => "success"));
} else { } else {
json::reply(array("result" => "error", "form" => (string)$form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
} }

View File

@ -62,7 +62,7 @@ class Admin_Product_Lines_Controller extends Controller
"product_name" => html::clean($product->name)))); "product_name" => html::clean($product->name))));
json::reply(array("result" => "success")); json::reply(array("result" => "success"));
} else { } else {
json::reply(array("result" => "error", "form" => (string)$form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
} }
@ -91,8 +91,7 @@ class Admin_Product_Lines_Controller extends Controller
$name = $product->name; $name = $product->name;
$product->delete(); $product->delete();
} else { } else {
json::reply(array("result" => "error", json::reply(array("result" => "error", "html" => (string)$form));
"form" => $form->__toString()));
} }
$message = t("Deleted user %product_name", array("product_name" => html::clean($name))); $message = t("Deleted user %product_name", array("product_name" => html::clean($name)));
@ -131,7 +130,7 @@ class Admin_Product_Lines_Controller extends Controller
array("product_name" => html::clean($product->name)))); array("product_name" => html::clean($product->name))));
json::reply(array("result" => "success")); json::reply(array("result" => "success"));
} else { } else {
json::reply(array("result" => "error", "form" => (string)$form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
} }

View File

@ -76,8 +76,7 @@ class Admin_Developer_Controller extends Admin_Controller {
} else { } else {
$v = $this->_get_module_create_content(arr::overwrite($form, $post->as_array()), $v = $this->_get_module_create_content(arr::overwrite($form, $post->as_array()),
arr::overwrite($errors, $post->errors())); arr::overwrite($errors, $post->errors()));
json::reply(array("result" => "error", json::reply(array("result" => "error", "html" => (string)$v));
"form" => $v->__toString()));
} }
} }
@ -127,8 +126,7 @@ class Admin_Developer_Controller extends Admin_Controller {
} else { } else {
$v = $this->_get_test_data_view(arr::overwrite($form, $post->as_array()), $v = $this->_get_test_data_view(arr::overwrite($form, $post->as_array()),
arr::overwrite($errors, $post->errors())); arr::overwrite($errors, $post->errors()));
json::reply(array("result" => "error", json::reply(array("result" => "error", "html" => (string)$v));
"form" => $v->__toString()));
} }
} }
@ -152,12 +150,10 @@ class Admin_Developer_Controller extends Admin_Controller {
message::success(empty($error_msg) ? $context["error_msg"] : $error_msg); message::success(empty($error_msg) ? $context["error_msg"] : $error_msg);
break; break;
} }
json::reply(array("result" => "success", json::reply(array("result" => "success", "task" => $task->as_array()));
"task" => $task->as_array()));
} else { } else {
json::reply(array("result" => "in_progress", json::reply(array("result" => "in_progress", "task" => $task->as_array()));
"task" => $task->as_array()));
} }
} }

View File

@ -32,12 +32,9 @@ class <?= $class_name ?>_Controller extends Controller {
message::success(t("<?= $name ?> Processing Successfully")); message::success(t("<?= $name ?> Processing Successfully"));
json::reply( json::reply(array("result" => "success"));
array("result" => "success"));
} else { } else {
json::reply( json::reply(array("result" => "error", "html" => (string)$form));
array("result" => "error",
"form" => $form->__toString()));
} }
} }

View File

@ -184,10 +184,10 @@ class Favourites_Controller extends Controller {
mail($email_address,$name."'s Favourites",$email, $from); mail($email_address,$name."'s Favourites",$email, $from);
json::reply(array("result" => "success","location" => url::site("favourites"))); json::reply(array("result" => "success", "location" => url::site("favourites")));
return; return;
} }
json::reply(array("result" => "error", "form" => (string) $form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
public function toggle_favourites($id){ public function toggle_favourites($id){

View File

@ -38,8 +38,7 @@ class Admin_Upload_Configure_Controller extends Controller
} }
else else
{ {
json::reply json::reply(array("result" => "error", "html" => (string) $form));
s(array("result" => "error", "form" => (string) $form));
return; return;
} }

View File

@ -26,7 +26,7 @@ class Uploader_Controller extends Controller {
$album = $album->parent(); $album = $album->parent();
} }
json::reply(array("form" => (string) $this->_get_add_form($album))); print $this->_get_add_form($album);
} }
public function add($id) { public function add($id) {
@ -85,7 +85,7 @@ class Uploader_Controller extends Controller {
batch::stop(); batch::stop();
json::reply(array("result" => "success")); json::reply(array("result" => "success"));
} else { } else {
json::reply(array("result" => "error", "form" => (string) $form)); json::reply(array("result" => "error", "html" => (string) $form));
} }
} }

View File

@ -18,7 +18,7 @@
*/ */
class register_Controller extends Controller { class register_Controller extends Controller {
public function index() { public function index() {
json::reply(array("form" => (string) $this->_get_form())); print $this->_get_form();
} }
public function handler() { public function handler() {
@ -59,7 +59,7 @@ class register_Controller extends Controller {
json::reply(array("result" => "success")); json::reply(array("result" => "success"));
} else { } else {
json::reply(array("result" => "error", "form" => (string) $form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
} }
@ -126,7 +126,7 @@ class register_Controller extends Controller {
public function change_password($id, $password) { public function change_password($id, $password) {
$user = user::lookup($id); $user = user::lookup($id);
json::reply(array("form" => (string) $this->_get_change_password_form($user, $password))); print $this->_get_change_password_form($user, $password);
} }
private function _get_form() { private function _get_form() {

View File

@ -123,7 +123,7 @@ class Admin_Schedule_Controller extends Admin_Maintenance_Controller {
} }
json::reply(array("result" => "success", "reload" => 1)); json::reply(array("result" => "success", "reload" => 1));
} else { } else {
json::reply(array("result" => "error", "form" => (string) $form)); json::reply(array("result" => "error", "html" => (string)$form));
} }
} }