Commit Graph

60 Commits

Author SHA1 Message Date
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
Tim Almdal
c3a0f419c6 Refactor the code to check for name or slug conflicts and to update code out of {Albums|Photos|Movies)_Controller and into the item helper so we can reuse it from the rest put handler. 2009-12-09 09:50:57 -08:00
Tim Almdal
16bed1ffd5 Remove the hidden form variable _method which was used in the no longer rest controllers. 2009-12-06 21:32:27 -08:00
Bharat Mediratta
fb899c313c Further simplifications to viewable(). Stop trying to optimize for
the case where we just have one restriction, it's unnecessary.
2009-12-06 21:28:40 -08:00
Bharat Mediratta
b9dadb77c3 Get rid of unused _method param in the item edit form.
Fix viewable() to properly OR view restrictions together.
2009-12-06 21:21:35 -08:00
Bharat Mediratta
96b00d6cfe Convert some more Database::instance() calls to db::build() form. 2009-11-26 21:14:54 -08:00
Bharat Mediratta
0121bfd585 ORM::orderby -> ORM::order_by 2009-11-25 19:26:52 -08:00
Bharat Mediratta
2e420522ec Preliminary work to cut over to Kohana 2.4
- Kohana::log() -> Kohana_Log::add()
- Kohana::config_XXX -> Kohana_Config::instance()->XXX
- Implement View::set_global in MY_View
- Updated Cache_Database_Driver to latest APIs
- ORM::$loaded -> ORM::loaded()
- Updated item::viewable() to use K2.4 parenthesization
2009-11-25 13:22:24 -08:00
Bharat Mediratta
1067e68292 Redesign the way that we consider page types to create buckets of page
types, and a subtype for specifics.  Currently the top level bucket

   collection, item, other

Here are the core subtypes so far:

   collection: album, search, tag
   item: movie, photo
   other: login, reset, comment-fragment, comment

It's legal to create new page_subtypes whenever you want.  Use the
appropriate page_type to get the coarse grain behavior that you want.
2009-11-17 14:04:45 -08:00
Tim Almdal
3c936d661a Change the name of identity library from Identity to IdentityProvider. Create a helper class called identity to simplify call the Identity Provider. Move the contents of MY_Session.php to the new helper class and remove the MY_Session class 2009-10-22 13:11:03 -07:00
Tim Almdal
78ee4193b7 Remove all non Identity API methods from Identity.php. Created an MY_Session class to provide the user state changes in the session and a login.php helper that has the login form. 2009-10-16 10:06:58 -07:00
Tim Almdal
00eacd659f Start simplifying the interface by moving the static methods from user.php and group.php. Tried creating a identity helper, but the helper identity.php was confused with the library Identity.php. So got around this by making the methods on Identity static and calling the instance within the static methods. Also temporarily moved the user.php and group.php back into the user module. 2009-10-16 08:53:31 -07:00
Chad Kieffer
3e6ba7acc3 Renamed most, if not all css selectors from gName to g-name. Moved a few shared images from wind to lib. Deleted unused images in the admin_wind. This will likely break a few ajax features. 2009-10-04 00:27:22 -06:00
Bharat Mediratta
0df4b7d705 Fix line > 100 chars. 2009-09-08 21:49:28 -07:00
Bharat Mediratta
77bd3d3d40 Replace two preg_replace() calls with a single trim() call. 2009-09-08 21:49:09 -07:00
Bharat Mediratta
48becbe017 Update item::convert_filename_to_slug() to eliminate leading and
trailing hyphens.
2009-09-08 20:03:55 -07:00
Bharat Mediratta
2aad580f53 Move specialized (pretty) url generation back into Item_Model so that
we're not relying on overriding url::site() to do tricks around item
urls.  This means that you won't get item urls by doing
url::site("albums/37"), for example, but it also means that we won't
get pretty urls where we don't expect them (like in the action of a
<form> element).

Incidentally, this will help us move over to using the slug format
because if you've got a bad character in a url, the edit forms will
now work on it since they'll be id based.
2009-09-08 13:44:52 -07:00