From 58d5624e401f1c369cbbf913008775bc5a165570 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 21:51:22 -0700 Subject: This commit moves a little further along the path: 1) moves the print button from the quick pane to thumb_bottom 2) Creates an entry into the proxy table --- modules/digibug/js/digibug.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 modules/digibug/js/digibug.js (limited to 'modules/digibug/js/digibug.js') diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js new file mode 100644 index 00000000..f30678c0 --- /dev/null +++ b/modules/digibug/js/digibug.js @@ -0,0 +1,24 @@ +$(document).ready(function() { + $(".gDigibugPrintButton a").click(function(e) { + e.preventDefault(); + queue_print(e); + }); +}); + +function queue_print(e) { + var parent = e.currentTarget.parentNode; + $(parent).addClass("gLoadingLarge"); + $.ajax({ + type: "GET", + url: e.currentTarget.href, + dataType: "json", + success: function(data) { + $(parent).removeClass("gLoadingLarge"); + if (data.location) { + window.location = data.location; + } else if (data.reload) { + window.location.reload(); + } + } + }); +}; -- cgit v1.2.3 From 231ad4f32950f42c76c16ab453246bedea8abf2c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 23 Jun 2009 22:13:28 -0700 Subject: This implements the Digibug printing. When a a print request is made the digibug shopping cart is opened in a new window. When the cart is emptied, the window is closed. Users can close the window by pressing the continue shopping button --- modules/digibug/controllers/digibug.php | 12 ++++--- modules/digibug/helpers/digibug_installer.php | 2 +- modules/digibug/helpers/digibug_theme.php | 1 - modules/digibug/js/digibug.js | 52 +++++++++++++++++++-------- modules/digibug/views/digibug_album.html.php | 2 +- modules/digibug/views/digibug_form.html.php | 16 +++++++++ 6 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 modules/digibug/views/digibug_form.html.php (limited to 'modules/digibug/js/digibug.js') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index b0807aa5..609da875 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -36,12 +36,13 @@ class Digibug_Controller extends Controller { $company_id = module::get_var("digibug", "company_id"); $event_id = module::get_var("digibug", "event_id"); } - $digibug_parms = array( + $v = new View("digibug_form.html"); + $v->order_parms = array( "digibug_api_version" => "100", "company_id" => $company_id, "event_id" => $event_id, "cmd" => "adding", - "return_url" => url::abs_site($this->input->get("return")), + "return_url" => url::abs_site("digibug/close_window"), "num_images" => "1", "image_1" => $url, "thumb_1" => "$url/thumb", @@ -51,9 +52,7 @@ class Digibug_Controller extends Controller { "thumb_width_1" => $item->thumb_width, "title" => $item->title); - message::success( - t("Photo '%title' was submitted for printing.", array("title" => $item->title))); - print json_encode(array("result" => "success", "reload" => 1)); + print $v; } public function print_proxy($id, $thumb=null) { @@ -90,4 +89,7 @@ class Digibug_Controller extends Controller { } } + public function close_window() { + print ""; + } } \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 73645eb7..0476e2cc 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -24,7 +24,7 @@ class digibug_installer { Database::instance() ->query("CREATE TABLE {proxies} ( `id` int(9) NOT NULL auto_increment, - `uuid` char(32) NOT NULL, + `uuid` char(36) NOT NULL, `item_id` int(9), PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 0fe2ce2e..e52fcc7f 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -34,7 +34,6 @@ class digibug_theme_Core { if ($theme->page_type() == "album" && $child->type == "photo") { $v = new View("digibug_album.html"); $v->id = $child->id; - $v->return = "album/{$child->parent()->id}"; $v->title = t("Print photo with Digibug"); return $v->render(); } diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js index f30678c0..e9e8933e 100644 --- a/modules/digibug/js/digibug.js +++ b/modules/digibug/js/digibug.js @@ -5,20 +5,42 @@ $(document).ready(function() { }); }); +function popUp(url, options) { + options = $.extend({ + /* default options */ + width: 400, + height: 400, + target: 'dbPopWin', + scrollbars: 'yes', + resizable: 'no', + menuBar: 'no', + addressBar: 'yes'}, options); + + /* center the window by default. */ + if (!options.winY) { + options.winY = screen.height / 2 - options.height / 2; + }; + if (!options.winX) { + options.winX = screen.width / 2 - options.width / 2; + }; + + open( + url, + options['target'], + 'width= ' + options.width + + ',height=' + options.height + + ',top=' + options.winY + + ',left=' + options.winX + + ',scrollbars=' + options.scrollbars + + ',resizable=' + options.resizable + + ',menubar=' + options.menuBar + + ',location=' + options.addressBar + ); + + return false; + +} + function queue_print(e) { - var parent = e.currentTarget.parentNode; - $(parent).addClass("gLoadingLarge"); - $.ajax({ - type: "GET", - url: e.currentTarget.href, - dataType: "json", - success: function(data) { - $(parent).removeClass("gLoadingLarge"); - if (data.location) { - window.location = data.location; - } else if (data.reload) { - window.location.reload(); - } - } - }); + return popUp(e.currentTarget.href, { width: 800, height: 600 } ); }; diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php index 0f1537e9..c3337324 100644 --- a/modules/digibug/views/digibug_album.html.php +++ b/modules/digibug/views/digibug_album.html.php @@ -1,7 +1,7 @@
" + href="" title=""> diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php new file mode 100644 index 00000000..c2cd889e --- /dev/null +++ b/modules/digibug/views/digibug_form.html.php @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 292d216f7c133152cb921db1cbc7a0c4843a977a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 24 Jun 2009 18:02:36 -0700 Subject: Implement printing support on the photo page. I've used an icon that doesn't quite match the theme temporarily. I'm hoping to have a matching icon soon. --- modules/digibug/helpers/digibug_menu.php | 18 +++++++----------- modules/digibug/js/digibug.js | 4 ++++ themes/default/css/screen.css | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) (limited to 'modules/digibug/js/digibug.js') diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php index 1ff0f6bf..6c466031 100644 --- a/modules/digibug/helpers/digibug_menu.php +++ b/modules/digibug/helpers/digibug_menu.php @@ -27,17 +27,13 @@ class digibug_menu { } static function photo($menu, $theme) { - } - - static function site($menu, $theme) { $item = $theme->item(); - - if ($item && access::can("edit", $item)) { - $options_menu = $menu->get("options_menu") - ->append(Menu::factory("dialog") - ->id("digibug") - ->label(t("Peform Digibug Processing")) - ->url(url::site("digibug/index/$item->id"))); - } + $csrf = access::csrf_token(); + $menu + ->append(Menu::factory("link") + ->id("digibug") + ->label(t("Print with Digibug")) + ->url(url::site("digibug/print_photo/{$item->id}?csrf={$csrf}")) + ->css_id("gDigibugLink")); } } diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js index e9e8933e..837c8f7f 100644 --- a/modules/digibug/js/digibug.js +++ b/modules/digibug/js/digibug.js @@ -3,6 +3,10 @@ $(document).ready(function() { e.preventDefault(); queue_print(e); }); + $("#gDigibugLink").click(function(e) { + e.preventDefault(); + return queue_print(e); + }); }); function popUp(url, options) { diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index a450356c..8967efdf 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -665,6 +665,10 @@ form .gError, background-image: url('../images/ico-view-comments.png'); } +#gViewMenu #gDigibugLink { + background-image: url('../images/ico-print.png'); +} + /* Breadcrumbs ~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ .gBreadcrumbs { -- cgit v1.2.3 From 2fbc03437ac6f861f597778964cf01737968bb94 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Jun 2009 15:55:47 -0700 Subject: Digibug simplification cleanup. Upgrade digibug module to version 2. 1) Simplify the admin settings page to what most of our users want. Eliminate basic_ and default_ ids. We just have company_id and default_id. Advanced users can use advanced settings for now. 2) Fix security in print_photos (didn't get it right in my last commit) 3) Use the regular thumb and full urls if the images are publicly available to reduce load on the proxy. 4) Simplify proxy expiration code. 5) Eliminate all specialized styles from the admin theme. --- modules/digibug/controllers/admin_digibug.php | 50 +----------------- modules/digibug/controllers/digibug.php | 72 ++++++++++---------------- modules/digibug/helpers/digibug_installer.php | 30 +++++++---- modules/digibug/images/digibug_logo.png | Bin 0 -> 17296 bytes modules/digibug/js/digibug.js | 31 +++++------ modules/digibug/models/digibug_proxy.php | 1 - modules/digibug/module.info | 2 +- modules/digibug/views/admin_digibug.html.php | 29 ++++++----- modules/digibug/views/digibug_form.html.php | 11 ++-- themes/admin_default/css/screen.css | 54 ------------------- themes/admin_default/images/digibug_logo.png | Bin 17296 -> 0 bytes 11 files changed, 82 insertions(+), 198 deletions(-) create mode 100644 modules/digibug/images/digibug_logo.png delete mode 100644 themes/admin_default/images/digibug_logo.png (limited to 'modules/digibug/js/digibug.js') diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php index bd9e9d95..7124338f 100644 --- a/modules/digibug/controllers/admin_digibug.php +++ b/modules/digibug/controllers/admin_digibug.php @@ -19,56 +19,8 @@ */ class Admin_Digibug_Controller extends Admin_Controller { public function index() { - print $this->_get_view(); - } - - public function update() { - access::verify_csrf(); - - $form = $this->_get_form(); - if ($form->validate()) { - module::set_var("digibug", "company_id", $form->group->company_id->value); - module::set_var("digibug", "event_id", $form->group->event_id->value); - message::success(t("Successfully updated Digibug company and event id's")); - - url::redirect("admin/digibug"); - } - - print $this->_get_view($form); - } - - public function default_settings() { - access::verify_csrf(); - - module::set_var("digibug", "company_id", null); - module::set_var("digibug", "event_id", null); - message::success(t("Successfully set Digibug company and event id's to default")); - - url::redirect("admin/digibug"); - } - - private function _get_view($form=null) { $v = new Admin_View("admin.html"); $v->content = new View("admin_digibug.html"); - $v->content->form = empty($form) ? $this->_get_form() : $form; - return $v; - } - - private function _get_form() { - $form = new Forge("admin/digibug/update", "", "post", - array("id" => "gDigibugForm")); - $group = $form->group("group") - ->label(t("Enter your account information.")); - $group->input("company_id") - ->label(t("Company Id")) - ->rules("required") - ->value(module::get_var("digibug", "company_id", "")); - $group->input("event_id") - ->label(t("Event Id")) - ->rules("required") - ->value(module::get_var("digibug", "event_id", "")); - $group->submit("")->value(t("Submit")); - - return $form; + print $v; } } \ No newline at end of file diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 45d3fde4..c1852009 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -20,55 +20,47 @@ class Digibug_Controller extends Controller { public function print_photo($id) { access::verify_csrf(); - $item = ORM::factory("item", $id); - access::required("view_full", $id); - - $proxy = ORM::factory("digibug_proxy"); - $proxy->uuid = md5(rand()); - $proxy->item_id = $item->id; - $proxy->save(); - - $url = url::abs_site("digibug/print_proxy/{$proxy->uuid}"); - $company_id = module::get_var("digibug", "company_id", - module::get_var("digibug", "default_company_id")); - $event_id = module::get_var("digibug", "event_id", - module::get_var("digibug", "default_event_id")); + access::required("view_full", $item); + + if (access::group_can(group::everybody(), "view_full", $item)) { + $full_url = $item->file_url(true); + $thumb_url = $item->thumb_url(true); + } else { + $proxy = ORM::factory("digibug_proxy"); + $proxy->uuid = md5(rand()); + $proxy->item_id = $item->id; + $proxy->save(); + $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid"); + $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid"); + } $v = new View("digibug_form.html"); $v->order_parms = array( "digibug_api_version" => "100", - "company_id" => $company_id, - "event_id" => $event_id, + "company_id" => module::get_var("digibug", "company_id"), + "event_id" => module::get_var("digibug", "event_id"), "cmd" => "addimg", "return_url" => url::abs_site("digibug/close_window"), "num_images" => "1", - "image_1" => $url, - "thumb_1" => "$url/thumb", + "image_1" => $full_url, + "thumb_1" => $thumb_url, "image_height_1" => $item->height, "image_width_1" => $item->width, "thumb_height_1" => $item->thumb_height, "thumb_width_1" => $item->thumb_width, "title_1" => p::clean($item->title)); - Kohana::log("error", Kohana::debug($v->order_parms)); print $v; } - public function print_proxy($id, $thumb=null) { - $proxy = ORM::factory("digibug_proxy") - ->where("uuid", $id) - ->find(); - - if (!$proxy->loaded) { - Kohana::show_404(); - } - - if (!$proxy->item->loaded) { + public function print_proxy($type, $id) { + $proxy = ORM::factory("digibug_proxy", array("uuid", $id)); + if (!$proxy->loaded || !$proxy->item->loaded) { Kohana::show_404(); } - $file = empty($thumb) ? $proxy->item->file_path() : $proxy->item->thumb_path(); + $file = $type == "full" ? $proxy->item->file_path() : $proxy->item->thumb_path(); if (!file_exists($file)) { kohana::show_404(); } @@ -76,8 +68,6 @@ class Digibug_Controller extends Controller { // We don't need to save the session for this request Session::abort_save(); - $this->_clean_expired(); - // Dump out the image header("Content-Type: $proxy->item->mime_type"); Kohana::close_buffers(false); @@ -86,9 +76,11 @@ class Digibug_Controller extends Controller { fclose($fd); // If the request was for the image and not the thumb, then delete the proxy. - if (empty($thumb)) { + if ($type == "full") { $proxy->delete(); } + + $this->_clean_expired(); } public function close_window() { @@ -96,17 +88,9 @@ class Digibug_Controller extends Controller { } private function _clean_expired() { - $expired = ORM::factory("digibug_proxy") - ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)") - ->find_all(); - - // Delete as many as we can in a second, so as to not slow up the request. - $start = microtime(true); - foreach ($expired as $proxy) { - if (microtime(true) - $start > 1.0) { - break; - } - $proxy->delete(); - } + Database::instance()>query( + "DELETE FROM {digibug_proxy} " . + "WHERE request_date <= (CURDATE() - INTERVAL 10 DAY) " . + "LIMIT 20"); } } \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index f1308fd3..1cd78b44 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -21,16 +21,28 @@ class digibug_installer { static function install() { Database::instance() ->query("CREATE TABLE {digibug_proxies} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `uuid` char(32) NOT NULL, - `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp, - `item_id` int(9) NOT NULL, - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + `id` int(9) NOT NULL AUTO_INCREMENT, + `uuid` char(32) NOT NULL, + `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp, + `item_id` int(9) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_var("digibug", "default_company_id", "3153"); - module::set_var("digibug", "default_event_id", "8491"); - module::set_version("digibug", 1); + module::set_var("digibug", "company_id", "3153"); + module::set_var("digibug", "event_id", "8491"); + module::set_version("digibug", 2); + } + + static function upgrade($version) { + if ($version == 1) { + module::clear_var("digibug", "default_company_id"); + module::clear_var("digibug", "default_event_id"); + module::clear_var("digibug", "basic_default_company_id"); + module::clear_var("digibug", "basic_event_id"); + module::set_var("digibug", "company_id", "3153"); + module::set_var("digibug", "event_id", "8491"); + module::set_version("digibug", $version = 2); + } } static function uninstall() { diff --git a/modules/digibug/images/digibug_logo.png b/modules/digibug/images/digibug_logo.png new file mode 100644 index 00000000..5eac2c7d Binary files /dev/null and b/modules/digibug/images/digibug_logo.png differ diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js index 837c8f7f..456dfecb 100644 --- a/modules/digibug/js/digibug.js +++ b/modules/digibug/js/digibug.js @@ -1,26 +1,25 @@ $(document).ready(function() { $(".gDigibugPrintButton a").click(function(e) { e.preventDefault(); - queue_print(e); + return popUp(e.currentTarget.href, { width: 800, height: 600 } ); }); $("#gDigibugLink").click(function(e) { e.preventDefault(); - return queue_print(e); + return popUp(e.currentTarget.href, { width: 800, height: 600 } ); }); }); function popUp(url, options) { options = $.extend({ /* default options */ - width: 400, - height: 400, target: 'dbPopWin', scrollbars: 'yes', resizable: 'no', menuBar: 'no', - addressBar: 'yes'}, options); + addressBar: 'yes' + }, options); - /* center the window by default. */ + // center the window by default. if (!options.winY) { options.winY = screen.height / 2 - options.height / 2; }; @@ -32,19 +31,15 @@ function popUp(url, options) { url, options['target'], 'width= ' + options.width + - ',height=' + options.height + - ',top=' + options.winY + - ',left=' + options.winX + - ',scrollbars=' + options.scrollbars + - ',resizable=' + options.resizable + - ',menubar=' + options.menuBar + - ',location=' + options.addressBar - ); + ',height=' + options.height + + ',top=' + options.winY + + ',left=' + options.winX + + ',scrollbars=' + options.scrollbars + + ',resizable=' + options.resizable + + ',menubar=' + options.menuBar + + ',location=' + options.addressBar + ); return false; } - -function queue_print(e) { - return popUp(e.currentTarget.href, { width: 800, height: 600 } ); -}; diff --git a/modules/digibug/models/digibug_proxy.php b/modules/digibug/models/digibug_proxy.php index c76afdae..036af9c7 100644 --- a/modules/digibug/models/digibug_proxy.php +++ b/modules/digibug/models/digibug_proxy.php @@ -18,5 +18,4 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Digibug_Proxy_Model extends ORM { - protected $has_one = array("item"); } diff --git a/modules/digibug/module.info b/modules/digibug/module.info index 58602c0d..c25a2454 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -1,3 +1,3 @@ name = Digibug description = Digibug Photo Printing Module -version = 1 +version = 2 diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php index 769fd415..7e4436ff 100644 --- a/modules/digibug/views/admin_digibug.html.php +++ b/modules/digibug/views/admin_digibug.html.php @@ -1,21 +1,22 @@ -
+ "> +

- + +

+ +
    +
  • + +
  • +
+ +

+ register with Digibug and enter your Digibug id in the Advanced Settings page you can make money off of your photos!", + array("signup_url" => "http://www.digibug.com/signup.php", + "advanced_settings_url" => url::site("admin/advanced_settings"))) ?>

-
-
-
- -

- -
-
diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php index e18cbc18..c6994cbe 100644 --- a/modules/digibug/views/digibug_form.html.php +++ b/modules/digibug/views/digibug_form.html.php @@ -1,16 +1,11 @@ - - - - + diff --git a/themes/admin_default/css/screen.css b/themes/admin_default/css/screen.css index d66115ef..f4173d4b 100644 --- a/themes/admin_default/css/screen.css +++ b/themes/admin_default/css/screen.css @@ -439,57 +439,3 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { overflow: hidden; } -/** ******************************************************************* - * 8) Digibug Print Administration - **********************************************************************/ -.gAdminDigibugIntro { - background-image: url(../images/digibug_logo.png); - background-repeat: no-repeat; - padding-bottom: 20px; - width: 820px; -} - -.gAdminDigibugIntro p { - font-family: Trebuchet MS,Arial,Verdana,Helvetica,sans-serif; - font-size: 1.3em; - font-weight: bold; - padding-left: 5px; - padding-top: 15px; - text-indent: 110px; -} - -.gDigibugAccount { - width: 820px; - height: 420px; -} - -.gDigibugTab .gDigibugText { - font-size: 12px; - font-weight: bold; - line-height: 17px; - padding-bottom: 15px; -} - -.gDigibugSignIn { - width: 115px; - float: left; -} - -.gDigibugSignIn a { - color: black; - font-size: 16px; - font-weight: bold; - text-decoration: underline; -} - -#gDigibugForm { - float: left; - padding-left: 30px; - width: 220px; -} - -.gDigibugDefault { - clear: none; - float: left; - margin: .3em 1em; -} diff --git a/themes/admin_default/images/digibug_logo.png b/themes/admin_default/images/digibug_logo.png deleted file mode 100644 index 5eac2c7d..00000000 Binary files a/themes/admin_default/images/digibug_logo.png and /dev/null differ -- cgit v1.2.3 From aad0dd357f44c75703e4d6368a1869a83e7ee8a2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Jun 2009 16:27:06 -0700 Subject: Create a new thumb_menu() and convert Digibug over to use it. 1) Eliminate digibug_album.html 2) Get rid of the $(document).ready() in digibug.js and rename popUp() to digibug_popup() then just make direct calls to digibug_popup() in the menu urls. --- modules/digibug/helpers/digibug_menu.php | 26 +++++++++++++++++++------- modules/digibug/helpers/digibug_theme.php | 11 ----------- modules/digibug/js/digibug.js | 15 +++------------ modules/digibug/views/digibug_album.html.php | 8 -------- modules/gallery/helpers/gallery_menu.php | 3 +++ modules/gallery/libraries/Theme_View.php | 10 +++++++--- themes/default/views/album.html.php | 1 + 7 files changed, 33 insertions(+), 41 deletions(-) delete mode 100644 modules/digibug/views/digibug_album.html.php (limited to 'modules/digibug/js/digibug.js') diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php index 6d127d72..4b8db5a2 100644 --- a/modules/digibug/helpers/digibug_menu.php +++ b/modules/digibug/helpers/digibug_menu.php @@ -28,12 +28,24 @@ class digibug_menu { static function photo($menu, $theme) { $item = $theme->item(); - $csrf = access::csrf_token(); - $menu - ->append(Menu::factory("link") - ->id("digibug") - ->label(t("Print with Digibug")) - ->url(url::site("digibug/print_photo/$item->id?csrf=$csrf")) - ->css_id("gDigibugLink")); + $menu->append( + Menu::factory("link") + ->id("digibug") + ->label(t("Print with Digibug")) + ->url("javascript:digibug_popup('" . + url::site("digibug/print_photo/$item->id?csrf=$theme->csrf") . "')") + ->css_id("gDigibugLink")); + } + + static function thumb($menu, $theme, $item) { + if ($item->type == "photo" && access::can("view_full", $item)) { + $menu->append( + Menu::factory("link") + ->id("digibug") + ->label(t("Print with Digibug")) + ->url("javascript:digibug_popup('" . + url::site("digibug/print_photo/$item->id?csrf=$theme->csrf") . "')") + ->css_id("gDigibugLink")); + } } } diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index a8e7e5b2..3b5be3b3 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -21,15 +21,4 @@ class digibug_theme_Core { static function head($theme) { return html::script("modules/digibug/js/digibug.js"); } - - static function thumb_bottom($theme, $child) { - if ($theme->page_type() == "album" && $child->type == "photo" && - access::can("view_full", $child)) { - $v = new View("digibug_album.html"); - $v->id = $child->id; - $v->title = t("Print photo with Digibug"); - return $v->render(); - } - return ""; - } } diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js index 456dfecb..78ca8cf3 100644 --- a/modules/digibug/js/digibug.js +++ b/modules/digibug/js/digibug.js @@ -1,17 +1,8 @@ -$(document).ready(function() { - $(".gDigibugPrintButton a").click(function(e) { - e.preventDefault(); - return popUp(e.currentTarget.href, { width: 800, height: 600 } ); - }); - $("#gDigibugLink").click(function(e) { - e.preventDefault(); - return popUp(e.currentTarget.href, { width: 800, height: 600 } ); - }); -}); - -function popUp(url, options) { +function digibug_popup(url, options) { options = $.extend({ /* default options */ + width: '800', + height: '600', target: 'dbPopWin', scrollbars: 'yes', resizable: 'no', diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php deleted file mode 100644 index 2fd8803b..00000000 --- a/modules/digibug/views/digibug_album.html.php +++ /dev/null @@ -1,8 +0,0 @@ - - diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index a25832fe..1f1e1ce2 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -94,6 +94,9 @@ class gallery_menu_Core { static function tag($menu, $theme) { } + static function thumb($menu, $theme, $item) { + } + static function photo($menu, $theme) { if (access::can("view_full", $theme->item())) { $menu->append(Menu::factory("link") diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 7b2ca840..4612a74b 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -121,16 +121,20 @@ class Theme_View_Core extends View { $this->_menu("photo"); } - private function _menu($type) { + public function thumb_menu($item) { + $this->_menu("thumb", $item); + } + + private function _menu($type, $item=null) { $menu = Menu::factory("root"); - call_user_func_array(array("gallery_menu", $type), array(&$menu, $this)); + call_user_func_array(array("gallery_menu", $type), array(&$menu, $this, $item)); foreach (module::active() as $module) { if ($module->name == "gallery") { continue; } $class = "{$module->name}_menu"; if (method_exists($class, $type)) { - call_user_func_array(array($class, $type), array(&$menu, $this)); + call_user_func_array(array($class, $type), array(&$menu, $this, $item)); } } diff --git a/themes/default/views/album.html.php b/themes/default/views/album.html.php index 7e6913df..46b0d29a 100644 --- a/themes/default/views/album.html.php +++ b/themes/default/views/album.html.php @@ -19,6 +19,7 @@ thumb_img(array("class" => "gThumbnail")) ?> thumb_bottom($child) ?> + thumb_menu($child) ?>

title) ?>