1
0

Reformatting

This commit is contained in:
unknown 2010-08-26 21:13:22 -05:00
parent 5953556295
commit ee214193d3
6 changed files with 106 additions and 81 deletions

View File

@ -19,34 +19,34 @@
*/ */
/** /**
* This is the API for handling photos. * This is the API for handling embedded videos.
* *
* Note: by design, this class does not do any permission checking. * Note: by design, this class does not do any permission checking.
*/ */
class embed_videos_Core { class embed_videos_Core {
static function get_add_form($album) { static function get_add_form($album) {
$form = new Forge("embedded_videos/create/{$album->id}", "", "post", array("id" => "g-add-embed-form")); $form = new Forge("embedded_videos/create/{$album->id}", "", "post", array("id" => "g-add-embed-form"));
$group = $form->group("add_embedded_video") $group = $form->group("add_embedded_video")
->label(t("Add embedded video to %album_title", array("album_title" => $album->title))); ->label(t("Add embedded video to %album_title", array("album_title" => $album->title)));
$group->input("title")->label(t("Title")) $group->input("title")->label(t("Title"))
->error_messages("required", t("You must provide a title")) ->error_messages("required", t("You must provide a title"))
->error_messages("length", t("Your title is too long")); ->error_messages("length", t("Your title is too long"));
$group->input("video_url")->label(t("Video URL")) $group->input("video_url")->label(t("Video URL"))
->error_messages( ->error_messages(
"conflict", t("There is already a movie with this ID")) "conflict", t("There is already a movie with this ID"))
->error_messages("required", t("You must provide a Youtube ID")) ->error_messages("required", t("You must provide a Youtube ID"))
->error_messages("length", t("Invalid Youtube ID")) ->error_messages("length", t("Invalid Youtube ID"))
->error_messages("invalid_id", t("Invalid Youtube ID")); ->error_messages("invalid_id", t("Invalid Youtube ID"));
$group->textarea("description")->label(t("Description")); $group->textarea("description")->label(t("Description"));
$group->input("slug")->label(t("Internet Address")) $group->input("slug")->label(t("Internet Address"))
->error_messages( ->error_messages(
"conflict", t("There is already a movie, photo or album with this internet address")) "conflict", t("There is already a movie, photo or album with this internet address"))
->error_messages( ->error_messages(
"not_url_safe", "not_url_safe",
t("The internet address should contain only letters, numbers, hyphens and underscores")) t("The internet address should contain only letters, numbers, hyphens and underscores"))
->error_messages("required", t("You must provide an internet address")) ->error_messages("required", t("You must provide an internet address"))
->error_messages("length", t("Your internet address is too long")); ->error_messages("length", t("Your internet address is too long"));
module::event("item_add_form", $album, $form); module::event("item_add_form", $album, $form);
@ -55,23 +55,23 @@ class embed_videos_Core {
return $form; return $form;
} }
static function get_edit_form($photo) { static function get_edit_form($photo) {
$form = new Forge("embedded_videos/update/$photo->id", "", "post", array("id" => "g-edit-embed-form")); $form = new Forge("embedded_videos/update/$photo->id", "", "post", array("id" => "g-edit-embed-form"));
$form->hidden("from_id")->value($photo->id); $form->hidden("from_id")->value($photo->id);
$group = $form->group("edit_item")->label(t("Edit Embedded Video")); $group = $form->group("edit_item")->label(t("Edit Embedded Video"));
$group->input("title")->label(t("Title"))->value($photo->title) $group->input("title")->label(t("Title"))->value($photo->title)
->error_messages("required", t("You must provide a title")) ->error_messages("required", t("You must provide a title"))
->error_messages("length", t("Your title is too long")); ->error_messages("length", t("Your title is too long"));
$group->textarea("description")->label(t("Description"))->value($photo->description); $group->textarea("description")->label(t("Description"))->value($photo->description);
$group->input("slug")->label(t("Internet Address"))->value($photo->slug) $group->input("slug")->label(t("Internet Address"))->value($photo->slug)
->error_messages( ->error_messages(
"conflict", t("There is already a movie, photo or album with this internet address")) "conflict", t("There is already a movie, photo or album with this internet address"))
->error_messages( ->error_messages(
"not_url_safe", "not_url_safe",
t("The internet address should contain only letters, numbers, hyphens and underscores")) t("The internet address should contain only letters, numbers, hyphens and underscores"))
->error_messages("required", t("You must provide an internet address")) ->error_messages("required", t("You must provide an internet address"))
->error_messages("length", t("Your internet address is too long")); ->error_messages("length", t("Your internet address is too long"));
module::event("item_edit_form", $photo, $form); module::event("item_edit_form", $photo, $form);

View File

@ -1,9 +1,26 @@
<?php defined("SYSPATH") or die("No direct script access."); <?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.
*/
class embed_videos_event_Core { class embed_videos_event_Core {
static function item_created($item) { static function item_created($item) {
if ($item->type == "embedded_video") { if ($item->type == "embedded_video") {
// Build our thumbnail/resizes. // Build our thumbnail/resizes.
@ -11,8 +28,8 @@ class embed_videos_event_Core {
graphics::generate($item); graphics::generate($item);
} catch (Exception $e) { } catch (Exception $e) {
log::error("graphics", t("Couldn't create a thumbnail or resize for %item_title", log::error("graphics", t("Couldn't create a thumbnail or resize for %item_title",
array("item_title" => $item->title)), array("item_title" => $item->title)),
html::anchor($item->abs_url(), t("details"))); html::anchor($item->abs_url(), t("details")));
Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
} }
@ -23,21 +40,21 @@ class embed_videos_event_Core {
} }
} }
} }
static function item_deleted($item) { static function item_deleted($item) {
ORM::factory("embedded_video") ORM::factory("embedded_video")
->where("item_id", "=", $item->id) ->where("item_id", "=", $item->id)
->find() ->find()
->delete(); ->delete();
} }
static function site_menu($menu, $theme) { static function site_menu($menu, $theme) {
$item = $theme->item(); $item = $theme->item();
if ($can_add = $item && access::can("add", $item)) { if ($can_add = $item && access::can("add", $item)) {
$menu->get("add_menu") $menu->get("add_menu")
->append(Menu::factory("dialog") ->append(Menu::factory("dialog")
->id("embed_add") ->id("embed_add")
->label(t("Embed Video")) ->label(t("Embed Video"))
->url(url::site("form/add/embedded_videos/$item->id"))); ->url(url::site("form/add/embedded_videos/$item->id")));
} }
} }
} }

View File

@ -1,9 +1,27 @@
<?php defined("SYSPATH") or die("No direct script access."); <?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.
*/
class embed_videos_installer { class embed_videos_installer {
static function install() { static function install() {
$db = Database::instance(); $db = Database::instance();
$db->query("CREATE TABLE {embedded_videos} ( $db->query("CREATE TABLE {embedded_videos} (
`id` int(9) NOT NULL auto_increment, `id` int(9) NOT NULL auto_increment,
`embed_code` varchar(2048) DEFAULT NULL, `embed_code` varchar(2048) DEFAULT NULL,
`source` varchar(64) DEFAULT NULL, `source` varchar(64) DEFAULT NULL,
@ -11,16 +29,16 @@ class embed_videos_installer {
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY (`item_id`, `id`)) KEY (`item_id`, `id`))
DEFAULT CHARSET=utf8;"); DEFAULT CHARSET=utf8;");
module::set_version("embed_videos", 2); module::set_version("embed_videos", 2);
//exec("cd modules/gallery/controllers/; ln -s ../../embed/controllers/embeds.php embeds.php"); //exec("cd modules/gallery/controllers/; ln -s ../../embed/controllers/embeds.php embeds.php");
} }
static function deactivate() {
} static function deactivate() {
static function uninstall() {
$db = Database::instance(); }
$db->query("DROP TABLE IF EXISTS {embedded_videos};"); static function uninstall() {
module::delete("embed_videos"); $db = Database::instance();
} $db->query("DROP TABLE IF EXISTS {embedded_videos};");
module::delete("embed_videos");
}
} }

View File

@ -1,4 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access."); <?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.
*/
class Embedded_video_Model extends ORM { class Embedded_video_Model extends ORM {
public function __construct($id=null) { public function __construct($id=null) {

View File

@ -1,3 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/<?= substr($item->name, 0, strrpos($item->name, '.')); ?>" frameborder="0">
</iframe>

View File

@ -1,25 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? $embedded_video = ORM::factory('embedded_video')->where('item_id', $item->id)->find();
if ($embedded_video->loaded()) {
?>
<div id="g-item">
<?= $theme->photo_top() ?>
<?= $theme->paginator() ?>
<div id="g-movie" class="ui-helper-clearfix">
<?= $theme->resize_top($item) ?>
<?= $embedded_video->embed_code ?>
<?= $theme->resize_bottom($item) ?>
</div>
<div id="g-info">
<h1><?= html::purify($item->title) ?></h1>
<div><?= nl2br(html::purify($item->description)) ?></div>
</div>
<?= $theme->photo_bottom() ?>
</div>
<? } else {
require('themes/' . $theme->name . 'views/photo.html.php');
} ?>