diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2010-02-07 13:54:37 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2010-02-07 13:54:37 -0800 |
commit | 7df4d795e8c5d4b100637f0fea0ad8ef7f6aeabb (patch) | |
tree | 5fdb9d2a11f712cbff82a70e4aed19c77c5370ec /modules/g2_import | |
parent | 6340d8caf2261199e029841baca66e302c861679 (diff) | |
parent | adac97b5372322be5154996974a6496198105d16 (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/g2_import')
-rw-r--r-- | modules/g2_import/controllers/g2.php | 16 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import_task.php | 6 |
2 files changed, 18 insertions, 4 deletions
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 8260cf9f..347da649 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -35,15 +35,25 @@ class G2_Controller extends Controller { $id = $input->get("g2_itemId"); if ($id) { - $where = array("g2_id", "=", $id); + // Requests by id are either core.DownloadItem or + // core.ShowItem requests. + // Later versions of Gallery 2 don't specify g2_view if + // it's the default (core.ShowItem). + // And in some cases (bbcode, embedding) people are using + // the id style URLs although URL rewriting is enabled. + $where = array(array("g2_id", "=", $id)); + $view = $input->get("g2_view"); + if ($view) { + $where[] = array("g2_url", "like", "%g2_view=$view%"); + } // else: Assuming that the first search hit is sufficiently good. } else if ($path) { - $where = array("g2_url", "=", $path); + $where = array(array("g2_url", "=", $path)); } else { throw new Kohana_404_Exception(); } $g2_map = ORM::factory("g2_map") - ->merge_where(array($where)) + ->merge_where($where) ->find(); if (!$g2_map->loaded()) { diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php index 2e81adef..1ec6870e 100644 --- a/modules/g2_import/helpers/g2_import_task.php +++ b/modules/g2_import/helpers/g2_import_task.php @@ -23,7 +23,11 @@ class g2_import_task_Core { g2_import::lower_error_reporting(); if (g2_import::is_configured()) { g2_import::init(); - $version = g2_import::version(); + // Guard from common case where the import has been + // completed and the original files have been removed. + if (class_exists("GalleryCoreApi")) { + $version = g2_import::version(); + } } g2_import::restore_error_reporting(); |