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); } } }
public function jsonp($data) { $this->iaCore->factory('util'); echo sprintf('%s(%s)', isset($_GET['fn']) ? $_GET['fn'] : '', iaUtil::jsonEncode($data)); exit; }
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); }
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()); }
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); }