本文整理汇总了PHP中Zend_Json::useBuiltinEncoderDecoder方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Json::useBuiltinEncoderDecoder方法的具体用法?PHP Zend_Json::useBuiltinEncoderDecoder怎么用?PHP Zend_Json::useBuiltinEncoderDecoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Json
的用法示例。
在下文中一共展示了Zend_Json::useBuiltinEncoderDecoder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: testJsonWithBuiltins
public function testJsonWithBuiltins()
{
$u = Zend_Json::$useBuiltinEncoderDecoder;
Zend_Json::$useBuiltinEncoderDecoder = true;
$this->_testJson(array('string', 327, true, null));
Zend_Json::$useBuiltinEncoderDecoder = $u;
}
示例4: emitJSON
function emitJSON()
{
// Allow use of native json encoder/decoder for better performance when the content is huge
Zend_Json::$useBuiltinEncoderDecoder = true;
$response = Zend_Json::encode($this->prepareResponse());
return $response;
}
示例5: array
function _encodeResponse($data)
{
Zend_Json::$useBuiltinEncoderDecoder = true;
if (self::$encoding != 'UTF-8') {
array_walk_recursive($data, array(__CLASS__, 'encodingToUtf8'), self::$encoding);
}
return Zend_Json::encode($data);
}
示例6: decrypt
/**
* Descriptografa a URL
*
* @param null $paramValue
* @return mixed
*/
public static function decrypt($paramValue = NULL)
{
$_zendView = Zend_Controller_Front::getInstance();
if ($paramValue == NULL) {
$_strUrl = base64_decode($_zendView->getRequest()->getParam('url'));
} else {
$_strUrl = base64_decode($paramValue);
}
Zend_Json::$useBuiltinEncoderDecoder = TRUE;
return Zend_Json::decode($_strUrl);
}
示例7: send
public function send()
{
Zend_Json::$useBuiltinEncoderDecoder = true;
if ($this->getError()) {
$this->setR('error');
} else {
$this->setR('success');
}
Mage::app()->getFrontController()->getResponse()->setHeader('Content-Type', 'text/plain')->setBody(Zend_Json::encode($this->getData()));
Mage::app()->getFrontController()->getResponse()->sendResponse();
die;
}
示例8: process
public function process(Vtiger_Request $request)
{
$GLOBALS['csrf']['frame-breaker'] = false;
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$qualifiedModuleName = $request->getModule(false);
if (!$request->get("customlink") && !$request->get("type") || !$request->get("languages")) {
//Make JSON response
$response = new Vtiger_Response();
$response->setError('error-param', getTranslatedString("LBL_ERROR_PARAM", $moduleName));
$response->emit();
} else {
$languages = trim($request->get("languages"));
$a_languages = explode(",", $languages);
if ($request->get("customlink")) {
$a_customLink = $request->get("customlink");
//Repair bug with utf8 characters
if (!is_array($a_customLink)) {
$oldValue = Zend_Json::$useBuiltinEncoderDecoder;
Zend_Json::$useBuiltinEncoderDecoder = true;
$a_customLink = Zend_Json::decode($a_customLink);
Zend_Json::$useBuiltinEncoderDecoder = $oldValue;
foreach ($a_customLink as &$val) {
$val = utf8_encode($val);
}
}
}
if (empty($a_customLink)) {
$a_customLink["type"] = '';
$a_customLink["label"] = '';
$a_customLink["url"] = '';
$a_customLink["icon"] = '';
$a_customLink["handlerPath"] = '';
$a_customLink["handlerClass"] = '';
$a_customLink["handler"] = '';
$a_customLink["type"] = $request->get('type');
foreach ($a_languages as $language) {
$a_customLink["label_" . $language] = '';
}
}
$viewer->assign('MODULE', $moduleName);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('a_customLink', $a_customLink);
$viewer->assign('a_languages', $a_languages);
echo $viewer->view('EditCustomLinkPopup.tpl', $qualifiedModuleName, true);
}
}
示例9: process
public function process(Vtiger_Request $request)
{
$GLOBALS['csrf']['frame-breaker'] = false;
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$qualifiedModuleName = $request->getModule(false);
if (!$request->get("relatedlist") && !$request->get("relmodule") || !$request->get("languages")) {
//Make JSON response
$response = new Vtiger_Response();
$response->setError('error-param', getTranslatedString("LBL_ERROR_PARAM", $moduleName));
$response->emit();
} else {
$languages = trim($request->get("languages"));
$a_languages = explode(",", $languages);
if ($request->get("relatedlist")) {
$a_relatedList = $request->get("relatedlist");
//Repair bug with utf8 characters
if (!is_array($a_relatedList)) {
$oldValue = Zend_Json::$useBuiltinEncoderDecoder;
Zend_Json::$useBuiltinEncoderDecoder = true;
$a_relatedList = Zend_Json::decode($a_relatedList);
Zend_Json::$useBuiltinEncoderDecoder = $oldValue;
foreach ($a_relatedList as &$val) {
$val = utf8_encode($val);
}
}
}
if (empty($a_relatedList)) {
$a_relatedList["relatedModule"] = trim($request->get("relmodule"));
$a_relatedList["label"] = '';
$a_relatedList["functionName"] = '';
$a_relatedList["presence"] = '';
$a_relatedList["actionAdd"] = '';
$a_relatedList["actionSelect"] = '';
foreach ($a_languages as $language) {
$a_relatedList["label_" . $language] = '';
}
}
$viewer->assign('MODULE', $moduleName);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('a_relatedList', $a_relatedList);
$viewer->assign('a_languages', $a_languages);
echo $viewer->view('EditRelatedListPopup.tpl', $qualifiedModuleName, true);
}
}
示例10: process
public function process(Vtiger_Request $request)
{
$GLOBALS['csrf']['frame-breaker'] = false;
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$qualifiedModuleName = $request->getModule(false);
if (!$request->get("eventobj") && !$request->get("event") || !$request->get("languages")) {
//Make JSON response
$response = new Vtiger_Response();
$response->setError('error-param', getTranslatedString("LBL_ERROR_PARAM", $moduleName));
$response->emit();
} else {
$languages = trim($request->get("languages"));
$a_languages = explode(",", $languages);
if ($request->get("eventobj")) {
$a_event = $request->get("eventobj");
//Repair bug with utf8 characters
if (!is_array($a_event)) {
$oldValue = Zend_Json::$useBuiltinEncoderDecoder;
Zend_Json::$useBuiltinEncoderDecoder = true;
$a_event = Zend_Json::decode($a_event);
Zend_Json::$useBuiltinEncoderDecoder = $oldValue;
foreach ($a_event as &$val) {
$val = utf8_encode($val);
}
}
}
if (empty($a_event)) {
$a_event["eventName"] = trim($request->get("event"));
$a_event["handlerPath"] = '';
$a_event["handlerClass"] = '';
$a_event["cond"] = '';
$a_event["dependentOn"] = '';
$a_event["isActive"] = false;
}
$viewer->assign('MODULE', $moduleName);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('a_event', $a_event);
$viewer->assign('a_languages', $a_languages);
echo $viewer->view('EditEventPopup.tpl', $qualifiedModuleName, true);
}
}
示例11: sendResponse
public static function sendResponse($data, $type = 'xml')
{
$responseText = '';
switch ($type) {
case 'xml':
header('content-type: application/xml');
$responseText = is_array($data) ? self::array2xml($data) : $data;
break;
case 'json':
header('content-type: application/json');
Zend_Json::$useBuiltinEncoderDecoder = true;
$responseText = Zend_Json::encode($obj);
break;
default:
header('content-type: text/plain');
$responseText = $data;
}
echo $responseText;
die;
}
示例12: get_editor_json
public function get_editor_json($settings = array())
{
$this->EE->load->library('firephp');
// Are there any config overrides
$config_override = $this->EE->config->item('editor');
if ($config_override != false && is_array($config_override)) {
$settings = $this->array_extend($settings, $config_override);
}
require_once PATH_THIRD . 'editor/libraries/zend_json.php';
Zend_Json::$useBuiltinEncoderDecoder = true;
$js = new stdClass();
// Do we need to load an additional Language?
if (isset($settings['language']) === TRUE && $settings['language'] != 'en') {
$js->lang = $settings['language'];
}
// Minheight
if (isset($settings['height']) === TRUE && $settings['height'] > 0) {
$js->minHeight = $settings['height'];
}
// Direction
if (isset($settings['direction']) === TRUE && $settings['direction'] == 'rtl') {
$js->direction = 'rtl';
}
// Toolbar
if (isset($settings['toolbar']) === TRUE && $settings['toolbar'] == 'no') {
$js->toolbar = FALSE;
}
// Source
if (isset($settings['source']) === TRUE && $settings['source'] == 'no') {
$js->source = FALSE;
}
// focus
if (isset($settings['focus']) === TRUE && $settings['focus'] == 'yes') {
$js->focus = TRUE;
}
// Auto Resize
if (isset($settings['autoresize']) === TRUE && $settings['autoresize'] == 'no') {
$js->autoresize = FALSE;
}
// fixed
if (isset($settings['fixed']) === TRUE && $settings['fixed'] == 'yes') {
$js->fixed = TRUE;
}
// Convert Links
if (isset($settings['convertlinks']) === TRUE && $settings['convertlinks'] == 'no') {
$js->convertLinks = FALSE;
}
// Convert Divs
if (isset($settings['convertdivs']) === TRUE && $settings['convertdivs'] == 'no') {
$js->convertDivs = FALSE;
}
// Overlay
if (isset($settings['overlay']) === TRUE && $settings['overlay'] == 'no') {
$js->overlay = FALSE;
}
// Observe Images
if (isset($settings['observeimages']) === TRUE && $settings['observeimages'] == 'no') {
$js->observeImages = FALSE;
}
// Keyboard shortcuts
if (isset($settings['shortcuts']) === TRUE && $settings['shortcuts'] == 'no') {
$js->shortcuts = FALSE;
}
// wym
if (isset($settings['wym']) === TRUE && $settings['wym'] == 'yes') {
$js->wym = TRUE;
}
// protocol
if (isset($settings['protocol']) === TRUE && $settings['protocol'] == 'no') {
$js->protocol = '';
}
// Allowed Tags
if (isset($settings['allowedtags_option']) === TRUE && $settings['allowedtags_option'] == 'custom') {
if (isset($settings['allowedtags']) == FALSE || is_array($settings['allowedtags']) == FALSE) {
$settings['allowedtags'] = array();
}
$js->allowedTags = $settings['allowedtags'];
}
// Denied Tags
if (isset($settings['deniedtags_option']) === TRUE && $settings['deniedtags_option'] == 'custom') {
if (isset($settings['deniedtags']) == FALSE || is_array($settings['deniedtags']) == FALSE) {
$settings['deniedtags'] = array();
}
$js->deniedTags = $settings['deniedtags'];
}
// Formatting Tags
if (isset($settings['formattingtags']) === TRUE && empty($settings['formattingtags']) === FALSE) {
$js->formattingTags = $settings['formattingtags'];
}
// Custom CSS File
if (isset($settings['css_file']) === TRUE && empty($settings['css_file']) === FALSE) {
$css_file = trim($settings['css_file']);
if ($css_file != FALSE) {
$js->iframe = TRUE;
$js_css = json_encode(explode(',', $settings['css_file']));
$js->css = new Zend_Json_Expr($js_css);
}
}
// Buttons
if (isset($settings['buttons']) === TRUE) {
//.........这里部分代码省略.........
示例13: __call
/**
* Performs a jsonRCP request and gets the results as an array
*
* @param string $method
* @param array $params
* @return array
*/
public function __call($method, $params)
{
// check
if (!is_scalar($method)) {
throw new Exception('Method name has no scalar value');
}
// check
if (is_array($params)) {
// no keys
$params = array_values($params);
} else {
throw new Exception('Params must be given as array');
}
// sets notification or request task
if ($this->notification) {
$currentId = NULL;
} else {
$currentId = $this->id;
}
// prepares the request
$request = array('method' => $method, 'params' => $params, 'id' => $currentId);
require_once dirname(__FILE__) . '/../../../Library/Zend/Json.php';
Zend_Json::$useBuiltinEncoderDecoder = true;
$request = Zend_Json::encode($request);
$this->debug && ($this->debug .= '***** Request *****' . "\n" . $request . "\n" . '***** End Of request *****' . "\n\n");
$ch = curl_init();
$headers = array();
$headers[] = 'Content-type: application/json';
$headers[] = 'Origin: http://preprod.handicap.chatanoo.org';
if ($this->sessionKey) {
$headers[] = "Authorization: {$this->sessionKey}";
}
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if (!($response = curl_exec($ch))) {
throw new Exception('Unable to connect to ' . $this->url);
}
$info = curl_getinfo($ch);
if ($info['http_code'] != 200) {
throw new Exception('Authorization fail to ' . $this->url);
}
$this->debug && ($this->debug .= '***** Server response *****' . "\n" . $response . '***** End of server response *****' . "\n");
/*Zend_Debug::dump($response);
exit;*/
require_once dirname(__FILE__) . '/../../../Library/Zend/Json.php';
Zend_Json::$useBuiltinEncoderDecoder = true;
$response = Zend_Json::decode($response);
curl_close($ch);
// debug output
if ($this->debug) {
echo nl2br($this->debug);
}
// final checks and return
if (!$this->notification) {
// check
if ($response['id'] != $currentId) {
throw new Exception('Incorrect response id (request id: ' . $currentId . ', response id: ' . $response['id'] . ')');
}
if (@(!is_null($response['error']))) {
print_r($response);
throw new Exception('Request error: ' . $response['error']);
}
return $response['result'];
} else {
return true;
}
}
示例14: testWillDecodeStructureWithEmptyKeyToObjectProperly
/**
* @group ZF-7586
*/
public function testWillDecodeStructureWithEmptyKeyToObjectProperly()
{
Zend_Json::$useBuiltinEncoderDecoder = true;
$json = '{"":"test"}';
$object = Zend_Json::decode($json, Zend_Json::TYPE_OBJECT);
$this->assertTrue(isset($object->_empty_));
$this->assertEquals('test', $object->_empty_);
}
示例15: process
public function process(Vtiger_Request $request)
{
$GLOBALS['csrf']['frame-breaker'] = false;
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$qualifiedModuleName = $request->getModule(false);
if (!$request->get("field") && !$request->get("uitype") || !$request->get("mod") || !$request->get("languages")) {
//Make JSON response
$response = new Vtiger_Response();
$response->setError('error-param', getTranslatedString("LBL_ERROR_PARAM", $moduleName));
$response->emit();
} else {
$languages = trim($request->get("languages"));
$a_languages = explode(",", $languages);
if ($request->get("field")) {
$a_field = $request->get("field");
//Repair bug with utf8 characters
if (!is_array($a_field)) {
$oldValue = Zend_Json::$useBuiltinEncoderDecoder;
Zend_Json::$useBuiltinEncoderDecoder = true;
$a_field = Zend_Json::decode($a_field);
Zend_Json::$useBuiltinEncoderDecoder = $oldValue;
foreach ($a_field as &$val) {
if (is_string($val)) {
$val = utf8_encode($val);
}
}
}
}
if (empty($a_field)) {
$a_field["fieldName"] = '';
$a_field["oldFieldName"] = '';
$a_field["label"] = '';
$a_field["tableName"] = 'vtiger_' . strtolower($request->get('mod'));
$a_field["columnName"] = '';
$a_field["helpInfoLabel"] = '';
$a_field["defaultValue"] = '';
$a_field["generatedType"] = null;
$a_field["displayType"] = 1;
$a_field["isEntityIdentifier"] = false;
$a_field["entityIdentifierFieldName"] = '';
$a_field["inFilterAll"] = false;
$a_field["inPopup"] = false;
$a_field["popupSequence"] = '';
$a_field["inRelatedList"] = false;
$a_field["relatedListSequence"] = '';
$a_field["quickCreate"] = false;
$a_field["massEditable"] = false;
$a_field["readOnly"] = false;
$a_field["relatedModule"] = null;
$a_field["pickListValues"] = null;
foreach ($a_languages as $language) {
$a_field["label_" . $language] = '';
}
foreach ($a_languages as $language) {
$a_field["helpInfoLabel_" . $language] = '';
}
require_once "modules/{$moduleName}/UITypes.php";
foreach ($a_uitypes as $uitype) {
if ($uitype["num"] == $request->get("uitype")) {
$a_field["UITypeNum"] = $request->get("uitype");
$a_field["UITypeName"] = $uitype["label"];
$a_field["UITypeDBType"] = $uitype["dbtype"];
$a_field["UITypeDataType"] = $uitype["datatype"];
$a_field["mandatory"] = $uitype["mandatory"];
$a_field["twoColumns"] = $uitype["two_columns"];
break;
}
}
}
if ($a_field["UITypeNum"] == 10) {
if (empty($a_field["relatedModule"])) {
$a_field["relatedModule"] = array('');
} elseif (is_string($a_field["relatedModule"])) {
$a_field["relatedModule"] = array($a_field["relatedModule"]);
}
}
//Get modules
$db = PearDatabase::getInstance();
$query = "SELECT tablabel FROM vtiger_tab ORDER BY tablabel ASC";
$result = $db->pquery($query, array());
$a_modules = array();
while ($row = $db->fetchByAssoc($result)) {
$a_modules[] = $row["tablabel"];
}
$viewer->assign('MODULE', $moduleName);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('moduleName', $request->get('mod'));
$viewer->assign('a_modules', $a_modules);
$viewer->assign('a_field', $a_field);
$viewer->assign('a_languages', $a_languages);
echo $viewer->view('EditFieldPopup.tpl', $qualifiedModuleName, true);
}
}