1
0

More refactoring

This commit is contained in:
John Bowles 2010-08-26 09:56:37 -07:00
parent 3bae079610
commit 762684e92f
5 changed files with 2 additions and 162 deletions

3
.gitignore vendored
View File

@ -2,6 +2,3 @@
tmp
*~
*.swp
.settings
.project
.buildpath

View File

@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Embeds_Controller extends Items_Controller {
class Embedded_video_Controller extends Items_Controller {
public function show($movie) {
if (!is_object($movie)) {
// show() must be public because we route to it in url::parse_url(), so make
@ -111,7 +111,7 @@ class Embeds_Controller extends Items_Controller {
$file = fopen($temp_filename, "wb");
fwrite($file, $content);
fclose($file);
gallery_graphics::composite($temp_filename, $temp_filename, array("file" => "modules/embed/images/icon.png", "position" => "center", "transparency" => 95));
gallery_graphics::composite($temp_filename, $temp_filename, array("file" => "modules/embed/images/embed_video_icon.png", "position" => "center", "transparency" => 95));
$item->set_data_file($temp_filename);
$path_info = @pathinfo($temp_filename);
$item->save();

View File

@ -1,107 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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.
*/
/**
* This is the API for handling photos.
*
* Note: by design, this class does not do any permission checking.
*/
class embed_Core {
static function get_add_form($album) {
$form = new Forge("embeds/create/{$album->id}", "", "post", array("id" => "g-add-embed-form"));
$group = $form->group("add_embed")
->label(t("Add embedded video to %album_title", array("album_title" => $album->title)));
$group->input("title")->label(t("Title"))
->error_messages("required", t("You must provide a title"))
->error_messages("length", t("Your title is too long"));
$group->input("name")->label(t("Youtube ID"))
->error_messages(
"conflict", t("There is already a movie with this ID"))
->error_messages("required", t("You must provide a Youtube ID"))
->error_messages("length", t("Invalid Youtube ID"))
->error_messages("invalid_id", t("Invalid Youtube ID"));
$group->textarea("description")->label(t("Description"));
$group->input("slug")->label(t("Internet Address"))
->error_messages(
"conflict", t("There is already a movie, photo or album with this internet address"))
->error_messages(
"not_url_safe",
t("The internet address should contain only letters, numbers, hyphens and underscores"))
->error_messages("required", t("You must provide an internet address"))
->error_messages("length", t("Your internet address is too long"));
$group->hidden("type")->value("embed");
module::event("embed_add_form", $album, $form);
$group = $form->group("buttons")->label("");
$group->submit("")->value(t("Add"));
return $form;
}
static function get_edit_form($photo) {
$form = new Forge("embeds/update/$photo->id", "", "post", array("id" => "g-edit-embed-form"));
$form->hidden("from_id")->value($photo->id);
$group = $form->group("edit_item")->label(t("Edit Embedded Video"));
$group->input("title")->label(t("Title"))->value($photo->title)
->error_messages("required", t("You must provide a title"))
->error_messages("length", t("Your title is too long"));
$group->textarea("description")->label(t("Description"))->value($photo->description);
$group->input("slug")->label(t("Internet Address"))->value($photo->slug)
->error_messages(
"conflict", t("There is already a movie, photo or album with this internet address"))
->error_messages(
"not_url_safe",
t("The internet address should contain only letters, numbers, hyphens and underscores"))
->error_messages("required", t("You must provide an internet address"))
->error_messages("length", t("Your internet address is too long"));
module::event("item_edit_form", $photo, $form);
$group = $form->group("buttons")->label("");
$group->submit("")->value(t("Modify"));
return $form;
}
/**
* Return scaled width and height.
*
* @param integer $width
* @param integer $height
* @param integer $max the target size for the largest dimension
* @param string $format the output format using %d placeholders for width and height
*/
static function img_dimensions($width, $height, $max, $format="width=\"%d\" height=\"%d\"") {
if (!$width || !$height) {
return "";
}
if ($width > $height) {
$new_width = $max;
$new_height = (int)$max * ($height / $width);
} else {
$new_height = $max;
$new_width = (int)$max * ($width / $height);
}
return sprintf($format, $new_width, $new_height);
}
}

View File

@ -1,37 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
class embed_event_Core {
static function item_created($item) {
//access::add_item($item);
if ($item->is_embed()) {
// Build our thumbnail/resizes.
try {
graphics::generate($item);
} catch (Exception $e) {
log::error("graphics", t("Couldn't create a thumbnail or resize for %item_title",
array("item_title" => $item->title)),
html::anchor($item->abs_url(), t("details")));
Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
// If the parent has no cover item, make this it.
$parent = $item->parent();
if (access::can("edit", $parent) && $parent->album_cover_item_id == null) {
item::make_album_cover($item);
}
}
}
static function site_menu($menu, $theme) {
$item = $theme->item();
if ($can_add = $item && access::can("add", $item)) {
$menu->get("add_menu")
->append(Menu::factory("dialog")
->id("embed_add")
->label(t("Embed Video"))
->url(url::site("form/add/embeds/$item->id")));
}
}
}

View File

@ -1,13 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
class embed_installer {
static function install() {
exec("cd modules/gallery/controllers/; ln -s ../../embed/controllers/embeds.php embeds.php");
}
static function deactivate() {
if (is_file("modules/gallery/controllers/embeds.php")) {
unlink("modules/gallery/controllers/embeds.php");
}
}
}