diff options
Diffstat (limited to 'modules/organize')
| -rw-r--r-- | modules/organize/controllers/organize.php | 67 | ||||
| -rw-r--r-- | modules/organize/css/organize.css | 11 | ||||
| -rw-r--r-- | modules/organize/helpers/organize.php | 94 | ||||
| -rw-r--r-- | modules/organize/js/organize.js | 115 | ||||
| -rw-r--r-- | modules/organize/views/organize_button_pane.html.php | 5 | ||||
| -rw-r--r-- | modules/organize/views/organize_dialog.html.php | 9 | ||||
| -rw-r--r-- | modules/organize/views/organize_tree.html.php | 17 | 
7 files changed, 64 insertions, 254 deletions
| diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index cbaaca6e..95d71e9c 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -23,21 +23,20 @@ class Organize_Controller extends Controller {    function index($item_id) {      $item = ORM::factory("item", $item_id); -    $root = ($item->id == 1) ? $item : ORM::factory("item", 1); +    $root = $item->id == 1 ? $item : ORM::factory("item", 1);      access::required("view", $item);      access::required("edit", $item);      $v = new View("organize_dialog.html"); -    $v->root = $root; -    $v->item = $item; -    $v->album_tree = $this->_tree($item, $root); -    $v->micro_thumb_grid = $this->_get_micro_thumb_grid($item); -    $v->button_pane = new View("organize_button_pane.html"); -    $buttons = (object)array("left" => array(), "middle" =>array(), "right" => array(), -                             "item" => $item); -    module::event("organize_format_button_pane", $buttons); +    $v->title = $item->title; +    $parents = array(); +    foreach ($item->parents() as $parent) { +      $parents[$parent->id] = 1; +    } +    $parents[$item->id] = 1; -    $v->button_pane->buttons = $buttons; +    $v->album_tree = $this->_tree($root, $parents); +    $v->micro_thumb_grid = $this->_get_micro_thumb_grid($item);      print $v;    } @@ -50,28 +49,6 @@ 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, array("type" => "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(array("type" => "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; @@ -82,28 +59,20 @@ class Organize_Controller extends Controller {      return $v;    } -  private function _tree($item, $parent, $depth=0) { -    $albums = $parent->children(null, 0, array("type" => "album"), array("title" => "ASC")); - +  private function _tree($item, $parents) {      $v = new View("organize_tree.html"); -    $v->album = $parent; - -    if ($parent->id == $item->id) { -      $v->selected = true; -      $depth = 1; -    } else { -      $v->selected = false; -    } +    $v->album = $item; +    $keys = array_keys($parents); +    $v->selected = end($keys) == $item->id;      $v->children = array();      $v->album_icon = "gBranchEmpty"; + +    $albums = $item->children(null, 0, array("type" => "album"), array("title" => "ASC"));      if ($albums->count()) { -      $v->album_icon = "ui-icon-plus"; +      $v->album_icon = empty($parents[$item->id]) ? "ui-icon-plus" : "ui-icon-minus"; -      if ($depth <= 1) { -        $v->album_icon = "ui-icon-minus"; -        foreach ($albums as $album) { -          $v->children[] = $this->_tree($item, $album, ++$depth); -        } +      foreach ($albums as $album) { +        $v->children[] = $this->_tree($album, $parents);        }      }      return $v; diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css index 0a23a6bf..56ecc309 100644 --- a/modules/organize/css/organize.css +++ b/modules/organize/css/organize.css @@ -7,6 +7,11 @@  #gOrganize {    overflow: hidden; +  height: 100%; +} + +#gOrganize #bd { +  height: 100%;  }  #gOrganize .yui-u { @@ -22,16 +27,20 @@    width: 75%;  } +#gOrganizeDetail { +  height: 100%; +} +  #gMessage .gInfo {    font-weight: bold;    padding-left: 2em;  } -  /*******************************************************************   * Album Tree styling   */  #gOrganizeTreeContainer { +  height: 100%;    overflow: auto;    margin: 0 !important;    padding: 0 !important; diff --git a/modules/organize/helpers/organize.php b/modules/organize/helpers/organize.php deleted file mode 100644 index 25284771..00000000 --- a/modules/organize/helpers/organize.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php defined("SYSPATH") or die("No direct script access."); -/** - * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2009 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 organize_Core { -  static function get_general_edit_form($item) { -    $generalPane = new Forge("organize/__FUNCTION__", "", "post", -                             array("id" => "gEditGeneral", "ref" => "general")); -    // In this case we know there is only 1 item, but in general we should loop -    // and create multiple hidden items. -    $generalPane->hidden("item[]")->value($item->id); -    $generalPane->input("title")->label(t("Title"))->value($item->title); -    $generalPane->textarea("description")->label(t("Description"))->value($item->description); -    $generalPane->input("dirname")->label(t("Path Name"))->value($item->name) -      ->callback("item::validate_no_slashes") -      ->error_messages("no_slashes", t("The directory name can't contain a \"/\"")) -      ->callback("item::validate_no_trailing_period") -      ->error_messages("no_trailing_period", t("The directory name can't end in \".\"")) -      ->callback("item::validate_no_name_conflict") -      ->error_messages("conflict", t("The path name is not unique")); - -    return $generalPane; -  } - -  static function get_sort_edit_form($item) { -    $sortPane = new Forge("organize/__FUNCTION__", "", "post", -                          array("id" => "gEditSort", "ref" => "sort")); -    $sortPane->hidden("item[]")->value($item->id); -    $sortPane->dropdown("column", array("id" => "gAlbumSortColumn")) -      ->label(t("Sort by")) -      ->options(array("weight" => t("Order Added"), -                      "captured" => t("Capture Date"), -                      "created" => t("Creation Date"), -                      "title" => t("Title"), -                      "updated" => t("Updated Date"), -                      "view_count" => t("Number of views"), -                      "rand_key" => t("Random"))) -      ->selected($item->sort_column); -    $sortPane->dropdown("direction", array("id" => "gAlbumSortDirection")) -      ->label(t("Order")) -      ->options(array("ASC" => t("Ascending"), -                      "DESC" => t("Descending"))) -      ->selected($item->sort_order); - -    return $sortPane; -  } - -  static function get_tag_form($itemids) { -    $tagPane = new Forge("organize/__FUNCTION__", "", "post", -                             array("id" => "gEditTags", "ref" => "edit_tags")); -    $tagPane->hidden("item")->value(implode("|", $itemids)); -    $item_count = count($itemids); -    $ids = implode(", ", $itemids); - -    // Lame stopgap security check.  This code is going to get rewritten anyway. -    foreach ($itemids as $id) { -      $item = ORM::factory("item", $id); -      access::required("view", $item); -      access::required("edit", $item); -    } - -    $tags = Database::instance()->query( -      "SELECT t.name, COUNT(it.item_id) as count -         FROM {items_tags} it, {tags} t -        WHERE it.tag_id = t.id -          AND it.item_id in($ids) -       GROUP BY it.tag_id -       ORDER BY t.name ASC"); -    $taglist = array(); -    foreach ($tags as $tag) { -      $taglist[] = $tag->name . ($item_count > $tag->count ? "*" : ""); -    } -    $taglist = implode("; ", $taglist); -    $tagPane->textarea("tags")->label(t("Tags"))->value($taglist); - -    return $tagPane; -  } - -}
\ No newline at end of file diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 194a2a19..3e58f3f3 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -1,56 +1,45 @@  (function($) { -  $.fn.organize = function(options) { +  $.fn.organize = function() {      var size = $.getViewportSize();      var height = size.height() - 100;     // Leave 50 pixels on the top and bottom of the dialog      var width = size.width() - 100;       // Leave 50 pixels on the left and right of the dialog -    var opts = $.extend({}, $.fn.organize.defaults, {width: width, height: height}, options);      return this.each(function() {        $(this).click(function(event) {          var href = event.target.href; -        var size = $.getViewportSize();          $("body").append('<div id="gOrganizeDialog"></div>'); -        $("#gOrganizeDialog").dialog(opts); -        // Pass the approx height and width of the thumb grid to optimize thumb retrieval +        $("#gOrganizeDialog").dialog({ +          autoOpen: false, +          modal: true, +          resizable: false, +          width: width, +          height: height, +          position: "center", +          close: function () { +            $("#gOrganizeDialog").dialog("destroy").remove(); +            document.location.reload(); +         }, +          zIndex: 75 +        });          $.get(href, _init);          return false;        });      });    }; -  $.fn.organize.defaults = { -    autoOpen: false, -    modal: true, -    resizable: false, -    minWidth: 600, -    minHeight: 500, -    position: "center", -    close: function () { -      $("#gOrganizeDialog").trigger("organize_close"); -      $("#gOrganizeDialog").dialog("destroy").remove(); -    }, -    zIndex: 75 -  }; -    /**     * Dynamically initialize the organize dialog when it is displayed     */    function _init(data) { -    // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 +    // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 (target 1.8?)      $(".sf-menu li.sfHover ul").css("z-index", 70);      $("#gOrganizeDialog").html(data);      $("#gOrganizeDialog").dialog("open"); -    var heightMicroThumbPanel = $("#gOrganizeDialog").innerHeight(); -    heightMicroThumbPanel -= 2 * parseFloat($("#gOrganizeDialog").css("padding-bottom")); -    heightMicroThumbPanel -= $("#gMessage").outerHeight(); -    heightMicroThumbPanel = Math.floor(heightMicroThumbPanel); -    $("#gOrganizeTreeContainer").height(heightMicroThumbPanel); - -    heightMicroThumbPanel -= $("#gOrganizeEditDrawerHandle").outerHeight(); -    $("#gMicroThumbPanel").height(heightMicroThumbPanel); +    var height = $("#gOrganizeDetail").innerHeight(); +    $("#gMicroThumbPanel").height(height - $("#gOrganizeEditDrawerHandle").outerHeight());      if ($("#gOrganizeDialog h1").length) {        $("#gOrganizeDialog").dialog('option', 'title', $("#gOrganizeDialog h1:eq(0)").html()); @@ -58,54 +47,12 @@        $("#gOrganizeDialog").dialog('option', 'title', $("#gOrganizeDialog fieldset legend:eq(0)").html());      } -    $("#gOrganizeDialog #gMicroThumbDone").click(_dialog_close); -    $("#gOrganizeDialog").bind("organize_close", function(target) { -      $.gallery_reload(); +    $("#gOrganizeDialog #gMicroThumbDone").click(function(event) { +      $("#gOrganizeDialog").dialog("close");      });      $(".gBranchText span").click(_collapse_or_expanded_tree);      $(".gBranchText").click(_setContents); - -    //$(".gOrganizeBranch .ui-icon").click(organizeToggleChildren); -    //$(".gBranchText").droppable(treeDroppable); - -    //$("#gMicroThumbPanel").droppable(thumbDroppable); -    //$("#gMicroThumbPanel").selectable(selectable); -    //$("#gOrganizeEditDrawerHandle a").click(drawerHandleButtonsClick); - -    $(window).bind("resize", _size_dialog); -  }; - -  /** -   * Dynamically initialize the organize dialog when it is displayed -   */ -  function _size_dialog(event) { -    var size = $.getViewportSize(); -    var h = $("#gOrganizeDialog").dialog("option", "minHeight"); -    var sh = size.height() - 100; -    var height  = Math.max(sh, h); -    var w = $("#gOrganizeDialog").dialog("option", "minWidth"); -    var sw = size.width() - 100; -    var width = Math.max(w, sw); - -    $("#gOrganizeDialog").parent().css("height", height); -    $("#gOrganizeDialog").parent().css("width", width); -    $("#gOrganizeDialog").parent().css("left", "50px"); -    $("#gOrganizeDialog").parent().css("top", "50px"); - -    var heightMicroThumbPanel = height - 50; -    heightMicroThumbPanel -= 2 * parseFloat($("#gOrganizeDialog").css("padding-bottom")); -    heightMicroThumbPanel -= $("#gMessage").outerHeight(); -    heightMicroThumbPanel = Math.floor(heightMicroThumbPanel); -    $("#gOrganizeTreeContainer").height(heightMicroThumbPanel); - -    heightMicroThumbPanel -= $("#gOrganizeEditDrawerHandle").outerHeight(); -    $("#gMicroThumbPanel").height(heightMicroThumbPanel); -  }; - -  function _dialog_close(event) { -    event.preventDefault(); -    $("#gOrganizeDialog").dialog("close");    };    /** @@ -113,26 +60,12 @@     */    function _collapse_or_expanded_tree(event) {      event.stopPropagation(); -    var id = $(event.currentTarget).attr("ref");      if ($(event.currentTarget).hasClass("ui-icon-minus")) { -      $(event.currentTarget).removeClass("ui-icon-minus"); -      $(event.currentTarget).addClass("ui-icon-plus"); -      $("#gOrganizeChildren-" + id).hide(); +      $(event.currentTarget).removeClass("ui-icon-minus").addClass("ui-icon-plus");      } else { -      if ($("#gOrganizeChildren-" + id).is("div")) { -        $("#gOrganizeChildren-" + id).remove(); -        $("#gOrganizeBranch-" + id).after("<ul id=\"gOrganizeChildren-" + id + "></ul>"); -        var url = $("#gOrganizeAlbumTree").attr("ref").replace("__ITEM_ID__", id); -        $.get(url, function(data) { -          $("#gOrganizeChildren-" + id).html(data); -          $(".gBranchText span").click(_collapse_or_expanded_tree); -          $(".gBranchText").click(_setContents); -        }); -      } -      $("#gOrganizeChildren-" + id).show(); -      $(event.currentTarget).removeClass("ui-icon-plus"); -      $(event.currentTarget).addClass("ui-icon-minus"); +      $(event.currentTarget).removeClass("ui-icon-plus").addClass("ui-icon-minus");      } +    $("#gOrganizeChildren-" + $(event.currentTarget).attr("ref")).toggle();    }    /** @@ -145,14 +78,12 @@      }      var id = $(event.currentTarget).attr("ref");      $(".gBranchSelected").removeClass("gBranchSelected"); -    $(event.currentTarget).addClass("gBranchSelected"); +    $("#gOrganizeBranch-" + id).addClass("gBranchSelected");      var url = $("#gMicroThumbPanel").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0);      $.get(url, function(data) {        $("#gMicroThumbGrid").html(data);      }); -    } -  })(jQuery);  $("document").ready(function() { diff --git a/modules/organize/views/organize_button_pane.html.php b/modules/organize/views/organize_button_pane.html.php deleted file mode 100644 index 8eced107..00000000 --- a/modules/organize/views/organize_button_pane.html.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php defined("SYSPATH") or die("No direct script access.") ?> -<div id="gOrganizeEditHandleButtonsRight"> -  <a id="gMicroThumbDone" href="#" ref="done" -     class="gButtonLink ui-corner-all ui-state-default"><?= t("Close") ?></a> -</div> diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 1e6646e4..4f10297e 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -1,6 +1,6 @@  <?php defined("SYSPATH") or die("No direct script access.") ?>  <div id="gOrganize"> -  <h1 style="display:none"><?= t("Organize %name", array("name" => p::purify($item->title))) ?></h1> +  <h1 style="display:none"><?= t("Organize %name", array("name" => p::purify($title))) ?></h1>    <div id="bd">      <div class="yui-gf">        <div class="yui-u first"> @@ -12,7 +12,7 @@      </div>      <div class="yui-gf">        <div id="gOrganizeTreeContainer" class="yui-u first"> -        <ul id="gOrganizeAlbumTree" ref="<?= url::site("organize/children/__ITEM_ID__") ?>"> +        <ul id="gOrganizeAlbumTree">            <?= $album_tree ?>          </ul>        </div> @@ -27,7 +27,10 @@            <div id="gOrganizeEditDrawerPanel" class="yui-gf">            </div>            <div id="gOrganizeEditDrawerHandle"> -            <?= $button_pane ?> +            <div id="gOrganizeEditHandleButtonsRight"> +              <a id="gMicroThumbDone" href="#" ref="done" +                 class="gButtonLink ui-corner-all ui-state-default"><?= t("Close") ?></a> +            </div>            </div>          </div>        </div> diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php index d64410d8..280bdc5f 100644 --- a/modules/organize/views/organize_tree.html.php +++ b/modules/organize/views/organize_tree.html.php @@ -8,15 +8,12 @@      </span>      <?= p::clean($album->title) ?>    </div> -  <? if (empty($children)): ?> -    <div id="gOrganizeChildren-<?= $album->id ?>"></div> -  <? else: ?> -    <ul id="gOrganizeChildren-<?= $album->id ?>" -       class="<?= $album_icon == "ui-icon-plus" ? "gBranchCollapsed" : "" ?>"> -      <? foreach ($children as $child): ?> -        <?= $child ?> -      <? endforeach ?> -    </ul> -  <? endif ?> +  <ul id="gOrganizeChildren-<?= $album->id ?>" +      class="<?= $album_icon == "ui-icon-plus" ? "gBranchCollapsed" : "" ?>"> +    <li style="display:none"> </li> +    <? foreach ($children as $child): ?> +      <?= $child ?> +    <? endforeach ?> +  </ul>  </li> | 
