Skip to content

Commit

Permalink
Merge branch '1.x' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolineus committed Aug 20, 2020
2 parents e31731d + 4b21ef0 commit 7ca3611
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function filterPages(array $arrPages, $strConditions = '') {

$strConditions && $strConditions = 'AND (' . $strConditions . ')';
$objPage = $this->objStmt->query(
'SELECT id, pid, protected, groups
'SELECT ' . $this->getQuotedFieldsPart(['id', 'pid', 'protected', 'groups']) . '
FROM tl_page
WHERE id IN (' . implode(',', array_keys(array_flip($arrPages))) . ')
' . $strConditions
Expand Down Expand Up @@ -209,7 +209,7 @@ public function filterPages(array $arrPages, $strConditions = '') {
$arrPIDs = array();

$objPage = $this->objStmt->query(
'SELECT id, pid, protected, groups
'SELECT ' . $this->getQuotedFieldsPart(['id', 'pid', 'protected', 'groups']) . '
FROM tl_page
WHERE id IN (' . implode(',', array_keys($arrIDs)) . ')'
);
Expand Down Expand Up @@ -247,7 +247,7 @@ public function getNextLevel(array $arrPages, $strConditions = '') {

$strConditions && $strConditions = 'AND (' . $strConditions . ')';
$objNext = $this->objStmt->query(
'SELECT id, pid, protected, groups
'SELECT ' . $this->getQuotedFieldsPart(['id', 'pid', 'protected', 'groups']) . '
FROM tl_page
WHERE pid IN (' . implode(',', array_keys(array_flip($arrPages))) . ')
' . $strConditions . '
Expand Down Expand Up @@ -371,7 +371,7 @@ protected function renderNavigationTree(array $arrIDs, $strTemplate, $arrStop =
// we are at hard level, never draw submenu
$arrItem['class'] .= ' submenu leaf';

} elseif($intLevel >= $intStop && !$arrItem['isTrail'] && $varID !== $this->varActiveID) {
} elseif($intLevel >= $intStop && !$arrItem['isTrail'] && $varID !== $this->varActiveID && $arrItem['tid'] != $this->varActiveID) {
// we are at stop level and not trail and not active, never draw submenu
$arrItem['class'] .= ' submenu leaf';

Expand Down Expand Up @@ -627,6 +627,11 @@ public function getQueryPartErrorPages($blnShowErrorPages = false) {
}
}

protected function getQuotedFieldsPart(array $fields) : string
{
return implode(', ', array_map([$this->Database, 'quoteIdentifier'], $fields));
}

/**
* A helper method to generate BE wildcard.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function compile() {

protected function calculateRootIDs($arrStop = PHP_INT_MAX) {
$arrRootIDs = $this->backboneit_navigation_defineRoots
? array_map('intval', deserialize($this->backboneit_navigation_roots, true))
? $this->getRootIds()
: array($GLOBALS['objPage']->rootId);

$this->backboneit_navigation_currentAsRoot && array_unshift($arrRootIDs, $GLOBALS['objPage']->id);
Expand Down Expand Up @@ -125,7 +125,7 @@ public function compileNavigationTree(array $arrRootIDs, $arrStop = PHP_INT_MAX,
$arrFetched = $this->fetchItems($arrRootIDs, $arrStop, $intHard, 2);

$objRoots = $this->objStmt->query(
'SELECT ' . implode(',', $this->arrFields) . '
'SELECT ' . $this->getQuotedFieldsPart($this->arrFields) . '
FROM tl_page
WHERE id IN (' . implode(',', $arrRootIDs) . ')'
);
Expand Down Expand Up @@ -173,7 +173,7 @@ protected function fetchItems(array $arrPIDs, $arrStop = PHP_INT_MAX, $intHard =
$strConditions && $strConditions = 'AND (' . $strConditions . ')';

$strLevelQueryStart =
'SELECT ' . implode(',', $this->arrFields) . '
'SELECT ' . $this->getQuotedFieldsPart($this->arrFields) . '
FROM tl_page
WHERE pid IN (';
$strLevelQueryEnd = ')
Expand Down Expand Up @@ -270,4 +270,19 @@ protected function getFirstNavigationLevel(array $arrRootIDs) {
return $arrFirstIDs;
}

protected function getRootIds()
{
return array_map(
'intval',
array_values(
array_unique(
array_merge(
\Contao\StringUtil::deserialize($this->backboneit_navigation_roots_order, true),
\Contao\StringUtil::deserialize($this->backboneit_navigation_roots, true)
)
)
)
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CREATE TABLE `tl_module` (

-- general fields
`backboneit_navigation_roots` blob NULL,
`backboneit_navigation_roots_order` blob NULL,
`backboneit_navigation_start` smallint(5) NOT NULL default '0',
`backboneit_navigation_includeStart` char(1) NOT NULL default '',
`backboneit_navigation_respectHidden` char(1) NOT NULL default '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@
'eval' => array(
'multiple' => true,
'fieldType' => 'checkbox',
'tl_class' => 'clr'
'tl_class' => 'clr',
'orderField' => 'backboneit_navigation_roots_order'
)
);

$GLOBALS['TL_DCA']['tl_module']['fields']['backboneit_navigation_roots_order'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_module']['backboneit_navigation_roots_order'],
);

$GLOBALS['TL_DCA']['tl_module']['fields']['backboneit_navigation_start'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_module']['backboneit_navigation_start'],
'exclude' => true,
Expand Down

0 comments on commit 7ca3611

Please sign in to comment.