本文整理汇总了PHP中AError::toJSONResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP AError::toJSONResponse方法的具体用法?PHP AError::toJSONResponse怎么用?PHP AError::toJSONResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AError
的用法示例。
在下文中一共展示了AError::toJSONResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
if (!$this->user->canModify('listing_grid/location_zones')) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/location_zones'), 'reset_value' => true));
}
$this->loadModel('localisation/zone');
$this->loadLanguage('localisation/zone');
switch ($this->request->post['oper']) {
case 'del':
$this->loadModel('localisation/location');
$ids = explode(',', $this->request->post['id']);
if (!empty($ids)) {
foreach ($ids as $id) {
$this->model_localisation_location->deleteLocationZone($id);
}
}
break;
default:
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例2: save
public function save()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$output = array();
$this->loadLanguage('tool/rl_manager');
$this->document->setTitle($this->language->get('heading_title'));
if ($this->request->is_POST() && $this->_validateRLTypeForm($this->request->post)) {
$post_data = $this->request->post;
$rm = new AResourceManager();
if ($rm->updateResourceType($post_data)) {
$output['result_text'] = $this->language->get('text_success');
$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode($output));
} else {
$error = new AError('');
$err_data = array('error_text' => 'Unable to save resource type');
return $error->toJSONResponse('VALIDATION_ERROR_406', $err_data);
}
} else {
$error = new AError('');
$err_data = array('error_text' => $this->error);
return $error->toJSONResponse('VALIDATION_ERROR_406', $err_data);
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例3: update_field
/**
* update only one field
*
* @return void
*/
public function update_field()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
if (!$this->user->canModify('listing_grid/store')) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/store'), 'reset_value' => true));
}
$this->loadLanguage('setting/store');
$this->loadModel('setting/store');
if (isset($this->request->get['id'])) {
//request sent from edit form. ID in url
foreach ($this->request->post as $key => $value) {
$err = $this->_validateField($key, $value);
if (!empty($err)) {
$dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
return $dd->dispatch();
}
$data = array($key => $value);
$this->model_setting_store->editStore($this->request->get['id'], $data);
}
return;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例4: update
public function update()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
if (!$this->user->canModify($this->rt)) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), $this->rt), 'reset_value' => true));
}
$this->loadModel('localisation/language_definitions');
$this->loadLanguage('localisation/language_definitions');
$this->view->assign('success', $this->session->data['success']);
if (isset($this->session->data['success'])) {
unset($this->session->data['success']);
}
$this->document->setTitle($this->language->get('heading_title'));
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) {
foreach ($this->request->post['language_definition_id'] as $lang_id => $id) {
$data = array('language_id' => $lang_id, 'section' => $this->request->post['section'], 'block' => $this->request->post['block'], 'language_key' => $this->request->post['language_key'], 'language_value' => $this->request->post['language_value'][$lang_id]);
if ($id) {
$this->model_localisation_language_definitions->editLanguageDefinition($id, $data);
} else {
$this->model_localisation_language_definitions->addLanguageDefinition($data);
}
}
$this->view->assign('success', $this->language->get('text_success'));
}
$this->_getForm();
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例5: not_found
public function not_found()
{
//build not_found responce
$this->loadLanguage('error/not_found');
$error = new AError('');
$err_data = array('error_title' => $this->language->get('heading_title'), 'error_text' => $this->language->get('text_not_found'));
return $error->toJSONResponse('NOT_FOUND_404', $err_data);
}
示例6: updateField
public function updateField()
{
$this->loadLanguage('forms_manager/forms_manager');
$this->loadModel('tool/forms_manager');
if (!$this->_validateFieldForm($this->request->post) || !$this->request->get['form_id']) {
$error = new AError('');
return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $this->error));
}
$data = $this->request->post;
$data['form_id'] = $this->request->get['form_id'];
$this->model_tool_forms_manager->updateFormFieldData($data);
$this->response->setOutput('');
}
示例7: update
public function update()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
if (!$this->user->canModify($this->rt)) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), $this->rt), 'reset_value' => true));
}
$this->loadModel('localisation/language_definitions');
$this->loadLanguage('localisation/language_definitions');
if ($this->request->is_POST()) {
$output = array('error_text' => '', 'result_text' => '');
if ($this->_validateForm()) {
foreach ($this->request->post['language_definition_id'] as $lang_id => $id) {
$data = array('language_id' => $lang_id, 'section' => $this->request->post['section'], 'block' => $this->request->post['block'], 'language_key' => $this->request->post['language_key'], 'language_value' => $this->request->post['language_value'][$lang_id]);
if ($id) {
$this->model_localisation_language_definitions->editLanguageDefinition($id, $data);
} else {
$this->model_localisation_language_definitions->addLanguageDefinition($data);
}
}
$output['result_text'] = $this->language->get('text_success');
} else {
foreach ($this->error as $err) {
if (is_array($err)) {
$error_text[] = implode('<br>', $err);
} else {
$error_text[] = $err;
}
}
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_406', array('error_text' => $error_text, 'reset_value' => true));
}
$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode($output));
} else {
$this->view->assign('success', $this->session->data['success']);
if (isset($this->session->data['success'])) {
unset($this->session->data['success']);
}
$this->document->setTitle($this->language->get('heading_title'));
$this->_getForm();
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例8: main
public function main()
{
if (!$this->user->canModify('setting/setting_quick_form')) {
$this->error['warning'] = $this->language->get('error_permission');
}
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$output = array('result_text' => '');
$this->loadModel('setting/setting');
$this->loadLanguage('setting/setting');
$this->loadLanguage('common/header');
$this->view->assign('success', $this->session->data['success']);
if (isset($this->session->data['success'])) {
unset($this->session->data['success']);
}
$setting = explode('-', $this->request->get['active']);
$this->data['group'] = $setting[0];
$this->data['setting_key'] = $setting[1];
$this->data['store_id'] = !isset($this->session->data['current_store_id']) ? $setting[2] : $this->session->data['current_store_id'];
if (is_int(strpos($this->data['setting_key'], 'config_description'))) {
$this->data['setting_key'] = substr($this->data['setting_key'], 0, strrpos($this->data['setting_key'], '_'));
$this->request->get['active'] = $this->data['group'] . '-' . $setting[1] . '-' . $this->data['store_id'];
} else {
$this->request->get['active'] = $this->data['group'] . '-' . $this->data['setting_key'] . '-' . $this->data['store_id'];
}
$this->document->setTitle($this->language->get('heading_title'));
if ($this->request->is_POST()) {
if ($this->_validateForm($this->data['group'])) {
$this->model_setting_setting->editSetting($this->data['group'], $this->request->post, $this->data['store_id']);
$output['result_text'] = $this->language->get('text_success');
$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode($output));
} else {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_406', array('error_text' => $this->error, 'reset_value' => true));
}
} else {
$this->_getForm();
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例9: onControllerResponsesListingGridExtension_InitData
public function onControllerResponsesListingGridExtension_InitData()
{
if ($this->baseObject_method != 'update') {
return null;
}
$that = $this->baseObject;
if ($that->request->get['id'] != 'default_pp_express') {
return false;
}
if (!has_value($that->request->post['default_pp_express_custom_bg_color'])) {
return false;
}
$that->request->post['default_pp_express_custom_bg_color'] = ltrim($that->request->post['default_pp_express_custom_bg_color'], '#');
$is_valid = $this->_check_valid_colorhex($that->request->post['default_pp_express_custom_bg_color']);
if (!$is_valid) {
$that->loadLanguage('default_pp_express/default_pp_express');
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => $that->language->get('default_pp_express_error_bg_color'), 'reset_value' => false));
}
}
示例10: buildTask
public function buildTask()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->data['output'] = array();
if ($this->request->is_POST() && $this->_validate()) {
$this->loadModel('tool/backup');
$task_details = $this->model_tool_backup->createBackupTask('manual_backup', $this->request->post);
if (!$task_details) {
$this->errors = array_merge($this->errors, $this->model_tool_backup->errors);
$error = new AError('files backup error');
return $error->toJSONResponse('APP_ERROR_402', array('error_text' => implode(' ', $this->errors), 'reset_value' => true));
} else {
$this->data['output']['task_details'] = $task_details;
}
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode($this->data['output']));
}
示例11: update
public function update()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
if (!$this->user->canModify('listing_grid/extension')) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/extension'), 'reset_value' => true));
}
$this->loadLanguage('extension/extensions');
$store_id = $this->request->post_or_get('store_id');
if (empty($this->request->get['id'])) {
foreach ($this->request->post as $ext => $val) {
$val['store_id'] = $store_id;
$this->extension_manager->editSetting($ext, $val);
}
} else {
$val = $this->request->post;
$val['store_id'] = $store_id;
$val['one_field'] = true;
// sign that we change only one setting
$this->extension_manager->editSetting($this->request->get['id'], $val);
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
if ($this->extension_manager->errors) {
$error = new AError('');
return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => '<br>' . implode('<br>', $this->extension_manager->errors), 'reset_value' => true));
}
}
示例12: update_field
/**
* update only one field
*
* @return void
*/
public function update_field()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('design/content');
$this->acm = new AContentManager();
if (!$this->user->canModify('listing_grid/content')) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/content'), 'reset_value' => true));
}
$allowedFields = array('title', 'description', 'keyword', 'store_id', 'sort_order', 'status', 'parent_content_id');
if (isset($this->request->get['id'])) {
//request sent from edit form. ID in url
foreach ($this->request->post as $field => $value) {
if (!in_array($field, $allowedFields)) {
continue;
}
if ($field == 'keyword') {
if ($err = $this->html->isSEOkeywordExists('content_id=' . $this->request->get['id'], $value)) {
$error = new AError('');
return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err));
}
}
if ($field == 'sort_order') {
// NOTE: grid quicksave ids are not the same as id from form quick save request!
list($void, $parent_content_id) = explode('_', key($value));
$value = current($value);
}
$this->acm->editContentField($this->request->get['id'], $field, $value, $parent_content_id);
}
return null;
}
//request sent from jGrid. ID is key of array
foreach ($this->request->post as $field => $value) {
if (!in_array($field, $allowedFields)) {
continue;
}
// NOTE: grid quicksave ids are not the same as id from form quick save request!
list($parent_content_id, $content_id) = explode('_', key($value));
$this->acm->editContentField($content_id, $field, current($value), $parent_content_id);
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例13: update_field
/**
* update only one field
*
* @return void
*/
public function update_field()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('localisation/stock_status');
if (!$this->user->canModify('listing_grid/stock_status')) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/stock_status'), 'reset_value' => true));
}
$this->loadModel('localisation/stock_status');
if (isset($this->request->get['id']) && !empty($this->request->post['stock_status'])) {
//request sent from edit form. ID in url
foreach ($this->request->post['stock_status'] as $value) {
if (mb_strlen($value['name']) < 2 || mb_strlen($value['name']) > 32) {
$this->response->setOutput($this->language->get('error_name'));
return null;
}
}
$this->model_localisation_stock_status->editStockStatus($this->request->get['id'], $this->request->post);
return null;
}
//request sent from jGrid. ID is key of array
if (isset($this->request->post['stock_status'])) {
foreach ($this->request->post['stock_status'] as $id => $v) {
foreach ($v as $value) {
if (mb_strlen($value['name']) < 2 || mb_strlen($value['name']) > 32) {
$this->response->setOutput($this->language->get('error_name'));
return null;
}
}
$this->model_localisation_stock_status->editStockStatus($id, array('stock_status' => $v));
}
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
}
示例14: CompressBackup
public function CompressBackup()
{
if ($this->request->get['eta'] > 30) {
set_time_limit((int) $this->request->get['eta'] + 30);
}
$backup_name = preg_replace('[^0-9A-z_\\.]', '', $this->request->get['backup_name']);
$backup_name = !$backup_name ? 'manual_backup' : $backup_name;
$bkp = new ABackup($backup_name);
$arc_basename = DIR_BACKUP . $bkp->getBackupName();
if (is_file($arc_basename . '.tar')) {
unlink($arc_basename . '.tar');
}
if (is_file($arc_basename . '.tar.gz')) {
unlink($arc_basename . '.tar.gz');
}
$result = $bkp->archive($arc_basename . '.tar.gz', DIR_BACKUP, $bkp->getBackupName());
if ($result) {
$this->load->library('json');
$this->response->addJSONHeader();
$output = array('result' => true, 'filename' => $bkp->getBackupName());
$this->response->setOutput(AJson::encode($output));
} else {
$error = new AError('compress backup error');
return $error->toJSONResponse('APP_ERROR_402', array('error_text' => $bkp->error, 'reset_value' => true));
}
}
示例15: get_resource_details
public function get_resource_details()
{
if (!$this->user->canModify('common/resource_library')) {
$error = new AError('');
return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true));
}
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$resource_id = (int) $this->request->get['resource_id'];
$language_id = $this->language->getContentLanguageID();
$rm = new AResourceManager();
$info = $rm->getResource($resource_id, $language_id);
if (!$info) {
$info = null;
} else {
$rm->setType($info['type_name']);
$info['thumbnail_url'] = $rm->getResourceThumb($resource_id, $this->thumb_sizes['width'], $this->thumb_sizes['height'], $language_id);
}
$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode($info));
}