/** * Initializes listing for the given object * @param Cx\Core_Modules\Listing\Model\Listable $listableObject * @param int $mode (optional) A combination of the paging, sorting and filtering modes above (use |) * @returm Cx\Core_Modules\Listing\Model\DataSet Parsed data */ public function getData() { $params = array('offset' => $this->offset, 'count' => $this->count, 'order' => $this->order, 'criteria' => $this->criteria); foreach ($this->handlers as $handler) { $params = $handler->handle($params, $this->args); } $this->offset = $params['offset']; $this->count = $params['count']; $this->order = $params['order']; $this->criteria = $params['criteria']; // handle ajax requests if (false) { $jd = new \Cx\Core\Json\JsonData(); $jd->json(array('filtering' => $this->getAjaxFilteringData(), 'sorting' => $this->getAjaxSortingData(), 'paging' => $this->getAjaxPagingData()), true); // JsonData->json() does call die() itself } if ($this->entityClass instanceof \Cx\Core_Modules\Listing\Model\Entity\DataSet) { //$data = new \Cx\Core_Modules\Listing\Model\Entity\DataSet(); $data = $this->entityClass; $data = $data->sort($this->order); // add sorting and filtering $data = $data->limit($this->count, $this->offset); return $data; } // If a callback was specified, use it: $qb = \Env::get('em')->createQueryBuilder(); $qb->select('e')->from($this->entityClass, 'e'); $query = $qb->getQuery(); if (is_callable($this->callback)) { $callable = $this->callback; $query = $callable($this->offset, $this->count, $this->order, $this->criteria); if (!$query instanceof \Doctrine\ORM\Query) { return $query; } } if (!class_exists($this->entityClass)) { //throw new ListingException('No such entity "' . $this->entityClass . '"'); } // build query // TODO: check if entity class is managed //$qb = new \Doctrine\ORM\QueryBuilder(); $query->setFirstResult($this->offset); $query->setMaxResults($this->count); /*foreach ($this->order as $field=>$order) { $query->orderBy($field, $order); } foreach ($this->criteria as $crit=>$param) { $query->addWhere($crit); if ($param) { $query->addParameter($param[0], $param[1]); } } var_dump($query->getDQL());*/ $entities = $query->getResult(); // @todo: check if entities should be encapsulated in a class $data = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($entities); // return calculated data return $data; }
/** * Show modify block * * Show the block modification page * * @access private * @global array * @see blockLibrary::_getBlockContent(), blockLibrary::blockNamePrefix */ private function _showModifyBlock($copy = false) { global $_ARRAYLANG; \JS::activate('cx'); \JS::activate('ckeditor'); \JS::activate('jqueryui'); \JS::registerJS('lib/javascript/tag-it/js/tag-it.min.js'); \JS::registerCss('lib/javascript/tag-it/css/tag-it.css'); $mediaBrowserCkeditor = new MediaBrowser(); $mediaBrowserCkeditor->setCallback('ckeditor_image_button'); $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button', 'type' => 'button', 'style' => 'display:none')); $blockId = !empty($_REQUEST['blockId']) ? intval($_REQUEST['blockId']) : 0; $blockCat = 0; $blockName = ''; $blockStart = 0; $blockEnd = 0; $blockRandom = 0; $blockRandom2 = 0; $blockRandom3 = 0; $blockRandom4 = 0; $blockGlobal = 0; $blockDirect = 0; $blockCategory = 0; $blockWysiwygEditor = 1; $blockContent = array(); $blockAssociatedPageIds = array(); $blockLangActive = array(); $blockGlobalAssociatedPageIds = array(); $blockDirectAssociatedPageIds = array(); $blockCategoryAssociatedPageIds = array(); $this->_objTpl->loadTemplateFile('module_block_modify.html'); $this->_objTpl->setGlobalVariable(array('TXT_BLOCK_CONTENT' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_NAME' => $_ARRAYLANG['TXT_BLOCK_NAME'], 'TXT_BLOCK_RANDOM' => $_ARRAYLANG['TXT_BLOCK_RANDOM'], 'TXT_BLOCK_GLOBAL' => $_ARRAYLANG['TXT_BLOCK_SHOW_IN_GLOBAL'], 'TXT_BLOCK_SAVE' => $_ARRAYLANG['TXT_BLOCK_SAVE'], 'TXT_BLOCK_DEACTIVATE' => $_ARRAYLANG['TXT_BLOCK_DEACTIVATE'], 'TXT_BLOCK_ACTIVATE' => $_ARRAYLANG['TXT_BLOCK_ACTIVATE'], 'TXT_DONT_SHOW_ON_PAGES' => $_ARRAYLANG['TXT_DONT_SHOW_ON_PAGES'], 'TXT_SHOW_ON_ALL_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_ALL_PAGES'], 'TXT_SHOW_ON_SELECTED_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_SELECTED_PAGES'], 'TXT_BLOCK_CATEGORY' => $_ARRAYLANG['TXT_BLOCK_CATEGORY'], 'TXT_BLOCK_NONE' => $_ARRAYLANG['TXT_BLOCK_NONE'], 'TXT_BLOCK_SHOW_FROM' => $_ARRAYLANG['TXT_BLOCK_SHOW_FROM'], 'TXT_BLOCK_SHOW_UNTIL' => $_ARRAYLANG['TXT_BLOCK_SHOW_UNTIL'], 'TXT_BLOCK_SHOW_TIMED' => $_ARRAYLANG['TXT_BLOCK_SHOW_TIMED'], 'TXT_BLOCK_SHOW_ALWAYS' => $_ARRAYLANG['TXT_BLOCK_SHOW_ALWAYS'], 'TXT_BLOCK_LANG_SHOW' => $_ARRAYLANG['TXT_BLOCK_SHOW_BLOCK_IN_THIS_LANGUAGE'], 'TXT_BLOCK_BASIC_DATA' => $_ARRAYLANG['TXT_BLOCK_BASIC_DATA'], 'TXT_BLOCK_ADDITIONAL_OPTIONS' => $_ARRAYLANG['TXT_BLOCK_ADDITIONAL_OPTIONS'], 'TXT_BLOCK_SELECTED_PAGES' => $_ARRAYLANG['TXT_BLOCK_SELECTED_PAGES'], 'TXT_BLOCK_AVAILABLE_PAGES' => $_ARRAYLANG['TXT_BLOCK_AVAILABLE_PAGES'], 'TXT_BLOCK_SELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_SELECT_ALL'], 'TXT_BLOCK_UNSELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_UNSELECT_ALL'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DISPLAY_TIME' => $_ARRAYLANG['TXT_BLOCK_DISPLAY_TIME'], 'TXT_BLOCK_FORM_DESC' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_USE_WYSIWYG_EDITOR' => $_ARRAYLANG['TXT_BLOCK_USE_WYSIWYG_EDITOR'], 'TXT_BLOCK_TARGETING' => $_ARRAYLANG['TXT_BLOCK_TARGETING'], 'TXT_BLOCK_TARGETING_SHOW_PANE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_SHOW_PANE'], 'TXT_BLOCK_TARGETING_ALL_USERS' => $_ARRAYLANG['TXT_BLOCK_TARGETING_ALL_USERS'], 'TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $_ARRAYLANG['TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW'], 'TXT_BLOCK_TARGETING_INCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_INCLUDE'], 'TXT_BLOCK_TARGETING_EXCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_EXCLUDE'], 'TXT_BLOCK_TARGETING_TYPE_LOCATION' => $_ARRAYLANG['TXT_BLOCK_TARGETING_TYPE_LOCATION'], 'TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING' => $_ARRAYLANG['TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING'])); $targetingStatus = isset($_POST['targeting_status']) ? contrexx_input2int($_POST['targeting_status']) : 0; $targeting = array(); foreach ($this->availableTargeting as $targetingType) { $targetingArr = isset($_POST['targeting'][$targetingType]) ? $_POST['targeting'][$targetingType] : array(); if (empty($targetingArr)) { continue; } $targeting[$targetingType] = array('filter' => !empty($targetingArr['filter']) && in_array($targetingArr['filter'], array('include', 'exclude')) ? contrexx_input2raw($targetingArr['filter']) : 'include', 'value' => isset($targetingArr['value']) ? contrexx_input2raw($targetingArr['value']) : array()); } if (isset($_POST['block_save_block'])) { $blockCat = !empty($_POST['blockCat']) ? intval($_POST['blockCat']) : 0; $blockContent = isset($_POST['blockFormText_']) ? array_map('contrexx_input2raw', $_POST['blockFormText_']) : array(); $blockName = !empty($_POST['blockName']) ? contrexx_input2raw($_POST['blockName']) : $_ARRAYLANG['TXT_BLOCK_NO_NAME']; $blockStart = strtotime($_POST['inputStartDate']); $blockEnd = strtotime($_POST['inputEndDate']); $blockRandom = !empty($_POST['blockRandom']) ? intval($_POST['blockRandom']) : 0; $blockRandom2 = !empty($_POST['blockRandom2']) ? intval($_POST['blockRandom2']) : 0; $blockRandom3 = !empty($_POST['blockRandom3']) ? intval($_POST['blockRandom3']) : 0; $blockRandom4 = !empty($_POST['blockRandom4']) ? intval($_POST['blockRandom4']) : 0; $blockWysiwygEditor = isset($_POST['wysiwyg_editor']) ? 1 : 0; $blockLangActive = isset($_POST['blockFormLanguages']) ? array_map('intval', $_POST['blockFormLanguages']) : array(); // placeholder configurations // global block // 0 = not activated , 1 = on all pages , 2 = selected pages $blockGlobal = !empty($_POST['blockGlobal']) ? intval($_POST['blockGlobal']) : 0; // direct block and category block placeholders // 0 = on all pages , 1 = selected pages $blockDirect = !empty($_POST['blockDirect']) ? intval($_POST['blockDirect']) : 0; $blockCategory = !empty($_POST['blockCategory']) ? intval($_POST['blockCategory']) : 0; // block on page relations for each placeholder $blockGlobalAssociatedPageIds = isset($_POST['globalSelectedPagesList']) ? array_map('intval', explode(",", $_POST['globalSelectedPagesList'])) : array(); $blockDirectAssociatedPageIds = isset($_POST['directSelectedPagesList']) ? array_map('intval', explode(",", $_POST['directSelectedPagesList'])) : array(); $blockCategoryAssociatedPageIds = isset($_POST['categorySelectedPagesList']) ? array_map('intval', explode(",", $_POST['categorySelectedPagesList'])) : array(); if ($blockId) { if ($this->_updateBlock($blockId, $blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) { if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) { $this->storeTargetingSettings($blockId, $targetingStatus, $targeting); \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&modified=true&blockname=' . $blockName); exit; } } $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_UPDATED']; } else { if ($blockId = $this->_addBlock($blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) { if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) { $this->storeTargetingSettings($blockId, $targetingStatus, $targeting); \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&added=true&blockname=' . $blockName); exit; } } $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_ADDED']; } } elseif (($arrBlock = $this->_getBlock($blockId)) !== false) { $blockStart = $arrBlock['start']; $blockEnd = $arrBlock['end']; $blockCat = $arrBlock['cat']; $blockRandom = $arrBlock['random']; $blockRandom2 = $arrBlock['random2']; $blockRandom3 = $arrBlock['random3']; $blockRandom4 = $arrBlock['random4']; $blockWysiwygEditor = $arrBlock['wysiwyg_editor']; $blockContent = $arrBlock['content']; $blockLangActive = $arrBlock['lang_active']; $blockName = $arrBlock['name']; $blockGlobal = $arrBlock['global']; $blockDirect = $arrBlock['direct']; $blockCategory = $arrBlock['category']; $blockGlobalAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'global'); $blockDirectAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'direct'); $blockCategoryAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'category'); $targeting = $this->loadTargetingSettings($blockId); if (!empty($targeting)) { $targetingStatus = 1; } } $pageTitle = $blockId != 0 ? sprintf($copy ? $_ARRAYLANG['TXT_BLOCK_COPY_BLOCK'] : $_ARRAYLANG['TXT_BLOCK_MODIFY_BLOCK'], contrexx_raw2xhtml($blockName)) : $_ARRAYLANG['TXT_BLOCK_ADD_BLOCK']; $this->_pageTitle = $pageTitle; if ($copy) { $blockId = 0; } $this->_objTpl->setVariable(array('BLOCK_ID' => $blockId, 'BLOCK_MODIFY_TITLE' => $pageTitle, 'BLOCK_NAME' => contrexx_raw2xhtml($blockName), 'BLOCK_CATEGORIES_PARENT_DROPDOWN' => $this->_getCategoriesDropdown($blockCat), 'BLOCK_START' => !empty($blockStart) ? strftime('%Y-%m-%d %H:%M', $blockStart) : $blockStart, 'BLOCK_END' => !empty($blockEnd) ? strftime('%Y-%m-%d %H:%M', $blockEnd) : $blockEnd, 'BLOCK_WYSIWYG_EDITOR' => $blockWysiwygEditor == 1 ? 'checked="checked"' : '', 'BLOCK_RANDOM' => $blockRandom == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_2' => $blockRandom2 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_3' => $blockRandom3 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_4' => $blockRandom4 == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_0' => $blockGlobal == '0' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_1' => $blockGlobal == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_2' => $blockGlobal == '2' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_SHOW_PAGE_SELECTOR' => $blockGlobal == '2' ? 'block' : 'none', 'BLOCK_DIRECT_0' => $blockDirect == '0' ? 'checked="checked"' : '', 'BLOCK_DIRECT_1' => $blockDirect == '1' ? 'checked="checked"' : '', 'BLOCK_DIRECT_SHOW_PAGE_SELECTOR' => $blockDirect == '1' ? 'block' : 'none', 'BLOCK_CATEGORY_0' => $blockCategory == '0' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_1' => $blockCategory == '1' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_SHOW_PAGE_SELECTOR' => $blockCategory == '1' ? 'block' : 'none', 'BLOCK_WYSIWYG_MEDIABROWSER' => $mediaBrowserCkeditor->getXHtml(), 'BLOCK_TARGETING_ALL_USERS' => $targetingStatus == 0 ? 'checked="checked"' : '', 'BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $targetingStatus == 1 ? 'checked="checked"' : '', 'BLOCK_TARGETING_COUNTRY_INCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'include' ? 'selected="selected"' : '', 'BLOCK_TARGETING_COUNTRY_EXCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'exclude' ? 'selected="selected"' : '')); if (!empty($targeting['country']) && !empty($targeting['country']['value'])) { foreach ($targeting['country']['value'] as $countryId) { $countryName = \Cx\Core\Country\Controller\Country::getNameById($countryId); if (empty($countryName)) { continue; } $this->_objTpl->setVariable(array('BLOCK_TARGET_COUNTRY_ID' => contrexx_raw2xhtml($countryId), 'BLOCK_TARGET_COUNTRY_NAME' => contrexx_raw2xhtml($countryName))); $this->_objTpl->parse('block_targeting_country'); } } $jsonData = new \Cx\Core\Json\JsonData(); $pageTitlesTree = $jsonData->data('node', 'getPageTitlesTree'); $pageTitlesTree = $pageTitlesTree['data']; $objJs = \ContrexxJavascript::getInstance(); $blockGlobalPageSelects = $this->getPageSelections($pageTitlesTree, $blockGlobalAssociatedPageIds); $blockDirectPageSelects = $this->getPageSelections($pageTitlesTree, $blockDirectAssociatedPageIds); $blockCategoryPageSelects = $this->getPageSelections($pageTitlesTree, $blockCategoryAssociatedPageIds); $objJs->setVariable('globalPagesUnselectedOptions', $jsonData->json($blockGlobalPageSelects[1]), 'block'); $objJs->setVariable('globalPagesSelectedOptions', $jsonData->json($blockGlobalPageSelects[0]), 'block'); $objJs->setVariable('directPagesUnselectedOptions', $jsonData->json($blockDirectPageSelects[1]), 'block'); $objJs->setVariable('directPagesSelectedOptions', $jsonData->json($blockDirectPageSelects[0]), 'block'); $objJs->setVariable('categoryPagesUnselectedOptions', $jsonData->json($blockCategoryPageSelects[1]), 'block'); $objJs->setVariable('categoryPagesSelectedOptions', $jsonData->json($blockCategoryPageSelects[0]), 'block'); $objJs->setVariable('ckeditorconfigpath', substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT) + 1), 'block'); $arrActiveSystemFrontendLanguages = \FWLanguage::getActiveFrontendLanguages(); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'global'); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'direct'); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'category'); if (count($arrActiveSystemFrontendLanguages) > 0) { $intLanguageCounter = 0; $arrLanguages = array(0 => '', 1 => '', 2 => ''); $strJsTabToDiv = ''; foreach ($arrActiveSystemFrontendLanguages as $langId => $arrLanguage) { $boolLanguageIsActive = $blockId == 0 && $intLanguageCounter == 0 ? true : (isset($blockLangActive[$langId]) && $blockLangActive[$langId] == 1 ? true : false); $arrLanguages[$intLanguageCounter % 3] .= '<input id="languagebar_' . $langId . '" ' . ($boolLanguageIsActive ? 'checked="checked"' : '') . ' type="checkbox" name="blockFormLanguages[' . $langId . ']" value="1" onclick="switchBoxAndTab(this, \'lang_blockContent_' . $langId . '\');" /><label for="languagebar_' . $langId . '">' . contrexx_raw2xhtml($arrLanguage['name']) . ' [' . $arrLanguage['lang'] . ']</label><br />'; $strJsTabToDiv .= 'arrTabToDiv["lang_blockContent_' . $langId . '"] = "langTab_' . $langId . '";' . "\n"; ++$intLanguageCounter; } $this->_objTpl->setVariable(array('TXT_BLOCK_LANGUAGE' => $_ARRAYLANG['TXT_BLOCK_LANGUAGE'], 'EDIT_LANGUAGES_1' => $arrLanguages[0], 'EDIT_LANGUAGES_2' => $arrLanguages[1], 'EDIT_LANGUAGES_3' => $arrLanguages[2], 'EDIT_JS_TAB_TO_DIV' => $strJsTabToDiv)); } $arrLanguages = \FWLanguage::getLanguageArray(); $i = 0; $activeFlag = 0; foreach ($arrLanguages as $langId => $arrLanguage) { if ($arrLanguage['frontend'] != 1) { continue; } $tmpBlockContent = isset($blockContent[$langId]) ? $blockContent[$langId] : ''; $tmpBlockLangActive = isset($blockLangActive[$langId]) ? $blockLangActive[$langId] : 0; $tmpBlockContent = preg_replace('/\\{([A-Z0-9_-]+)\\}/', '[[\\1]]', $tmpBlockContent); if ($blockId != 0) { if (!$activeFlag && isset($blockLangActive[$langId])) { $activeClass = 'active'; $activeFlag = 1; } } elseif (!$activeFlag) { $activeClass = 'active'; $activeFlag = 1; } $this->_objTpl->setVariable(array('BLOCK_LANG_TAB_LANG_ID' => intval($langId), 'BLOCK_LANG_TAB_CLASS' => isset($activeClass) ? $activeClass : '', 'TXT_BLOCK_LANG_TAB_LANG_NAME' => contrexx_raw2xhtml($arrLanguage['name']), 'BLOCK_LANGTAB_DISPLAY' => $tmpBlockLangActive == 1 ? 'display:inline;' : ($blockId == 0 && $i == 0 ? 'display:inline;' : 'display:none;'))); $this->_objTpl->parse('block_language_tabs'); $this->_objTpl->setVariable(array('BLOCK_LANG_ID' => intval($langId), 'BLOCK_CONTENT_TEXT_HIDDEN' => contrexx_raw2xhtml($tmpBlockContent))); $this->_objTpl->parse('block_language_content'); $activeClass = ''; $i++; } if (!$this->getGeoIpComponent() || !$this->getGeoIpComponent()->getGeoIpServiceStatus()) { $this->_objTpl->touchBlock('warning_geoip_disabled'); } else { $this->_objTpl->hideBlock('warning_geoip_disabled'); } }
protected function fetchResponse($license, $_CONFIG, $forceTemplate, $_CORELANG) { $v = preg_split('#\\.#', $_CONFIG['coreCmsVersion']); $e = $_CONFIG['coreCmsEdition']; $version = current($v); unset($v[key($v)]); foreach ($v as $part) { $version *= 100; $version += $part; } $srvUri = 'updatesrv1.contrexx.com'; $srvPath = '/'; $data = array('installationId' => $license->getInstallationId(), 'licenseKey' => $license->getLicenseKey(), 'edition' => $license->getEditionName(), 'version' => $this->coreCmsVersion, 'versionstate' => $this->coreCmsStatus, 'domainName' => $this->domainUrl, 'sendTemplate' => $forceTemplate); if (true) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_INSTANCE_PATH . ASCMS_INSTANCE_OFFSET . '/config/License.lic'); $rawData = $objFile->getData(); $response = json_decode(base64_decode($rawData)); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { $license->setState(License::LICENSE_ERROR); $license->setGrayzoneMessages(array(\FWLanguage::getLanguageCodeById(LANG_ID) => new Message(\FWLanguage::getLanguageCodeById(LANG_ID), $_CORELANG['TXT_LICENSE_COMMUNICATION_ERROR']))); $license->check(); throw $e; } return $response; } $a = $_SERVER['REMOTE_ADDR']; $r = 'http://'; if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { $r = 'https://'; } $r .= $_SERVER['SERVER_NAME'] . ASCMS_INSTANCE_OFFSET; $request = new \HTTP_Request2('http://' . $srvUri . $srvPath . '?v=' . $version, \HTTP_Request2::METHOD_POST); $request->setHeader('X-Edition', $e); $request->setHeader('X-Remote-Addr', $a); $request->setHeader('Referer', $r); $jd = new \Cx\Core\Json\JsonData(); $request->addPostParameter('data', $jd->json($data)); try { $objResponse = $request->send(); if ($objResponse->getStatus() !== 200) { $license->setState(License::LICENSE_ERROR); $license->setGrayzoneMessages(array(\FWLanguage::getLanguageCodeById(LANG_ID) => new Message(\FWLanguage::getLanguageCodeById(LANG_ID), $_CORELANG['TXT_LICENSE_COMMUNICATION_ERROR']))); $license->check(); return null; } else { \DBG::dump($objResponse->getBody()); $response = json_decode($objResponse->getBody()); } } catch (\HTTP_Request2_Exception $objException) { $license->setState(License::LICENSE_ERROR); $license->setGrayzoneMessages(array(\FWLanguage::getLanguageCodeById(LANG_ID) => new Message(\FWLanguage::getLanguageCodeById(LANG_ID), $_CORELANG['TXT_LICENSE_COMMUNICATION_ERROR']))); $license->check(); throw $objException; } return $response; }
/** * Execute one of the commands listed in getCommandsForCommandMode() * * Data command is deprecated. Use /api/v1/ instead * @see getCommandsForCommandMode() * @param string $command Name of command to execute * @param array $arguments List of arguments for the command * @param array $dataArguments (optional) List of data arguments for the command * @return void */ public function executeCommand($command, $arguments) { switch ($command) { case 'Data': if (!isset($arguments[static::ARGUMENT_INDEX_OUTPUT_MODULE]) || !isset($arguments[static::ARGUMENT_INDEX_DATA_ADAPTER]) || !isset($arguments[static::ARGUMENT_INDEX_DATA_METHOD])) { throw new \Exception('Not enough arguments'); } $outputModule = $arguments[static::ARGUMENT_INDEX_OUTPUT_MODULE]; $dataAdapter = $arguments[static::ARGUMENT_INDEX_DATA_ADAPTER]; $dataMethod = $arguments[static::ARGUMENT_INDEX_DATA_METHOD]; unset($arguments[static::ARGUMENT_INDEX_OUTPUT_MODULE]); unset($arguments[static::ARGUMENT_INDEX_DATA_ADAPTER]); unset($arguments[static::ARGUMENT_INDEX_DATA_METHOD]); $dataArguments = array('get' => $arguments); $json = new \Cx\Core\Json\JsonData(); $data = $json->data($dataAdapter, $dataMethod, $dataArguments); if ($data['status'] != 'success') { if (empty($data['message'])) { throw new \Exception('Fetching data failed without message'); } throw new \Exception($data['message']); } switch ($outputModule) { case 'Plain': echo $data['data']['content']; break; case 'Json': echo $json->json($data, true); break; default: throw new \Exception('No such output module: "' . $outputModule . '"'); break; } break; } }