/** * 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); }
/** * 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); }
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; }
/** * 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); }
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; }
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')); }
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; }
/** * 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; }
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; }
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(); } }
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)); }
/** * 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))); }
<?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 }} ?>
/** * 获取菜单 */ 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; }
/** * 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); }
public function toOptionArray() { /** @var Mage_Core_Model_Cache */ $cache = Mage::app()->getCacheInstance(); if (!($fonts = $cache->load(self::CACHE_KEY))) { $ch = curl_init($this->googlefonts_url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $fonts = curl_exec($ch); curl_close($ch); $fonts = Zend_Json::decode($fonts); $options = array(); if (!isset($fonts['items'])) { return $options; } // can't connect to google font foreach ($fonts['items'] as $item) { $options[$item['family']] = array('value' => $item['family'], 'label' => $item['family']); } ksort($options); $options = array_values($options); $cache->save(serialize($options), self::CACHE_KEY, array(), self::CACHE_LIFETIME); return $options; } else { return unserialize($fonts); } }
public function getHtml() { if (Mage::getStoreConfig('webforms/captcha/api') != 'ajax') { return parent::getHtml(); } $return = ""; $div_id = "webform_recaptcha"; if (Mage::registry('webform')) { $div_id = "webform_" . Mage::registry('webform')->getId() . "_recaptcha"; } $return .= <<<HTML \t\t<div id="{$div_id}"></div> HTML; $return .= <<<SCRIPT <script type="text/javascript" src="https://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script> SCRIPT; if (!empty($this->_options)) { $encoded = Zend_Json::encode($this->_options); } $return .= <<<SCRIPT <script type="text/javascript"> \tRecaptcha.create("{$this->_publicKey}", "{$div_id}", {$encoded}); </script> SCRIPT; return $return; }
public function getWorkflowQuery($workflow) { $conditions = Zend_Json::decode(decode_html($workflow->test)); $moduleName = $workflow->moduleName; $queryGenerator = new QueryGenerator($moduleName, $this->user); $queryGenerator->setFields(array('id')); $this->addWorkflowConditionsToQueryGenerator($queryGenerator, $conditions); if ($moduleName == 'Calendar' || $moduleName == 'Events') { if ($conditions) { $queryGenerator->addConditionGlue('AND'); } // We should only get the records related to proper activity type if ($moduleName == 'Calendar') { $queryGenerator->addCondition('activitytype', 'Emails', 'n'); $queryGenerator->addCondition('activitytype', 'Task', 'e', 'AND'); } else { if ($moduleName == "Events") { $queryGenerator->addCondition('activitytype', 'Emails', 'n'); $queryGenerator->addCondition('activitytype', 'Task', 'n', 'AND'); } } } $query = $queryGenerator->getQuery(); return $query; }
/** * Get Current Rate * @return JSON Data */ function getCurrentRateJson() { $db = $this->getAdapter(); $sql = "SELECT `id`,`in_cur_id`,`out_cur_id`,`rate_in`,`rate_out`\r\n\t\t\t\tFROM `cs_rate` as r\r\n \t\t\tWHERE r.`active` = 1\r\n\t\t\t\tORDER BY r.`in_cur_id`, r.`out_cur_id`"; $rows = $db->fetchAll($sql); return Zend_Json::encode($rows); }
function content_5694a5cf68a7b($_smarty_tpl) { $_smarty_tpl->tpl_vars["FIELD_INFO"] = new Smarty_variable(Vtiger_Util_Helper::toSafeHTML(Zend_Json::encode($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->getFieldInfo())), null, 0); $_smarty_tpl->tpl_vars["SPECIAL_VALIDATOR"] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->getValidator(), null, 0); ?> <input id="<?php echo $_smarty_tpl->tpl_vars['MODULE']->value; ?> _editView_fieldName_<?php echo $_smarty_tpl->tpl_vars['FIELD_MODEL']->value->get('name'); ?> " type="text" class="input-large" data-validation-engine="validate[<?php if ($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->isMandatory() == true) { ?> required,<?php } ?> funcCall[Vtiger_Base_Validator_Js.invokeValidation]]" name="<?php echo $_smarty_tpl->tpl_vars['FIELD_MODEL']->value->getFieldName(); ?> "value="<?php echo $_smarty_tpl->tpl_vars['FIELD_MODEL']->value->get('fieldvalue'); ?> " data-fieldinfo='<?php echo $_smarty_tpl->tpl_vars['FIELD_INFO']->value; ?> ' <?php if (!empty($_smarty_tpl->tpl_vars['SPECIAL_VALIDATOR']->value)) { ?> data-validator=<?php echo Zend_Json::encode($_smarty_tpl->tpl_vars['SPECIAL_VALIDATOR']->value); } ?> /><?php }
/** * Gets our JSON response * * @param String $url Url to query * @return Zend_Json $result Our JSON response * */ protected function _getJsonResponse($url) { $client = new Zend_Http_Client($url); $response = $client->request(); $this->_checkResponse($response); return Zend_Json::decode($response->getBody(), Zend_Json::TYPE_OBJECT); }
public function runAction() { try { $feed = $this->_getFeedModel(); $mode = $this->getRequest()->getParam('mode'); if (!$mode || $mode == 'new') { $feed->getGenerator()->getState()->reset(); } $this->getResponse()->clearBody(); $result = array('success' => true, 'message' => ''); $feed->generate(); $state = $feed->getGenerator()->getState(); $result['status'] = $state->getStatus(); $result['success'] = true; if ($state->isReady()) { $result['message'] = __('Feed file was generated at <a target="_blank" href="' . $feed->getUrl() . '?rand=' . microtime(true) . '">' . $feed->getUrl() . '</a>'); } elseif ($state->isProcessing() || $state->isError()) { $result['message'] = nl2br($feed->getGenerator()->getState()->toHtml()); } } catch (Exception $e) { $result['success'] = false; $result['message'] = $e->getMessage(); } $this->getResponse()->setBody(Zend_Json::encode($result)); }
public function saveAction() { if ($datas = $this->getRequest()->getPost()) { try { if (!empty($datas["name"])) { if (is_numeric(substr($datas["name"], 0, 1))) { throw new Exception("Ce champ ne peut pas commencer par un chiffre"); } $this->getApplication()->setName($datas['name'])->save(); } else { if (!empty($datas['bundle_id'])) { if (count(explode('.', $datas['bundle_id'])) < 2) { throw new Exception($this->_('The entered bundle id is incorrect, it should be like: com.siberiancms.app')); } $this->getApplication()->setBundleId($datas['bundle_id'])->save(); } else { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } } $html = array('success' => '1'); } catch (Exception $e) { $html = array('message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
/** * @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(); }
/** * 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}" . "°ree_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); } } }
public function viewAction() { // Sociel Gaming $app = $this->getApplication(); $option = $this->getCurrentOptionValue(); $current_game = new Socialgaming_Model_Game(); $current_game->findCurrent($app->getId()); if (!$current_game->getId()) { $current_game->findDefault(); } list($start, $end) = $current_game->getFromDateToDate(); $log = new LoyaltyCard_Model_Customer_Log(); $customers = $log->getBestCustomers($app->getId(), $start->toString('y-MM-dd HH:mm:ss'), $end->toString('y-MM-dd HH:mm:ss'), false); $team_leader = $customers->current(); $customers->removeCurrent(); $this->loadPartials($this->getFullActionName('_') . '_l' . $this->_layout_id, false); $this->getLayout()->getPartial('content')->setCurrentGame($current_game)->setTeamLeader($team_leader)->setCustomers($customers); $html = array('html' => $this->getLayout()->render()); if ($url = $option->getBackgroundImageUrl()) { $html['background_image_url'] = $url; } $html['use_homepage_background_image'] = (int) $option->getUseHomepageBackgroundImage() && !$option->getHasBackgroundImage(); $html['title'] = $option->getTabbarName(); $this->getLayout()->setHtml(Zend_Json::encode($html)); }
/** * DataStore view helper. * * @param string $id JavaScript id for the data store. * @param string $dojoType DojoType of the data store (e.g., dojox.data.QueryReadStore) * @param array $attribs Attributes for the data store. */ public function dataStore($id = '', $dojoType = '', array $attribs = array()) { if (!$id || !$dojoType) { throw new Zend_Exception('Invalid arguments: required jsId and dojoType.'); } $this->dojo->requireModule($dojoType); // Programmatic if ($this->_useProgrammatic()) { if (!$this->_useProgrammaticNoScript()) { $this->dojo->addJavascript('var ' . $id . ";\n"); $js = $id . ' = ' . 'new ' . $dojoType . '(' . Zend_Json::encode($attribs) . ");"; $this->dojo->_addZendLoad("function(){{$js}}"); } return ''; } // Set extra attribs for declarative if (!array_key_exists('id', $attribs)) { $attribs['id'] = $id; } if (!array_key_exists('jsId', $attribs)) { $attribs['jsId'] = $id; } if (!array_key_exists('dojoType', $attribs)) { $attribs['dojoType'] = $dojoType; } return '<div' . $this->_htmlAttribs($attribs) . "></div>\n"; }
function NoteBookCreate(Vtiger_Request $request) { $adb = PearDatabase::getInstance(); $userModel = Users_Record_Model::getCurrentUserModel(); $linkId = $request->get('linkId'); $noteBookName = $request->get('notePadName'); $noteBookContent = $request->get('notePadContent'); $blockid = $request->get('blockid'); $isdefault = $request->get('isdefault'); $width = $request->get('width'); $height = $request->get('height'); $date_var = date("Y-m-d H:i:s"); $date = $adb->formatDate($date_var, true); $dataValue = array(); $dataValue['contents'] = $noteBookContent; $dataValue['lastSavedOn'] = $date; $data = Zend_Json::encode((object) $dataValue); $size = Zend_Json::encode(array('width' => $width, 'height' => $height)); $query = "INSERT INTO vtiger_module_dashboard(`linkid`, `blockid`, `filterid`, `title`, `data`, `isdefault`, `size`) VALUES(?,?,?,?,?,?,?)"; $params = array($linkId, $blockid, 0, $noteBookName, $data, $isdefault, $size); $adb->pquery($query, $params); $id = $adb->getLastInsertID(); $result = array(); $result['success'] = TRUE; $result['widgetId'] = $id; $response = new Vtiger_Response(); $response->setResult($result); $response->emit(); }
/** * Encode data as JSON, disable layouts, and set response header * * If $keepLayouts is true, does not disable layouts. * If $encodeJson is false, does not JSON-encode $data * * @param mixed $data * @param bool $keepLayouts * NOTE: if boolean, establish $keepLayouts to true|false * if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false * this array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false * that will not be passed to Zend_Json::encode method but will be used here * @param bool $encodeData * @return string|void */ public function json($data, $keepLayouts = false, $encodeData = true) { $options = array(); if (is_array($keepLayouts)) { $options = $keepLayouts; $keepLayouts = false; if (array_key_exists('keepLayouts', $options)) { $keepLayouts = $options['keepLayouts']; unset($options['keepLayouts']); } if (array_key_exists('encodeData', $options)) { $encodeData = $options['encodeData']; unset($options['encodeData']); } } if ($encodeData) { $data = Zend_Json::encode($data, null, $options); } if (!$keepLayouts) { require_once 'Zend/Layout.php'; $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->disableLayout(); } } $response = Zend_Controller_Front::getInstance()->getResponse(); $response->setHeader('Content-Type', 'application/json', true); return $data; }
/** * Initial connect function to get the user details and also to check the user tocken */ public function connectAction() { $this->_getSession()->unsSignup(); $token = $this->getRequest()->getParam('token'); $host = $this->getRequest()->getParam('host'); //Load the user object with the bc-token $user = App_Main::getModel('stages/user')->load($token, 'bc_auth_token'); //login and redirect to homepage if the user is already registered if ($user->getId()) { $user->setSessionUser($user); echo Zend_Json::encode(array('redirect' => App_Main::getUrl(''))); return; } //Get the Basecamp connect object $bcConnect = new Connect_Basecamp($host, $token, 'X', 'xml'); $userXml = $bcConnect->getMe(); if (!empty($userXml['body']) && $userXml['status'] == '200 OK') { $userArray = App_Main::getHelper('stages')->XMLToArray($userXml['body']); $return = array('success' => 1, 'username' => $userArray['user-name'], 'firstname' => $userArray['first-name'], 'lastname' => $userArray['last-name'], 'avatar' => $userArray['avatar-url'], 'token' => $userArray['token']); $signUp = App_Main::getModel('core/object'); $signUp->setMode('bc_token_connect'); $signUp->setToken($token); $signUp->setHost($host); $this->_getSession()->setSignup($signUp); } else { $return = array('success' => 0); } echo Zend_Json::encode($return); }