Add a second style where we use unordered lists instead of a <select>.
It's hacky, but works. Switch between styles using Admin > Settings > Advanced and changing albumtree.style between "select" and "list".
This commit is contained in:
parent
114997695c
commit
6288579384
@ -26,9 +26,10 @@ class albumtree_block_Core {
|
||||
$block = new Block();
|
||||
switch ($block_id) {
|
||||
case "albumtree":
|
||||
$style = module::get_var("albumtree", "style", "select");
|
||||
$block->css_id = "g-albumtree";
|
||||
$block->title = t("Album Tree");
|
||||
$block->content = new View("albumtree_block.html");
|
||||
$block->content = new View("albumtree_block_{$style}.html");
|
||||
$block->content->root = item::root();
|
||||
break;
|
||||
}
|
||||
|
33
3.1/modules/albumtree/helpers/albumtree_installer.php
Normal file
33
3.1/modules/albumtree/helpers/albumtree_installer.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class albumtree_installer {
|
||||
static function install() {
|
||||
module::set_var("albumtree", "style", "select");
|
||||
module::set_version("albumtree", 2);
|
||||
}
|
||||
|
||||
static function upgrade($version) {
|
||||
$db = Database::instance();
|
||||
if ($version == 1) {
|
||||
module::set_var("albumtree", "style", "select");
|
||||
module::set_version("albumtree", $version = 2);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
name = "Album Tree"
|
||||
description = "Provides a block in the sidebar with quick links to all other albums."
|
||||
version = 1
|
||||
version = 2
|
||||
|
38
3.1/modules/albumtree/views/albumtree_block_list.html.php
Normal file
38
3.1/modules/albumtree/views/albumtree_block_list.html.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<style type="text/css">
|
||||
ul.treealbumnav {
|
||||
height: 225px;
|
||||
width: 190px;
|
||||
overflow: auto;
|
||||
border: 1px solid #666;
|
||||
padding: 2px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<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)) ?>
|
||||
|
||||
<? // While there are still items to show, pick the next one and show it ?>
|
||||
<? while ($stack): ?>
|
||||
<? list($level, $album) = array_pop($stack) ?>
|
||||
<li>
|
||||
<a href="/index.php/items/<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?>
|
||||
</li>
|
||||
|
||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
||||
<? $tmp = array(); ?>
|
||||
<? foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
||||
<? $tmp[] = array($level + 1, $child) ?>
|
||||
<? 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 ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
24
3.1/modules/albumtree/views/albumtree_block_select.html.php
Normal file
24
3.1/modules/albumtree/views/albumtree_block_select.html.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<select onchange="window.location='<?= url::site("items/__ID__")?>'.replace('__ID__', this.value)">
|
||||
<? // We'll keep track of the list of items that we want to display in a stack ?>
|
||||
<? $stack = array(array(0, $root)) ?>
|
||||
|
||||
<? // While there are still items to show, pick the next one and show it ?>
|
||||
<? while ($stack): ?>
|
||||
<? list($level, $album) = array_pop($stack) ?>
|
||||
<option value="<?= $album->id ?>"><?= str_repeat(" ", $level) ?><?= $album->title ?></option>
|
||||
|
||||
<? // Then take all of that album's children and put them next on the stack. ?>
|
||||
<? $tmp = array(); ?>
|
||||
<? foreach ($album->viewable()->children(null, null, array(array("type", "=", "album"))) as $child): ?>
|
||||
<? $tmp[] = array($level + 1, $child) ?>
|
||||
<? 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>
|
Reference in New Issue
Block a user