/** * Get selected pages for a block to display in overview page * @see $this->_showOverview() * * @param integer $blockId Block id * @param string $placeholder Placeholder (global, direct) * @param \ContentTree $objContentTree ContentTree instance * @param \Cx\Core\ContentManager\Model\Repository\PageRepository $pageRepo PageRepository instance * * @return string Return the selected pages as <ul><li></li></ul> */ function getSelectedPages($blockId, $placeholder, \ContentTree $objContentTree, \Cx\Core\ContentManager\Model\Repository\PageRepository $pageRepo) { $pageLinkTemplate = '<li><a href="%1$s" target="_blank">%2$s</a></li>'; $blockAssociatedPageIds = $this->_getAssociatedPageIds($blockId, $placeholder); $selectedPages = array(); $strSelectedPages = ''; foreach ($objContentTree->getTree() as $arrData) { if (!in_array($arrData['catid'], $blockAssociatedPageIds)) { continue; } $page = $pageRepo->findOneById($arrData['catid']); if (!$page) { continue; } $selectedPages[] = sprintf($pageLinkTemplate, \Cx\Core\Routing\Url::fromPage($page)->toString(), contrexx_raw2xhtml($arrData['catname'])); } if ($selectedPages) { $strSelectedPages = '<ul>' . implode($selectedPages) . '</ul>'; } return $strSelectedPages; }
/** * Edit a banner * * @global object $objDatabase * @param integer $intBannerId: The banner with this id will be changed */ function editBanner($intBannerId) { global $objDatabase, $_ARRAYLANG; $intBannerId = intval($intBannerId); // initialize variables $this->_objTpl->loadTemplateFile('module_banner_edit.html', true, true); $this->pageTitle = $_ARRAYLANG['TXT_BANNER_EDIT_TITLE']; $this->_objTpl->setVariable(array('TXT_BANNER_EDIT_TITLE' => $_ARRAYLANG['TXT_BANNER_EDIT_TITLE'], 'TXT_BANNER_EDIT_NAME' => $_ARRAYLANG['TXT_BANNER_ADD_NAME'], 'TXT_BANNER_EDIT_GROUP' => $_ARRAYLANG['TXT_BANNER_ADD_GROUP'], 'TXT_BANNER_EDIT_GROUP_SELECT' => $_ARRAYLANG['TXT_BANNER_ADD_GROUP_SELECT'], 'TXT_BANNER_EDIT_STATUS' => $_ARRAYLANG['TXT_BANNER_ADD_STATUS'], 'TXT_BANNER_EDIT_CODE' => $_ARRAYLANG['TXT_BANNER_ADD_CODE'], 'TXT_BANNER_EDIT_RELATION' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION'], 'TXT_BANNER_EDIT_RELATION_CONTENT' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_CONTENT'], 'TXT_BANNER_EDIT_RELATION_NEWS' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_NEWS'], 'TXT_BANNER_EDIT_RELATION_TEASER' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_TEASER'], 'TXT_BANNER_EDIT_RELATION_SELECT' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_SELECT'], 'TXT_BANNER_EDIT_RELATION_DESELECT' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_DESELECT'], 'TXT_BANNER_EDIT_RELATION_SAVE' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_SAVE'])); //relation $objResult = $objDatabase->Execute('SELECT page_id, type FROM ' . DBPREFIX . 'module_banner_relations WHERE banner_id=' . $intBannerId . ' '); $arrRelationContent = array(); $arrRelationNews = array(); $arrRelationTeaser = array(); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { switch ($objResult->fields['type']) { case 'news': $arrRelationNews[$objResult->fields['page_id']] = ''; break; case 'teaser': $arrRelationTeaser[$objResult->fields['page_id']] = ''; break; default: $arrRelationContent[$objResult->fields['page_id']] = ''; } $objResult->MoveNext(); } } // create new ContentTree instance $objContentTree = new ContentTree(); foreach ($objContentTree->getTree() as $arrData) { $strSpacer = ''; $intLevel = intval($arrData['level']); for ($i = 0; $i < $intLevel; $i++) { $strSpacer .= ' '; } if (array_key_exists($arrData['catid'], $arrRelationContent)) { $strSelectedPages .= '<option value="' . $arrData['catid'] . '">' . $strSpacer . htmlentities($arrData['catname'], ENT_QUOTES, CONTREXX_CHARSET) . ' (' . $arrData['catid'] . ') </option>' . "\n"; } else { $strUnselectedPages .= '<option value="' . $arrData['catid'] . '">' . $strSpacer . htmlentities($arrData['catname'], ENT_QUOTES, CONTREXX_CHARSET) . ' (' . $arrData['catid'] . ') </option>' . "\n"; } } //get news-categories $objResult = $objDatabase->Execute('SELECT catid, name FROM ' . DBPREFIX . 'module_news_categories ORDER BY name ASC '); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { if (array_key_exists($objResult->fields['catid'], $arrRelationNews)) { $strSelectedNews .= '<option value="' . $objResult->fields['catid'] . '">' . htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET) . ' (' . $objResult->fields['catid'] . ') </option>' . "\n"; } else { $strUnselectedNews .= '<option value="' . $objResult->fields['catid'] . '">' . htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET) . ' (' . $objResult->fields['catid'] . ') </option>' . "\n"; } $objResult->MoveNext(); } } //get teaser-categories $objResult = $objDatabase->Execute('SELECT id, name FROM ' . DBPREFIX . 'module_news_teaser_frame ORDER BY name ASC '); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { if (array_key_exists($objResult->fields['id'], $arrRelationTeaser)) { $strSelectedTeaser .= '<option value="' . $objResult->fields['id'] . '">' . htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET) . ' (' . $objResult->fields['id'] . ') </option>' . "\n"; } else { $strUnselectedTeaser .= '<option value="' . $objResult->fields['id'] . '">' . htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET) . ' (' . $objResult->fields['id'] . ') </option>' . "\n"; } $objResult->MoveNext(); } } //values $objResult = $objDatabase->Execute('SELECT parent_id, name, banner_code, status FROM ' . DBPREFIX . 'module_banner_system WHERE id=' . $intBannerId . ' LIMIT 1 '); $this->_objTpl->setVariable(array('BANNER_EDIT_ID' => $intBannerId, 'BANNER_EDIT_NAME' => stripslashes($objResult->fields['name']), 'BANNER_EDIT_GROUP_MENU' => $this->getBannerGroupMenu(1, $objResult->fields['parent_id']), 'BANNER_EDIT_STATUS' => $objResult->fields['status'] == 1 ? 'checked' : '', 'BANNER_EDIT_CODE' => htmlentities($objResult->fields['banner_code'], ENT_QUOTES, CONTREXX_CHARSET), 'BANNER_EDIT_RELATION_PAGES_UNSELECTED' => $strUnselectedPages, 'BANNER_EDIT_RELATION_PAGES_SELECTED' => $strSelectedPages, 'BANNER_EDIT_RELATION_NEWS_UNSELECTED' => $strUnselectedNews, 'BANNER_EDIT_RELATION_NEWS_SELECTED' => $strSelectedNews, 'BANNER_EDIT_RELATION_TEASER_UNSELECTED' => $strUnselectedTeaser, 'BANNER_EDIT_RELATION_TEASER_SELECTED' => $strSelectedTeaser)); }
/** * Show overview * * Show the blocks overview page * * @access private * @global array * @global ADONewConnection * @global array * @see blockLibrary::getBlocks(), blockLibrary::blockNamePrefix */ function _showOverview() { global $_ARRAYLANG, $objDatabase, $_CORELANG; if (isset($_POST['displaysubmit'])) { foreach ($_POST['displayorder'] as $blockId => $value) { $query = "UPDATE " . DBPREFIX . "module_block_blocks SET `order`='" . intval($value) . "' WHERE id='" . intval($blockId) . "'"; $objDatabase->Execute($query); } } $this->_pageTitle = $_ARRAYLANG['TXT_BLOCK_BLOCKS']; $this->_objTpl->loadTemplateFile('module_block_overview.html'); $catId = !empty($_REQUEST['catId']) ? intval($_REQUEST['catId']) : 0; $this->_objTpl->setVariable(array('TXT_BLOCK_BLOCKS' => $_ARRAYLANG['TXT_BLOCK_BLOCKS'], 'TXT_BLOCK_NAME' => $_ARRAYLANG['TXT_BLOCK_NAME'], 'TXT_BLOCK_PLACEHOLDER' => $_ARRAYLANG['TXT_BLOCK_PLACEHOLDER'], 'TXT_BLOCK_SUBMIT_SELECT' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_SELECT'], 'TXT_BLOCK_SUBMIT_DELETE' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_DELETE'], 'TXT_BLOCK_SUBMIT_ACTIVATE' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_ACTIVATE'], 'TXT_BLOCK_SUBMIT_DEACTIVATE' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_DEACTIVATE'], 'TXT_BLOCK_SUBMIT_GLOBAL' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_GLOBAL'], 'TXT_BLOCK_SUBMIT_GLOBAL_OFF' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_GLOBAL_OFF'], 'TXT_BLOCK_SELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_SELECT_ALL'], 'TXT_BLOCK_DESELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_DESELECT_ALL'], 'TXT_BLOCK_RANDOM' => $_ARRAYLANG['TXT_BLOCK_RANDOM'], 'TXT_BLOCK_PLACEHOLDER' => $_ARRAYLANG['TXT_BLOCK_PLACEHOLDER'], 'TXT_BLOCK_FUNCTIONS' => $_ARRAYLANG['TXT_BLOCK_FUNCTIONS'], 'TXT_BLOCK_DELETE_SELECTED_BLOCKS' => $_ARRAYLANG['TXT_BLOCK_DELETE_SELECTED_BLOCKS'], 'TXT_BLOCK_CONFIRM_DELETE_BLOCK' => $_ARRAYLANG['TXT_BLOCK_CONFIRM_DELETE_BLOCK'], 'TXT_SAVE_CHANGES' => $_CORELANG['TXT_SAVE_CHANGES'], 'TXT_BLOCK_OPERATION_IRREVERSIBLE' => $_ARRAYLANG['TXT_BLOCK_OPERATION_IRREVERSIBLE'], 'TXT_BLOCK_STATUS' => $_ARRAYLANG['TXT_BLOCK_STATUS'], 'TXT_BLOCK_CATEGORY' => $_ARRAYLANG['TXT_BLOCK_CATEGORY'], 'TXT_BLOCK_CATEGORIES_ALL' => $_ARRAYLANG['TXT_BLOCK_CATEGORIES_ALL'], 'TXT_BLOCK_ORDER' => $_ARRAYLANG['TXT_BLOCK_ORDER'], 'TXT_BLOCK_LANGUAGE' => $_ARRAYLANG['TXT_BLOCK_LANGUAGE'], 'TXT_BLOCK_INCLUDED_IN_GLOBAL_BLOCK' => $_ARRAYLANG['TXT_BLOCK_INCLUDED_IN_GLOBAL_BLOCK'], 'BLOCK_CATEGORIES_DROPDOWN' => $this->_getCategoriesDropdown($catId), 'DIRECTORY_INDEX' => CONTREXX_DIRECTORY_INDEX, 'CSRF_PARAM' => \Cx\Core\Csrf\Controller\Csrf::param())); $arrBlocks = $this->getBlocks($catId); // create new ContentTree instance $objContentTree = new \ContentTree(); if (count($arrBlocks) > 0) { $rowNr = 0; foreach ($arrBlocks as $blockId => $arrBlock) { if ($arrBlock['active'] == '1') { $status = '<a href="index.php?cmd=Block&act=deactivate&blockId=' . $blockId . '" title="' . $_ARRAYLANG['TXT_BLOCK_ACTIVE'] . '"><img src="../core/Core/View/Media/icons/led_green.gif" width="13" height="13" border="0" alt="' . $_ARRAYLANG['TXT_BLOCK_ACTIVE'] . '" /></a>'; } else { $status = '<a href="index.php?cmd=Block&act=activate&blockId=' . $blockId . '" title="' . $_ARRAYLANG['TXT_BLOCK_INACTIVE'] . '"><img src="../core/Core/View/Media/icons/led_red.gif" width="13" height="13" border="0" alt="' . $_ARRAYLANG['TXT_BLOCK_INACTIVE'] . '" /></a>'; } if ($arrBlock['random'] == '1') { $random = '<img src="' . ASCMS_MODULE_WEB_PATH . '/Block/View/Media/Shuffle1.png" width="16" height="16" border="0" alt="random 1" class="tooltip-trigger" /><span class="tooltip-message">' . $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO'] . '</span>'; } else { $random = '<img src="../core/Core/View/Media/icons/pixel.gif" width="16" height="16" border="0" alt="" title="" />'; } if ($arrBlock['random2'] == '1') { $random2 = '<img src="' . ASCMS_MODULE_WEB_PATH . '/Block/View/Media/Shuffle2.png" width="16" height="16" border="0" alt="random 2" class="tooltip-trigger" /><span class="tooltip-message">' . $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO'] . '</span>'; } else { $random2 = '<img src="../core/Core/View/Media/icons/pixel.gif" width="16" height="16" border="0" alt="" title="" />'; } if ($arrBlock['random3'] == '1') { $random3 = '<img src="' . ASCMS_MODULE_WEB_PATH . '/Block/View/Media/Shuffle3.png" width="16" height="16" border="0" alt="random 3" class="tooltip-trigger" /><span class="tooltip-message">' . $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO'] . '</span>'; } else { $random3 = '<img src="../core/Core/View/Media/icons/pixel.gif" width="16" height="16" border="0" alt="" title="" />'; } if ($arrBlock['random4'] == '1') { $random4 = '<img src="' . ASCMS_MODULE_WEB_PATH . '/Block/View/Media/Shuffle4.png" width="16" height="16" border="0" alt="random 4" class="tooltip-trigger" /><span class="tooltip-message">' . $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO'] . '</span>'; } else { $random4 = '<img src="../core/Core/View/Media/icons/pixel.gif" width="16" height="16" border="0" alt="" title="" />'; } if ($arrBlock['global'] == '1') { $global = '<img src="../core/Core/View/Media/icons/upload.gif" width="16" height="16" border="0" alt="upload" title="upload" />'; } else { $global = ' '; } $lang = array(); foreach ($arrBlock['lang'] as $langId) { $lang[] = \FWLanguage::getLanguageCodeById($langId); } $langString = implode(', ', $lang); switch ($arrBlock['global']) { case '1': $checkImage = "../core/Core/View/Media/icons/check.gif"; break; case '2': $checkImage = "../core/Core/View/Media/icons/check.gif"; $blockAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'global'); $selectedPages = array(); $strSelectedPages = ''; foreach ($objContentTree->getTree() as $arrData) { if (in_array($arrData['catid'], $blockAssociatedPageIds)) { $selectedPages[] = contrexx_raw2xhtml($arrData['catname']); } } $strSelectedPages = implode('<br />', $selectedPages); break; default: $checkImage = '../core/Core/View/Media/icons/pixel.gif'; break; } $this->_objTpl->setVariable(array('BLOCK_ROW_CLASS' => $rowNr % 2 ? "row1" : "row2", 'BLOCK_ID' => $blockId, 'BLOCK_RANDOM' => $random, 'BLOCK_RANDOM_2' => $random2, 'BLOCK_RANDOM_3' => $random3, 'BLOCK_RANDOM_4' => $random4, 'BLOCK_CATEGORY_NAME' => $this->_categoryNames[$arrBlock['cat']], 'BLOCK_GLOBAL' => $global, 'BLOCK_ORDER' => $arrBlock['order'], 'BLOCK_PLACEHOLDER' => $this->blockNamePrefix . $blockId, 'BLOCK_NAME' => contrexx_raw2xhtml($arrBlock['name']), 'BLOCK_MODIFY' => sprintf($_ARRAYLANG['TXT_BLOCK_MODIFY_BLOCK'], contrexx_raw2xhtml($arrBlock['name'])), 'BLOCK_COPY' => sprintf($_ARRAYLANG['TXT_BLOCK_COPY_BLOCK'], contrexx_raw2xhtml($arrBlock['name'])), 'BLOCK_DELETE' => sprintf($_ARRAYLANG['TXT_BLOCK_DELETE_BLOCK'], contrexx_raw2xhtml($arrBlock['name'])), 'BLOCK_STATUS' => $status, 'BLOCK_LANGUAGES_NAME' => $langString, 'BLOCK_GLOBAL_CHECK_IMAGE' => $checkImage, 'BLOCK_CHECK_IMAGE_DISPLAY' => $arrBlock['global'] == 0 ? 'display:none' : 'display:block', 'BLOCK_CHECK_IMAGE_TITLE' => $arrBlock['global'] == 1 ? $_ARRAYLANG['TXT_BLOCK_DISPLAY_ALL_PAGE'] : ($arrBlock['global'] == 2 ? $_ARRAYLANG['TXT_BLOCK_DISPLAY_SELECTED_PAGE'] . '<br />' . $strSelectedPages : ''))); $this->_objTpl->parse('blockBlockList'); $rowNr++; } } }