summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/item.php
AgeCommit message (Collapse)Author
2013-07-08Move "item_moved" event later in the item update process. Fixes #2077.shadlaws
Before, this was before the children's caches were cleared, so if the "item_moved" set an album cover, it would fail with an invalid path. For the same reason, we move it after the data file update, too. Lastly, get we get rid of duplicated code in item::move() since the "item_moved" event already does this.
2013-02-26#2010 - Revise item::find_by_path to search for jpg-converted items.shadlaws
- added extra $var_subdir argument to item::find_by_path. - changed item::find_by_path to use $var_subdir to detect if we should look for a jpg-converted item or not (e.g. movie thumbs) - moved the album thumb detection to item::find_by_path to ensure it knows to look for an exact album match. - added more sanity checks to item::find_by_path (now has fewer false positive possibilities). - updated file_proxy to remove the need to guess different movie files. - updated File_Proxy_Controller - new sanity checks catch previously undetected bug. - added additional unit tests for item::find_by_path.
2013-01-31#1982 - Add placeholder for albums with no album cover.shadlaws
- Added missing_album_cover.jpg placeholder image. - Modified the graphics helper to use it. Calling graphics::generate will copy it. - Modified item::remove_album_cover and gallery_event::item_created to run graphics::generate. - Added unit test to Graphics_Helper_Test.
2013-01-30Follow-in to cff1e76e8da2055f9faf7449222b43a686014b1c for #1978Bharat Mediratta
Restrict which album cover ids we swap over to the hierarchy of the current album, otherwise we can wind up in sticky situations with hierarchical album cover chains. Eg, you have a hierarchy like this: root -> A1 -> A2 --> A3 -> P1 A4 -> P2 P1 is the album cover for its entire hierarchy. But then you swap A2's album cover for A3 making this: root -> A1 -> A2 + A3 -> P1 \-> A4 -> P2 Since A1, A2 and A3 all had P1 as their album cover item id. Now we're swapping it over to P2 but we want to leave P1 as A3's album cover item id. So only look at A4's hierarchy and ignore its peers.
2013-01-30When changing the album cover, find and retarget any other albums which were ↵Bharat Mediratta
using the old item as their album cover. Fixes #1978.
2013-01-30#1968 - Improve album cover generation/removal/etc.shadlaws
- Added stanza to Item_Model::save that handles when cover id is null. - Added logic to graphics::generate to copy/convert album cover thumbs from their item thumbs to ensure they're always jpg, and eliminate the possibility that we copy/convert a dirty thumb. - Redirected other places in code where we want to do one of the above two things to use these two functions instead (gallery_event::item_updated_data_file, item::make_album_cover, item::remove_album_cover). - Improved validation in Item_Model so only albums can have covers and all covers must be non-albums. - Added unit tests to Graphics_Helper_Test.
2013-01-26#1946, 1947 - Make altered names/slugs more user-friendly, make ↵shadlaws
conflict-finding code check filenames with no extensions - Reduced from four places that alter names/slugs to two (one to populate empty slugs, one to handle conflicting names/slugs). - For empty slugs, fill with generic human-readable name (e.g. "photo") instead of random value. - For conflicting names/slugs, add suffix that's sequential (e.g. "-01"), only using random after 99 conflicts. - Made conflict-finding code check filenames with no extensions. - Renamed _randomize_name_or_slug_on_conflict to _check_and_fix_conflicts. - Added unit tests. Also cleaned up existing unit tests to reflect new logic and removed a redundant test. - Added installer logic to correct existing items now considered in conflict. - Revised gallery_task to look for duplicate names based on new criteria.
2013-01-23Extract reweighting logic out of Organize_Controller intoBharat Mediratta
item::reweight_all_children as an API and write a test for it. Work in progress on #1914.
2013-01-21Update copyright to 2013. Fixes #1953.Bharat Mediratta
2012-12-09Eliminate the search context if we encounter an item that cannot beBharat Mediratta
found in the search results. Fixes #1923.
2012-02-27Update copyright to 2012. #1822Bharat Mediratta
2012-02-06Don't support display contexts for robots. Fixes #1819.Bharat Mediratta
2012-02-06Add tags for all Cache::instance()->set calls that don't have one.Bharat Mediratta
Fixes #1818.
2011-12-23Use Albums_Controller::get_display_context as the default display context. ↵Bharat Mediratta
Fixes #1812.
2011-08-30Patch for #1774Tim Almdal
2011-08-27Refactor the display context code a bit:Bharat Mediratta
1) Move the display context code into the controller themselves so that it's more logically a continuation callback from the original controller rendering code. 2) Simplify the display context set/get code and put it in the item helper, it's just a couple of lines of code now. 3) Add more descriptive breadcrumb strings
2011-04-22Do simple transliteration when converting filenames to slugs, but checkBharat Mediratta
to see if the transliteration module is available and use a more complex transliteration if possible. Fixes #1668.
2011-01-21Update copyright to 2011.Bharat Mediratta
2011-01-11Update some comments.Bharat Mediratta
2011-01-09Moved item_Model::get_position() method to the Item helper. It now calls ↵Jérémy Subtil
the viewable() method on every query.
2010-12-21Implement item::find_by_relative_url with tests.Bharat Mediratta
2010-12-21Change item::find_by_path() to check the relative_path_cache first,Bharat Mediratta
and only fall back the name/level comparison if there's no cached entry. Update tests accordingly.
2010-12-21Return an empty Item_Model when item::find_by_path failsBharat Mediratta
2010-12-21Tighten up item::find_by_path slightly. Augment the tests to coverBharat Mediratta
special characters in the file name ("+" is an edge case differentiator between rawurlencode and urlencode).
2010-12-22Minor changes to satisfy the G3 code standards.Kriss Andsten
2010-12-22Packaging + tests of Bharat's find_by_path routine.Kriss Andsten
2010-12-15Consolidate all the random code into a random helper that offers:Bharat Mediratta
random::hash() random::string() random::percent() random::int() So that we don't have lots of different ways to get random values all over the code. Follow-on to #1527.
2010-11-08Updated item::random_query() PHPdoc to include example usageBharat Mediratta
2010-07-27Don't invoke a graphics toolkit when setting the album cover from aBharat Mediratta
clean thumbnail; we can just copy it over. Should be a decent perf improvement in many cases. Fixes ticket #1255.
2010-07-10Pass along the from_id in item::get_delete_form() and then check toBharat Mediratta
see if we're deleting the album we're inside in quick::delete. If we delete the album we're currently viewing, redirect to the parent. This fixes ticket #1185.
2010-06-20Add a loading indicator to the delete form by tagging some JS on atBharat Mediratta
the end which triggers .gallery_show_loading(). Not a complete fix for #817 but it's a start and it takes care of one place where we have a long running process.
2010-06-15Revert "Change the item rest update processing to call theBharat Mediratta
item::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Changed the item::move method so it returns a message to be displayed if the caller chooses. And changed the move controller to display the message returned by the move if the item name was renamed as part of the move." Rolling this back for a couple of reasons: 1) Bug in move.php ("message.info" is not a function name) 2) Having the message come back from the API call as a side-effect is sloppy. We should find a cleaner way to do this checking. 3) having item::move() call save() on any changed values in the ORM is counter-intuitive. Move should move, save should save. I think the right approach here is to roll the move() code properly into save(). This reverts commit 2492280cc0ec9eb64a8daeccc7b5698ece7fea66.
2010-06-15Revert "Fix for ticket #1118. Create a item::save_with_retries helperBharat Mediratta
method, which encapsulates saving an item and handling name and slug conflicts. Call this instead of doing a save directly." Rolled this back because it fails KISS. We already have an API for saving models with Item_Model::save() that's consistent with all of our other model code. Adding a new way to save items is confusing and inconsistent. This reverts commit 9504f71efcadc7ed27f6f09e5d663e8025bf3b86.
2010-06-15Fix for ticket #1118. Create a item::save_with_retries helper method, which ↵Tim Almdal
encapsulates saving an item and handling name and slug conflicts. Call this instead of doing a save directly.
2010-06-15Change the item rest update processing to call the item::move(source, ↵Tim Almdal
target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Changed the item::move method so it returns a message to be displayed if the caller chooses. And changed the move controller to display the message returned by the move if the item name was renamed as part of the move.
2010-06-10Change the pattern used to convert the file name to a title. Fixes ticket#1061Tim Almdal
2010-06-05item::random_query() doesn't need to take a "where" clause becauseBharat Mediratta
it's returning a query, so the caller can add the where clause himself. This makes for a cleaner API.
2010-03-03Update the copyright to 2010. It's only 3 months into the year :-)Bharat Mediratta
2010-02-09Rename item name and slug if necessary to avoid a conflict when weBharat Mediratta
move photos. Fixes ticket #957.
2010-01-20Two fixes:Bharat Mediratta
1) Don't call ORM_MPTT::move_to() directly. Use the new model-based-validation approach of changing the parent_id and saving. 2) Item_Model::parent() can return null; check for it.
2010-01-19Don't try to set the album cover for the grandparent if we don't have edit ↵Bharat Mediratta
permissions for it.
2010-01-14Begin the process of converting to model based validation. RightBharat Mediratta
now only Albums_Controller::update() supports the pattern. All form and controller based validation happening when editing an album has been moved over. Model based validation means that our REST controllers share the same validation as web controllers. We'll have consistency enforced at the model level, which is a Good Thing. The basic pattern is now: 1) Rules are in the model 2) ORM::validate() (which is called by ORM::save() but you can call it directly, too) checks the model for all the rules and throws an ORM_Validation_Exception if there are failures 3) Actions are no longer taken when you call Item_Model::__set(). Instead, they're all queued up and executed when you call Item_Model::save(). Notes: - item::validate_xxx() functions are now in Item_Model:: - We still call $form->validate() because the form can have rules (and forms triggered by events will likely continue to have rules.
2010-01-08Move the random image functionality into the gallery REST helper sinceBharat Mediratta
choosing a random image is essentially a function on an item collection. Also implemented a bunch of other query filters for item collections. Created item::random_query() as a way of generating a reasonable starting point for random queries.
2010-01-08Remove debug code.Bharat Mediratta
2010-01-08Add item::random() to return a random Item_Model.Bharat Mediratta
2009-12-30Rollback the refactoring of the update into a helper method. Also remove the ↵Tim Almdal
refactoring for check for commits
2009-12-27Clean up validation the check for duplicate names or slugs, finish ↵Tim Almdal
converting the rest API to Kohana 2.4
2009-12-26Forgot to commit local changes to item helper for K2.4Tim Almdal
2009-12-26Merge branch 'master' into talmdal_devTim Almdal
Conflicts: modules/gallery/controllers/albums.php modules/gallery/controllers/movies.php modules/gallery/controllers/photos.php
2009-12-22Add merge_or_where() to MY_Datatabase_Builder and use that instead ofBharat Mediratta
or_where() for compatibility and convenience. Caught by failing unit tests.