本文整理汇总了PHP中AJson类的典型用法代码示例。如果您正苦于以下问题:PHP AJson类的具体用法?PHP AJson怎么用?PHP AJson使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AJson类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('tool/files');
if (!$this->user->canAccess('tool/file_uploads')) {
$response = new stdClass();
$response->userdata->error = sprintf($this->language->get('error_permission_access'), 'tool/file_uploads');
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
return null;
}
$this->loadModel('tool/file_uploads');
$page = $this->request->post['page'];
// get the requested page
$limit = $this->request->post['rows'];
// get how many rows we want to have into the grid
$sidx = $this->request->post['sidx'];
// get index row - i.e. user click to sort
$sord = $this->request->post['sord'];
// get the direction
$filter = array();
//process custom search form
$allowedSearchFilter = array('date_added', 'section');
if (isset($this->request->post['filters']) && $this->request->post['filters'] != '') {
$this->request->post['filters'] = json_decode(html_entity_decode($this->request->post['filters']));
$filter['value'] = $this->request->post['filters']->rules[0]->data;
}
// process jGrid search parameter
$data = array('sort' => $sidx . ":" . $sord, 'offset' => ($page - 1) * $limit, 'limit' => $limit, 'filter' => $filter);
$total = $this->model_tool_file_uploads->getTotalRows($filter);
if ($total > 0) {
$total_pages = ceil($total / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) {
$page = $total_pages;
$data['offset'] = ($page - 1) * $limit;
}
$response = new stdClass();
$response->page = $page;
$response->total = $total_pages;
$response->records = $total;
$results = (array) $this->model_tool_file_uploads->getLog($data);
$i = 0;
foreach ($results as $k => $result) {
$k++;
$response->rows[$i]['id'] = $k;
$response->rows[$i]['cell'] = array($k, $result['date_added'], $result['section'], is_file($result['path']) ? '<a target="_blank" title="' . $this->language->get('text_download') . '" href="' . $this->html->getSecureUrl('tool/files/download', '&filename=' . urlencode($result['name'])) . '&attribute_type=' . $result['section'] . '&attribute_id=' . $result['section_id'] . '">' . $result['name'] . '</a>' : '');
$i++;
}
$this->data = $response;
// for hook access
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode($this->data));
}
示例2: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('catalog/download');
$this->loadModel('catalog/download');
//Prepare filter config
$grid_filter_params = array('name');
$filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params, 'additional_filter_string' => 'shared=1'));
$filter_data = $filter->getFilterData();
$total = $this->model_catalog_download->getTotalDownloads($filter_data);
$response = new stdClass();
$response->page = $filter->getParam('page');
$response->total = $filter->calcTotalPages($total);
$response->records = $total;
$response->userdata = new stdClass();
$results = $this->model_catalog_download->getDownloads($filter_data);
$i = 0;
foreach ($results as $result) {
if (!is_file(DIR_RESOURCE . $result['filename'])) {
$response->userdata->classes[$result['download_id']] = 'warning';
}
$response->rows[$i]['id'] = $result['download_id'];
$response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'name[' . $result['download_id'] . ']', 'value' => $result['name'], 'attr' => ' maxlength="64" ')), $this->html->buildCheckbox(array('name' => 'status[' . $result['download_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $result['product_count']);
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例3: main
public function main()
{
$this->loadLanguage('forms_manager/forms_manager');
$this->loadModel('tool/forms_manager');
//Clean up parametres if needed
if (isset($this->request->get['keyword']) && $this->request->get['keyword'] == $this->language->get('filter_form')) {
unset($this->request->get['keyword']);
}
//Prepare filter config
$filter_params = array('status', 'keyword', 'match');
$grid_filter_params = array('form_name', 'description', 'status');
$filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
$filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
$total = $this->model_tool_forms_manager->getTotalForms(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()));
$response = new stdClass();
$response->page = $filter_grid->getParam('page');
$response->total = $filter_grid->calcTotalPages($total);
$response->records = $total;
$results = $this->model_tool_forms_manager->getForms(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()));
$i = 0;
foreach ($results as $result) {
$response->rows[$i]['id'] = $result['form_id'];
$response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'form_name[' . $result['form_id'] . ']', 'value' => $result['form_name'])), $this->html->buildInput(array('name' => 'form_description[' . $result['form_id'] . ']', 'value' => $result['description'])), $this->html->buildCheckbox(array('name' => 'form_status[' . $result['form_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')));
$i++;
}
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例4: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('report/purchased');
$this->loadModel('report/purchased');
//Prepare filter config
$filter_params = array('date_start', 'date_end');
if (!$this->request->get['date_start']) {
$this->request->get['date_start'] = dateInt2Display(strtotime('-30 day'));
}
if (!$this->request->get['date_end']) {
$this->request->get['date_end'] = dateInt2Display(time());
}
$filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
$filter_grid = new AFilter(array('method' => 'post'));
$data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData());
$total = $this->model_report_purchased->getTotalOrderedProducts($data);
$response = new stdClass();
$response->page = $filter_grid->getParam('page');
$response->total = $filter_grid->calcTotalPages($total);
$response->records = $total;
$results = $this->model_report_purchased->getProductPurchasedReport($data);
$i = 0;
foreach ($results as $result) {
$response->rows[$i]['id'] = $i;
$response->rows[$i]['cell'] = array($result['name'], $result['model'], $result['quantity'], $this->currency->format($result['total'], $this->config->get('config_currency')));
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例5: test
public function test()
{
$this->registry->set('force_skip_errors', true);
$this->loadLanguage('default_twilio/default_twilio');
$this->loadModel('setting/setting');
include_once DIR_EXT . 'default_twilio/core/lib/Services/Twilio.php';
$cfg = $this->model_setting_setting->getSetting('default_twilio', (int) $this->session->data['current_store_id']);
$AccountSid = $cfg['default_twilio_username'];
$AuthToken = $cfg['default_twilio_token'];
$sender = new Services_Twilio($AccountSid, $AuthToken);
if ($this->config->get('default_twilio_test')) {
//sandbox number without errors from api
$from = '+15005550006';
} else {
$from = $this->config->get('default_twilio_sender_phone');
$from = '+' . ltrim($from, '+');
}
$error_message = '';
try {
$sender->account->sms_messages->create($from, "+15005550006", 'test message', array());
} catch (Exception $e) {
$error_message = $e->getMessage();
}
$this->registry->set('force_skip_errors', false);
$json = array();
if (!$error_message) {
$json['message'] = $this->language->get('text_connection_success');
$json['error'] = false;
} else {
$json['message'] = "Connection to Twilio server can not be established.<br>" . $error_message . ".<br>Check your server configuration or contact your hosting provider.";
$json['error'] = true;
}
$this->load->library('json');
$this->response->setOutput(AJson::encode($json));
}
示例6: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('localisation/location');
$this->loadModel('localisation/location');
//Prepare filter config
$grid_filter_params = array('name');
$filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
$total = $this->model_localisation_location->getTotalLocations($filter->getFilterData());
$response = new stdClass();
$response->page = $filter->getParam('page');
$response->total = $filter->calcTotalPages($total);
$response->records = $total;
$results = $this->model_localisation_location->getLocations($filter->getFilterData());
$i = 0;
foreach ($results as $result) {
$response->rows[$i]['id'] = $result['location_id'];
$response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'name[' . $result['location_id'] . ']', 'value' => $result['name'])));
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例7: encode
public static function encode($data)
{
if (function_exists('json_encode')) {
return json_encode($data);
} else {
switch (gettype($data)) {
case 'boolean':
return $data ? 'true' : 'false';
case 'integer':
case 'double':
return $data;
case 'resource':
case 'string':
return '"' . str_replace(array("\r", "\n", "<", ">", "&"), array('\\r', '\\n', '\\x3c', '\\x3e', '\\x26'), addslashes($data)) . '"';
case 'array':
if (empty($data) || array_keys($data) === range(0, sizeof($data) - 1)) {
$stdout = array();
foreach ($data as $value) {
$stdout[] = AJson::encode($value);
}
return '[ ' . implode(', ', $stdout) . ' ]';
}
case 'object':
$stdout = array();
foreach ($data as $key => $value) {
$stdout[] = AJson::encode(strval($key)) . ': ' . AJson::encode($value);
}
return '{ ' . implode(', ', $stdout) . ' }';
default:
return 'null';
}
}
}
示例8: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$page = $this->request->post['page'];
// get the requested page
$limit = $this->request->post['rows'];
// get how many rows we want to have into the grid
$sidx = $this->request->post['sidx'];
// get index row - i.e. user click to sort
$sord = $this->request->post['sord'];
// get the direction
$data = array('sort' => $sidx, 'order' => $sord, 'start' => ($page - 1) * $limit, 'limit' => $limit, 'language_id' => $this->session->data['content_language_id']);
$total = $this->attribute_manager->getTotalAttributeGroups();
if ($total > 0) {
$total_pages = ceil($total / $limit);
} else {
$total_pages = 0;
}
$response = new stdClass();
$response->page = $page;
$response->total = $total_pages;
$response->records = $total;
$results = $this->attribute_manager->getAttributeGroups($data);
$i = 0;
foreach ($results as $result) {
$response->rows[$i]['id'] = $result['attribute_group_id'];
$response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'name[' . $result['attribute_group_id'] . ']', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'sort_order[' . $result['attribute_group_id'] . ']', 'value' => $result['sort_order'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['attribute_group_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')));
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例9: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('localisation/country');
$this->loadModel('localisation/country');
//Prepare filter config
$grid_filter_params = array('name' => 'cd.name', 'iso_code_2' => 'c.iso_code_2', 'iso_code_3' => 'c.iso_code_3');
$filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
$total = $this->model_localisation_country->getTotalCountries($filter->getFilterData());
$response = new stdClass();
$response->page = $filter->getParam('page');
$response->total = $filter->calcTotalPages($total);
$response->records = $total;
$results = $this->model_localisation_country->getCountries($filter->getFilterData());
$i = 0;
$language_id = $this->language->getContentLanguageID();
foreach ($results as $result) {
$response->rows[$i]['id'] = $result['country_id'];
$response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'country_name[' . $result['country_id'] . '][' . $language_id . '][name]', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'iso_code_2[' . $result['country_id'] . ']', 'value' => $result['iso_code_2'])), $this->html->buildInput(array('name' => 'iso_code_3[' . $result['country_id'] . ']', 'value' => $result['iso_code_3'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['country_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')));
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例10: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
//load available groups for settings
$this->loadLanguage('setting/setting');
$this->loadModel('setting/setting');
//Prepare filter config
$grid_filter_params = array('alias', 'group', 'key');
$filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
$total = $this->model_setting_setting->getTotalSettings($filter_grid->getFilterData());
$response = new stdClass();
$response->page = $filter_grid->getParam('page');
$response->total = $filter_grid->calcTotalPages($total);
$response->records = $total;
$results = $this->model_setting_setting->getAllSettings($filter_grid->getFilterData());
$i = 0;
foreach ($results as $result) {
if (($result['value'] == '1' || $result['value'] == '0') && !is_int(strpos($result['key'], '_id')) && !is_int(strpos($result['key'], 'level'))) {
$value = $this->html->buildCheckbox(array('name' => '', 'value' => $result['value'], 'style' => 'btn_switch', 'attr' => 'readonly="true"'));
} else {
$value = $result['value'];
}
$response->rows[$i]['id'] = $result['group'] . '-' . $result['key'] . '-' . $result['store_id'];
$response->rows[$i]['cell'] = array($result['alias'], $result['group'], $result['key'], $value);
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例11: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('catalog/manufacturer');
$this->loadModel('catalog/manufacturer');
$this->loadModel('tool/image');
//Prepare filter config
$grid_filter_params = array('name');
$filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
$filter_data = $filter->getFilterData();
$total = $this->model_catalog_manufacturer->getTotalManufacturers($filter_data);
$response = new stdClass();
$response->page = $filter->getParam('page');
$response->total = $filter->calcTotalPages($total);
$response->records = $total;
$results = $this->model_catalog_manufacturer->getManufacturers($filter_data);
$resource = new AResource('image');
$i = 0;
foreach ($results as $result) {
$thumbnail = $resource->getMainThumb('manufacturers', $result['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true);
$response->rows[$i]['id'] = $result['manufacturer_id'];
$response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $this->html->buildInput(array('name' => 'name[' . $result['manufacturer_id'] . ']', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'sort_order[' . $result['manufacturer_id'] . ']', 'value' => $result['sort_order'])));
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例12: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('sale/customer_group');
$this->loadModel('sale/customer_group');
//Prepare filter config
$grid_filter_params = array('name', 'tax_exempt');
$filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
$total = $this->model_sale_customer_group->getTotalCustomerGroups($filter->getFilterData());
$response = new stdClass();
$response->page = $filter->getParam('page');
$response->total = $filter->calcTotalPages($total);
$response->records = $total;
$results = $this->model_sale_customer_group->getCustomerGroups($filter->getFilterData());
$i = 0;
$yesno = array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no'));
foreach ($results as $result) {
$response->rows[$i]['id'] = $result['customer_group_id'];
$response->rows[$i]['cell'] = array($result['name'] . ($result['customer_group_id'] == $this->config->get('config_customer_group_id') ? $this->language->get('text_default') : NULL), $yesno[(int) $result['tax_exempt']]);
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例13: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('catalog/review');
$this->loadModel('catalog/review');
$this->loadModel('tool/image');
//Prepare filter config
$filter_params = array('product_id', 'status');
$grid_filter_params = array('name', 'author');
$filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
$filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
$total = $this->model_catalog_review->getTotalReviews(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()));
$response = new stdClass();
$response->page = $filter_grid->getParam('page');
$response->total = $filter_grid->calcTotalPages($total);
$response->records = $total;
$results = $this->model_catalog_review->getReviews(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()));
$resource = new AResource('image');
$i = 0;
foreach ($results as $result) {
$thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), true);
$response->rows[$i]['id'] = $result['review_id'];
$response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name'], $result['author'], $result['rating'], $this->html->buildCheckbox(array('name' => 'status[' . $result['review_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), dateISO2Display($result['date_added'], $this->language->get('date_format_short')));
$i++;
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->setOutput(AJson::encode($response));
}
示例14: 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__);
}
示例15: complete
/**
* post-trigger of task
*/
public function complete()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$task_id = (int) $this->request->post['task_id'];
if ($task_id) {
$tm = new ATaskManager();
$tm->deleteTask($task_id);
$install_upgrade_history = new ADataset('install_upgrade_history', 'admin');
$backup_name = $this->request->get_or_post('backup_name');
$backup_name = !$backup_name ? 'manual_backup' : $backup_name;
$display_name = '';
if (is_file(DIR_BACKUP . $backup_name . '.tar.gz')) {
$display_name = $backup_name . '.tar.gz';
$result_text = $this->html->convertLinks($this->language->get('backup_complete_text_file'));
} elseif (is_dir(DIR_BACKUP . $backup_name)) {
$display_name = $backup_name . '/...';
$result_text = sprintf($this->language->get('backup_complete_text_dir'), DIR_BACKUP . $backup_name);
}
$install_upgrade_history->addRows(array('date_added' => date("Y-m-d H:i:s", time()), 'name' => 'Manual Backup', 'version' => VERSION, 'backup_file' => $display_name, 'backup_date' => date("Y-m-d H:i:s", time()), 'type' => 'backup', 'user' => $this->user->getUsername()));
}
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->load->library('json');
$this->response->addJSONHeader();
$this->response->setOutput(AJson::encode(array('result' => true, 'result_text' => $result_text)));
}