summaryrefslogtreecommitdiff
path: root/core/controllers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-17 04:45:35 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-17 04:45:35 +0000
commitfc7b78492bc671f6dd78e04f5d42de958cdfb1d7 (patch)
tree9ee1738b0869cd183f688180eedc144bb4fa385a /core/controllers
parentf8a0c91ce689c5e0ae7bf05cc75b9982a3b26baf (diff)
Separate thumbnails out into var/thumbs. This clears up some ambiguity in Item_Model and simplifies
file_proxy. It also means we can stop munging file names in the var/resizes hierarchy. In the process, rename "thumbnail" to "thumb" everywhere in honor of Chad (well, ok because it's shorter)..
Diffstat (limited to 'core/controllers')
-rw-r--r--core/controllers/file_proxy.php32
-rw-r--r--core/controllers/welcome.php13
2 files changed, 23 insertions, 22 deletions
diff --git a/core/controllers/file_proxy.php b/core/controllers/file_proxy.php
index c3b92e99..5bb15ebb 100644
--- a/core/controllers/file_proxy.php
+++ b/core/controllers/file_proxy.php
@@ -50,21 +50,10 @@ class File_Proxy_Controller extends Controller {
// We only handle var/resizes and var/albums
$paths = explode("/", $file);
$type = array_shift($paths);
- if ($type != "resizes" && $type != "albums") {
+ if ($type != "resizes" && $type != "albums" && $type != "thumbs") {
kohana::show_404();
}
- // Pull the last item off of the list, explode it out to get the "resize" or "thumb" tag, then
- // put it back together without that tag. This will give us the matching item name.
- $exploded_last = explode(".", array_pop($paths));
- $extension = array_pop($exploded_last);
- $image_type = array_pop($exploded_last);
- if ($image_type != "resize" && $image_type != "thumb") {
- kohana::show_404();
- }
- array_push($exploded_last, $extension);
- array_push($paths, implode(".", $exploded_last));
-
// Walk down from the root until we find the item that matches this path
$item = ORM::factory("item", 1);
while ($path = array_shift($paths)) {
@@ -77,11 +66,8 @@ class File_Proxy_Controller extends Controller {
kohana::show_404();
}
- // Try to detect when we're asking for an album thumbnail or resize. In that case, the
- // second to last element will be an album and the last element will be .thumb.jpg or
- // .resize.jpg except we'll have stripped the .thumb and .resize parts so it'll just be .jpg
- if ($item->type == "album" && count($paths) == 1 &&
- $paths[0][0] == '.' && strlen($paths[0]) == 4) {
+ // If the last element is _album.jpg then we're done.
+ if (count($paths) == 1 && $paths[0] == "_album.jpg") {
break;
}
}
@@ -91,7 +77,17 @@ class File_Proxy_Controller extends Controller {
kohana::show_404();
}
- $path = $image_type == "thumb" ? $item->thumbnail_path() : $item->resize_path();
+ if ($type == "albums") {
+ if ($item->is_album()) {
+ kohana::show_404();
+ }
+ $path = $item->file_path();
+ } else if ($type == "resizes") {
+ $path = $item->resize_path();
+ } else {
+ $path = $item->thumb_path();
+ }
+
if (!file_exists($path)) {
kohana::show_404();
}
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index 7235e2c0..b341b1af 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -92,10 +92,15 @@ class Welcome_Controller extends Template_Controller {
try {
call_user_func(array("{$module->name}_installer", "uninstall"));
} catch (Exception $e) {
+ print $e;
}
}
}
- } catch (Exception $e) { }
+ core_installer::uninstall();
+ } catch (Exception $e) {
+ print $e;
+ }
+
// Since we're in a state of flux, it's possible that other stuff went wrong with the
// uninstall, so back off and nuke it from orbit. It's the only way to be sure.
@@ -206,15 +211,15 @@ class Welcome_Controller extends Template_Controller {
$type = rand(0, 10) ? "photo" : "album";
}
if ($type == "album") {
- $thumbnail_size = module::get_var("core", "thumbnail_size");
+ $thumb_size = module::get_var("core", "thumb_size");
$parents[] = album::create(
$parent->id, "rnd_" . rand(), "Rnd $i", "random album $i", $owner_id)
- ->set_thumbnail(DOCROOT . "core/tests/test.jpg", $thumbnail_size, $thumbnail_size)
+ ->set_thumb(DOCROOT . "core/tests/test.jpg", $thumb_size, $thumb_size)
->save();
} else {
$photo_index = rand(0, count($test_images) - 1);
photo::create($parent->id, $test_images[$photo_index], basename($test_images[$photo_index]),
- "rnd_" . rand(), "sample thumbnail", $owner_id);
+ "rnd_" . rand(), "sample thumb", $owner_id);
}
}
url::redirect("welcome");