/** * 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; }
/** * Show all banners of a group * * @global object $objDatabase * @global array $_ARRAYLANG * @param integer $intGid: The group with this id will be shown */ function showGroupDetails($intGid = 0) { global $objDatabase, $_ARRAYLANG; switch ($_POST['frmShowBanner_MultiAction']) { case 'delete': if (isset($_POST['selectedBannerId'])) { foreach ($_POST['selectedBannerId'] as $intBannerId) { $this->deleteBanner($intBannerId); } } break; case 'activate': if (isset($_POST['selectedBannerId'])) { foreach ($_POST['selectedBannerId'] as $intBannerId) { $this->changeBannerStatus($intBannerId, 1); } } break; case 'deactivate': if (isset($_POST['selectedBannerId'])) { foreach ($_POST['selectedBannerId'] as $intBannerId) { $this->changeBannerStatus($intBannerId, 0); } } break; default: //do nothing } if (!empty($_POST['saveDefault'])) { $this->setDefaultBanner($intGid, $_POST['defaultBanner']); } $intGid = intval($intGid); $objContentTree = new ContentTree(); $this->_objTpl->loadTemplateFile('module_banner_group_details.html', true, true); $this->pageTitle = $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_TITLE']; $this->_objTpl->setVariable(array('BANNER_GROUP_ID' => $intGid, 'TXT_BANNER_GROUP_DETAILS_STATUS' => $_ARRAYLANG['TXT_BANNER_ADD_STATUS'], 'TXT_BANNER_GROUP_DETAILS_STATUS_2' => $_ARRAYLANG['TXT_BANNER_ADD_STATUS'], 'TXT_BANNER_GROUP_DETAILS_DEFAULT' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DEFAULT'], 'TXT_BANNER_GROUP_DETAILS_NAME' => $_ARRAYLANG['TXT_BANNER_ADD_NAME'], 'TXT_BANNER_GROUP_DETAILS_RELATION_CONTENT' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_CONTENT'], 'TXT_BANNER_GROUP_DETAILS_RELATION_NEWS' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_NEWS'], 'TXT_BANNER_GROUP_DETAILS_RELATION_TEASER' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_TEASER'], 'TXT_BANNER_GROUP_DETAILS_FUNCTIONS' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_FUNCTIONS'], 'TXT_BANNER_GROUP_DETAILS_DELETE' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DELETE'], 'TXT_BANNER_GROUP_DETAILS_DELETE_JS' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DELETE_JS'], 'TXT_BANNER_GROUP_DETAILS_DELETE_ALL_JS' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_DELETE_ALL_JS'], 'TXT_BANNER_GROUP_DETAILS_EDIT' => $_ARRAYLANG['TXT_BANNER_GROUP_DETAILS_EDIT'], 'TXT_BANNER_GROUP_DETAILS_SAVE' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_SAVE'], 'TXT_BANNER_GROUP_DETAILS_SELECT_ALL' => $_ARRAYLANG['TXT_BANNER_SELECT_ALL'], 'TXT_BANNER_GROUP_DETAILS_DESELECT_ALL' => $_ARRAYLANG['TXT_BANNER_DESELECT_ALL'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_SELECT' => $_ARRAYLANG['TXT_BANNER_SUBMIT_SELECT'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_EXPAND' => $_ARRAYLANG['TXT_BANNER_SUBMIT_EXPAND'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_COMPRESS' => $_ARRAYLANG['TXT_BANNER_SUBMIT_COMPRESS'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_DELETE' => $_ARRAYLANG['TXT_BANNER_SUBMIT_DELETE'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_ACTIVATE' => $_ARRAYLANG['TXT_BANNER_SUBMIT_ACTIVATE'], 'TXT_BANNER_GROUP_DETAILS_SUBMIT_DEACTIVATE' => $_ARRAYLANG['TXT_BANNER_SUBMIT_DEACTIVATE'])); $objResult = $objDatabase->Execute('SELECT id, name FROM ' . DBPREFIX . 'module_banner_groups ORDER BY id ASC '); if ($objResult->RecordCount() > 0) { $strDropDown = '<select name="ddGroup" onChange="window.location=this.options[this.selectedIndex].value">'; while (!$objResult->EOF) { $strDropDown .= '<option value="' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=banner') . '&act=group_details&id=' . $objResult->fields['id'] . '"' . ($objResult->fields['id'] == $intGid ? ' selected' : '') . '>' . $objResult->fields['name'] . '</option>'; $objResult->MoveNext(); } $strDropDown .= '</select>'; } $this->_objTpl->setVariable('BANNER_GROUP_DROPDOWN', $strDropDown); //create news-cat-array $objResult = $objDatabase->Execute('SELECT catid, name FROM ' . DBPREFIX . 'module_news_categories ORDER BY name ASC '); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { $arrNewsCategories[$objResult->fields['catid']] = $objResult->fields['name']; $objResult->MoveNext(); } } //create teaser-cat-array ($arrTeaserCategories) $objResult = $objDatabase->Execute('SELECT id, name FROM ' . DBPREFIX . 'module_news_teaser_frame ORDER BY name ASC '); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { $arrTeaserCategories[$objResult->fields['id']] = $objResult->fields['name']; $objResult->MoveNext(); } } $objResult = $objDatabase->Execute('SELECT id, name, banner_code, status, is_default FROM ' . DBPREFIX . 'module_banner_system WHERE parent_id=' . $intGid . ' ORDER BY is_default DESC, name ASC '); $i = 0; if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { $objSubResult = $objDatabase->Execute(' SELECT page_id, type FROM ' . DBPREFIX . 'module_banner_relations WHERE banner_id=' . $objResult->fields['id'] . ' '); $strRelationsContent = ''; $strRelationsNews = ''; $strRelationsTeaser = ''; if ($objSubResult->RecordCount() > 0) { while (!$objSubResult->EOF) { switch ($objSubResult->fields['type']) { case 'news': $strRelationsNews .= '<a href="?cmd=News&act=newscat">' . $arrNewsCategories[$objSubResult->fields['page_id']] . ' (' . $objSubResult->fields['page_id'] . '</a>)<br />'; break; case 'teaser': $strRelationsTeaser .= '<a href="?cmd=News&act=teasers&tpl=editFrame&frameId=' . $objSubResult->fields['page_id'] . '">' . $arrTeaserCategories[$objSubResult->fields['page_id']] . ' (' . $objSubResult->fields['page_id'] . '</a>)<br />'; break; default: $arrValues = $objContentTree->getThisNode($objSubResult->fields['page_id']); $strRelationsContent .= '<a href="?cmd=ContentManager&act=edit&pageId=' . $arrValues['catid'] . '">' . $arrValues['catname'] . ' (' . $arrValues['catid'] . '</a>)<br />'; } $objSubResult->MoveNext(); } } $strStatusIcon = $objResult->fields['status'] == 0 ? 'status_red.gif' : 'status_green.gif'; $this->_objTpl->setVariable(array('BANNER_ROWCLASS' => $objResult->fields['is_default'] == 0 ? 'row' . ($i % 2 + 1) : 'rowWarn', 'BANNER_ID' => $objResult->fields['id'], 'BANNER_STATUS_ICON' => $strStatusIcon, 'BANNER_DEFAULT' => $objResult->fields['is_default'] == 0 ? '' : 'checked', 'BANNER_NAME' => stripslashes($objResult->fields['name']), 'BANNER_LIVE' => stripslashes($objResult->fields['banner_code']), 'BANNER_CODE' => htmlspecialchars($objResult->fields['banner_code'], ENT_QUOTES, CONTREXX_CHARSET), 'BANNER_RELATIONS_CONTENT' => $strRelationsContent, 'BANNER_RELATIONS_NEWS' => $strRelationsNews, 'BANNER_RELATIONS_TEASER' => $strRelationsTeaser)); $this->_objTpl->parse('showBanner'); $i++; $objResult->MoveNext(); } } else { $this->_objTpl->hideBlock('showBanner'); } }
/** * 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++; } } }