mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-07-27 18:24:03 -04:00
commit 41d379c2b777ae7b3a11f528971228e234f8976f Author: Chad Parry <github@chad.parry.org> Date: Thu Jul 21 00:10:10 2011 -0600 Replace an overly-complicated regular expression with a simple in_array, at Bharat's suggestion. commit 1b3f7111d4c2607baaa2da0aab3b501f2d9a1426 Merge: 8f7904a403f64bAuthor: Chad Parry <github@chad.parry.org> Date: Wed Jul 20 21:02:56 2011 -0600 Merge branch 'master' into rawphoto commit403f64bf2aAuthor: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Tue Jul 12 21:44:14 2011 -0700 Automated update of .build_number to 163 for branch master Last update:e8382b960a(1 commits ago) commit51726f9e4bAuthor: Tim Almdal <tnalmdal@shaw.ca> Date: Tue Jul 12 21:44:40 2011 -0700 Fix for ticket #1752. Add an RSS field link for the current album. Or, in the case of a photo or movie, add a link to the rss field of the parent album. commite8382b960aAuthor: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Mon Jun 27 22:27:04 2011 -0700 Automated update of .build_number to 162 for branch master Last update:40cda7fa3f(1 commits ago) commit1afbcafe0eMerge:40cda7ffc6c139Author: Bharat Mediratta <bharat@menalto.com> Date: Mon Jun 27 22:26:41 2011 -0700 Merge pull request #56 from alindeman/alindeman/1758 [Fixes #1758] Link to themes codex page instead of modules codex page commit40cda7fa3fAuthor: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com> Date: Mon Jun 27 22:25:54 2011 -0700 Automated update of .build_number to 161 for branch master Last update:771de0a374(1 commits ago) commitaa08df7f0aMerge:771de0a784c429Author: Bharat Mediratta <bharat@menalto.com> Date: Mon Jun 27 22:25:46 2011 -0700 Merge pull request #55 from alindeman/alindeman/1757 [Fixes #1757] Redirect to root album if path comes in as main.php or index.php commitfc6c1390d3Author: Andy Lindeman <alindeman@gmail.com> Date: Mon Jun 27 08:25:50 2011 -0400 [Fixes #1758] Link to themes codex page instead of modules codex page commit784c429070Author: Andy Lindeman <alindeman@gmail.com> Date: Mon Jun 27 07:24:37 2011 -0400 [Fixes #1757] Redirect to root album if path comes in as main.php or index.php commit 8f7904ab62c71a7e4ee68762f936030b4dcb4ea1 Merge: e950573771de0aAuthor: Chad Parry <github@chad.parry.org> Date: Sat Jun 25 14:12:39 2011 -0600 Merge branches 'master' and 'rawphoto' into rawphoto commit e95057337996351e49915d9f85d007d50103a4be Author: Chad Parry <github@chad.parry.org> Date: Wed Jun 15 20:24:18 2011 -0600 Merge branches 'rawphoto-squash' and 'rawphoto' into rawphoto
97 lines
3.3 KiB
PHP
97 lines
3.3 KiB
PHP
<?php defined("SYSPATH") or die("No direct script access.");
|
|
/**
|
|
* Gallery - a web based photo album viewer and editor
|
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
* your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
class G2_Controller extends Controller {
|
|
/**
|
|
* Redirect Gallery 2 urls to their appropriate matching Gallery 3 url.
|
|
*
|
|
* We use mod_rewrite to create this path, so Gallery2 urls like this:
|
|
* /gallery2/v/Family/Wedding.jpg.html
|
|
* /gallery2/main.php?g2_view=core.ShowItem&g2_itemId=1234
|
|
*
|
|
* Show up here like this:
|
|
* /g2/map?path=v/Family/Wedding.jpg.html
|
|
* /g2/map?g2_view=core.ShowItem&g2_itemId=1931
|
|
*/
|
|
public function map() {
|
|
$input = Input::instance();
|
|
$path = $input->get("path");
|
|
$id = $input->get("g2_itemId");
|
|
|
|
if (($path && $path != 'index.php' && $path != 'main.php') || $id) {
|
|
if ($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 == "core.DownloadItem") {
|
|
$where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full"));
|
|
} else 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(array("g2_url", "IN", array($path, str_replace(" ", "+", $path))));
|
|
} else {
|
|
throw new Kohana_404_Exception();
|
|
}
|
|
|
|
$g2_map = ORM::factory("g2_map")
|
|
->merge_where($where)
|
|
->find();
|
|
|
|
if (!$g2_map->loaded()) {
|
|
throw new Kohana_404_Exception();
|
|
}
|
|
|
|
$item = ORM::factory("item", $g2_map->g3_id);
|
|
if (!$item->loaded()) {
|
|
throw new Kohana_404_Exception();
|
|
}
|
|
$resource_type = $g2_map->resource_type;
|
|
} else {
|
|
$item = item::root();
|
|
$resource_type = "album";
|
|
}
|
|
access::required("view", $item);
|
|
|
|
|
|
// Redirect the user to the new url
|
|
switch ($resource_type) {
|
|
case "thumbnail":
|
|
url::redirect($item->thumb_url(true));
|
|
|
|
case "resize":
|
|
url::redirect($item->resize_url(true));
|
|
|
|
case "file":
|
|
case "full":
|
|
url::redirect($item->file_url(true));
|
|
|
|
case "item":
|
|
case "album":
|
|
url::redirect($item->abs_url());
|
|
|
|
case "group":
|
|
case "user":
|
|
default:
|
|
throw new Kohana_404_Exception();
|
|
}
|
|
}
|
|
} |