Commit Graph

76 Commits

Author SHA1 Message Date
shadlaws
d0aef95a65 Move "item_moved" event later in the item update process. Fixes #2077.
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-07-08 09:39:54 +02:00
shadlaws
251e9d5c8f #2010 - Revise item::find_by_path to search for jpg-converted items.
- 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-02-26 18:39:59 +01:00
shadlaws
f83ed5f871 #1982 - Add placeholder for albums with no album cover.
- 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-31 17:18:39 +01:00
Bharat Mediratta
8d15e5cb2e Follow-in to cff1e76e8d for #1978
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-30 21:42:47 -05:00
Bharat Mediratta
cff1e76e8d When changing the album cover, find and retarget any other albums which were using the old item as their album cover. Fixes #1978. 2013-01-30 21:08:36 -05:00
shadlaws
cf07742595 #1968 - Improve album cover generation/removal/etc.
- 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-30 01:07:36 +01:00
shadlaws
cc2aed656c #1946, 1947 - Make altered names/slugs more user-friendly, make 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-26 08:38:31 +01:00
Bharat Mediratta
aa8fffcd8f 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.
2013-01-23 21:33:19 -05:00
Bharat Mediratta
d45a737779 Update copyright to 2013. Fixes #1953. 2013-01-21 01:22:01 -05:00
Bharat Mediratta
a74e3aea6f Eliminate the search context if we encounter an item that cannot be
found in the search results.  Fixes #1923.
2012-12-09 20:26:16 -08:00
Bharat Mediratta
bf2bb3e1ea Update copyright to 2012. #1822 2012-02-27 09:48:23 -08:00
Bharat Mediratta
cdbd9b5a9d Don't support display contexts for robots. Fixes #1819. 2012-02-06 20:02:32 -08:00
Bharat Mediratta
065dd32f31 Add tags for all Cache::instance()->set calls that don't have one.
Fixes #1818.
2012-02-06 19:48:52 -08:00
Bharat Mediratta
2725d30c34 Use Albums_Controller::get_display_context as the default display context. Fixes #1812. 2011-12-23 11:22:43 -08:00
Tim Almdal
96a4a261a4 Patch for #1774 2011-08-30 20:04:31 -07:00
Bharat Mediratta
ce43f29e2c Refactor the display context code a bit:
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-08-27 11:18:07 -07:00
Bharat Mediratta
526859d960 Do simple transliteration when converting filenames to slugs, but check
to see if the transliteration module is available and use a more complex
transliteration if possible.  Fixes #1668.
2011-04-22 13:57:46 -07:00
Bharat Mediratta
423daa52d5 Update copyright to 2011. 2011-01-21 23:01:06 -08:00
Bharat Mediratta
92db7f4218 Update some comments. 2011-01-11 15:24:40 -08:00
Jérémy Subtil
0d7e951aa5 Moved item_Model::get_position() method to the Item helper. It now calls the viewable() method on every query. 2011-01-09 12:14:46 +01:00
Bharat Mediratta
98fd1e9957 Implement item::find_by_relative_url with tests. 2010-12-21 20:47:07 -08:00
Bharat Mediratta
d9299f3b3f Change item::find_by_path() to check the relative_path_cache first,
and only fall back the name/level comparison if there's no cached
entry.  Update tests accordingly.
2010-12-21 19:33:47 -08:00
Bharat Mediratta
2a08cbf76d Return an empty Item_Model when item::find_by_path fails 2010-12-21 16:58:54 -08:00
Bharat Mediratta
f493130e59 Tighten up item::find_by_path slightly. Augment the tests to cover
special characters in the file name ("+" is an edge case differentiator
between rawurlencode and urlencode).
2010-12-21 16:55:01 -08:00
Kriss Andsten
addd384bbd Minor changes to satisfy the G3 code standards. 2010-12-22 08:22:25 +08:00
Kriss Andsten
48640005a4 Packaging + tests of Bharat's find_by_path routine. 2010-12-22 08:22:25 +08:00
Bharat Mediratta
cd48b89f31 Consolidate all the random code into a random helper that offers:
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-12-15 14:57:00 -08:00
Bharat Mediratta
dae8354491 Updated item::random_query() PHPdoc to include example usage 2010-11-08 19:52:43 -08:00
Bharat Mediratta
52f1c4b8c6 Don't invoke a graphics toolkit when setting the album cover from a
clean thumbnail; we can just copy it over.  Should be a decent perf
improvement in many cases.  Fixes ticket #1255.
2010-07-27 10:49:47 -07:00
Bharat Mediratta
7ca201b118 Pass along the from_id in item::get_delete_form() and then check to
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-07-10 12:00:06 -07:00
Bharat Mediratta
892727830d Add a loading indicator to the delete form by tagging some JS on at
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-20 16:52:10 -07:00
Bharat Mediratta
a432a43b3b Revert "Change the item rest update processing to call the
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 2492280cc0.
2010-06-15 17:18:22 -07:00
Bharat Mediratta
48dc07dbc8 Revert "Fix for ticket #1118. Create a item::save_with_retries helper
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 9504f71efc.
2010-06-15 17:17:25 -07:00
Tim Almdal
9504f71efc Fix for ticket #1118. Create a item::save_with_retries helper method, which encapsulates saving an item and handling name and slug conflicts. Call this instead of doing a save directly. 2010-06-15 14:18:23 -07:00
Tim Almdal
2492280cc0 Change the item rest update processing to call the 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. 2010-06-15 12:52:28 -07:00
Tim Almdal
58b21e909d Change the pattern used to convert the file name to a title. Fixes ticket#1061 2010-06-10 18:49:29 -07:00
Bharat Mediratta
4e56176f35 item::random_query() doesn't need to take a "where" clause because
it's returning a query, so the caller can add the where clause
himself.  This makes for a cleaner API.
2010-06-05 23:47:47 -07:00
Bharat Mediratta
c3c2b45280 Update the copyright to 2010. It's only 3 months into the year :-) 2010-03-03 10:15:34 -08:00
Bharat Mediratta
8a8d8b4bc4 Rename item name and slug if necessary to avoid a conflict when we
move photos.  Fixes ticket #957.
2010-02-09 15:49:43 -08:00
Bharat Mediratta
16ccda0f3d Two fixes:
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-20 23:49:10 -08:00
Bharat Mediratta
a587426cfd Don't try to set the album cover for the grandparent if we don't have edit permissions for it. 2010-01-19 01:12:09 -08:00
Bharat Mediratta
b3e328c9ff Begin the process of converting to model based validation. Right
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-14 21:04:09 -08:00
Bharat Mediratta
9864ab4b27 Move the random image functionality into the gallery REST helper since
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-08 14:56:08 -08:00
Bharat Mediratta
fb65a0a585 Remove debug code. 2010-01-08 14:20:15 -08:00
Bharat Mediratta
895ac72e70 Add item::random() to return a random Item_Model. 2010-01-08 11:49:18 -08:00
Tim Almdal
d6ddbd1a31 Rollback the refactoring of the update into a helper method. Also remove the refactoring for check for commits 2009-12-30 16:12:32 -08:00
Tim Almdal
bccb6fc021 Clean up validation the check for duplicate names or slugs, finish converting the rest API to Kohana 2.4 2009-12-27 08:32:12 -08:00
Tim Almdal
07e83718a0 Forgot to commit local changes to item helper for K2.4 2009-12-26 11:26:44 -08:00
Tim Almdal
3060a6f662 Merge branch 'master' into talmdal_dev
Conflicts:
	modules/gallery/controllers/albums.php
	modules/gallery/controllers/movies.php
	modules/gallery/controllers/photos.php
2009-12-26 11:24:50 -08:00
Bharat Mediratta
0650109d4b Add merge_or_where() to MY_Datatabase_Builder and use that instead of
or_where() for compatibility and convenience.  Caught by failing unit
tests.
2009-12-22 13:50:52 -08:00