1
0

Merge pull request #136 from mikeage/master

New panorama module
This commit is contained in:
Bharat Mediratta 2013-01-16 14:59:45 -08:00
commit f8fbedac07
7 changed files with 192 additions and 0 deletions

View File

@ -0,0 +1,4 @@
panorama
========
Panorama module for Gallery3

View File

@ -0,0 +1,61 @@
<?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 panorama_event_Core {
static function item_edit_form($item, $form) {
if ($item->is_photo()) {
$panorama = ORM::factory("panorama")->where("item_id", "=", $item->id)->find();
$form->edit_item->checkbox("panorama_panorama")
->label(t("Display as a panorama"))
->id("g-panorama-panorama")
->checked($panorama->checked);
$form->edit_item->input("panorama_HFOV")
->label(t("Horizontal FOV"))
->id("g-panorama-HFOV")
->value($panorama->HFOV);
$form->edit_item->input("panorama_VFOV")
->label(t("Vertical FOV"))
->id("g-panorama-VFOV")
->value($panorama->VFOV);
}
}
static function item_edit_form_completed($item, $form) {
$panorama = ORM::factory("panorama")->where("item_id", "=", $item->id)->find();
if (!($panorama->loaded())) {
$panorama->item_id = $item->id;
}
$panorama->checked= $form->edit_item->panorama_panorama->checked;
$panorama->HFOV= $form->edit_item->panorama_HFOV->value;
$panorama->VFOV= $form->edit_item->panorama_VFOV->value;
/* If unspecified, we'll assume it's a full 360 panorama. Otherwise, we assume HFOV is accurate. In either case, we calculate the other value from the given one plus the image ratio */
if (!($panorama->HFOV) && !($panorama->VFOV)) {
$panorama->HFOV = 360;
$panorama->VFOV = $panorama->HFOV / $item->width * $item->height;
} else if ($panorama->HFOV) {
$panorama->VFOV = $panorama->HFOV / $item->width * $item->height;
} else {
$panorama->HFOV = $panorama->VFOV * $item->width / $item->height;
}
$panorama->save();
}
}

View File

@ -0,0 +1,52 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2012 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 panorama_installer {
static function install() {
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {panoramas} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
`checked` boolean default 0,
`HFOV` int(3),
`VFOV` int(3),
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
module::set_version("panorama", 1);
}
static function upgrade($version) {
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {panoramas} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
`checked` boolean default 0,
`HFOV` int(3),
`VFOV` int(3),
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
module::set_version("panorama", 1);
}
static function deactivate() {
}
}

Binary file not shown.

View File

@ -0,0 +1,46 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2012 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 Item_Model extends Item_Model_Core {
public function resize_img($extra_attrs) {
$panorama = ORM::factory("panorama")->where("item_id", "=", $this->id)->find();
if ($panorama->loaded() && $panorama->checked) {
$swfUrl = url::file("modules/panorama/lib/pan0.swf");
$panoramaHFOV = $panorama->HFOV;
$panoramaVFOV = $panorama->VFOV;
$img_url = $this->file_url();
return "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"
codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\"
width=\"640\" height=\"480\" title=\"FSPP Panorama Viewer\">
<param name=\"allowFullScreen\" value=\"true\" />
<param name=\"movie\" value=\"$swfUrl?panoSrc=$img_url&FOV=40&minFOV=20&maxFOV=40&panHFOV=$panoramaHFOV&panVFOV=$panorama->VFOV\" />
<param name=\"quality\" value=\"high\" />
<param name=\"BGCOLOR\" value=\"#AAAAAA\" />
<embed src=\"$swfUrl?panoSrc=$img_url&FOV=40&minFOV=20&maxFOV=40&panHFOV=$panoramaHFOV&panVFOV=$panoramaVFOV\"
allowFullScreen=\"true\"
width=\"640\" height=\"480\" quality=\"high\"
pluginspage=\"http://www.macromedia.com/go/getflashplayer\"
type=\"application/x-shockwave-flash\" bgcolor=\"#DDDDDD\">
</embed>
</object>";
} else {
return parent::resize_img($extra_attrs);
}
}
}

View File

@ -0,0 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2012 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 Panorama_Model extends ORM {
}

View File

@ -0,0 +1,7 @@
name = "Panorama"
description = "View panoramas with an interactive viewer (forked from fspp's pan0)"
version = 1
author_name ="mikeage"
author_url = "http://mikeage.net"
info_url = "http://TODO"
discuss_url = "http://TODO"