diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-08-05 08:31:58 -0700 | 
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-08-05 08:31:58 -0700 | 
| commit | 869c3de9612a598dae0ce400991bdbe173a2decc (patch) | |
| tree | 4a366cf137c6d1c91e85401943b7573bb7615540 /modules/organize/controllers/organize.php | |
| parent | 5f47271e3216c0a3c533174d8ff0937f9947584e (diff) | |
Enable the expand/collapse of branches by clicking on the plus/minus
icons.  Branches with no albums, will not have an icon.
Diffstat (limited to 'modules/organize/controllers/organize.php')
| -rw-r--r-- | modules/organize/controllers/organize.php | 59 | 
1 files changed, 38 insertions, 21 deletions
| diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index d7854c53..e10e33b5 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -50,6 +50,27 @@ class Organize_Controller extends Controller {      print $v->__toString();    } +  function children($item_id) { +    $item = ORM::factory("item", $item_id); +    access::required("view", $item); +    access::required("edit", $item); + +    $albums = $item->children(null, 0, "album", array("title" => "ASC")); + +    $children = ""; +    foreach ($albums as $album) { +      $v = new View("organize_tree.html"); +      $v->album = $album; +      $v->selected = false; +      $v->children = array(); +      $v->album_icon = $album->children_count("album") ? "ui-icon-plus" : "gBranchEmpty"; + +      $children .= $v->__toString(); +    } + +    print $children; +  } +    private function _get_micro_thumb_grid($item, $offset=0) {      $v = new View("organize_thumb_grid.html");      $v->item_id = $item->id; @@ -60,34 +81,30 @@ class Organize_Controller extends Controller {      return $v;    } -  private function _tree($item, $parent, $selected=false) { -    access::required("view", $item); -    access::required("edit", $item); - -    $albums = ORM::factory("item") -      ->where(array("parent_id" => $parent->id, "type" => "album")) -      ->orderby(array("title" => "ASC")) -      ->find_all(); +  private function _tree($item, $parent, $depth=0) { +    $albums = $parent->children(null, 0, "album", array("title" => "ASC"));      $v = new View("organize_tree.html");      $v->album = $parent; -    $v->selected = false; -    $v->children = ""; -    $v->album_icon = "ui-icon-plus"; -    if (!$selected) { -      $v->selected = $parent->id == $item->id; +    if ($parent->id == $item->id) { +      $v->selected = true; +      $depth = 1; +    } else { +      $v->selected = false; +    } +    $v->children = array(); +    $v->album_icon = "gBranchEmpty"; +    if ($albums->count()) { +      $v->album_icon = "ui-icon-plus"; -      if ($albums->count() && ($parent->id == 1 || $v->selected) ) { +      if ($depth <= 1) {          $v->album_icon = "ui-icon-minus"; -      } - -      foreach ($albums as $album) { -        $v->children .= $this->_tree($item, $album, $v->selected); +        foreach ($albums as $album) { +          $v->children[] = $this->_tree($item, $album, ++$depth); +        }        }      } -    return $v->__toString(); +    return $v;    } - -  } | 
