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))));
json::reply(array("result" => "success"));
} 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;
$postage->delete();
} 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)));
@ -129,7 +129,7 @@ class Admin_Postage_Bands_Controller extends Controller
array("postage_name" => html::clean($postage->name))));
json::reply(array("result" => "success"));
} 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))));
json::reply(array("result" => "success"));
} 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;
$product->delete();
} else {
json::reply(array("result" => "error",
"form" => $form->__toString()));
json::reply(array("result" => "error", "html" => (string)$form));
}
$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))));
json::reply(array("result" => "success"));
} else {
json::reply(array("result" => "error", "form" => (string)$form));
json::reply(array("result" => "error", "html" => (string)$form));
}
}

View File

@ -69,15 +69,14 @@ class Admin_Developer_Controller extends Admin_Controller {
$task = task::create($task_def, array_merge($task_context, $post->as_array()));
json::reply(array("result" => "started",
"max_iterations" => 15,
"url" => url::site("admin/developer/run_task/{$task->id}?csrf=" .
access::csrf_token()),
"task" => $task->as_array()));
"max_iterations" => 15,
"url" => url::site("admin/developer/run_task/{$task->id}?csrf=" .
access::csrf_token()),
"task" => $task->as_array()));
} else {
$v = $this->_get_module_create_content(arr::overwrite($form, $post->as_array()),
arr::overwrite($errors, $post->errors()));
json::reply(array("result" => "error",
"form" => $v->__toString()));
json::reply(array("result" => "error", "html" => (string)$v));
}
}
@ -120,15 +119,14 @@ class Admin_Developer_Controller extends Admin_Controller {
batch::start();
json::reply(array("result" => "started",
"max_iterations" => $total + 5,
"url" => url::site("admin/developer/run_task/{$task->id}?csrf=" .
access::csrf_token()),
"task" => $task->as_array()));
"max_iterations" => $total + 5,
"url" => url::site("admin/developer/run_task/{$task->id}?csrf=" .
access::csrf_token()),
"task" => $task->as_array()));
} else {
$v = $this->_get_test_data_view(arr::overwrite($form, $post->as_array()),
arr::overwrite($errors, $post->errors()));
json::reply(array("result" => "error",
"form" => $v->__toString()));
arr::overwrite($errors, $post->errors()));
json::reply(array("result" => "error", "html" => (string)$v));
}
}
@ -152,12 +150,10 @@ class Admin_Developer_Controller extends Admin_Controller {
message::success(empty($error_msg) ? $context["error_msg"] : $error_msg);
break;
}
json::reply(array("result" => "success",
"task" => $task->as_array()));
json::reply(array("result" => "success", "task" => $task->as_array()));
} else {
json::reply(array("result" => "in_progress",
"task" => $task->as_array()));
json::reply(array("result" => "in_progress", "task" => $task->as_array()));
}
}

View File

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

View File

@ -184,10 +184,10 @@ class Favourites_Controller extends Controller {
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;
}
json::reply(array("result" => "error", "form" => (string) $form));
json::reply(array("result" => "error", "html" => (string)$form));
}
public function toggle_favourites($id){
@ -195,9 +195,9 @@ class Favourites_Controller extends Controller {
$infavour = $favourites ->toggle($id);
$title = $infavour?t("Remove from favourites"):t("Add to favourites");
json::reply(array("result" => "success",
"favourite" => $infavour,
"hasfavourites" => $favourites->hasFavourites(),
"title" => (string)$title));
"favourite" => $infavour,
"hasfavourites" => $favourites->hasFavourites(),
"title" => (string)$title));
}
public function clear_favourites(){

View File

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

View File

@ -26,7 +26,7 @@ class Uploader_Controller extends Controller {
$album = $album->parent();
}
json::reply(array("form" => (string) $this->_get_add_form($album)));
print $this->_get_add_form($album);
}
public function add($id) {
@ -85,7 +85,7 @@ class Uploader_Controller extends Controller {
batch::stop();
json::reply(array("result" => "success"));
} 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 {
public function index() {
json::reply(array("form" => (string) $this->_get_form()));
print $this->_get_form();
}
public function handler() {
@ -59,7 +59,7 @@ class register_Controller extends Controller {
json::reply(array("result" => "success"));
} 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) {
$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() {

View File

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