本文整理汇总了PHP中json::reply方法的典型用法代码示例。如果您正苦于以下问题:PHP json::reply方法的具体用法?PHP json::reply怎么用?PHP json::reply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json
的用法示例。
在下文中一共展示了json::reply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _send_reset
private function _send_reset($form)
{
$user_name = $form->reset->inputs["name"]->value;
$user = user::lookup_by_name($user_name);
if ($user && !empty($user->email)) {
$user->hash = random::hash();
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
$message->user = $user;
Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->message($message->render())->send();
log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
} else {
if (!$user) {
// Don't include the username here until you're sure that it's XSS safe
log::warning("user", t("Password reset email requested for user %user_name, which does not exist.", array("user_name" => $user_name)));
} else {
log::warning("user", t("Password reset failed for %user_name (has no email address on record).", array("user_name" => $user->name)));
}
}
// Always pretend that an email has been sent to avoid leaking
// information on what user names are actually real.
message::success(t("Password reset email sent"));
json::reply(array("result" => "success"));
}
示例2: save
public function save($module_name, $var_name)
{
access::verify_csrf();
module::set_var($module_name, $var_name, Input::instance()->post("value"));
message::success(t("Saved value for %var (%module_name)", array("var" => $var_name, "module_name" => $module_name)));
json::reply(array("result" => "success"));
}
示例3: auth
public function auth()
{
if (!identity::active_user()->admin) {
access::forbidden();
}
access::verify_csrf();
$form = self::_form();
$valid = $form->validate();
$user = identity::active_user();
if ($valid) {
module::event("user_auth", $user);
if (!request::is_ajax()) {
message::success(t("Successfully re-authenticated!"));
}
url::redirect(Session::instance()->get_once("continue_url"));
} else {
$name = $user->name;
log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
module::event("user_auth_failed", $name);
if (request::is_ajax()) {
$v = new View("reauthenticate.html");
$v->form = $form;
$v->user_name = identity::active_user()->name;
json::reply(array("html" => (string) $v));
} else {
self::_show_form($form);
}
}
}
示例4: reset_api_key
public function reset_api_key()
{
access::verify_csrf();
rest::reset_access_key();
message::success(t("Your REST API key has been reset."));
json::reply(array("result" => "success"));
}
示例5: confirm
public function confirm()
{
access::verify_csrf();
$messages = array("error" => array(), "warn" => array());
$desired_list = array();
foreach (module::available() as $module_name => $info) {
if ($info->locked) {
continue;
}
if ($desired = Input::instance()->post($module_name) == 1) {
$desired_list[] = $module_name;
}
if ($info->active && !$desired && module::is_active($module_name)) {
$messages = array_merge($messages, module::can_deactivate($module_name));
} else {
if (!$info->active && $desired && !module::is_active($module_name)) {
$messages = array_merge($messages, module::can_activate($module_name));
}
}
}
if (empty($messages["error"]) && empty($messages["warn"])) {
$this->_do_save();
$result["reload"] = 1;
} else {
$v = new View("admin_modules_confirm.html");
$v->messages = $messages;
$v->modules = $desired_list;
$result["dialog"] = (string) $v;
$result["allow_continue"] = empty($messages["error"]);
}
json::reply($result);
}
示例6: show
/**
* Allows the given item to be displayed again.
*
* @param int $id the item id
*/
public function show($id)
{
$item = model_cache::get("item", $id);
$msg = t("Displayed <b>%title</b> item", array("title" => html::purify($item->title)));
$this->_check_hide_permissions($item);
hide::show($item);
message::success($msg);
json::reply(array("result" => "success", "reload" => 1));
}
示例7: star_only_off
public function star_only_off()
{
//$item = model_cache::get("item", $id);
access::verify_csrf();
$msg = t("Showing all items.");
//$this->_check_star_permissions($item);
star::star_only_off();
message::success($msg);
json::reply(array("result" => "success", "reload" => 1));
}
示例8: save
public function save()
{
access::verify_csrf();
if (!identity::active_user()->admin) {
access::forbidden();
}
$locale = Gallery_I18n::instance()->locale();
$input = Input::instance();
$key = $input->post("l10n-message-key");
$root_message = ORM::factory("incoming_translation")->where("key", "=", $key)->where("locale", "=", "root")->find();
if (!$root_message->loaded()) {
throw new Exception("@todo bad request data / illegal state");
}
$is_plural = Gallery_I18n::is_plural_message(unserialize($root_message->message));
$is_empty = true;
if ($is_plural) {
$plural_forms = l10n_client::plural_forms($locale);
$translation = array();
foreach ($plural_forms as $plural_form) {
$value = $input->post("l10n-edit-plural-translation-{$plural_form}");
if (null === $value || !is_string($value)) {
throw new Exception("@todo bad request data");
}
$translation[$plural_form] = $value;
$is_empty = $is_empty && empty($value);
}
} else {
$translation = $input->post("l10n-edit-translation");
$is_empty = empty($translation);
if (null === $translation || !is_string($translation)) {
throw new Exception("@todo bad request data");
}
}
$entry = ORM::factory("outgoing_translation")->where("key", "=", $key)->where("locale", "=", $locale)->find();
if ($is_empty) {
if ($entry->loaded()) {
$entry->delete();
}
} else {
if (!$entry->loaded()) {
$entry->key = $key;
$entry->locale = $locale;
$entry->message = $root_message->message;
$entry->base_revision = null;
}
$entry->translation = serialize($translation);
$entry_from_incoming = ORM::factory("incoming_translation")->where("key", "=", $key)->where("locale", "=", $locale)->find();
if (!$entry_from_incoming->loaded()) {
$entry->base_revision = $entry_from_incoming->revision;
}
$entry->save();
}
Gallery_I18n::clear_cache($locale);
json::reply(new stdClass());
}
示例9: auth_ajax
public function auth_ajax()
{
access::verify_csrf();
list($valid, $form) = $this->_auth("login/auth_ajax");
if ($valid) {
json::reply(array("result" => "success"));
} else {
$view = new View("login_ajax.html");
$view->form = $form;
json::reply(array("result" => "error", "html" => (string) $view));
}
}
示例10: doClear
public function doClear($id)
{
$photo = ORM::factory("item", $id);
$rateid = "rate" . $id;
$ratable = db::build()->select("id")->from("ratables")->where("ratableKey", "=", $rateid)->execute()->current();
if (db::build()->select("id")->from("ratings")->where("ratable_id", "=", $ratable->id)->execute()->count() < 1) {
message::warning(t("No votes have been registered for this item: Nothing cleared!"));
json::reply(array("result" => "success", "location" => $photo->url()));
return;
}
$ratings = db::build()->delete("ratings")->where("ratable_id", "=", $ratable->id)->execute();
message::success(t("All ratings and votes for this item have been cleared!"));
json::reply(array("result" => "success", "location" => $photo->url()));
}
示例11: _reauth_check
private static function _reauth_check()
{
$session = Session::instance();
$last_active_auth = $session->get("active_auth_timestamp", 0);
$last_admin_area_activity = $session->get("admin_area_activity_timestamp", 0);
$admin_area_timeout = module::get_var("gallery", "admin_area_timeout");
$time_remaining = max($last_active_auth, $last_admin_area_activity) + $admin_area_timeout - time();
$result = new stdClass();
$result->result = "success";
if ($time_remaining < 30) {
message::success(t("Automatically logged out of the admin area for your security"));
$result->location = url::abs_site("");
}
json::reply($result);
}
示例12: send
public function send($id)
{
access::verify_csrf();
$user = identity::lookup_user($id);
if (!$this->_can_view_profile_pages($user)) {
throw new Kohana_404_Exception();
}
$form = user_profile::get_contact_form($user);
if ($form->validate()) {
Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
json::reply(array("result" => "success"));
} else {
json::reply(array("result" => "error", "html" => (string) $form));
}
}
示例13: save
public function save()
{
access::verify_csrf();
$input = Input::instance();
locales::update_installed($input->post("installed_locales"));
$installed_locales = array_keys(locales::installed());
$new_default_locale = $input->post("default_locale");
if (!in_array($new_default_locale, $installed_locales)) {
if (!empty($installed_locales)) {
$new_default_locale = $installed_locales[0];
} else {
$new_default_locale = "en_US";
}
}
module::set_var("gallery", "default_locale", $new_default_locale);
json::reply(array("result" => "success"));
}
示例14: create
/**
* Add a new comment to the collection.
*/
public function create($id)
{
$item = ORM::factory("item", $id);
access::required("view", $item);
if (!comment::can_comment()) {
access::forbidden();
}
$form = comment::get_add_form($item);
try {
$valid = $form->validate();
$comment = ORM::factory("comment");
$comment->item_id = $id;
$comment->author_id = identity::active_user()->id;
$comment->text = $form->add_comment->text->value;
$comment->guest_name = $form->add_comment->inputs["name"]->value;
$comment->guest_email = $form->add_comment->email->value;
$comment->guest_url = $form->add_comment->url->value;
$comment->validate();
} catch (ORM_Validation_Exception $e) {
// Translate ORM validation errors into form error messages
foreach ($e->validation->errors() as $key => $error) {
switch ($key) {
case "guest_name":
$key = "name";
break;
case "guest_email":
$key = "email";
break;
case "guest_url":
$key = "url";
break;
}
$form->add_comment->inputs[$key]->add_error($error, 1);
}
$valid = false;
}
if ($valid) {
$comment->save();
$view = new Theme_View("comment.html", "other", "comment-fragment");
$view->comment = $comment;
json::reply(array("result" => "success", "view" => (string) $view, "form" => (string) comment::get_add_form($item)));
} else {
$form = comment::prefill_add_form($form);
json::reply(array("result" => "error", "form" => (string) $form));
}
}
示例15: create
public function create($item_id)
{
$item = ORM::factory("item", $item_id);
access::required("view", $item);
access::required("edit", $item);
$form = tag::get_add_form($item);
if ($form->validate()) {
foreach (explode(",", $form->add_tag->inputs["name"]->value) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
$tag = tag::add($item, $tag_name);
}
}
json::reply(array("result" => "success", "cloud" => (string) tag::cloud(30)));
} else {
json::reply(array("result" => "error", "html" => (string) $form));
}
}