Browse files

put multiple root elements into a <ul> of their own, do not show thei…

…r children initially
  • Loading branch information...
1 parent cac4e63 commit 21cf019e75c46cc4db7853a89cfca964dfb8b681 @ssp ssp committed Jul 23, 2012
Showing with 23 additions and 4 deletions.
  1. +18 −3 lib/class.tx_nkwgok_tree.php
  2. +5 −1 res/nkwgok.css
View
21 lib/class.tx_nkwgok_tree.php
@@ -83,11 +83,25 @@ public function getMarkup () {
'',
'gok ASC',
'');
-
+
+ $resultCount = $GLOBALS['TYPO3_DB']->sql_num_rows($queryResult);
+ $topElementType = 'span';
+ $topItemContainer = $container;
+ if ($resultCount > 1) {
+ $topElementType = 'li';
+ $ul = $this->doc->createElement('ul');
+ $container->appendChild($ul);
+ $topItemContainer = $ul;
+ }
+
while ($GOK = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResult)) {
- $topElement = $this->appendGOKTreeItem($container, 'span', $GOK, Array(), 1, False);
+ $topElement = $this->appendGOKTreeItem($topItemContainer, $topElementType, $GOK, Array(), 1, ($resultCount > 1));
$topElement->setAttribute('class', 'rootNode');
- $this->appendGOKTreeChildren($GOK['ppn'], $container, Array(), 1);
+
+ if ($resultCount === 1) {
+ // There is a single element: display expanded tree without controls at top level.
+ $this->appendGOKTreeChildren($GOK['ppn'], $container, Array(), 1);
+ }
}
return $this->doc;
@@ -159,6 +173,7 @@ function expandGOK" . $this->objectID . " (id) {
. "'tx_" . NKWGOKExtKey . "[language]': '" . $this->language . "', "
. "'tx_" . NKWGOKExtKey . "[expand][0]': id, "
. "'tx_" . NKWGOKExtKey . "[style]': '" . $this->arguments['style'] . "', "
+ . "'tx_" . NKWGOKExtKey . "[omitXXX]': '" . $this->arguments['omitXXX'] . "', "
. "'tx_" . NKWGOKExtKey . "[objectID]': '" . $this->objectID . "'},
function (html) {
plusMinus.text('[-]');
View
6 res/nkwgok.css
@@ -40,7 +40,6 @@ Styles for the GOK Tree
text-align: right;
color: #999;
position: relative;
- left: -9.5em;
}
.gokContainer.tree.hideGOKID ul li {
@@ -60,6 +59,11 @@ Styles for the GOK Tree
left: -0.5em;
}
+.gokContainer.tree a .GOKID,
+.gokContainer.tree ul .rootNode .GOKID {
+ left: -9.5em
+}
+
a:hover .GOKID {
text-decoration: none;
color: #666;

0 comments on commit 21cf019

Please sign in to comment.