From 08f11ce90edae83729537323925f167ef11b659e Mon Sep 17 00:00:00 2001 From: Florent Paterno Date: Mon, 1 Mar 2010 17:23:56 +0100 Subject: Fix bug #1015 : repeated ids are prohibited --- modules/organize/helpers/organize_event.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'modules/organize/helpers') diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index 4b048630..a9d64637 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -26,7 +26,7 @@ class organize_event_Core { ->append(Menu::factory("dialog") ->id("organize") ->label(t("Organize album")) - ->css_id("g-organize-link") + ->css_id("g-menu-organize-link") ->url(url::site("organize/dialog/{$item->id}"))); } } @@ -37,8 +37,7 @@ class organize_event_Core { ->append(Menu::factory("dialog") ->id("organize") ->label(t("Organize album")) - ->css_id("g-organize-link") - ->css_class("ui-icon-folder-open") + ->css_class("ui-icon-folder-open g-organize-link") ->url(url::site("organize/dialog/{$item->id}"))); } } -- cgit v1.2.3 From 67a8ef427798d37a9629c2f3d9672c03520b9987 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 27 Mar 2010 11:16:41 -0700 Subject: Convert the old organize to the new flex based organize --- modules/organize/controllers/organize.php | 163 ++--------- modules/organize/css/organize.css | 156 ---------- modules/organize/css/organize_theme.css | 18 +- modules/organize/helpers/organize_theme.php | 6 - modules/organize/js/organize.js | 317 --------------------- modules/organize/views/organize_dialog.html.php | 160 ++++++++--- .../organize/views/organize_thumb_grid.html.php | 22 -- modules/organize/views/organize_tree.html.php | 29 -- 8 files changed, 145 insertions(+), 726 deletions(-) delete mode 100644 modules/organize/css/organize.css delete mode 100644 modules/organize/js/organize.js delete mode 100644 modules/organize/views/organize_thumb_grid.html.php delete mode 100644 modules/organize/views/organize_tree.html.php (limited to 'modules/organize/helpers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 8dc8692c..8f9c3b5d 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -19,159 +19,30 @@ */ class Organize_Controller extends Controller { function dialog($album_id) { + $input = Input::instance(); + $album = ORM::factory("item", $album_id); access::required("view", $album); access::required("edit", $album); $v = new View("organize_dialog.html"); $v->album = $album; - $v->album_tree = self::_expanded_tree(ORM::factory("item", 1), $album); - $v->micro_thumb_grid = self::_get_micro_thumb_grid($album, 0); - print $v; - } - - function album($album_id, $offset) { - $album = ORM::factory("item", $album_id); - access::required("view", $album); - access::required("edit", $album); - - print json_encode( - array("grid" => (string)self::_get_micro_thumb_grid($album, $offset), - "sort_column" => $album->sort_column, - "sort_order" => $album->sort_order)); - } - - function move_to($target_album_id) { - access::verify_csrf(); - - $target_album = ORM::factory("item", $target_album_id); - access::required("view", $target_album); - access::required("add", $target_album); - - $source_album = null; - foreach (Input::instance()->post("source_ids") as $source_id) { - $source = ORM::factory("item", $source_id); - if (empty($source_album)) { // get the source_album - $source_album = $source->parent(); - } - if (!$source->contains($target_album)) { - access::required("edit", $source); - item::move($source, $target_album); - } + // @todo turn this into an api call. + $v->file_filter = json_encode(array("Images" => "*.jpg; *.jpeg; *.gif; *.png", + "Movies" => "*.flv; *.mp4")); + $v->domain = $input->server("SERVER_NAME"); + // @todo figure out how to connect this w/o a dependency + $v->base_url = url::abs_site("rest") . "/"; + + $v->sort_order = json_encode(array("ASC" => (string)t("Ascending"), "DESC" => (string)t("Descending"))); + $sort_fields = array(); + foreach (album::get_sort_order_options() as $field => $description) { + $sort_fields[$field] = (string)$description; } + $v->sort_fields = json_encode($sort_fields); - print json_encode( - array("tree" => (string)self::_expanded_tree(ORM::factory("item", 1), $source_album), - "grid" => (string)self::_get_micro_thumb_grid($source_album, 0))); - } - - function rearrange($target_id, $before_or_after) { - access::verify_csrf(); - - $target = ORM::factory("item", $target_id); - $album = $target->parent(); - access::required("view", $album); - access::required("edit", $album); - - //if (locales::is_rtl()) { // invert the position if the locale is rtl - // $before_or_after = $before_or_after == "after" ? "before" : "after"; - //} - - $source_ids = Input::instance()->post("source_ids", array()); - - if ($album->sort_column != "weight") { - $i = 0; - foreach ($album->children() as $child) { - // Do this directly in the database to avoid sending notifications - db::build() - ->update("items") - ->set("weight", ++$i) - ->where("id", "=", $child->id) - ->execute(); - } - $album->sort_column = "weight"; - $album->sort_order = "ASC"; - $album->save(); - $target->reload(); - } - - // Find the insertion point - $target_weight = $target->weight; - if ($before_or_after == "after") { - $target_weight++; - } - - // Make a hole - $count = count($source_ids); - db::build() - ->update("items") - ->set("weight", new Database_Expression("`weight` + $count")) - ->where("weight", ">=", $target_weight) - ->where("parent_id", "=", $album->id) - ->execute(); - - // Insert source items into the hole - foreach ($source_ids as $source_id) { - db::build() - ->update("items") - ->set("weight", $target_weight++) - ->where("id", "=", $source_id) - ->execute(); - } - - module::event("album_rearrange", $album); - - print json_encode( - array("grid" => (string)self::_get_micro_thumb_grid($album, 0), - "sort_column" => $album->sort_column, - "sort_order" => $album->sort_order)); - } - - public function sort_order($album_id, $col, $dir) { - access::verify_csrf(); - - $album = ORM::factory("item", $album_id); - access::required("view", $album); - access::required("edit", $album); - - $options = album::get_sort_order_options(); - if (!isset($options[$col])) { - return; - } - - $album->sort_column = $col; - $album->sort_order = $dir; - $album->save(); - - print json_encode( - array("grid" => (string)self::_get_micro_thumb_grid($album, 0), - "sort_column" => $album->sort_column, - "sort_order" => $album->sort_order)); - } - - private static function _get_micro_thumb_grid(Item_Model $album, $offset) { - $v = new View("organize_thumb_grid.html"); - $v->album = $album; - $v->offset = (int) $offset; - return $v; - } - - public function tree($album_id) { - $album = ORM::factory("item", $album_id); - access::required("view", $album); - - print self::_expanded_tree($album); - } - - /** - * Create an HTML representation of the tree from the root down to the selected album. We only - * include albums along the descendant hierarchy that includes the selected album, and the - * immediate child albums. - */ - private static function _expanded_tree($root, $selected_album=null) { - $v = new View("organize_tree.html"); - $v->album = $root; - $v->selected = $selected_album; - return $v; + $user = identity::active_user(); + $v->api_key = rest::get_access_token($user->id)->access_key; + print $v; } } diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css deleted file mode 100644 index 7a8c3a5f..00000000 --- a/modules/organize/css/organize.css +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************* - * Dialog wide styles - */ - -#g-organize { - margin: 0 !important; - min-height: auto; - padding: 0 !important; - position: relative; - width: 100%; -} - -#g-organize-content-pane { - height: 100%; - margin: 0 !important; - padding: 0 !important; - position: absolute; - width: 100%; -} - -/******************************************************************* - * Album Tree styles - */ - -#g-organize #g-organize-tree-container { - margin: 0; - min-height: 100%; - padding: 0; - position: relative; - width: 20%; -} - -#g-organize #g-organize-tree-container h3 { - margin-bottom: 0.1em; -} - -#g-organize-album-tree { - overflow: auto; -} - -#g-organize-album-tree ul li { - padding: 0 0 .2em 1.2em; - width: 90%; -} - -.rtl #g-organize-album-tree ul li { - padding: 0 1.2em .2em 0; - width: 90%; -} - -.g-organize-album span { - cursor: pointer; -} - -.g-organize-album-text { - cursor: pointer; - display: block; - margin: 2px 0px 1px 2px; - width: auto; -} - -.rtl .g-organize-album-text { - cursor: pointer; - display: block; - margin: 2px 2px 1px 1px; - width: auto; -} - -.g-organize-album-text:hover { - border-width: 1px; - border-style: dotted; -} - -/******************************************************************* - * Album panel styles - */ - -#g-organize #g-organize-detail { - margin: 0 !important; - min-height: 100%; - padding: 0 !important; - position: relative; - width: 80%; -} - -#g-organize #g-organize-detail .g-message-block { - margin: 0; -} - -#g-organize #g-organize-detail .g-message-block li { - padding-bottom: .2em; - padding-top: .2em; - width: auto; -} - -#g-organize-microthumb-grid { - border-width: 1px; - border-style: solid; - bottom: 1.8em; - left: 0; - margin: 0 !important; - overflow-x: hidden; - overflow-y: auto; - padding: .4em !important; - position: absolute; - right: 0; - top: 1.6em; -} -.g-organize-microthumb-grid-cell { - display: block; - height: 100px; - margin: 6px; - padding: .4em 0 !important; - position: relative; - text-align: center; - width: 110px; -} - -.ui-selectable-helper { - z-index: 2000 !important; -} - -.g-organize-microthumb-grid-cell .ui-icon { - bottom: 0; - left: 0; - position: absolute; - z-index: 4000; -} - -/**************************************************************** - * Controls styles - */ - -#g-organize-controls { - bottom: 0; - height: 1.9em; - left: 0; - margin: 0 !important; - padding: .1em .4em; - position: absolute; - right: 0; -} - -#g-organize-controls #g-organize-sort-order-text { - padding: .2em 0 0 0; -} - - -#g-organize-controls select { - margin-left: .42em; - display: inline; -} - -#g-organize-close { - margin-right: 12px; -} diff --git a/modules/organize/css/organize_theme.css b/modules/organize/css/organize_theme.css index 3d289755..e698f88d 100644 --- a/modules/organize/css/organize_theme.css +++ b/modules/organize/css/organize_theme.css @@ -1,16 +1,18 @@ /** ******************************************************************* * Organize styles that are theme overrideable *********************************************************************/ -.g-organize-microthumb-grid-cell.ui-selected { - background: #DFEFFC !important; +#g-organize { + background-color: #FFFFFF; + border: 0px solid #000000; + color: #0E2B52; } -#g-organize-microthumb-grid, -#g-organize-drop-target-marker, -.g-organize-album-text:hover { - border-color: #79B7E7; +#g-organize-hover { + background-color: #CFDEFF; + display: none; } -#g-organize-drop-target-marker { - background-color: #79B7E7; +#g-organize-active { + background-color: #6699CC; + display: none; } diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index da4a1b41..d69ab82c 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -21,12 +21,6 @@ class organize_theme { static function head($theme) { $item = $theme->item(); if ($item && access::can("edit", $item) && $item->is_album()) { - // @todo: Defer loading js/css until we're loading the organize dialog as + +" /> + + +
+

