diff --git a/3.0/modules/panorama/README.md b/3.0/modules/panorama/README.md new file mode 100644 index 00000000..d4ea2ec8 --- /dev/null +++ b/3.0/modules/panorama/README.md @@ -0,0 +1,4 @@ +panorama +======== + +Panorama module for Gallery3 diff --git a/3.0/modules/panorama/helpers/panorama_event.php b/3.0/modules/panorama/helpers/panorama_event.php new file mode 100644 index 00000000..700d11cc --- /dev/null +++ b/3.0/modules/panorama/helpers/panorama_event.php @@ -0,0 +1,61 @@ +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(); + } + +} + diff --git a/3.0/modules/panorama/helpers/panorama_installer.php b/3.0/modules/panorama/helpers/panorama_installer.php new file mode 100644 index 00000000..1a0d3d79 --- /dev/null +++ b/3.0/modules/panorama/helpers/panorama_installer.php @@ -0,0 +1,52 @@ +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() { + } +} diff --git a/3.0/modules/panorama/lib/pan0.swf b/3.0/modules/panorama/lib/pan0.swf new file mode 100644 index 00000000..0e222aa3 Binary files /dev/null and b/3.0/modules/panorama/lib/pan0.swf differ diff --git a/3.0/modules/panorama/models/MY_Item_Model.php b/3.0/modules/panorama/models/MY_Item_Model.php new file mode 100644 index 00000000..bf9f1bf1 --- /dev/null +++ b/3.0/modules/panorama/models/MY_Item_Model.php @@ -0,0 +1,46 @@ +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 " + + VFOV\" /> + + + + + "; + } else { + return parent::resize_img($extra_attrs); + } + } +} diff --git a/3.0/modules/panorama/models/panorama.php b/3.0/modules/panorama/models/panorama.php new file mode 100644 index 00000000..691546ce --- /dev/null +++ b/3.0/modules/panorama/models/panorama.php @@ -0,0 +1,22 @@ +