diff options
author | Bharat Mediratta <bharat@menalto.com> | 2013-01-23 21:33:19 -0500 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2013-01-23 21:33:19 -0500 |
commit | aa8fffcd8fc7d16f4bd84a9f8f7ead206d9ce45a (patch) | |
tree | 484ad936b32d0683c0ad45c898fa900ca5857546 /modules/gallery/helpers/item.php | |
parent | de78d3bfca20fec80fc87a7c5e2d18f3fdd791f1 (diff) |
Extract reweighting logic out of Organize_Controller into
item::reweight_all_children as an API and write a test for it. Work
in progress on #1914.
Diffstat (limited to 'modules/gallery/helpers/item.php')
-rw-r--r-- | modules/gallery/helpers/item.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 20a865d1..b2c4cadf 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -437,4 +437,16 @@ class item_Core { } return call_user_func_array($callback, $args); } + + /** + * Reset all child weights of a given album to a monotonically increasing sequence based on the + * current sort order of the album. + */ + static function resequence_child_weights($album) { + $weight = 0; + foreach ($album->children() as $child) { + $child->weight = ++$weight; + $child->save(); + } + } }
\ No newline at end of file |