本文整理汇总了PHP中Zend_Json类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Json类的具体用法?PHP Zend_Json怎么用?PHP Zend_Json使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Json类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toJson
/**
* Opis konfiliktujących zmian w formacie JSON
* @return string
*/
public function toJson()
{
$json = new Zend_Json();
$conflicts = array();
foreach ($this->_expected as $k => $v) {
$conflicts[] = array('fname' => $k, 'value' => $this->_changed[$k], 'expected' => $v);
}
return $json->encode($conflicts);
}
示例2: render
/**
* Renderização da Referência Bibliográfica
* @return string Conteúdo Resultado
*/
public function render()
{
// Tipo do Artigo
$translator = array('artigo' => 'article');
$tipo = $translator[$this->tipo];
// Conteúdo do Artigo
$json = new Zend_Json();
$info = $json->decode($this->conteudo);
// Resultado
return $this->_render($tipo, $info);
}
示例3: testAction
public function testAction()
{
$a = array();
$a['menu'] = true;
$a['a'] = 'action';
$a['c'] = 'controller';
$a['m'] = 'module';
$a['p'] = array('param1' => 1, 'param2' => 2);
$json = new Zend_Json();
echo $json->encode($a);
die;
}
示例4: datePicker
/**
* Create a jQuery UI Widget Date Picker
*
* @link http://docs.jquery.com/UI/Datepicker
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function datePicker($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs = $this->_prepareAttributes($id, $value, $attribs);
//
// Prepare params
//
if (!isset($params['dateFormat']) && Zend_Registry::isRegistered('Zend_Locale')) {
$params['dateFormat'] = $this->_resolveLocaleToDatePickerFormat();
}
// TODO: Allow translation of DatePicker Text Values to get this action from client to server
if (count($params) > 0) {
/**
* @see Zend_Json
*/
require_once "Zend/Json.php";
$params = Zend_Json::encode($params);
} else {
$params = "{}";
}
$js = sprintf('%s("#%s").datepicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
//
// Add DatePicker callup to onLoad Stack
//
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例5: getMainMenu
public function getMainMenu()
{
$modulesDb = new Application_Model_DbTable_Module();
$modules = $modulesDb->fetchAll();
$mainmenu = array();
foreach ($modules as $module) {
if ($module->active && $module->menu) {
$data = Zend_Json::decode($module->menu);
foreach ($data as $key => $value) {
if (isset($mainmenu[$key]['childs'])) {
foreach ($value['childs'] as $ordering => $child) {
$mainmenu[$key]['childs'][$ordering] = $child;
}
} else {
$mainmenu[$key] = $value;
}
}
}
}
foreach ($mainmenu as $key => $value) {
if (isset($value['childs'])) {
ksort($mainmenu[$key]['childs']);
}
}
return $mainmenu;
}
示例6: vtEditExpressions
function vtEditExpressions($adb, $appStrings, $current_language, $theme, $formodule = '')
{
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty = new vtigerCRM_Smarty();
$smarty->assign('APP', $appStrings);
$mod = array_merge(return_module_language($current_language, 'FieldFormulas'), return_module_language($current_language, 'Settings'));
$jsStrings = array('NEED_TO_ADD_A' => $mod['NEED_TO_ADD_A'], 'CUSTOM_FIELD' => $mod['LBL_CUSTOM_FIELD'], 'LBL_USE_FUNCTION_DASHDASH' => $mod['LBL_USE_FUNCTION_DASHDASH'], 'LBL_USE_FIELD_VALUE_DASHDASH' => $mod['LBL_USE_FIELD_VALUE_DASHDASH'], 'LBL_DELETE_EXPRESSION_CONFIRM' => $mod['LBL_DELETE_EXPRESSION_CONFIRM']);
$smarty->assign("JS_STRINGS", Zend_Json::encode($jsStrings));
$smarty->assign("MOD", $mod);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE_NAME", 'FieldFormulas');
$smarty->assign("PAGE_NAME", 'LBL_FIELDFORMULAS');
$smarty->assign("PAGE_TITLE", 'LBL_FIELDFORMULAS');
$smarty->assign("PAGE_DESC", 'LBL_FIELDFORMULAS_DESCRIPTION');
$smarty->assign("FORMODULE", $formodule);
if (file_exists("modules/{$formodule}/{$formodule}.php")) {
$focus = CRMEntity::getInstance($formodule);
$validationArray = split_validationdataArray(getDBValidationData($focus->tab_name, getTabid($formodule)));
$smarty->assign('VALIDATION_DATA_FIELDNAME', $validationArray['fieldname']);
$smarty->assign('VALIDATION_DATA_FIELDDATATYPE', $validationArray['datatype']);
$smarty->assign('VALIDATION_DATA_FIELDLABEL', $validationArray['fieldlabel']);
}
$smarty->display(vtlib_getModuleTemplate('FieldFormulas', 'EditExpressions.tpl'));
}
示例7: _afterToHtml
protected function _afterToHtml($html)
{
$html = parent::_afterToHtml($html);
if ('product.info.options.configurable' == $this->getNameInLayout() && 'true' != (string) Mage::getConfig()->getNode('modules/Amasty_Stockstatus/active')) {
$allProducts = $this->getProduct()->getTypeInstance(true)->getUsedProducts(null, $this->getProduct());
$_attributes = $this->getProduct()->getTypeInstance(true)->getConfigurableAttributes($this->getProduct());
foreach ($allProducts as $product) {
$key = array();
foreach ($_attributes as $attribute) {
$key[] = $product->getData($attribute->getData('product_attribute')->getData('attribute_code'));
}
$stockStatus = '';
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
if (!$product->isInStock()) {
$stockStatus = Mage::helper('amxnotif')->__('Out of Stock');
}
if ($key) {
$aStockStatus[implode(',', $key)] = array('is_in_stock' => $product->isSaleable(), 'custom_status' => $stockStatus, 'is_qnt_0' => (int) ($product->isInStock() && $stockItem->getData('qty') <= 0), 'product_id' => $product->getId(), 'stockalert' => Mage::helper('amxnotif')->getStockAlert($product, $this->helper('customer')->isLoggedIn()));
}
}
foreach ($aStockStatus as $k => $v) {
if (!$v['is_in_stock'] && !$v['custom_status']) {
$v['custom_status'] = Mage::helper('amxnotif')->__('Out of Stock');
$aStockStatus[$k] = $v;
}
}
$html = '<script type="text/javascript">var stStatus = new StockStatus(' . Zend_Json::encode($aStockStatus) . ');</script>' . $html;
}
return $html;
}
示例8: 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;
}
示例9: statisticsAction
public function statisticsAction()
{
$request = $this->getRequest()->getParams();
$option = isset($request['option']) ? $request['option'] : 'data';
if ($option == 'data') {
$doc_type = isset($request['doc_type']) && $request['doc_type'] != '' ? $request['doc_type'] : null;
$transaction_type = isset($request['transaction_type']) && $request['transaction_type'] != '' ? $request['transaction_type'] : null;
} else {
$doc_type = isset($request['doc_type']) && $request['doc_type'] != '' ? json_encode(explode(',', $request['doc_type'])) : null;
$transaction_type = isset($request['transaction_type']) && $request['transaction_type'] != '' ? json_encode(explode(',', $request['transaction_type'])) : null;
}
$warehouse_type = isset($request['warehouse_type']) && $request['warehouse_type'] != 'null' ? $request['warehouse_type'] : null;
$warehouse = isset($request['warehouse']) && $request['warehouse'] != 'null' ? $request['warehouse'] : null;
$key = isset($request['key']) ? $request['key'] : '';
$date_from = isset($request['date_from']) ? $request['date_from'] : date('Y-m-01');
$date_to = isset($request['date_to']) ? $request['date_to'] : date('Y-m-t');
$page = isset($request['page']) ? $request['page'] : 1;
$limit = isset($request['limit']) ? $request['limit'] : 0;
$stock = new Erp_Model_Stock_Stock();
// 查询条件
$condition = array('warehouse_type' => $warehouse_type, 'warehouse' => $warehouse, 'doc_type' => $doc_type, 'transaction_type' => $transaction_type, 'key' => $key, 'date_from' => $date_from, 'date_to' => $date_to, 'page' => $page, 'limit' => $limit, 'type' => $option);
$data = $stock->getStatisticsData($condition);
if ($option == 'csv') {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$h = new Application_Model_Helpers();
$h->exportCsv($data, '库存交易统计');
} else {
echo Zend_Json::encode($data);
}
exit;
}
示例10: errorAction
public function errorAction()
{
$http_accept = $_SERVER['HTTP_ACCEPT'];
$this->_redirecUnknownImage($http_accept);
$errors = $this->_getParam('error_handler');
$msg = $errors->exception->getMessage();
$backTrace = $errors->exception->getTraceAsString();
$this->_handleMessage($errors);
$this->_helper->viewRenderer->setViewScriptPathSpec('error/' . $this->getResponse()->getHttpResponseCode() . '.:suffix');
$this->view->exception = $errors->exception;
$this->view->request = $errors->request;
$this->view->ui = 1;
$logPath = realpath(APPLICATION_PATH . '/../log') . "/error";
if (!is_dir($logPath)) {
mkdir($logPath, 755, TRUE);
}
$log = new Zend_Log(new Zend_Log_Writer_Stream($logPath . "/" . date("Ymd") . "_applicationException.log"));
$params1 = $this->_request->getParams();
unset($params1["error_handler"]);
$params = Zend_Json::encode($params1);
$messages = array($msg, $backTrace, $params, "HTTP_ACCEPT: " . $http_accept, "");
$log->err(implode(self::LOG_EOL, $messages));
try {
self::$_dispatcher->notify(new sfEvent($this, 'error.log', array('message' => array($msg, $backTrace), 'priority' => 3)));
return;
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例11: 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));
}
示例12: indexAction
/**
* Index Action
*
*/
public function indexAction()
{
if ($this->getRequest()->getParam('isAjax', false)) {
Mage_AdminNotification_Model_Survey::saveSurveyViewed(true);
}
$this->getResponse()->setBody(Zend_Json::encode(array('survey_decision_saved' => 1)));
}
示例13: if
<?php if ($_valid && !is_callable('content_56059c18e4bca')) {function content_56059c18e4bca($_smarty_tpl) {?>
<?php $_smarty_tpl->tpl_vars["FIELD_INFO"] = new Smarty_variable(Zend_Json::encode($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->getFieldInfo()), null, 0);?><div class="row-fluid"><?php $_smarty_tpl->tpl_vars['ASSIGNED_USER_ID'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->get('name'), null, 0);?><?php $_smarty_tpl->tpl_vars['ALL_ACTIVEUSER_LIST'] = new Smarty_variable($_smarty_tpl->tpl_vars['USER_MODEL']->value->getAccessibleUsers(), null, 0);?><?php $_smarty_tpl->tpl_vars['SEARCH_VALUES'] = new Smarty_variable(explode(',',$_smarty_tpl->tpl_vars['SEARCH_INFO']->value['searchValue']), null, 0);?><?php $_smarty_tpl->tpl_vars['SEARCH_VALUES'] = new Smarty_variable(array_map("trim",$_smarty_tpl->tpl_vars['SEARCH_VALUES']->value), null, 0);?><?php if ($_smarty_tpl->tpl_vars['ASSIGNED_USER_ID']->value!='modifiedby'){?><?php $_smarty_tpl->tpl_vars['ALL_ACTIVEGROUP_LIST'] = new Smarty_variable($_smarty_tpl->tpl_vars['USER_MODEL']->value->getAccessibleGroups(), null, 0);?><?php }else{ ?><?php $_smarty_tpl->tpl_vars['ALL_ACTIVEGROUP_LIST'] = new Smarty_variable(array(), null, 0);?><?php }?><?php $_smarty_tpl->tpl_vars['ACCESSIBLE_USER_LIST'] = new Smarty_variable($_smarty_tpl->tpl_vars['USER_MODEL']->value->getAccessibleUsersForModule($_smarty_tpl->tpl_vars['MODULE']->value), null, 0);?><?php $_smarty_tpl->tpl_vars['ACCESSIBLE_GROUP_LIST'] = new Smarty_variable($_smarty_tpl->tpl_vars['USER_MODEL']->value->getAccessibleGroupForModule($_smarty_tpl->tpl_vars['MODULE']->value), null, 0);?><select class="select2 listSearchContributor span10 <?php echo $_smarty_tpl->tpl_vars['ASSIGNED_USER_ID']->value;?>
" name="<?php echo $_smarty_tpl->tpl_vars['ASSIGNED_USER_ID']->value;?>
" multiple style="width:150px;"data-fieldinfo='<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['FIELD_INFO']->value, ENT_QUOTES, 'UTF-8', true);?>
'><optgroup label="<?php echo vtranslate('LBL_USERS');?>
"><?php $_smarty_tpl->tpl_vars['OWNER_NAME'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['OWNER_NAME']->_loop = false;
$_smarty_tpl->tpl_vars['OWNER_ID'] = new Smarty_Variable;
$_from = $_smarty_tpl->tpl_vars['ALL_ACTIVEUSER_LIST']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['OWNER_NAME']->key => $_smarty_tpl->tpl_vars['OWNER_NAME']->value){
$_smarty_tpl->tpl_vars['OWNER_NAME']->_loop = true;
$_smarty_tpl->tpl_vars['OWNER_ID']->value = $_smarty_tpl->tpl_vars['OWNER_NAME']->key;
?><option value="<?php echo $_smarty_tpl->tpl_vars['OWNER_NAME']->value;?>
" data-picklistvalue= '<?php echo $_smarty_tpl->tpl_vars['OWNER_NAME']->value;?>
' <?php if (in_array(trim(decode_html($_smarty_tpl->tpl_vars['OWNER_NAME']->value)),$_smarty_tpl->tpl_vars['SEARCH_VALUES']->value)){?> selected <?php }?><?php if (array_key_exists($_smarty_tpl->tpl_vars['OWNER_ID']->value,$_smarty_tpl->tpl_vars['ACCESSIBLE_USER_LIST']->value)){?> data-recordaccess=true <?php }else{ ?> data-recordaccess=false <?php }?>data-userId="<?php echo $_smarty_tpl->tpl_vars['CURRENT_USER_ID']->value;?>
"><?php echo $_smarty_tpl->tpl_vars['OWNER_NAME']->value;?>
</option><?php } ?></optgroup><?php if (count($_smarty_tpl->tpl_vars['ALL_ACTIVEGROUP_LIST']->value)>0){?><optgroup label="<?php echo vtranslate('LBL_GROUPS');?>
"><?php $_smarty_tpl->tpl_vars['OWNER_NAME'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['OWNER_NAME']->_loop = false;
$_smarty_tpl->tpl_vars['OWNER_ID'] = new Smarty_Variable;
$_from = $_smarty_tpl->tpl_vars['ALL_ACTIVEGROUP_LIST']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['OWNER_NAME']->key => $_smarty_tpl->tpl_vars['OWNER_NAME']->value){
$_smarty_tpl->tpl_vars['OWNER_NAME']->_loop = true;
$_smarty_tpl->tpl_vars['OWNER_ID']->value = $_smarty_tpl->tpl_vars['OWNER_NAME']->key;
?><option value="<?php echo $_smarty_tpl->tpl_vars['OWNER_NAME']->value;?>
" data-picklistvalue= '<?php echo $_smarty_tpl->tpl_vars['OWNER_NAME']->value;?>
' <?php if (in_array(trim($_smarty_tpl->tpl_vars['OWNER_NAME']->value),$_smarty_tpl->tpl_vars['SEARCH_VALUES']->value)){?> selected <?php }?><?php if (array_key_exists($_smarty_tpl->tpl_vars['OWNER_ID']->value,$_smarty_tpl->tpl_vars['ACCESSIBLE_GROUP_LIST']->value)){?> data-recordaccess=true <?php }else{ ?> data-recordaccess=false <?php }?> ><?php echo $_smarty_tpl->tpl_vars['OWNER_NAME']->value;?>
</option><?php } ?></optgroup><?php }?></select></div><?php }} ?>
开发者ID:jeremyevans6,项目名称:kulturedTiger-,代码行数:26,代码来源:9c2ecfb7c13367f1444988c9d4238cff159be627.file.OwnerFieldSearchView.tpl.php
示例14: getmenusAction
/**
* 获取菜单
*/
public function getmenusAction()
{
// 请求参数
$request = $this->getRequest()->getParams();
// 请求菜单的层级ID
$parent_id = isset($request['parent_id']) ? $request['parent_id'] : 0;
$option = isset($request['option']) ? $request['option'] : null;
$menu = new Home_Model_Menu();
//echo date('H:i:s').'<br>';
if ($option == 'treedata') {
echo Zend_Json::encode($menu->getTreeData($parent_id));
} else {
$data = $menu->getMenuData($parent_id);
/* echo '<pre>';
print_r($data);
exit; */
$json = Zend_Json::encode($data);
$patterns[0] = '/"disabled":"0"/';
$patterns[1] = '/"disabled":"1"/';
$patterns[2] = '/"handler":"menuClick"/';
$replacements[2] = '"disabled":0';
$replacements[1] = '"disabled":1';
$replacements[0] = '"handler":menuClick';
// 转换JSON中的数据格式(临时解决办法)
echo preg_replace($patterns, $replacements, $json);
}
//echo date('H:i:s').'<br>';
exit;
}
示例15: AjaxExecuteTaskGroupAction
/**
* Execute tasks group
*
*/
public function AjaxExecuteTaskGroupAction()
{
$groupCode = $this->getRequest()->getParam('group_code');
$group = mage::getResourceModel('BackgroundTask/Taskgroup')->loadByGroupCode($groupCode);
$hasError = 0;
$hasFinished = 0;
$progressPercent = 0;
try {
$group->execute();
} catch (Exception $ex) {
$hasError = 1;
}
//set values
$progressPercent = $group->getProgressPercent();
if ((int) $progressPercent >= 100) {
$hasFinished = 1;
}
//return result
$response = array();
$response['error'] = $hasError;
$response['finished'] = $hasFinished;
$response['progress'] = $progressPercent;
$response = Zend_Json::encode($response);
$this->getResponse()->setBody($response);
}