fixing these so that they play nicely with galleries not rooted at /
also modifying code to be more concise...using recursion instead of the ugly stack stuff
This commit is contained in:
parent
bc30a7ac0f
commit
d9084d5b4d
|
@ -10,29 +10,21 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<ul class="treealbumnav">
|
<ul class="treealbumnav">
|
||||||
<? // We'll keep track of the list of items that we want to display in a stack ?>
|
<?
|
||||||
<? $stack = array(array(0, $root)) ?>
|
function makelist($album,$level){
|
||||||
|
//print out the list item
|
||||||
<? // While there are still items to show, pick the next one and show it ?>
|
?>
|
||||||
<? while ($stack): ?>
|
|
||||||
<? list($level, $album) = array_pop($stack) ?>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="/index.php/items/<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?>
|
<a href="<?= item::root()->url() ?><?= $album->relative_url_cache ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></a>
|
||||||
</li>
|
</li>
|
||||||
|
<?
|
||||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
//recurse over the children, and print their list items as well
|
||||||
<? $tmp = array(); ?>
|
foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child){
|
||||||
<? foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
makelist($child,$level+1);
|
||||||
<? $tmp[] = array($level + 1, $child) ?>
|
}
|
||||||
<? endforeach ?>
|
}
|
||||||
|
makelist($root,0);
|
||||||
<? // Since we'll pull them off the stack in the opposite order that we put them on, ?>
|
?>
|
||||||
<? // and the order that we put them on is the order in which we want to display them, ?>
|
|
||||||
<? // We need to reverse the order of the children on the stack ?>
|
|
||||||
<? if ($tmp): ?>
|
|
||||||
<? $stack = array_merge($stack, array_reverse($tmp)) ?>
|
|
||||||
<? endif ?>
|
|
||||||
<? endwhile ?>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
<select onchange="window.location='<?= url::site("items/__ID__")?>'.replace('__ID__', this.value)">
|
<select onchange="window.location=this.value">
|
||||||
<? // We'll keep track of the list of items that we want to display in a stack ?>
|
<?
|
||||||
<? $stack = array(array(0, $root)) ?>
|
function makeselect($album, $level){
|
||||||
|
//print out the list item as a select option
|
||||||
<? // While there are still items to show, pick the next one and show it ?>
|
?>
|
||||||
<? while ($stack): ?>
|
<option value="<?= item::root()->url() ?><?= $album->relative_url_cache ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></option>
|
||||||
<? list($level, $album) = array_pop($stack) ?>
|
<?
|
||||||
<option value="<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></option>
|
//recurse over the children, and print their list items as well
|
||||||
|
foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child){
|
||||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
makeselect($child,$level+1);
|
||||||
<? $tmp = array(); ?>
|
}
|
||||||
<? foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
}
|
||||||
<? $tmp[] = array($level + 1, $child) ?>
|
makeselect($root,0);
|
||||||
<? endforeach ?>
|
?>
|
||||||
|
|
||||||
<? // Since we'll pull them off the stack in the opposite order that we put them on, ?>
|
|
||||||
<? // and the order that we put them on is the order in which we want to display them, ?>
|
|
||||||
<? // We need to reverse the order of the children on the stack ?>
|
|
||||||
<? if ($tmp): ?>
|
|
||||||
<? $stack = array_merge($stack, array_reverse($tmp)) ?>
|
|
||||||
<? endif ?>
|
|
||||||
<? endwhile ?>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -10,29 +10,21 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<ul class="treealbumnav">
|
<ul class="treealbumnav">
|
||||||
<? // We'll keep track of the list of items that we want to display in a stack ?>
|
<?
|
||||||
<? $stack = array(array(0, $root)) ?>
|
function makelist($album,$level){
|
||||||
|
//print out the list item
|
||||||
<? // While there are still items to show, pick the next one and show it ?>
|
?>
|
||||||
<? while ($stack): ?>
|
|
||||||
<? list($level, $album) = array_pop($stack) ?>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="/index.php/items/<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?>
|
<a href="<?= item::root()->url() ?><?= $album->relative_url_cache ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></a>
|
||||||
</li>
|
</li>
|
||||||
|
<?
|
||||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
//recurse over the children, and print their list items as well
|
||||||
<? $tmp = array(); ?>
|
foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child){
|
||||||
<? foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
makelist($child,$level+1);
|
||||||
<? $tmp[] = array($level + 1, $child) ?>
|
}
|
||||||
<? endforeach ?>
|
}
|
||||||
|
makelist($root,0);
|
||||||
<? // Since we'll pull them off the stack in the opposite order that we put them on, ?>
|
?>
|
||||||
<? // and the order that we put them on is the order in which we want to display them, ?>
|
|
||||||
<? // We need to reverse the order of the children on the stack ?>
|
|
||||||
<? if ($tmp): ?>
|
|
||||||
<? $stack = array_merge($stack, array_reverse($tmp)) ?>
|
|
||||||
<? endif ?>
|
|
||||||
<? endwhile ?>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
<select onchange="window.location='<?= url::site("items/__ID__")?>'.replace('__ID__', this.value)">
|
<select onchange="window.location=this.value">
|
||||||
<? // We'll keep track of the list of items that we want to display in a stack ?>
|
<?
|
||||||
<? $stack = array(array(0, $root)) ?>
|
function makeselect($album, $level){
|
||||||
|
//print out the list item as a select option
|
||||||
<? // While there are still items to show, pick the next one and show it ?>
|
?>
|
||||||
<? while ($stack): ?>
|
<option value="<?= item::root()->url() ?><?= $album->relative_url_cache ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></option>
|
||||||
<? list($level, $album) = array_pop($stack) ?>
|
<?
|
||||||
<option value="<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></option>
|
//recurse over the children, and print their list items as well
|
||||||
|
foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child){
|
||||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
makeselect($child,$level+1);
|
||||||
<? $tmp = array(); ?>
|
}
|
||||||
<? foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
}
|
||||||
<? $tmp[] = array($level + 1, $child) ?>
|
makeselect($root,0);
|
||||||
<? endforeach ?>
|
?>
|
||||||
|
|
||||||
<? // Since we'll pull them off the stack in the opposite order that we put them on, ?>
|
|
||||||
<? // and the order that we put them on is the order in which we want to display them, ?>
|
|
||||||
<? // We need to reverse the order of the children on the stack ?>
|
|
||||||
<? if ($tmp): ?>
|
|
||||||
<? $stack = array_merge($stack, array_reverse($tmp)) ?>
|
|
||||||
<? endif ?>
|
|
||||||
<? endwhile ?>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
Reference in New Issue
Block a user