/** * Do something before content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_CONFIG, $page, $themesPages, $page_template; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: if ($_CONFIG['blockStatus'] == '1') { $content = \Env::get('cx')->getPage()->getContent(); \Cx\Modules\Block\Controller\Block::setBlocks($content, $page); \Env::get('cx')->getPage()->setContent($content); \Cx\Modules\Block\Controller\Block::setBlocks($themesPages, $page); // TODO: this call in unhappy, becase the content/home template already gets parsed just the line above \Cx\Modules\Block\Controller\Block::setBlocks($page_template, $page); } break; } }
/** * Searches the content and returns an array that is built as needed by the search module. * * @param string $searchTerm * * @return array */ public function searchResultsForSearchModule($searchTerm) { $em = \Env::get('cx')->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); // only list results in case the associated page of the module is active $page = $pageRepo->findOneBy(array('module' => 'MediaDir', 'lang' => FRONTEND_LANG_ID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION)); //If page is not exists or page is inactive then return empty result if (!$page || !$page->isActive()) { return array(); } //get the config site values \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml'); $coreListProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config'); $searchVisibleContentOnly = \Cx\Core\Setting\Controller\Setting::getValue('searchVisibleContentOnly', 'Config'); //get the config otherConfigurations value \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml'); $searchDescriptionLength = \Cx\Core\Setting\Controller\Setting::getValue('searchDescriptionLength', 'Config'); $hasPageAccess = true; $isNotVisible = $searchVisibleContentOnly == 'on' && !$page->isVisible(); if ($coreListProtectedPages == 'off' && $page->isFrontendProtected()) { $hasPageAccess = \Permission::checkAccess($page->getFrontendAccessId(), 'dynamic', true); } //If the page is invisible and frontend access is denied then return empty result if ($isNotVisible || !$hasPageAccess) { return array(); } //get the media directory entry by the search term $entries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($this->moduleName); $entries->getEntries(null, null, null, $searchTerm); //if no entries found then return empty result if (empty($entries->arrEntries)) { return array(); } $results = array(); $formEntries = array(); $defaultEntries = null; $objForm = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, $this->moduleName); $numOfEntries = intval($entries->arrSettings['settingsPagingNumEntries']); foreach ($entries->arrEntries as $entry) { $pageUrlResult = null; $entryForm = $objForm->arrForms[$entry['entryFormId']]; //Get the entry's link url //check the entry's form detail view exists if not, //check the entry's form overview exists if not, //check the default overview exists if not, dont show the corresponding entry in entry switch (true) { case $entries->checkPageCmd('detail' . $entry['entryFormId']): $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, 'detail' . $entry['entryFormId'], FRONTEND_LANG_ID, array('eid' => $entry['entryId'])); break; case $pageCmdExists = $entries->checkPageCmd($entryForm['formCmd']): case $entries->checkPageCmd(''): if ($pageCmdExists && !isset($formEntries[$entryForm['formCmd']])) { $formEntries[$entryForm['formCmd']] = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $formEntries[$entryForm['formCmd']]->getEntries(null, null, null, null, null, null, 1, null, 'n', null, null, $entryForm['formId']); } if (!$pageCmdExists && !isset($defaultEntries)) { $defaultEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $defaultEntries->getEntries(); } //get entry's form overview / default page paging position $entriesPerPage = $numOfEntries; if ($pageCmdExists) { $entriesPerPage = !empty($entryForm['formEntriesPerPage']) ? $entryForm['formEntriesPerPage'] : $numOfEntries; } $pageCmd = $pageCmdExists ? $entryForm['formCmd'] : ''; $entryKeys = $pageCmdExists ? array_keys($formEntries[$entryForm['formCmd']]->arrEntries) : array_keys($defaultEntries->arrEntries); $entryPos = array_search($entry['entryId'], $entryKeys); $position = floor($entryPos / $entriesPerPage); $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, $pageCmd, FRONTEND_LANG_ID, array('pos' => $position * $entriesPerPage)); break; default: break; } //If page url is empty then dont show it in the result if (!$pageUrlResult) { continue; } //Get the search results title and content from the form context field 'title' and 'content' $title = current($entry['entryFields']); $content = ''; $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName); $inputFields = $objInputfields->getInputfields(); foreach ($inputFields as $arrInputfield) { $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : ''; if (!in_array($contextType, array('title', 'content'))) { continue; } $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : ''; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null; $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus); if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) { $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[(BLOCK_[A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']); \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage()); } } catch (\Exception $e) { \DBG::log($e->getMessage()); continue; } $inputFieldValue = $arrInputfieldContent[$this->moduleConstVar . '_INPUTFIELD_VALUE']; if (empty($inputFieldValue)) { continue; } if ($contextType == 'title') { $title = $inputFieldValue; } elseif ($contextType == 'content') { $content = \Cx\Core_Modules\Search\Controller\Search::shortenSearchContent($inputFieldValue, $searchDescriptionLength); } } $results[] = array('Score' => 100, 'Title' => html_entity_decode(contrexx_strip_tags($title), ENT_QUOTES, CONTREXX_CHARSET), 'Content' => $content, 'Link' => $pageUrlResult->toString()); } return $results; }
function listInputfields($objTpl, $intView, $intEntryId) { global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID, $objInit; usort($this->arrInputfields, array(__CLASS__, "sortInputfields")); switch ($intView) { case 1: //Settings View $objTpl->addBlockfile($this->moduleLangVar . '_SETTINGS_INPUTFIELDS_CONTENT', 'settings_inputfields_content', 'module_' . $this->moduleNameLC . '_settings_inputfields.html'); $objForms = new MediaDirectoryForm($this->intFormId, $this->moduleName); $arrShow = array(1 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_BACK_N_FRONTEND'], 2 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_FRONTEND'], 3 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_BACKEND']); $i = 0; $intLastId = 0; foreach ($this->arrInputfields as $key => $arrInputfield) { $strMustfield = $arrInputfield['required'] == 1 ? 'checked="checked"' : ''; $strExpSearch = $arrInputfield['search'] == 1 ? 'checked="checked"' : ''; if ($arrInputfield['id'] > $intLastId) { $intLastId = $arrInputfield['id']; } $objTpl->setGlobalVariable(array($this->moduleLangVar . '_SETTINGS_INPUTFIELD_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_SETTINGS_INPUTFIELD_LASTID' => $intLastId)); if ($arrInputfield['id'] != 1 && $arrInputfield['id'] != 2) { $objTpl->setGlobalVariable(array($this->moduleLangVar . '_SETTINGS_INPUTFIELD_ID' => $arrInputfield['id'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_FORM_ID' => $this->intFormId, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_ORDER' => $arrInputfield['order'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_TYPE' => $this->buildDropdownmenu($this->getInputfieldTypes(), $arrInputfield['type']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_VERIFICATION' => $this->buildDropdownmenu($this->getInputfieldVerifications(), $arrInputfield['verification']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_SHOW' => $this->buildDropdownmenu($arrShow, $arrInputfield['show_in']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_CONTEXT' => $this->buildDropdownmenu($this->getInputContexts(), $arrInputfield['context_type']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_MUSTFIELD' => $strMustfield, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_EXP_SEARCH' => $strExpSearch, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_NAME_MASTER' => $arrInputfield['name'][0], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_DEFAULTVALUE_MASTER' => contrexx_raw2xhtml($arrInputfield['default_value'][0]), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_INFO_MASTER' => $arrInputfield['info'][0])); //fieldname foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_NAME_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_NAME_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_NAME_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_NAME' => $arrInputfield['name'][$arrLang['id']])); $objTpl->parse($this->moduleNameLC . 'InputfieldNameList'); } //default values foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_DEFAULTVALUE' => contrexx_raw2xhtml($arrInputfield['default_value'][$arrLang['id']]))); $objTpl->parse($this->moduleNameLC . 'InputfieldDefaultvalueList'); } //infotext foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_INFO_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_INFO_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_INFO_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_INFO' => $arrInputfield['info'][$arrLang['id']])); $objTpl->parse($this->moduleNameLC . 'InputfieldInfoList'); } //language names foreach ($this->arrFrontendLanguages as $key => $arrLang) { if ($key + 1 == count($this->arrFrontendLanguages)) { $minimize = "<a id=\"inputfieldMinimize_" . $arrInputfield['id'] . "\" href=\"javascript:ExpandMinimizeInputfields('inputfieldName', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldDefaultvalue', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldLanguages', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldInfo', '" . $arrInputfield['id'] . "');\">« " . $_ARRAYLANG['TXT_MEDIADIR_MINIMIZE'] . "</a>"; } else { $minimize = ""; } $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_MINIMIZE' => $minimize)); $objTpl->parse($this->moduleNameLC . 'InputfieldLanguagesList'); } if ($arrInputfield['exp_search'] == 0) { $objTpl->hideBlock($this->moduleNameLC . 'InputfieldAdvancedSearch'); } else { $objTpl->touchBlock($this->moduleNameLC . 'InputfieldAdvancedSearch'); } $objTpl->parse($this->moduleNameLC . 'Inputfield'); } else { if ($arrInputfield['id'] == 2 && $objForms->arrForms[$this->intFormId]['formUseLevel'] || $arrInputfield['id'] == 1 && $objForms->arrForms[$this->intFormId]['formUseCategory']) { $objTpl->setVariable(array($this->moduleLangVar . '_SETTINGS_SELECTOR_ID' => $arrInputfield['id'], $this->moduleLangVar . '_SETTINGS_SELECTOR_NAME' => $arrInputfield['name'][0], $this->moduleLangVar . '_SETTINGS_SELECTOR_ORDER' => $arrInputfield['order'], $this->moduleLangVar . '_SETTINGS_SELECTOR_EXP_SEARCH' => $strExpSearch)); $objTpl->parse($this->moduleNameLC . 'Selector'); } } $i++; $objTpl->parse($this->moduleNameLC . 'InputfieldList'); } $objTpl->parse('settings_inputfields_content'); break; case 2: //modify (add/edit) View $objAddStep = new MediaDirectoryAddStep($this->moduleName); $i = 0; $isFileInputFound = false; foreach ($this->arrInputfields as $key => $arrInputfield) { $strInputfield = null; if ($arrInputfield['required'] == 1) { $strRequiered = '<font color="#ff0000"> *</font>'; } else { $strRequiered = null; } if (!empty($arrInputfield['type'])) { if (!$isFileInputFound && in_array($arrInputfield['type_name'], array('image', 'file', 'downloads'))) { $isFileInputFound = true; } $strType = $arrInputfield['type_name']; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); switch ($strType) { case 'add_step': $objAddStep->addNewStep(empty($arrInputfield['name'][$_LANGID]) ? $arrInputfield['name'][0] . $strRequiered : $arrInputfield['name'][$_LANGID]); $strInputfield = $objInputfield->getInputfield(1, $arrInputfield, $intEntryId, $objAddStep); break; case 'field_group': //to do break; default: if ($arrInputfield['show_in'] == 1) { $bolGetInputfield = true; } else { if ($objInit->mode == 'backend' && $arrInputfield['show_in'] == 3) { $bolGetInputfield = true; } else { if ($objInit->mode == 'frontend' && $arrInputfield['show_in'] == 2) { $bolGetInputfield = true; } else { $bolGetInputfield = false; } } } if ($bolGetInputfield) { $strInputfield = $objInputfield->getInputfield(1, $arrInputfield, $intEntryId); } else { $strInputfield = null; } break; } if ($strInputfield != null) { $this->makeJavascriptInputfieldArray($arrInputfield['id'], $this->moduleNameLC . "Inputfield[" . $arrInputfield['id'] . "]", $arrInputfield['required'], $arrInputfield['regex'], $strType); $this->strJavascriptInputfieldCheck[$strType] = $objInputfield->getJavascriptCheck(); $this->arrJavascriptFormOnSubmit[$arrInputfield['id']] = $objInputfield->getFormOnSubmit($arrInputfield['id']); } } catch (Exception $error) { echo "Error: " . $error->getMessage(); } } else { $objForms = new MediaDirectoryForm($this->intFormId, $this->moduleName); /*if($objInit->mode == 'backend') { $strStyle = 'style="overflow: auto; border: 1px solid #0A50A1; background-color: #ffffff; width: 298px; height: 200px; float: left; list-style: none; padding: 0px; margin: 0px 5px 0px 0px;"'; } else { $strStyle = 'style="overflow: auto; float: left; list-style: none; padding: 0px; margin: 0px 5px 0px 0px;"'; }*/ if ($arrInputfield['id'] == 2 && $objForms->arrForms[$this->intFormId]['formUseLevel'] || $arrInputfield['id'] == 1 && $objForms->arrForms[$this->intFormId]['formUseCategory']) { if ($arrInputfield['id'] == 2) { $objLevel = new MediaDirectoryLevel(null, null, 1, $this->moduleName); $arrSelectorOptions = $objLevel->listLevels($objTpl, 4, null, null, $intEntryId); $strSelectedOptionsName = "selectedLevels"; $strNotSelectedOptionsName = "deselectedLevels"; } else { $objCategory = new MediaDirectoryCategory(null, null, 1, $this->moduleName); $arrSelectorOptions = $objCategory->listCategories($objTpl, 4, null, null, $intEntryId); $strSelectedOptionsName = "selectedCategories"; $strNotSelectedOptionsName = "deselectedCategories"; } $strInputfield .= '<div class="mediadirSelector container-fluid"><div class="row"><div class="col-md-offset-3">'; $strInputfield .= '<div class="col-md-4 col-sm-12 col-xs-12 mediadirSelectorLeft"><div class="row"><select id="' . $strNotSelectedOptionsName . '" name="' . $strNotSelectedOptionsName . '[]" size="12" multiple="multiple">'; $strInputfield .= $arrSelectorOptions['not_selected']; $strInputfield .= '</select></div></div>'; $strInputfield .= '<div class="mediadirSelectorCenter col-md-2 col-sm-12 col-xs-12">'; $strInputfield .= '<input class="btn btn-default" value=" >> " name="addElement" onclick="moveElement(document.entryModfyForm.elements[\'' . $strNotSelectedOptionsName . '\'],document.entryModfyForm.elements[\'' . $strSelectedOptionsName . '\'],addElement,removeElement);" type="button">'; $strInputfield .= '<br />'; $strInputfield .= '<input class="btn btn-default" value=" << " name="removeElement" onclick="moveElement(document.entryModfyForm.elements[\'' . $strSelectedOptionsName . '\'],document.entryModfyForm.elements[\'' . $strNotSelectedOptionsName . '\'],removeElement,addElement);" type="button">'; $strInputfield .= '</div>'; $strInputfield .= '<div class="col-md-4 col-sm-12 col-xs-12 mediadirSelectorRight"><div class="row"><select id="' . $strSelectedOptionsName . '" name="' . $strSelectedOptionsName . '[]" size="12" multiple="multiple">'; $strInputfield .= $arrSelectorOptions['selected']; $strInputfield .= '</select></div></div>'; $strInputfield .= '</div></div></div>'; $this->makeJavascriptInputfieldArray($arrInputfield['id'], $strSelectedOptionsName, 1, 1, "selector"); $this->arrJavascriptFormOnSubmit[$arrInputfield['id']] = "selectAll(document.entryModfyForm.elements['" . $strSelectedOptionsName . "[]']); "; } } if ($arrInputfield['type_name'] == 'add_step' && $objInit->mode != 'backend') { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_ADDSTEP' => $strInputfield)); $objTpl->parse($this->moduleNameLC . 'InputfieldAddStep'); } else { if ($strInputfield != null) { if ($arrInputfield['type_name'] == 'title') { $strStartTitle = '<h2>'; $strEndTitle = '</h2>'; } else { $strStartTitle = ''; $strEndTitle = ''; } $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_INPUTFIELD_NAME' => $strStartTitle . (empty($arrInputfield['name'][$_LANGID]) ? $arrInputfield['name'][0] . $strRequiered : $arrInputfield['name'][$_LANGID] . $strRequiered) . $strEndTitle, $this->moduleLangVar . '_INPUTFIELD_FIELD' => $strInputfield, $this->moduleLangVar . '_INPUTFIELD_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2')); if ($arrInputfield['type_name'] != 'add_step') { $i++; $objTpl->parse($this->moduleNameLC . 'InputfieldList'); } } } if ($objInit->mode != 'backend') { $objTpl->parse($this->moduleNameLC . 'InputfieldElement'); } } if ($isFileInputFound && $objInit->mode != 'backend') { // init uploader to upload images $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setCallback($this->moduleNameLC . 'UploaderCallback'); $uploader->setOptions(array('id' => $this->moduleNameLC . 'ImageUploader', 'style' => 'display:none', 'data-upload-limit' => 1)); $objTpl->setVariable(array($this->moduleLangVar . '_UPLOADER_ID' => $uploader->getId(), $this->moduleLangVar . '_UPLOADER_CODE' => $uploader->getXHtml())); } if (!empty($objAddStep->arrSteps) && $objInit->mode != 'backend') { $objAddStep->getStepNavigation($objTpl); $objTpl->parse($this->moduleNameLC . 'EntryAddStepNavigation'); $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_ADDSTEP_TERMINATOR' => "</div>")); } break; case 3: //frontend View foreach ($this->arrInputfields as $key => $arrInputfield) { $intInputfieldId = intval($arrInputfield['id']); $intInputfieldType = intval($arrInputfield['type']); if (($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId) || $objTpl->blockExists($this->moduleNameLC . '_inputfields')) && ($intInputfieldType != 16 && $intInputfieldType != 17)) { if (!empty($arrInputfield['type'])) { $strType = $arrInputfield['type_name']; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); if (intval($arrInputfield['type_multi_lang']) == 1) { $arrInputfieldContent = $objInputfield->getContent($intEntryId, $arrInputfield, $this->arrTranslationStatus); } else { $arrInputfieldContent = $objInputfield->getContent($intEntryId, $arrInputfield, null); } if (!empty($arrInputfieldContent)) { if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) { $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[([A-Z][A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']); \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage()); } foreach ($arrInputfieldContent as $strPlaceHolder => $strContent) { $objTpl->setVariable(array(strtoupper($strPlaceHolder) => $strContent)); } if ($objTpl->blockExists($this->moduleNameLC . '_inputfields')) { $objTpl->parse($this->moduleNameLC . '_inputfields'); } else { if ($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId)) { $objTpl->parse($this->moduleNameLC . '_inputfield_' . $intInputfieldId); } } } else { if ($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId)) { $objTpl->hideBlock($this->moduleNameLC . '_inputfield_' . $intInputfieldId); } } } catch (Exception $error) { echo "Error: " . $error->getMessage(); } } } $objTpl->clearVariables(); } break; case 4: //Exp Search View $strInputfields = ''; foreach ($this->arrInputfields as $key => $arrInputfield) { if ($this->checkFieldTypeIsExpSeach($arrInputfield['type'])) { if (!empty($arrInputfield['type'])) { $strType = $arrInputfield['type_name']; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); $strInputfield = $objInputfield->getInputfield(2, $arrInputfield); if ($strInputfield != null) { $strInputfields .= '<p><label>' . $arrInputfield['name'][0] . '</label>' . $strInputfield . '</p>'; } } catch (Exception $error) { echo "Error: " . $error->getMessage(); } } } } return $strInputfields; break; } }
/** * Get the block content as html * * @param array $params all given params from http request * @throws NoPermissionException * @throws NotEnoughArgumentsException * @throws NoBlockFoundException * @return string the html content of the block */ public function getBlockContent($params) { global $_CORELANG, $objDatabase; // check for necessary arguments if (empty($params['get']) || empty($params['get']['block']) || empty($params['get']['lang']) || empty($params['get']['page'])) { throw new NotEnoughArgumentsException('not enough arguments'); } // get id and langugage id $id = intval($params['get']['block']); $lang = \FWLanguage::getLanguageIdByCode($params['get']['lang']); if (!defined('FRONTEND_LANG_ID')) { if (!$lang) { $lang = 1; } define('FRONTEND_LANG_ID', $lang); } if (!$lang) { $lang = FRONTEND_LANG_ID; } // database query to get the html content of a block by block id and // language id $query = "SELECT\n c.content\n FROM\n `" . DBPREFIX . "module_block_blocks` b\n INNER JOIN\n `" . DBPREFIX . "module_block_rel_lang_content` c\n ON c.block_id = b.id\n WHERE\n b.id = " . $id . "\n AND\n (c.lang_id = " . $lang . " AND c.active = 1)"; $result = $objDatabase->Execute($query); // nothing found if ($result === false || $result->RecordCount() == 0) { throw new NoBlockFoundException('no block content found with id: ' . $id); } $content = $result->fields['content']; $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $cx->parseGlobalPlaceholders($content); $em = $cx->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $page = $pageRepo->find($params['get']['page']); \Cx\Modules\Block\Controller\Block::setBlocks($content, $page); \LinkGenerator::parseTemplate($content); $ls = new \LinkSanitizer($cx, $cx->getCodeBaseOffsetPath() . \Env::get('virtualLanguageDirectory') . '/', $content); return array('content' => $ls->replace()); }