summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/downloadfullsize/controllers/admin_downloadfullsize.php93
-rw-r--r--modules/downloadfullsize/controllers/downloadfullsize.php37
-rw-r--r--modules/downloadfullsize/css/downloadfullsize_menu.css3
-rw-r--r--modules/downloadfullsize/helpers/downloadfullsize_block.php51
-rw-r--r--modules/downloadfullsize/helpers/downloadfullsize_event.php57
-rw-r--r--modules/downloadfullsize/helpers/downloadfullsize_theme.php26
-rw-r--r--modules/downloadfullsize/images/ico-view-downloadfullsize.pngbin0 -> 4125 bytes
-rw-r--r--modules/downloadfullsize/module.info7
-rw-r--r--modules/downloadfullsize/views/admin_downloadfullsize.html.php5
-rw-r--r--modules/downloadfullsize/views/downloadfullsize_block.html.php18
10 files changed, 297 insertions, 0 deletions
diff --git a/modules/downloadfullsize/controllers/admin_downloadfullsize.php b/modules/downloadfullsize/controllers/admin_downloadfullsize.php
new file mode 100644
index 00000000..6836c9c8
--- /dev/null
+++ b/modules/downloadfullsize/controllers/admin_downloadfullsize.php
@@ -0,0 +1,93 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 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 Admin_DownloadFullsize_Controller extends Admin_Controller {
+ public function index() {
+ // Generate a new admin page.
+ $view = new Admin_View("admin.html");
+ $view->content = new View("admin_downloadfullsize.html");
+ $view->content->downloadlinks_form = $this->_get_admin_form();
+ print $view;
+ }
+
+ public function saveprefs() {
+ // Prevent Cross Site Request Forgery
+ access::verify_csrf();
+
+ // Figure out which boxes where checked
+ $dlLinks_array = Input::instance()->post("DownloadLinkOptions");
+ $fButton = false;
+ $download_original_button = false;
+ for ($i = 0; $i < count($dlLinks_array); $i++) {
+ if ($dlLinks_array[$i] == "fButton") {
+ $fButton = true;
+ }
+ }
+
+ if (module::is_active("keeporiginal")) {
+ $keeporiginal_array = Input::instance()->post("DownloadOriginalOptions");
+ for ($i = 0; $i < count($keeporiginal_array); $i++) {
+ if ($keeporiginal_array[$i] == "DownloadOriginalImage") {
+ $download_original_button = true;
+ }
+ }
+ module::set_var("downloadfullsize", "DownloadOriginalImage", $download_original_button);
+ }
+
+ // Save Settings.
+ module::set_var("downloadfullsize", "fButton", $fButton);
+ message::success(t("Your Selection Has Been Saved."));
+
+ // Load Admin page.
+ $view = new Admin_View("admin.html");
+ $view->content = new View("admin_downloadfullsize.html");
+ $view->content->downloadlinks_form = $this->_get_admin_form();
+ print $view;
+
+ }
+
+ private function _get_admin_form() {
+ // Make a new Form.
+ $form = new Forge("admin/downloadfullsize/saveprefs", "", "post",
+ array("id" => "g-download-fullsize-adminForm"));
+
+ // Make an array for the different types of download links.
+ $linkOptions["fButton"] = array(t("Show Floppy Disk Picture Link"), module::get_var("downloadfullsize", "fButton"));
+
+ // Setup a few checkboxes on the form.
+ $add_links = $form->group("DownloadLinks");
+ $add_links->checklist("DownloadLinkOptions")
+ ->options($linkOptions);
+
+ if (module::is_active("keeporiginal")) {
+ $KeepOriginalOptions["DownloadOriginalImage"] = array(t("Allow visitors to download the original image when available?"), module::get_var("downloadfullsize", "DownloadOriginalImage"));
+ $keeporiginal_group = $form->group("KeepOriginalPrefs")
+ ->label(t("KeepOriginal Preferences"));
+ $keeporiginal_group->checklist("DownloadOriginalOptions")
+ ->options($KeepOriginalOptions);
+ }
+
+ // Add a save button to the form.
+ $form->submit("SaveLinks")->value(t("Save"));
+
+ // Return the newly generated form.
+ return $form;
+ }
+} \ No newline at end of file
diff --git a/modules/downloadfullsize/controllers/downloadfullsize.php b/modules/downloadfullsize/controllers/downloadfullsize.php
new file mode 100644
index 00000000..b678a1a8
--- /dev/null
+++ b/modules/downloadfullsize/controllers/downloadfullsize.php
@@ -0,0 +1,37 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 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 downloadfullsize_Controller extends Controller {
+
+ public function send($id) {
+ $item = ORM::factory("item", $id);
+ access::required("view_full", $item);
+
+ if (module::is_active("keeporiginal") && $item->is_photo() && module::get_var("downloadfullsize", "DownloadOriginalImage")) {
+ $original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
+ if (file_exists($original_image)) {
+ download::force($original_image);
+ } else {
+ download::force($item->file_path());
+ }
+ } else {
+ download::force($item->file_path());
+ }
+ }
+}
diff --git a/modules/downloadfullsize/css/downloadfullsize_menu.css b/modules/downloadfullsize/css/downloadfullsize_menu.css
new file mode 100644
index 00000000..a608a66a
--- /dev/null
+++ b/modules/downloadfullsize/css/downloadfullsize_menu.css
@@ -0,0 +1,3 @@
+#g-view-menu #g-download-fullsize-link {
+ background-image: url('../images/ico-view-downloadfullsize.png');
+}
diff --git a/modules/downloadfullsize/helpers/downloadfullsize_block.php b/modules/downloadfullsize/helpers/downloadfullsize_block.php
new file mode 100644
index 00000000..50e9558d
--- /dev/null
+++ b/modules/downloadfullsize/helpers/downloadfullsize_block.php
@@ -0,0 +1,51 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 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 downloadfullsize_block_Core {
+ static function get_site_list() {
+ return array("downloadfullsize" => t("Download Item"));
+ }
+
+ static function get($block_id, $theme) {
+ $item = $theme->item;
+ switch ($block_id) {
+ case "downloadfullsize":
+
+ // If Item is movie then...
+ if ($item && $item->is_movie() && access::can("view_full", $item)) {
+ $block = new Block();
+ $block->css_id = "g-download-fullsize";
+ $block->title = t("Download Movie");
+ $block->content = new View("downloadfullsize_block.html");
+ return $block;
+ }
+
+ // If Item is photo then...
+ if ($item && $item->is_photo() && access::can("view_full", $item)) {
+ $block = new Block();
+ $block->css_id = "g-download-fullsize";
+ $block->title = t("Download Photo");
+ $block->content = new View("downloadfullsize_block.html");
+ return $block;
+ }
+ }
+ return "";
+ }
+
+}
diff --git a/modules/downloadfullsize/helpers/downloadfullsize_event.php b/modules/downloadfullsize/helpers/downloadfullsize_event.php
new file mode 100644
index 00000000..a9aa86e2
--- /dev/null
+++ b/modules/downloadfullsize/helpers/downloadfullsize_event.php
@@ -0,0 +1,57 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 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 downloadfullsize_event_Core {
+ static function photo_menu($menu, $theme) {
+ if (access::can("view_full", $theme->item)) {
+ if (module::get_var("downloadfullsize", "fButton")) {
+ $downloadLink = url::site("downloadfullsize/send/{$theme->item->id}");
+ $menu
+ ->append(Menu::factory("link")
+ ->id("downloadfullsize")
+ ->label(t("Download Fullsize Image"))
+ ->url($downloadLink)
+ ->css_id("g-download-fullsize-link"));
+ }
+ }
+ }
+
+ static function movie_menu($menu, $theme) {
+ if (access::can("view_full", $theme->item)) {
+ if (module::get_var("downloadfullsize", "fButton")) {
+ $downloadLink = url::site("downloadfullsize/send/{$theme->item->id}");
+ $menu
+ ->append(Menu::factory("link")
+ ->id("downloadfullsize")
+ ->label(t("Download Video"))
+ ->url($downloadLink)
+ ->css_id("g-download-fullsize-link"));
+ }
+ }
+ }
+
+ static function admin_menu($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("downloadfullsize")
+ ->label(t("Download Photo Links"))
+ ->url(url::site("admin/downloadfullsize")));
+ }
+
+}
diff --git a/modules/downloadfullsize/helpers/downloadfullsize_theme.php b/modules/downloadfullsize/helpers/downloadfullsize_theme.php
new file mode 100644
index 00000000..547d3549
--- /dev/null
+++ b/modules/downloadfullsize/helpers/downloadfullsize_theme.php
@@ -0,0 +1,26 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 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 downloadfullsize_theme {
+ static function head($theme) {
+ if ($theme->item && access::can("view_full", $theme->item)) {
+ return $theme->css("downloadfullsize_menu.css");
+ }
+ }
+}
diff --git a/modules/downloadfullsize/images/ico-view-downloadfullsize.png b/modules/downloadfullsize/images/ico-view-downloadfullsize.png
new file mode 100644
index 00000000..ce7804d2
--- /dev/null
+++ b/modules/downloadfullsize/images/ico-view-downloadfullsize.png
Binary files differ
diff --git a/modules/downloadfullsize/module.info b/modules/downloadfullsize/module.info
new file mode 100644
index 00000000..078371a9
--- /dev/null
+++ b/modules/downloadfullsize/module.info
@@ -0,0 +1,7 @@
+name = "DownloadFullsize"
+description = "Displays a link to download the fullsize version of the current photo."
+version = 1
+author_name = ""
+author_url = ""
+info_url = "http://codex.gallery2.org/Gallery3:Modules:downloadfullsize"
+discuss_url = "http://gallery.menalto.com/forum_module_downloadfullsize"
diff --git a/modules/downloadfullsize/views/admin_downloadfullsize.html.php b/modules/downloadfullsize/views/admin_downloadfullsize.html.php
new file mode 100644
index 00000000..5dc5cef6
--- /dev/null
+++ b/modules/downloadfullsize/views/admin_downloadfullsize.html.php
@@ -0,0 +1,5 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div id="g-download-fullsize-admin">
+ <h2> <?= t("Download Fullsize Links") ?> </h2>
+ <?= $downloadlinks_form ?>
+</div>
diff --git a/modules/downloadfullsize/views/downloadfullsize_block.html.php b/modules/downloadfullsize/views/downloadfullsize_block.html.php
new file mode 100644
index 00000000..a9ccc2a6
--- /dev/null
+++ b/modules/downloadfullsize/views/downloadfullsize_block.html.php
@@ -0,0 +1,18 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+
+<? if ($theme->item->is_photo()) { ?>
+<div class="g-download-fullsize-block">
+<a href="<?= url::site("downloadfullsize/send/{$theme->item->id}") ?>"
+ title="<?= t("Download Photo") ?>"
+ class="g-button ui-icon-left ui-state-default ui-corner-all"><?= t("Download Fullsize Image") ?></a>
+</div>
+<? } ?>
+
+<? if ($theme->item->is_movie()) { ?>
+<div class="g-download-fullsize-block">
+<a href="<?= url::site("downloadfullsize/send/{$theme->item->id}") ?>"
+ title="<?= t("Download Video") ?>"
+ class="g-button ui-icon-left ui-state-default ui-corner-all"><?= t("Download Movie") ?></a>
+</div>
+<? } ?>
+