diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/SimpleUploader.swf | bin | 301344 -> 301349 bytes | |||
-rw-r--r-- | core/controllers/simple_uploader.php | 14 | ||||
-rw-r--r-- | core/helpers/graphics.php | 1 | ||||
-rw-r--r-- | core/helpers/movie.php | 2 | ||||
-rw-r--r-- | core/helpers/photo.php | 11 | ||||
-rw-r--r-- | core/models/item.php | 26 |
6 files changed, 31 insertions, 23 deletions
diff --git a/core/SimpleUploader.swf b/core/SimpleUploader.swf Binary files differindex 2be9841f..152917b1 100644 --- a/core/SimpleUploader.swf +++ b/core/SimpleUploader.swf diff --git a/core/controllers/simple_uploader.php b/core/controllers/simple_uploader.php index 4e2be4c8..b56bce16 100644 --- a/core/controllers/simple_uploader.php +++ b/core/controllers/simple_uploader.php @@ -46,19 +46,19 @@ class Simple_Uploader_Controller extends Controller { access::verify_csrf(); $file_validation = new Validation($_FILES); - $file_validation->add_rules("file", "upload::valid", "upload::type[gif,jpg,png,flv]"); + $file_validation->add_rules("file", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]"); if ($file_validation->validate()) { - $temp_filename = upload::save("file"); + $temp_filename = upload::save("file"); $title = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $path_info = pathinfo($temp_filename); - if ($path_info["extension"] == "flv") { + if (in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { $movie = movie::create($album, $temp_filename, $title, $title); - log::success("content", t("Added a movie"), html::anchor("movies/$movie->id", - t("view movie"))); + log::success("content", t("Added a movie"), + html::anchor("movies/$movie->id", t("view movie"))); } else { $photo = photo::create($album, $temp_filename, $title, $title); - log::success("content", t("Added a photo"), html::anchor("photos/$photo->id", - t("view photo"))); + log::success("content", t("Added a photo"), + html::anchor("photos/$photo->id", t("view photo"))); } } } diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php index 92e1c3f7..d30701a0 100644 --- a/core/helpers/graphics.php +++ b/core/helpers/graphics.php @@ -107,6 +107,7 @@ class graphics_Core { foreach ($ops as $target => $output_file) { if ($input_item->is_movie()) { // Convert the movie to a JPG first + $output_file = preg_replace("/...$/", "jpg", $output_file); movie::extract_frame($input_file, $output_file); $working_file = $output_file; } else { diff --git a/core/helpers/movie.php b/core/helpers/movie.php index 9941fcee..9a93afbf 100644 --- a/core/helpers/movie.php +++ b/core/helpers/movie.php @@ -60,7 +60,7 @@ class movie_Core { $movie->owner_id = $owner_id; $movie->width = $movie_info[0]; $movie->height = $movie_info[1]; - $movie->mime_type = "video/x-flv"; + $movie->mime_type = strtolower($pi["extension"]) == "mp4" ? "video/mp4" : "video/x-flv"; $movie->thumb_dirty = 1; $movie->resize_dirty = 1; diff --git a/core/helpers/photo.php b/core/helpers/photo.php index 9b773dc4..aab72a87 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -44,13 +44,6 @@ class photo_Core { } $image_info = getimagesize($filename); - if ($image_info) { - $type = "photo"; - } else { - $movie_info = movie::getmoviesize($filename); - $image_info = array(200, 200, 'mime' => 'video/x-flv'); - $type = "movie"; - } // Force an extension onto the name $pi = pathinfo($name); @@ -60,7 +53,7 @@ class photo_Core { } $photo = ORM::factory("item"); - $photo->type = $type; + $photo->type = "photo"; $photo->title = $title; $photo->description = $description; $photo->name = $name; @@ -109,7 +102,7 @@ class photo_Core { $group->input("name")->label(t("Name")); $group->input("title")->label(t("Title")); $group->textarea("description")->label(t("Description")); - $group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif,flv]"); + $group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif,flv,mp4]"); $group->hidden("type")->value("photo"); $group->submit("")->value(t("Upload")); $form->add_rules_from(ORM::factory("item")); diff --git a/core/models/item.php b/core/models/item.php index 329f9c43..cc242abf 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -180,8 +180,15 @@ class Item_Model extends ORM_MPTT { * photo: /var/albums/album1/photo.thumb.jpg */ public function thumb_path() { - return VARPATH . "thumbs/" . $this->relative_path() . - ($this->is_album() ? "/.album.jpg" : ""); + $base = VARPATH . "thumbs/" . $this->relative_path(); + if ($this->is_photo()) { + return $base; + } else if ($this->is_album()) { + return $base . "/.album.jpg"; + } else if ($this->is_movie()) { + // Replace the extension with jpg + return preg_replace("/...$/", "jpg", $base); + } } /** @@ -189,10 +196,17 @@ class Item_Model extends ORM_MPTT { * photo: http://example.com/gallery3/var/albums/album1/photo.thumb.jpg */ public function thumb_url($full_uri=true) { - return ($full_uri ? - url::abs_file("var/thumbs/" . $this->relative_path()) : - url::file("var/thumbs/" . $this->relative_path())) . - ($this->is_album() ? "/.album.jpg" : ""); + $base = ($full_uri ? + url::abs_file("var/thumbs/" . $this->relative_path()) : + url::file("var/thumbs/" . $this->relative_path())); + if ($this->is_photo()) { + return $base; + } else if ($this->is_album()) { + return $base . "/.album.jpg"; + } else if ($this->is_movie()) { + // Replace the extension with jpg + return preg_replace("/...$/", "jpg", $base); + } } /** |