'blank' => null,
'join' => null,
'join_bottom' => null,
+ 'join_top' => null,
'plus' => null,
'plus_bottom' => null,
'plus_only' => null,
}
for ($i = intval($this->_static); $i < $this->_nodes[$node_id]['indent']; ++$i) {
- $line .= $this->_generateImage(($this->_dropline[$i] && $this->getOption('lines', false, true)) ? $this->_images['line'] : $this->_images['blank']);
+ $line .= $this->_generateImage(($this->_dropline[$i] && $this->getOption('lines')) ? $this->_images['line'] : $this->_images['blank']);
}
$line .= $this->_setNodeToggle($node_id) . $this->_setNodeIcon($node_id);
if ($this->getOption('multiline')) {
{
$link_start = '';
- if (($this->_nodes[$node_id]['indent'] == 0) &&
- isset($this->_nodes[$node_id]['children'])) {
- /* Top level node with children. */
+ /* Top level node. */
+ if ($this->_nodes[$node_id]['indent'] == 0) {
$this->_dropline[0] = false;
+
if ($this->_static) {
return '';
- } elseif (!$this->getOption('lines', false, true)) {
- $img = $this->_images['blank'];
- } elseif ($this->_nodes[$node_id]['expanded']) {
- $img = $this->_images['minus_only'];
- } else {
- $img = $this->_images['plus_only'];
}
- if (!$this->_static) {
- $link_start = $this->_generateUrlTag($node_id);
+ /* KEY:
+ * 0: Only node
+ * 1: Top node
+ * 2: Middle node
+ * 3: Bottom node */
+ $node_type = 0;
+ if ($this->getOption('lines_base') &&
+ (count($this->_root_nodes) > 1)) {
+ switch (array_search($node_id, $this->_root_nodes)) {
+ case 0:
+ $node_type = 1;
+ $this->_dropline[0] = true;
+ break;
+
+ case (count($this->_root_nodes) - 1):
+ $node_type = 3;
+ break;
+
+ default:
+ $node_type = 2;
+ $this->_dropline[0] = true;
+ break;
+ }
}
- } elseif (($this->_nodes[$node_id]['indent'] != 0) &&
- !isset($this->_nodes[$node_id]['children'])) {
- /* Node without children. */
- if ($this->_node_pos[$node_id]['pos'] < $this->_node_pos[$node_id]['count']) {
- /* Not last node. */
- $img = $this->getOption('lines', false, true)
- ? $this->_images['join']
- : $this->_images['blank'];
- $this->_dropline[$this->_nodes[$node_id]['indent']] = true;
- } else {
- /* Last node. */
- $img = $this->getOption('lines', false, true)
- ? $this->_images['join_bottom']
- : $this->_images['blank'];
+ if (isset($this->_nodes[$node_id]['children'])) {
+ if (!$this->getOption('lines')) {
+ $img = $this->_images['blank'];
+ } elseif ($this->_nodes[$node_id]['expanded']) {
+ $img = $node_type
+ ? (($node_type == 2) ? $this->_images['minus'] : $this->_images['minus_bottom'])
+ : $this->_images['minus_only'];
+ } else {
+ $img = $node_type
+ ? (($node_type == 2) ? $this->_images['plus'] : $this->_images['plus_bottom'])
+ : $this->_images['plus_only'];
+ }
- $this->_dropline[$this->_nodes[$node_id]['indent']] = false;
+ $link_start = $this->_generateUrlTag($node_id);
+ } else {
+ if ($this->getOption('lines')) {
+ switch ($node_type) {
+ case 0:
+ $img = $this->_images['null_only'];
+ break;
+
+ case 1:
+ $img = $this->_images['join_top'];
+ break;
+
+ case 2:
+ $img = $this->_images['join'];
+ break;
+
+ case 3:
+ $img = $this->_images['join_bottom'];
+ break;
+ }
+ } else {
+ $img = $this->_images['blank'];
+ }
}
} elseif (isset($this->_nodes[$node_id]['children'])) {
/* Node with children. */
if ($this->_node_pos[$node_id]['pos'] < $this->_node_pos[$node_id]['count']) {
/* Not last node. */
- if (!$this->getOption('lines', false, true)) {
+ if (!$this->getOption('lines')) {
$img = $this->_images['blank'];
} elseif ($this->_static) {
$img = $this->_images['join'];
$this->_dropline[$this->_nodes[$node_id]['indent']] = true;
} else {
/* Last node. */
- if (!$this->getOption('lines', false, true)) {
+ if (!$this->getOption('lines')) {
$img = $this->_images['blank'];
} elseif ($this->_static) {
$img = $this->_images['join_bottom'];
$link_start = $this->_generateUrlTag($node_id);
}
} else {
- /* Top level node with no children. */
- if ($this->_static) {
- return '';
- }
+ /* Node without children. */
+ if ($this->_node_pos[$node_id]['pos'] < $this->_node_pos[$node_id]['count']) {
+ /* Not last node. */
+ $img = $this->getOption('lines')
+ ? $this->_images['join']
+ : $this->_images['blank'];
- $img = $this->getOption('lines', false, true)
- ? $this->_images['null_only']
- : $this->_images['blank'];
+ $this->_dropline[$this->_nodes[$node_id]['indent']] = true;
+ } else {
+ /* Last node. */
+ $img = $this->getOption('lines')
+ ? $this->_images['join_bottom']
+ : $this->_images['blank'];
- $this->_dropline[0] = false;
+ $this->_dropline[$this->_nodes[$node_id]['indent']] = false;
+ }
}
return $link_start .
{
var node = this.nodes[nodeId];
- if (node.indent == '0' && node.children) {
+ if (node.indent == '0') {
// Top level with children.
this.dropline[0] = false;
+
if (this.renderStatic) {
return '';
}
- } else if (node.indent != '0' && !node.children) {
- // Node no children.
- this.dropline[node.indent] = (this.node_pos[nodeId].pos < this.node_pos[nodeId].count);
- } else if (node.children) {
- this.dropline[node.indent] = (this.node_pos[nodeId].pos < this.node_pos[nodeId].count);
- } else {
- // Top level node with no children.
- if (this.renderStatic) {
- return '';
+
+ switch (this._getLineType(nodeId)) {
+ case 1:
+ case 2:
+ this.dropline[0] = true;
+ break;
}
- this.dropline[0] = false;
+ } else {
+ this.dropline[node.indent] = (this.node_pos[nodeId].pos < this.node_pos[nodeId].count);
}
return new Element('SPAN', { id: "nodeToggle_" + nodeId }).addClassName('treeToggle').addClassName('treeImg').addClassName('treeImg' + this._getNodeToggle(nodeId));
_getNodeToggle: function(nodeId)
{
- var node = this.nodes[nodeId];
+ var type,
+ node = this.nodes[nodeId];
- if (node.indent == '0' && node.children) {
- // Top level with children.
+ if (node.indent == '0') {
if (this.renderStatic) {
return '';
- } else if (!this.opts.options.lines) {
+ }
+
+ if (!this.opts.options.lines) {
return this.opts.imgBlank;
- } else if (node.expanded) {
- return this.opts.imgMinusOnly;
}
- return this.opts.imgPlusOnly;
- }
+ type = this._getLineType(nodeId);
- if (node.indent != '0' && !node.children) {
- // Node no children.
- if (this.node_pos[nodeId].pos < this.node_pos[nodeId].count) {
- // Not last node.
- return this.opts.options.lines
- ? this.opts.imgJoin
- : this.opts.imgBlank;
+ if (node.children) {
+ // Top level with children.
+ if (node.expanded) {
+ return type
+ ? ((type == 2) ? this.opts.imgMinus : this.opts.imgMinusBottom)
+ : this.opts.imgMinusOnly;
+ }
+
+ return type
+ ? ((type == 2) ? this.opts.imgPlus : this.opts.imgPlusBottom)
+ : this.opts.imgPlusOnly;
}
- // Last node.
- return this.opts.options.lines
- ? this.opts.imgJoinBottom
- : this.opts.imgBlank;
+ switch (type) {
+ case 0:
+ return this.opts.imgNullOnly;
+
+ case 1:
+ return this.opts.imgJoinTop;
+
+ case 2:
+ return this.opts.imgJoin;
+
+ case 3:
+ return this.opts.imgJoinBottom;
+ }
}
if (node.children) {
return this.opts.imgPlusBottom;
}
- // Top level node with no children.
- if (this.renderStatic) {
- return '';
+ // Node no children.
+ if (this.node_pos[nodeId].pos < this.node_pos[nodeId].count) {
+ // Not last node.
+ return this.opts.options.lines
+ ? this.opts.imgJoin
+ : this.opts.imgBlank;
}
+ // Last node.
return this.opts.options.lines
- ? this.opts.imgNullOnly
+ ? this.opts.imgJoinBottom
: this.opts.imgBlank;
},
+ _getLineType: function(nodeId)
+ {
+ if (this.opts.options.lines_base &&
+ this.rootNodes.size() > 1) {
+ switch (this.rootNodes.indexOf(nodeId)) {
+ case 0:
+ return 1;
+
+ case (this.rootNodes.size() - 1):
+ return 3;
+
+ default:
+ return 2;
+ }
+ }
+
+ return 0;
+ },
+
_setNodeIcon: function(nodeId)
{
var img,