html::purify($album->title))) ?>

-
-
-

-
    - -
-
-
-
    -
  • -
-
"> - -
-
- -
-
    -
  • -
  • - "g-organize-sort-column"), - album::get_sort_order_options(), $album->sort_column) ?> -
  • -
  • - "g-organize-sort-order"), - array("ASC" => t("Ascending"), "DESC" => t("Descending")), $album->sort_order) ?> -
  • -
-
-
-
-
+
 
- - diff --git a/modules/organize/views/organize_thumb_grid.html.php b/modules/organize/views/organize_thumb_grid.html.php deleted file mode 100644 index f5db53d4..00000000 --- a/modules/organize/views/organize_thumb_grid.html.php +++ /dev/null @@ -1,22 +0,0 @@ - -children(25, $offset) as $child): ?> -
" - ref="id ?>"> - thumb_img(array("class" => "g-thumbnail", "ref" => $child->id), 90, true) ?> - is_album() ? " class=\"ui-icon ui-icon-note\"" : "" ?>> -
- - -children_count() > $offset): ?> - - diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php deleted file mode 100644 index 044b6858..00000000 --- a/modules/organize/views/organize_tree.html.php +++ /dev/null @@ -1,29 +0,0 @@ - -
  • " - ref="id ?>"> - - - " - ref="id ?>"> - title) ?> - - viewable()->children(null, null, array(array("type", "=", "album"))); ?> - -
      - - contains($selected)): ?> - $selected, "album" => $child)); ?> - -
    • " - ref="id ?>"> - - " ref="id ?>"> - title) ?> - -
    • - - -
    - -
  • - -- cgit v1.2.3 From 32fa15ca3a54ef0266f4dd8ce0edb570ad526df7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 9 May 2010 20:39:31 -0700 Subject: Add dependency checking to insure the administrator is notified if the rest module is deactivated --- modules/organize/helpers/organize_event.php | 18 ++++++++++++++ modules/organize/helpers/organize_installer.php | 32 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 modules/organize/helpers/organize_installer.php (limited to 'modules/organize/helpers') diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index a9d64637..c7d08893 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -42,4 +42,22 @@ class organize_event_Core { } } + static function pre_deactivate($data) { + if ($data->module == "rest") { + $data->messages["warn"][] = t("The Organize module requires the Rest module."); + } + } + + static function module_change($changes) { + if (!module::is_active("rest") || in_array("rest", $changes->deactivate)) { + site_status::warning( + t("The Organize module requires the Rest module.. " . + "Activate the Rest module now", + array("url" => html::mark_clean(url::site("admin/modules")))), + "organize_needs_rest"); + } else { + site_status::clear("organize_needs_rest"); + } + } + } diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php new file mode 100644 index 00000000..7585438f --- /dev/null +++ b/modules/organize/helpers/organize_installer.php @@ -0,0 +1,32 @@ + Date: Tue, 15 Jun 2010 15:29:45 -0700 Subject: Remove a stray period. --- modules/organize/helpers/organize_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/organize/helpers') diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index c7d08893..ae05fb5d 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -51,7 +51,7 @@ class organize_event_Core { static function module_change($changes) { if (!module::is_active("rest") || in_array("rest", $changes->deactivate)) { site_status::warning( - t("The Organize module requires the Rest module.. " . + t("The Organize module requires the Rest module. " . "Activate the Rest module now", array("url" => html::mark_clean(url::site("admin/modules")))), "organize_needs_rest"); -- cgit v1.2.3 From 8fb56abf034dd1f5c561e7af12bf6e097a3de6f6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 15 Jun 2010 16:30:02 -0700 Subject: Bump the organize module to version 2, and check to make sure that the REST module is active. --- modules/organize/helpers/organize_installer.php | 14 ++++++++++++++ modules/organize/module.info | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'modules/organize/helpers') diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php index 7585438f..bbe6fc65 100644 --- a/modules/organize/helpers/organize_installer.php +++ b/modules/organize/helpers/organize_installer.php @@ -22,6 +22,20 @@ class organize_installer { site_status::clear("organize_needs_rest"); } + static function upgrade($version) { + if ($version == 1) { + if (!module::is_active("rest")) { + site_status::warning( + t("The Organize module requires the Rest module. " . + "Activate the Rest module now", + array("url" => html::mark_clean(url::site("admin/modules")))), + "organize_needs_rest"); + } + + module::set_version("organize", $version = 2); + } + } + static function can_activate() { $messages = array(); if (!module::is_active("rest")) { diff --git a/modules/organize/module.info b/modules/organize/module.info index 5c6b1de0..d7199571 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -1,3 +1,3 @@ name = "Organize" description = "Organize your gallery by apply tags or moving images" -version = 1 +version = 2 -- cgit v1.2.3