本文整理汇总了PHP中iaUtil::jsonEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP iaUtil::jsonEncode方法的具体用法?PHP iaUtil::jsonEncode怎么用?PHP iaUtil::jsonEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iaUtil
的用法示例。
在下文中一共展示了iaUtil::jsonEncode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createJsFile
protected function _createJsFile($file, $type = 'config')
{
$this->iaCore->factory('util');
// required in order the class iaUtil to be loaded
$iaDb =& $this->iaCore->iaDb;
switch ($type) {
case 'lang':
case 'admin_lang':
// get phrases
$stmt = "`code` = :lang AND `category` NOT IN ('tooltip', 'page', :category)";
$iaDb->bind($stmt, array('lang' => $this->iaCore->iaView->language, 'category' => $type == 'admin_lang' ? 'frontend' : iaCore::ADMIN));
$phrases = $iaDb->keyvalue(array('key', 'value'), $stmt, iaLanguage::getTable());
// get list of languages
$languagesList = $iaDb->assoc(array('code', 'title', 'direction', 'flagicon', 'iso' => 'code'), 'admin_lang' == $type ? null : "`status` = 'active'", 'languages');
$fileContent = 'intelli.' . ('admin_lang' == $type ? 'admin.' : '') . 'lang = ' . iaUtil::jsonEncode($phrases) . ';' . 'intelli.languages = ' . iaUtil::jsonEncode($languagesList) . ';';
break;
case 'config':
$stmt = "`private` = 0 && `type` != 'divider' && `config_group` != 'email_templates'";
$config = $iaDb->keyvalue(array('name', 'value'), $stmt, iaCore::getConfigTable());
if (file_exists(IA_INCLUDES . 'custom.inc.php')) {
include IA_INCLUDES . 'custom.inc.php';
}
$config['ia_url'] = IA_CLEAR_URL;
$config['packages'] = $this->iaCore->setPackagesData();
$config['items'] = array();
$config['extras'] = array(array('core', iaLanguage::get('core', 'Core')));
$array = $iaDb->all(array('name', 'title'), "`status` = 'active' ORDER BY `type`", null, null, 'extras');
foreach ($array as $item) {
$config['extras'][] = array($item['name'], $item['title']);
}
$array = $iaDb->onefield('`item`', "`item` != 'transactions'", null, null, 'items');
foreach ($array as $item) {
$config['items'][] = array($item, iaLanguage::get($item, $item));
}
$fileContent = 'intelli.config = ' . iaUtil::jsonEncode($config) . ';';
}
if (isset($fileContent)) {
if ($fh = fopen($file, 'w')) {
fwrite($fh, $fileContent);
fclose($fh);
}
}
}
示例2: jsonp
public function jsonp($data)
{
$this->iaCore->factory('util');
echo sprintf('%s(%s)', isset($_GET['fn']) ? $_GET['fn'] : '', iaUtil::jsonEncode($data));
exit;
}
示例3: _parseTreeNodes
private function _parseTreeNodes($nodesFlatData)
{
$nestedIds = array();
$preservedKeys = array('id', 'text', 'parent');
$data = iaUtil::jsonDecode($nodesFlatData);
foreach ($data as $i => $node) {
foreach ($node as $key => $value) {
if (!in_array($key, $preservedKeys)) {
unset($data[$i][$key]);
}
}
$alias = strtolower(iaSanitize::alias($node['text']));
$nestedIds[$node['id']] = array('node_id' => $node['id'], 'text' => $node['text'], 'parent_node_id' => '#' != $node['parent'] ? $node['parent'] : '', 'alias' => '#' != $node['parent'] && isset($nestedIds[$node['parent']]) ? $nestedIds[$node['parent']]['alias'] . $alias . IA_URL_DELIMITER : $alias . IA_URL_DELIMITER);
}
return array(iaUtil::jsonEncode($data), $nestedIds);
}
示例4: _assignValues
protected function _assignValues(&$iaView, array &$entryData)
{
$pageGroups = array();
$visibleOn = array();
// get groups
$groups = $this->_iaDb->onefield('`group`', '1 GROUP BY `group`', null, null, 'pages');
$rows = $this->_iaDb->all(array('id', 'name', 'title'), null, null, null, 'admin_pages_groups');
foreach ($rows as $row) {
if (in_array($row['id'], $groups)) {
$pageGroups[$row['id']] = $row;
}
}
if (iaCore::ACTION_EDIT == $iaView->get('action')) {
if ($array = $this->_iaDb->onefield('page_name', "`object_type` = 'blocks' && " . iaDb::convertIds($this->getEntryId(), 'object'), null, null, 'objects_pages')) {
$visibleOn = $array;
}
} elseif (!empty($_POST['pages'])) {
$visibleOn = $_POST['pages'];
}
if (!empty($_POST['menus'])) {
$iaView->assign('treeData', iaSanitize::html(iaUtil::jsonEncode($_POST['menus'])));
}
$iaView->assign('visibleOn', $visibleOn);
$iaView->assign('pages', $this->_getPages());
$iaView->assign('pagesGroup', $pageGroups);
$iaView->assign('positions', $this->getHelper()->getPositions());
}
示例5: _parseTreeNodes
private function _parseTreeNodes($nodesFlatData)
{
$preservedKeys = array('id', 'text', 'parent');
$data = iaUtil::jsonDecode($nodesFlatData);
foreach ($data as $i => $node) {
foreach ($node as $key => $value) {
if (!in_array($key, $preservedKeys)) {
unset($data[$i][$key]);
}
}
}
return iaUtil::jsonEncode($data);
}