当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Json::decode方法代码示例

本文整理汇总了PHP中Zend_Json::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Json::decode方法的具体用法?PHP Zend_Json::decode怎么用?PHP Zend_Json::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Json的用法示例。


在下文中一共展示了Zend_Json::decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setData

 /**
  * Recorre los datos y llena el excel
  * @param array $data
  * @param array $json_fields
  */
 public function setData($data, $json_fields = array())
 {
     if (count($data) > 0) {
         $j = 2;
         foreach ($data as $row) {
             $json_data = array();
             if (count($json_fields) > 0) {
                 foreach ($json_fields as $json) {
                     $json_data = array_merge(Zend_Json::decode($row[$json]), $json_data);
                 }
             }
             $i = 0;
             foreach ($this->_columnas as $columna => $valores) {
                 $ok = true;
                 if (isset($valir["permiso"]) && !$valir["permiso"]) {
                     $ok = false;
                 }
                 if ($ok) {
                     $this->_excel->setActiveSheetIndex(0)->setCellValueByColumnAndRow($i, $j, trim($this->_procesaValor($valores, $row, $json_data)));
                     $i++;
                 }
             }
             $j++;
         }
     }
 }
开发者ID:CarlosAyala,项目名称:midas-codeigniter-modulo-emergencias,代码行数:31,代码来源:Excel_json.php

