本文整理汇总了PHP中iaUtil::jsonDecode方法的典型用法代码示例。如果您正苦于以下问题:PHP iaUtil::jsonDecode方法的具体用法?PHP iaUtil::jsonDecode怎么用?PHP iaUtil::jsonDecode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iaUtil
的用法示例。
在下文中一共展示了iaUtil::jsonDecode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getRemotePlugins
private function _getRemotePlugins($start, $limit, $dir, $filter)
{
$pluginsData = array();
if ($cachedData = $this->_iaCore->iaCache->get('subrion_plugins', 3600, true)) {
$pluginsData = $cachedData;
} else {
if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/plugin/' . IA_VERSION)) {
$response = iaUtil::jsonDecode($response);
if (!empty($response['error'])) {
$this->addMessage($response['error']);
} elseif ($response['total'] > 0) {
if (isset($response['extensions']) && is_array($response['extensions'])) {
$pluginsData = array();
$installedPlugins = $this->_iaDb->keyvalue(array('name', 'version'), iaDb::convertIds(iaExtra::TYPE_PLUGIN, 'type'));
foreach ($response['extensions'] as $entry) {
$pluginInfo = (array) $entry;
$pluginInfo['install'] = 0;
// exclude installed plugins
if (!array_key_exists($pluginInfo['name'], $installedPlugins)) {
$pluginsData['pluginsList'][$pluginInfo['name']] = $pluginInfo['title'];
if (isset($pluginInfo['compatibility']) && version_compare($pluginInfo['compatibility'], IA_VERSION, '<=')) {
$pluginInfo['install'] = 1;
}
$pluginInfo['date'] = gmdate(iaDb::DATE_FORMAT, $pluginInfo['date']);
$pluginInfo['file'] = $pluginInfo['name'];
$pluginInfo['readme'] = false;
$pluginInfo['reinstall'] = false;
$pluginInfo['uninstall'] = false;
$pluginInfo['remove'] = false;
$pluginInfo['removable'] = false;
$pluginsData['plugins'][$pluginInfo['name']] = $pluginInfo;
}
}
// cache well-formed results
$this->_iaCore->iaCache->write('subrion_plugins', $pluginsData);
} else {
$this->addMessage('error_incorrect_format_from_subrion');
}
}
} else {
$this->addMessage('error_incorrect_response_from_subrion');
}
}
return $this->getMessages() ? array('result' => false, 'message' => $this->getMessages()) : $this->_sortPlugins($pluginsData, $start, $limit, $dir, $filter);
}
示例2: _getList
private function _getList()
{
$templates = $this->getHelper()->getList();
// get list of available local templates
$remoteTemplates = array();
if ($this->_iaCore->get('allow_remote_templates')) {
if ($cachedData = $this->_iaCore->iaCache->get('subrion_templates', 3600, true)) {
$remoteTemplates = $cachedData;
// get templates list from cache, cache lives for 1 hour
} else {
if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/template/' . IA_VERSION)) {
$response = iaUtil::jsonDecode($response);
if (!empty($response['error'])) {
$this->_messages[] = $response['error'];
$this->_error = true;
} elseif ($response['total'] > 0) {
if (isset($response['extensions']) && is_array($response['extensions'])) {
foreach ($response['extensions'] as $entry) {
$templateInfo = (array) $entry;
// exclude installed templates
if (!array_key_exists($templateInfo['name'], $templates)) {
$templateInfo['date'] = gmdate(iaDb::DATE_FORMAT, $templateInfo['date']);
$templateInfo['buttons'] = '';
$templateInfo['notes'] = array();
$templateInfo['remote'] = true;
$remoteTemplates[] = $templateInfo;
}
}
// cache well-formed results
$this->_iaCore->iaCache->write('subrion_templates', $remoteTemplates);
} else {
$this->addMessage('error_incorrect_format_from_subrion');
$this->_error = true;
}
}
} else {
$this->addMessage('error_incorrect_response_from_subrion');
$this->_error = true;
}
}
}
return array_merge($templates, $remoteTemplates);
}
示例3: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
function recursive_read_menu($menus, $pages, &$list, $menuId)
{
foreach ($menus as $menu) {
$pageId = reset(explode('_', $menu['id']));
$list[] = array('parent_id' => 'root' == $menu['parentId'] ? 0 : $menu['parentId'], 'menu_id' => $menuId, 'el_id' => $menu['id'], 'level' => $menu['depth'] - 1, 'page_name' => $pageId > 0 && isset($pages[$pageId]) ? $pages[$pageId] : 'node');
}
}
$menus = isset($data['menus']) && $data['menus'] ? $data['menus'] : '';
$menus = iaUtil::jsonDecode($menus);
array_shift($menus);
$rows = array();
$pages = $this->_iaDb->keyvalue(array('id', 'name'), null, 'pages');
recursive_read_menu($menus, $pages, $rows, $this->getEntryId());
$this->_iaDb->setTable(iaBlock::getMenusTable());
$this->_iaDb->delete(iaDb::convertIds($this->getEntryId(), 'menu_id'));
empty($rows) || $this->_iaDb->insert($rows);
$this->_iaDb->resetTable();
if (iaCore::ACTION_EDIT == $action) {
$this->_iaCore->iaCache->remove('menu_' . $this->getEntryId() . '.inc');
}
}
示例4: _checkForUpdates
private function _checkForUpdates()
{
$url = sprintf(iaUtil::REMOTE_TOOLS_URL . 'get/updates/%s/', IA_VERSION);
$content = iaUtil::getPageContent($url);
if (!$content) {
return;
}
$content = iaUtil::jsonDecode($content);
if (is_array($content) && $content) {
$messages = array();
foreach ($content as $entry) {
switch ($entry['type']) {
case self::UPDATE_TYPE_INFO:
$messages[] = array($entry['id'], $entry['message']);
break;
case self::UPDATE_TYPE_PATCH:
$version = explode('.', $entry['version']);
if (count($version) > 3) {
if ($this->_iaCore->get('auto_apply_critical_upgrades')) {
$result = iaSystem::forceUpgrade($entry['version']);
if (is_bool($result) && $result) {
$this->_iaCore->factory('cache')->clearGlobalCache();
$message = iaLanguage::getf('script_upgraded', array('version' => $entry['version']));
$this->_iaCore->iaView->setMessages($message, iaView::SUCCESS);
iaUtil::go_to(IA_SELF);
} else {
iaDebug::debug($result, 'Forced upgrade to the version ' . $entry['version']);
}
}
} else {
$url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $entry['version']);
$this->_iaCore->iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $entry['version'])), iaView::SYSTEM);
}
}
}
$this->_iaCore->iaView->assign('updatesInfo', $messages);
}
}
示例5: _parseTreeNodes
protected function _parseTreeNodes($packedNodes)
{
$result = array();
$nodes = iaUtil::jsonDecode($packedNodes);
$indent = array();
foreach ($nodes as $node) {
$id = $node['id'];
$parent = $node['parent'];
$indent[$id] = 0;
'#' != $parent && ++$indent[$id] && (isset($indent[$parent]) ? $indent[$id] += $indent[$parent] : ($indent[$parent] = 0));
}
foreach ($nodes as $node) {
$result[$node['id']] = str_repeat(' ', $indent[$node['id']]) . ' — ' . $node['text'];
}
return $result;
}
示例6: getRemoteList
private function getRemoteList($localPackages)
{
$remotePackages = array();
if ($cachedData = $this->_iaCore->iaCache->get('subrion_packages', 3600 * 24 * 7, true)) {
$remotePackages = $cachedData;
// get templates list from cache, cache lives for 1 hour
} else {
if ($response = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'list/package/' . IA_VERSION)) {
$response = iaUtil::jsonDecode($response);
if (!empty($response['error'])) {
$this->_messages[] = $response['error'];
$this->_error = true;
} elseif ($response['total'] > 0) {
if (isset($response['extensions']) && is_array($response['extensions'])) {
foreach ($response['extensions'] as $entry) {
$packageInfo = (array) $entry;
// exclude uploaded packages
if (!in_array($packageInfo['name'], $localPackages)) {
$packageInfo['date'] = gmdate(iaDb::DATE_FORMAT, $packageInfo['date']);
$packageInfo['status'] = '';
$packageInfo['summary'] = $packageInfo['description'];
$packageInfo['buttons'] = false;
$packageInfo['remote'] = true;
$remotePackages[] = $packageInfo;
}
}
// cache well-formed results
$this->_iaCore->iaCache->write('subrion_packages', $remotePackages);
} else {
$this->addMessage('error_incorrect_format_from_subrion');
$this->_error = true;
}
}
} else {
$this->addMessage('error_incorrect_response_from_subrion');
$this->_error = true;
}
}
return $remotePackages;
}
示例7: urlencode
<?php
//##copyright##
if (iaView::REQUEST_HTML == $iaView->getRequestType() && $iaView->blockExists('current_weather')) {
$city = urlencode($iaCore->get('current_weather_city'));
$units = array('Celsius' => 'metric', 'Fahrenheit' => 'imperial');
$unitParam = $units[$iaCore->get('current_weather_unit')];
$degrees = array('Celsius' => 'C', 'Fahrenheit' => 'F');
$degreesParam = $degrees[$iaCore->get('current_weather_unit')];
$appID = $iaCore->get('current_weather_key');
$weatherData = iaUtil::jsonDecode(file_get_contents("http://api.openweathermap.org/data/2.5/weather?q={$city}&mode=json&units={$unitParam}&appid={$appID}"));
$weatherTemp = round($weatherData['main']['temp']);
if ($weatherData) {
$images = array('Mist' => 'img/mist.png', 'Snow' => 'img/snow.png', 'Thunderstorm' => 'img/thunderstorm.png', 'Rain' => 'img/rain.png', 'Shower rain' => 'img/shower_rain.png', 'Broken clouds' => 'img/clouds.png', 'Clouds' => 'img/clouds.png', 'Scattered clouds' => 'img/clouds.png', 'Few clouds' => 'img/cloudy_day.png', 'Clear sky' => 'img/clear_sky.png', 'Clear' => 'img/clear_sky.png');
$weatherIcon = str_replace('img/', 'img/' . $iaCore->get('current_weather_scheme') . '/', $images[$weatherData['weather'][0]['main']]);
$iaView->assign('icon', $weatherIcon);
$iaView->assign('weather_temp', $weatherTemp);
$iaView->add_css('_IA_URL_plugins/current_weather/templates/front/css/style');
}
$iaView->assign('degrees', $degreesParam);
$iaView->assign('weather_data', $weatherData);
}
示例8: _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);
}
示例9: _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);
}
示例10: _indexPage
//.........这里部分代码省略.........
default:
$classInstance = $iaCore->factoryPackage($itemName, $pluginType, iaCore::ADMIN);
}
if (!$customizationMode && in_array($itemName, $disabledWidgets)) {
continue;
}
if ($classInstance) {
if (method_exists($classInstance, self::STATISTICS_GETTER_METHOD)) {
if ($classInstance->dashboardStatistics) {
$data = $classInstance->{self::STATISTICS_GETTER_METHOD}();
isset($data['icon']) || ($data['icon'] = $itemName);
isset($data['caption']) || ($data['caption'] = $itemName);
$data['caption'] = iaLanguage::get($data['caption'], $data['caption']);
$widgetFormat = isset($data['_format']) && in_array($data['_format'], $validSizes) ? $data['_format'] : $validSizes[0];
$statistics[$widgetFormat][$itemName] = $data;
}
}
}
}
$iaView->assign('statistics', $statistics);
//
if (($customizationMode || !in_array('changelog', $disabledWidgets)) && $iaCore->get('display_changelog') && is_file(IA_HOME . 'changelog.txt')) {
$index = 0;
$log = array();
$titles = array();
$lines = file(IA_HOME . 'changelog.txt');
foreach ($lines as $line_num => $line) {
$line = trim($line);
if ($line) {
if ($line[0] == '>') {
$index++;
$log[$index] = array('title' => trim($line, '<> '), 'added' => '', 'modified' => '', 'bugfixes' => '', 'other' => '');
$titles[trim($line, '<> ')] = $index;
} elseif ($index > 0) {
switch ($line[0]) {
case '+':
$class = 'added';
break;
case '-':
$class = 'bugfixes';
break;
case '*':
$class = 'modified';
break;
default:
$class = 'other';
}
$issue = preg_replace('/#(\\d+)/', '<a href="http://dev.subrion.org/issues/$1" target="_blank">#$1</a>', ltrim($line, '+-* '));
$log[$index][$class] .= '<li>' . $issue . '</li>';
}
}
}
unset($log[0]);
ksort($titles);
$titles = array_reverse($titles);
$iaView->assign('changelog_titles', $titles);
$iaView->assign('changelog', $log);
}
// twitter widget
if ($customizationMode || !in_array('twitter', $disabledWidgets)) {
$data = iaUtil::getPageContent('http://tools.intelliants.com/timeline/');
$iaView->assign('timeline', iaUtil::jsonDecode($data));
}
if ($customizationMode || !in_array('recent-activity', $disabledWidgets)) {
$data = $iaCore->factory('log')->get();
$iaView->assign('activity_log', $data);
}
if ($customizationMode || !in_array('website-visits', $disabledWidgets)) {
$data = $iaCore->factory('users')->getVisitorsInfo();
$iaView->assign('online_members', $data);
}
if ($iaCore->get('check_for_updates')) {
if ($content = iaUtil::getPageContent(iaUtil::REMOTE_TOOLS_URL . 'get/patch/')) {
$content = iaUtil::jsonDecode($content);
if (is_array($content) && $content) {
foreach ($content as $versionFrom => $versionTo) {
if (version_compare($versionFrom, IA_VERSION) === 0 && version_compare($versionTo, IA_VERSION)) {
$version = explode('.', $versionTo);
if (count($version) > 3) {
if ($iaCore->get('auto_apply_critical_upgrades')) {
$result = iaSystem::forceUpgrade($versionTo);
if (is_bool($result) && $result) {
$iaCore->factory('cache')->clearGlobalCache();
$message = iaLanguage::getf('script_upgraded', array('version' => $versionTo));
$iaView->setMessages($message, iaView::SUCCESS);
iaUtil::go_to(IA_SELF);
} else {
iaDebug::debug($result, 'Forced upgrade to the version ' . $versionTo);
}
}
} else {
$url = sprintf('%sinstall/upgrade/check/%s/', IA_CLEAR_URL, $versionTo);
$iaView->setMessages(iaLanguage::getf('upgrade_available', array('url' => $url, 'version' => $versionTo)), iaView::SYSTEM);
}
}
}
}
}
}
}