示例2: update_0

 /**
  * update to 5.1
  *  - move task status to key field config
  */
 public function update_0()
 {
     $tasksAppId = Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId();
     // remove status_id keys
     $this->_backend->dropForeignKey('tasks', 'tasks::status_id--tasks_status::id');
     $this->_backend->dropIndex('tasks', 'status_id');
     // need to replace all NULL values first
     $this->_db->update(SQL_TABLE_PREFIX . 'tasks', array('status_id' => 1), "`status_id` IS NULL");
     // alter status_id -> status
     $declaration = new Setup_Backend_Schema_Field_Xml('
         <field>
             <name>status</name>
             <type>text</type>
             <length>40</length>
             <default>NEEDS-ACTION</default>
             <notnull>true</notnull>
         </field>');
     $this->_backend->alterCol('tasks', $declaration, 'status_id');
     // get all current status datas and drop old status table
     $stmt = $this->_db->query("SELECT * FROM `" . SQL_TABLE_PREFIX . "tasks_status`");
     $statusDatas = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     $this->_backend->dropTable('tasks_status', $tasksAppId);
     // update task table
     $statusMap = array();
     // oldId => newId
     foreach ($statusDatas as $statusData) {
         $statusMap[$statusData['id']] = $statusData['status_name'];
         $this->_db->update(SQL_TABLE_PREFIX . 'tasks', array('status' => $statusData['status_name']), "`status` = '{$statusData['id']}'");
     }
     // create status config
     $cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
     $tasksStatusConfig = array('name' => Tasks_Config::TASK_STATUS, 'records' => array(array('id' => 'NEEDS-ACTION', 'value' => 'No response', 'is_open' => 1, 'icon' => 'images/oxygen/16x16/actions/mail-mark-unread-new.png', 'system' => true), array('id' => 'COMPLETED', 'value' => 'Completed', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/ok.png', 'system' => true), array('id' => 'CANCELLED', 'value' => 'Cancelled', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png', 'system' => true), array('id' => 'IN-PROCESS', 'value' => 'In process', 'is_open' => 1, 'icon' => 'images/oxygen/16x16/actions/view-refresh.png', 'system' => true)));
     // add non system custom status
     foreach ($statusDatas as $statusData) {
         if (!in_array($statusData['status_name'], array('NEEDS-ACTION', 'COMPLETED', 'CANCELLED', 'IN-PROCESS'))) {
             $tasksStatusConfig['records'][] = array('id' => $statusData['status_name'], 'value' => $statusData['status_name'], 'is_open' => $statusData['status_is_open'], 'icon' => $statusData['status_icon']);
         }
     }
     $cb->create(new Tinebase_Model_Config(array('application_id' => $tasksAppId, 'name' => Tasks_Config::TASK_STATUS, 'value' => json_encode($tasksStatusConfig))));
     // update persistent filters
     $stmt = $this->_db->query("SELECT * FROM `" . SQL_TABLE_PREFIX . "filter` WHERE " . "`application_id` = '" . $tasksAppId . "' AND " . "`model` = 'Tasks_Model_TaskFilter'");
     $pfiltersDatas = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     foreach ($pfiltersDatas as $pfilterData) {
         $filtersData = Zend_Json::decode($pfilterData['filters']);
         foreach ($filtersData as &$filterData) {
             if (array_key_exists('field', $filterData) && $filterData['field'] == 'status_id') {
                 $filterData['field'] = 'status';
                 $newStatusIds = array();
                 foreach ((array) $filterData['value'] as $oldStatusId) {
                     $newStatusIds[] = $statusMap[$oldStatusId];
                 }
                 $filterData['value'] = is_array($filterData['value']) ? $newStatusIds : $newStatusIds[0];
                 Tinebase_Core::getLogger()->ERR(print_r($filterData, TRUE));
             }
         }
         $this->_db->update(SQL_TABLE_PREFIX . 'filter', array('filters' => Zend_Json::encode($filtersData)), "`id` LIKE '{$pfilterData['id']}'");
     }
     $this->setTableVersion('tasks', '4');
     $this->setApplicationVersion('Tasks', '5.1');
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:64,代码来源:Release5.php

示例3: studentAction

 /**
  * The default action - show the home page
  */
 public function studentAction()
 {
     $this->_helper->viewRenderer->setNoRender(false);
     $request = $this->getRequest();
     $department = $request->getParam('department_id');
     $degree = $request->getParam('degree_id');
     $batch = $request->getParam('batch');
     if (isset($degree) and isset($department) and isset($batch)) {
         $client = new Zend_Http_Client('http://' . CORE_SERVER . '/batch/getbatchstudent' . "?department_id={$department}" . "&degree_id={$degree}" . "&batch_id={$batch}");
         $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
         $response = $client->request();
         if ($response->isError()) {
             $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getHeader('Message');
             throw new Zend_Exception($remoteErr, Zend_Log::ERR);
         } else {
             $jsonContent = $response->getBody($response);
             $students = Zend_Json::decode($jsonContent);
             $this->_helper->logger($jsonContent);
             $this->view->assign('students', $students);
             $this->view->assign('department', $department);
             $this->view->assign('degree', $degree);
             $this->view->assign('batch', $batch);
         }
     }
 }
开发者ID:sivarajankumar,项目名称:eduis,代码行数:28,代码来源:BarcodeController.php

示例4: get

 /**
  * Get key value (otherwise default value)
  */
 function get($key, $defvalue = '')
 {
     $value = $defvalue;
     if (isset($this->valuemap[$key])) {
         $value = $this->valuemap[$key];
     }
     if ($value === '' && isset($this->defaultmap[$key])) {
         $value = $this->defaultmap[$key];
     }
     $isJSON = false;
     if (is_string($value)) {
         // NOTE: Zend_Json or json_decode gets confused with big-integers (when passed as string)
         // and convert them to ugly exponential format - to overcome this we are performin a pre-check
         if (strpos($value, "[") === 0 || strpos($value, "{") === 0) {
             $isJSON = true;
         }
     }
     if ($isJSON) {
         $oldValue = Zend_Json::$useBuiltinEncoderDecoder;
         Zend_Json::$useBuiltinEncoderDecoder = false;
         $decodeValue = Zend_Json::decode($value);
         if (isset($decodeValue)) {
             $value = $decodeValue;
         }
         Zend_Json::$useBuiltinEncoderDecoder = $oldValue;
     }
     //Handled for null because vtlib_purify returns empty string
     if (!empty($value)) {
         $value = vtlib_purify($value);
     }
     return $value;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:35,代码来源:Request.php

示例5: aroundExecute

 /**
  * @param \Magento\Customer\Controller\Ajax\Login $subject
  * @param \Closure $proceed
  * @return $this
  * @throws \Zend_Json_Exception
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function aroundExecute(\Magento\Customer\Controller\Ajax\Login $subject, \Closure $proceed)
 {
     $captchaFormIdField = 'captcha_form_id';
     $captchaInputName = 'captcha_string';
     /** @var \Magento\Framework\App\RequestInterface $request */
     $request = $subject->getRequest();
     $loginParams = [];
     $content = $request->getContent();
     if ($content) {
         $loginParams = \Zend_Json::decode($content);
     }
     $username = isset($loginParams['username']) ? $loginParams['username'] : null;
     $captchaString = isset($loginParams[$captchaInputName]) ? $loginParams[$captchaInputName] : null;
     $loginFormId = isset($loginParams[$captchaFormIdField]) ? $loginParams[$captchaFormIdField] : null;
     foreach ($this->formIds as $formId) {
         $captchaModel = $this->helper->getCaptcha($formId);
         if ($captchaModel->isRequired($username) && !in_array($loginFormId, $this->formIds)) {
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setData(['errors' => true, 'message' => __('Provided form does not exist')]);
         }
         if ($formId == $loginFormId) {
             $captchaModel->logAttempt($username);
             if (!$captchaModel->isCorrect($captchaString)) {
                 $this->sessionManager->setUsername($username);
                 /** @var \Magento\Framework\Controller\Result\Json $resultJson */
                 $resultJson = $this->resultJsonFactory->create();
                 return $resultJson->setData(['errors' => true, 'message' => __('Incorrect CAPTCHA')]);
             }
         }
     }
     return $proceed();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:40,代码来源:AjaxLogin.php

示例6: removeAction

 public function removeAction()
 {
     $customerGroupIds = Zend_Json::decode($this->_getParam('data'));
     $isValid = true;
     if (in_array(Axis_Account_Model_Customer_Group::GROUP_GUEST_ID, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default Guest group id: %s ", Axis_Account_Model_Customer_Group));
     }
     if (in_array(Axis_Account_Model_Customer_Group::GROUP_ALL_ID, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default All group id: %s ", Axis_Account_Model_Customer_Group::GROUP_ALL_ID));
     }
     if (true === in_array(Axis::config()->account->main->defaultCustomerGroup, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default customer group id: %s ", $id));
     }
     if (!sizeof($customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__('No data to delete'));
     }
     if ($isValid) {
         Axis::single('account/customer_group')->delete($this->db->quoteInto('id IN(?)', $customerGroupIds));
         Axis::message()->addSuccess(Axis::translate('admin')->__('Group was deleted successfully'));
     }
     $this->_helper->json->sendJson(array('success' => $isValid));
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:26,代码来源:GroupController.php

示例7: process

 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     if (!$request->get("label") && !$request->get("block") || !$request->get("languages")) {
         //Make JSON response
         $response = new Vtiger_Response();
         $response->setError('error-param', getTranslatedString("LBL_ERROR_PARAM", $moduleName));
         $response->emit();
         exit;
     }
     $languages = trim($request->get("languages"));
     $a_languages = explode(",", $languages);
     $a_block = $request->get("block");
     //Repair bug with utf8 characters
     if (!is_array($a_block)) {
         $oldValue = Zend_Json::$useBuiltinEncoderDecoder;
         Zend_Json::$useBuiltinEncoderDecoder = true;
         $a_block = Zend_Json::decode($a_block);
         Zend_Json::$useBuiltinEncoderDecoder = $oldValue;
         foreach ($a_block as &$val) {
             $val = utf8_encode($val);
         }
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('LIST_PARENT_TABS', $a_parent_tabs);
     $viewer->assign('LIST_MODULES', $a_modules);
     $viewer->assign('LIST_MANIFEST_TEMPLATES', $a_manifest_templates);
     $viewer->assign('LIST_DIR_TEMPLATES', $a_dir_templates);
     $viewer->assign('a_block', $a_block);
     $viewer->assign('a_languages', $a_languages);
     echo $viewer->view('EditBlockPopup.tpl', $qualifiedModuleName, true);
 }
开发者ID:jmangarret,项目名称:vtigercrm,代码行数:35,代码来源:EditBlock.php

示例8: calculationSettingsChangeAction

 public function calculationSettingsChangeAction()
 {
     $this->getHelper('viewRenderer')->setNoRender();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = $request->getPost();
         if (!isset($post['changeSet']) || empty($post['changeSet'])) {
             $this->ajaxException("Nieprawidłowa wartość parametrów");
             return;
         } else {
             $data = Zend_Json::decode($post['changeSet']);
             for ($i = 0; $i < $data['formsCount']; $i++) {
                 $form = $data[$i];
                 if (count($form['changes']) == 0) {
                     Logic_FormsTracker::invalidate(Zend_Session::getId() . '_' . $form['trackingName'], Zend_Auth::getInstance()->getIdentity()->id);
                 } else {
                     Logic_FormsTracker::store(Zend_Session::getId(), $form['trackingName'], $form['changes']);
                 }
             }
             echo Zend_Json::encode(array('result' => 'success', 'message' => 'ok'));
         }
     } else {
         $this->ajaxException("Bad request");
         return;
     }
 }
开发者ID:knatorski,项目名称:SMS,代码行数:26,代码来源:AjaxController.php

示例9: removeAction

 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     Axis::model('account/customer_valueSet')->delete($this->db->quoteInto('id IN (?)', $data));
     Axis::message()->addSuccess(Axis::translate('admin')->__('Group was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:7,代码来源:ValueSetController.php

示例10: removeAction

 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     Axis::single('import/profile')->delete($data);
     Axis::message()->addSuccess(Axis::translate('admin')->__('Profile was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:7,代码来源:IndexController.php

示例11: updateJsonAction

 /**     
  * @param   request data  tax rows information (if 'id'=0 this is a new row)
  * @see plugins/taxes/js/edit.js
  * @return 	json    json array information: success or failure
  */
 function updateJsonAction()
 {
     $dataJson = $this->_getParam('data', '[]');
     $data = Zend_Json::decode($dataJson);
     $iso = $this->_getParam('iso', RM_Environment::getInstance()->getLocale());
     $unitTaxesModel = new RM_UnitTaxes();
     $model = new RM_Taxes();
     foreach ($data as $row) {
         if (isset($row['name'])) {
             $row[$iso] = $row['name'];
             unset($row['name']);
         }
         $unitIDs = explode(',', $row['units']);
         unset($row['units']);
         if ($row['id'] == 0) {
             unset($row['id']);
             $taxID = $model->insert($row);
             $tax = $model->find($taxID)->current();
         } else {
             $tax = $model->find($row['id'])->current();
             if ($tax == null) {
                 continue;
             }
             foreach ($row as $key => $value) {
                 $tax->{$key} = $value;
             }
             $tax->save();
         }
         $unitTaxesModel->insertRows($tax, $unitIDs);
     }
     return array('data' => array('success' => true));
 }
开发者ID:laiello,项目名称:resmania,代码行数:37,代码来源:TaxesController.php

示例12: ajaxUpdateAction

 /**
  * Update setting action called through an ajax request
  */
 public function ajaxUpdateAction()
 {
     // Disable view & layout output
     $this->_disableDisplay();
     // Alwasy set response type to json
     $this->_response->setHeader('Content-Type', 'application/json', true);
     // Try to get the data from the request body
     try {
         $data = Zend_Json::decode($this->_request->getRawBody(), Zend_Json::TYPE_OBJECT);
     } catch (Zend_Json_Exception $exception) {
         $this->_response->setHttpResponseCode(500);
         $this->_response->setBody(Zend_Json::encode(array('status' => 'error', 'message' => 'data decoding failed')));
         return;
     }
     // Retrieve the setting
     $setting = Setting::getKey($data->settingKey, $data->component);
     if (null === $setting) {
         $this->_response->setHttpResponseCode(404);
         $this->_response->setBody(Zend_Json::encode(array('status' => 'error', 'message' => 'setting key/component pair not found')));
         return;
     }
     // Update the setting
     $setting->value = $data->value;
     $success = $setting->trySave();
     if (false === $success) {
         $this->_response->setHttpResponseCode(500);
         $this->_response->setBody(Zend_Json::encode(array('status' => 'error', 'message' => 'saving failed due to validation errors')));
         return;
     }
     // Return success response
     $this->_response->setHttpResponseCode(200);
     $this->_response->setBody(Zend_Json::encode(array('status' => 'success', 'message' => 'setting saved')));
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:36,代码来源:SettingsController.php

示例13: saveAction

 public function saveAction()
 {
     $id = $this->_getParam("id");
     $table = new Formbuilder_Formbuilder();
     $name = $table->getName($id);
     $configuration = Zend_Json::decode($this->_getParam("configuration"));
     $values = Zend_Json::decode($this->_getParam("values"));
     if ($values["name"] != $name) {
         $values["name"] = $this->correctClassname($values["name"]);
         $table = new Formbuilder_Formbuilder();
         $table->rename($id, $values["name"]);
     }
     if (!is_dir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/")) {
         mkdir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/");
     }
     if (file_exists(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json")) {
         unlink(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json");
     }
     $settings = $values;
     $settings["mainDefinitions"] = $configuration;
     $config = new Zend_Config($settings, true);
     $writer = new Zend_Config_Writer_Json(array("config" => $config, "filename" => PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json"));
     $writer->write();
     $builder = new Formbuilder_Builder();
     $builder->setDatas($config->toArray());
     $builder->buildForm($id);
     $this->removeViewRenderer();
 }
开发者ID:mkliche,项目名称:Zendformbuilder,代码行数:28,代码来源:SettingsController.php

示例14: updatePleiadesData

 function updatePleiadesData($uri)
 {
     $output = false;
     $db = $this->startDB();
     $uri = $this->cleanPleiadesURI($uri);
     if ($uri != false) {
         $sql = "SELECT id FROM gap_gazuris WHERE uri = '{$uri}' LIMIT 1;";
         $result = $db->fetchAll($sql, 2);
         if ($result) {
             $jsonURI = $uri . "/json";
             @($jsonStringData = file_get_contents($jsonURI));
             if ($jsonStringData) {
                 @($jsonData = Zend_Json::decode($jsonStringData));
                 if (is_array($jsonData)) {
                     $where = "uri = '{$uri}' ";
                     $data = array();
                     $data["label"] = $jsonData["title"];
                     if ($jsonData["reprPoint"][1] != 0 && $jsonData["reprPoint"][0] != 0) {
                         $data["latitude"] = $jsonData["reprPoint"][1];
                         $data["longitude"] = $jsonData["reprPoint"][0];
                     }
                     $db->update('gap_gazuris', $data, $where);
                     $output = true;
                 } else {
                     $this->noteError("Pleiades not responding with usable data for '{$uri}'.");
                 }
             } else {
                 $this->noteError("Pleiades not recognizing '{$uri}' as a valid URI.");
             }
         }
     } else {
         $this->noteError("Not a valid Pleiades Place URI");
     }
     return $output;
 }
开发者ID:shawngraham,项目名称:gap2,代码行数:35,代码来源:GazetteerURIs.php

示例15: request

 /**
  * Perform an API request to Amazon
  *
  * @param string $path
  *    REST path e.g. user/profile
  * @param array $postParams
  *    POST paramaters
  * @return result
  */
 public function request($path, array $postParams = array())
 {
     $sandbox = Mage::getStoreConfig('payment/amazon_payments/sandbox') ? 'sandbox.' : '';
     $client = new Zend_Http_Client();
     $client->setUri("https://api.{$sandbox}amazon.com/{$path}");
     $client->setConfig($this->http_client_config);
     $client->setMethod($postParams ? 'POST' : 'GET');
     foreach ($postParams as $key => $value) {
         $client->setParameterPost($key, $value);
     }
     try {
         $response = $client->request();
     } catch (Zend_Http_Client_Adapter_Exception $e) {
         Mage::logException($e);
         return;
     }
     $data = $response->getBody();
     try {
         $data = Zend_Json::decode($data, true);
     } catch (Exception $e) {
         Mage::logException($e);
     }
     if (empty($data)) {
         return false;
     } else {
         return $data;
     }
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:37,代码来源:Api.php


注:本文中的Zend_Json::decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。