From 39cf3c2b046b03691937e112268403130508da63 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 21 Jun 2009 08:52:26 -0700 Subject: The start of the digibug printing module. The first cut at the administration panels. This is still a work in progress. --- modules/digibug/helpers/digibug_installer.php | 43 +++++++++++++++++++++++++++ modules/digibug/helpers/digibug_menu.php | 42 ++++++++++++++++++++++++++ modules/digibug/helpers/digibug_theme.php | 25 ++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 modules/digibug/helpers/digibug_installer.php create mode 100644 modules/digibug/helpers/digibug_menu.php create mode 100644 modules/digibug/helpers/digibug_theme.php (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php new file mode 100644 index 00000000..90dab990 --- /dev/null +++ b/modules/digibug/helpers/digibug_installer.php @@ -0,0 +1,43 @@ +query("CREATE TABLE {print_proxy} ( + `id` int(9) NOT NULL auto_increment, + `proxy_id` char(55) NOT NULL, + `item_id` int(9), + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + module::set_var("digibug", "basic_company_id", "3153"); + module::set_var("digibug", "basic_event_id", "8491"); + module::set_var("digibug", "mode", "basic"); + + module::set_version("digibug", 1); + } + } + + static function uninstall() { + Database::instance()->query("DROP TABLE IF EXISTS {print_proxy}"); + module::delete("digibug"); + } +} diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php new file mode 100644 index 00000000..3f41bb16 --- /dev/null +++ b/modules/digibug/helpers/digibug_menu.php @@ -0,0 +1,42 @@ +get("settings_menu") + ->append(Menu::factory("link") + ->id("digibug_menu") + ->label(t("Digibug Administration")) + ->url(url::site("admin/digibug"))); + } + + 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"))); + } + } +} diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php new file mode 100644 index 00000000..06d656c8 --- /dev/null +++ b/modules/digibug/helpers/digibug_theme.php @@ -0,0 +1,25 @@ +"; + } +} -- cgit v1.2.3 From f981484a8051c0d5d05dae55882aefdb7094403a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 05:52:47 -0700 Subject: Add a digibug printing button to the quick pane --- modules/digibug/helpers/digibug_quick.php | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/digibug/helpers/digibug_quick.php (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/helpers/digibug_quick.php b/modules/digibug/helpers/digibug_quick.php new file mode 100644 index 00000000..dce0c519 --- /dev/null +++ b/modules/digibug/helpers/digibug_quick.php @@ -0,0 +1,34 @@ +type == "photo") { + $csrf = access::csrf_token(); + $elements["center"][] = (object)array( + "title" => t("Print photo with Digibug"), + "class" => "gButtonLink", + "icon" => "ui-icon-print", + "href" => url::site("digibug/print/$item->id?csrf=$csrf")); + } + + return $elements; + } +} -- cgit v1.2.3 From 05f8659a7ffa35cb1458c69e4db1196aa384fff0 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 06:03:55 -0700 Subject: Fix preamble so tests pass --- modules/digibug/controllers/admin_digibug.php | 3 ++- modules/digibug/controllers/digibug.php | 5 +++-- modules/digibug/helpers/digibug_installer.php | 3 ++- modules/digibug/helpers/digibug_menu.php | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php index 86338f6b..8263fc83 100644 --- a/modules/digibug/controllers/admin_digibug.php +++ b/modules/digibug/controllers/admin_digibug.php @@ -1,4 +1,5 @@ - $form->__toString())); } } - + private function _get_form() { $form = new Forge("digibug/handler", "", "post", array("id" => "gDigibugForm")); diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 90dab990..33b5107b 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -1,4 +1,5 @@ -label(t("Digibug Administration")) ->url(url::site("admin/digibug"))); } - + static function photo($menu, $theme) { } - + static function site($menu, $theme) { $item = $theme->item(); -- cgit v1.2.3 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/controllers/digibug.php | 64 ++++++++++++++++++--------- modules/digibug/css/digibug.css | 3 ++ modules/digibug/helpers/digibug.php | 57 ++++++++++++++++++++++++ modules/digibug/helpers/digibug_installer.php | 6 +-- modules/digibug/helpers/digibug_quick.php | 34 -------------- modules/digibug/helpers/digibug_theme.php | 23 ++++++++++ modules/digibug/js/digibug.js | 24 ++++++++++ modules/digibug/models/proxy.php | 22 +++++++++ 8 files changed, 175 insertions(+), 58 deletions(-) create mode 100644 modules/digibug/helpers/digibug.php delete mode 100644 modules/digibug/helpers/digibug_quick.php create mode 100644 modules/digibug/js/digibug.js create mode 100644 modules/digibug/models/proxy.php (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index f2f3d6cd..f90b88e2 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -18,35 +18,57 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Digibug_Controller extends Controller { - public function index() { - print $this->_get_form(); - } - - public function handler() { + public function print_photo($id) { access::verify_csrf(); - $form = $this->_get_form(); - if ($form->validate()) { - // @todo process the admin form + $item = ORM::factory("item", $id); - message::success(t("Digibug Processing Successfully")); + $proxy = ORM::factory("proxy"); + $proxy->uuid = digibug::uuid(); + $proxy->item_id = $item->id; + $proxy->save(); - print json_encode( - array("result" => "success")); + $url = url::abs_site("digibug/print_proxy/{$proxy->uuid}"); + if (module::get_var("digibug", "mode", "basic")) { + $company_id = module::get_var("digibug", "basic_company_id"); + $event_id = module::get_var("digibug", "basic_event_id"); } else { - print json_encode( - array("result" => "error", - "form" => $form->__toString())); + $company_id = module::get_var("digibug", "company_id"); + $event_id = module::get_var("digibug", "event_id"); } + $digibug_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")), + "num_images" => "1", + "image_1" => $url, + "thumb_1" => "$url/thumb", + "image_height_1" => $item->height, + "image_width_1" => $item->width, + "thumb_height_1" => $item->thumb_height, + "thumb_width_1" => $item->thumb_width, + "title" => $item->title); + + Kohana::log("error", Kohana::debug($digibug_parms)); + + message::success( + t("Photo '%title' was submitted for printing.", array("title" => $item->title))); + print json_encode(array("result" => "success", "reload" => 1)); } - private function _get_form() { - $form = new Forge("digibug/handler", "", "post", - array("id" => "gDigibugForm")); - $group = $form->group("group")->label(t("Digibug Handler")); - $group->input("text")->label(t("Text"))->rules("required"); - $group->submit("submit")->value(t("Submit")); + public function print_proxy($id, $thumb=null) { + + // We don't need to save the session for this request + Session::abort_save(); - return $form; + // Dump out the image + header("Content-Type: $item->mime_type"); + Kohana::close_buffers(false); + $fd = fopen($file, "rb"); + fpassthru($fd); + fclose($fd); } + } \ No newline at end of file diff --git a/modules/digibug/css/digibug.css b/modules/digibug/css/digibug.css index f5cd6717..a09e4551 100644 --- a/modules/digibug/css/digibug.css +++ b/modules/digibug/css/digibug.css @@ -84,5 +84,8 @@ width: 180px; } +.gDigibugPrintButton { + float: left; +} diff --git a/modules/digibug/helpers/digibug.php b/modules/digibug/helpers/digibug.php new file mode 100644 index 00000000..46c9d945 --- /dev/null +++ b/modules/digibug/helpers/digibug.php @@ -0,0 +1,57 @@ +> 4; + $time_hi_and_version = $time_hi_and_version | 0x4000; + + /** + * Set the two most significant bits (bits 6 and 7) of the + * clock_seq_hi_and_reserved to zero and one, respectively. + */ + $clock_seq_hi_and_reserved = hexdec ( $clock_seq_hi_and_reserved ); + $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2; + $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000; + + return sprintf ('%08s-%04s-%04x-%04x-%012s', + $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node); + } +} diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 33b5107b..73645eb7 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -22,9 +22,9 @@ class digibug_installer { $version = module::get_version("digibug"); if ($version == 0) { Database::instance() - ->query("CREATE TABLE {print_proxy} ( + ->query("CREATE TABLE {proxies} ( `id` int(9) NOT NULL auto_increment, - `proxy_id` char(55) NOT NULL, + `uuid` char(32) NOT NULL, `item_id` int(9), PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); @@ -38,7 +38,7 @@ class digibug_installer { } static function uninstall() { - Database::instance()->query("DROP TABLE IF EXISTS {print_proxy}"); + Database::instance()->query("DROP TABLE IF EXISTS {proxys}"); module::delete("digibug"); } } diff --git a/modules/digibug/helpers/digibug_quick.php b/modules/digibug/helpers/digibug_quick.php deleted file mode 100644 index dce0c519..00000000 --- a/modules/digibug/helpers/digibug_quick.php +++ /dev/null @@ -1,34 +0,0 @@ -type == "photo") { - $csrf = access::csrf_token(); - $elements["center"][] = (object)array( - "title" => t("Print photo with Digibug"), - "class" => "gButtonLink", - "icon" => "ui-icon-print", - "href" => url::site("digibug/print/$item->id?csrf=$csrf")); - } - - return $elements; - } -} diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 06d656c8..2e44b115 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -18,8 +18,31 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class digibug_theme_Core { + static function head($theme) { + $head[] = ""; + $head[] = html::script("modules/digibug/js/digibug.js");; + return implode("\n", $head); + } + static function admin_head($theme) { return ""; } + + static function thumb_bottom($theme, $child) { + if ($theme->page_type() == "album" && $child->type == "photo") { + $csrf = access::csrf_token(); + $return = "album/{$child->parent()->id}"; + $href = url::site("digibug/print_photo/$child->id?csrf={$csrf}&return=$return"); + $title = t("Print photo with Digibug"); + return ""; + } + return ""; + } } 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(); + } + } + }); +}; diff --git a/modules/digibug/models/proxy.php b/modules/digibug/models/proxy.php new file mode 100644 index 00000000..ce10c592 --- /dev/null +++ b/modules/digibug/models/proxy.php @@ -0,0 +1,22 @@ + Date: Tue, 23 Jun 2009 06:06:33 -0700 Subject: This change implements the print_proxy method. This method allows a 1 time security bypass for the remote print processor to retrieve the fullsize image. --- modules/digibug/controllers/digibug.php | 25 ++++++++++++++++++++++--- modules/digibug/helpers/digibug_theme.php | 15 +++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index f90b88e2..b0807aa5 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -51,24 +51,43 @@ class Digibug_Controller extends Controller { "thumb_width_1" => $item->thumb_width, "title" => $item->title); - Kohana::log("error", Kohana::debug($digibug_parms)); - message::success( t("Photo '%title' was submitted for printing.", array("title" => $item->title))); print json_encode(array("result" => "success", "reload" => 1)); } public function print_proxy($id, $thumb=null) { + $proxy = ORM::factory("proxy") + ->where("uuid", $id) + ->find(); + + if (!$proxy->loaded) { + Kohana::show_404(); + } + + if (!$proxy->item->loaded) { + Kohana::show_404(); + } + + $file = empty($thumb) ? $proxy->item->file_path() : $proxy->item->thumb_path(); + if (!file_exists($file)) { + kohana::show_404(); + } // We don't need to save the session for this request Session::abort_save(); // Dump out the image - header("Content-Type: $item->mime_type"); + header("Content-Type: $proxy->item->mime_type"); Kohana::close_buffers(false); $fd = fopen($file, "rb"); fpassthru($fd); fclose($fd); + + // If the request was for the image and not the thumb, then delete the proxy. + if (empty($thumb)) { + $proxy->delete(); + } } } \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 2e44b115..0fe2ce2e 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -32,16 +32,11 @@ class digibug_theme_Core { static function thumb_bottom($theme, $child) { if ($theme->page_type() == "album" && $child->type == "photo") { - $csrf = access::csrf_token(); - $return = "album/{$child->parent()->id}"; - $href = url::site("digibug/print_photo/$child->id?csrf={$csrf}&return=$return"); - $title = t("Print photo with Digibug"); - return ""; + $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(); } return ""; } -- 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/helpers') 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 0062f8a24a62fe8f5abdffcea8c35382afa32244 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 24 Jun 2009 05:47:58 -0700 Subject: Add a timestamp column to the proxies table. --- modules/digibug/helpers/digibug_installer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 0476e2cc..baff2075 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -23,9 +23,10 @@ class digibug_installer { if ($version == 0) { Database::instance() ->query("CREATE TABLE {proxies} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `uuid` char(36) NOT NULL, - `item_id` int(9), + `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp, + `item_id` int(9) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); @@ -38,7 +39,7 @@ class digibug_installer { } static function uninstall() { - Database::instance()->query("DROP TABLE IF EXISTS {proxys}"); + Database::instance()->query("DROP TABLE IF EXISTS {proxies}"); module::delete("digibug"); } } -- cgit v1.2.3 From 40e27e128e34601380079a02dca9346aed54c3bf Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 24 Jun 2009 13:11:53 -0700 Subject: Create a maintenance task that allows the administrator to remove any proxy requests that are still active after 10 days. Digibug requires that the image be available for 5 days, so we'll give them an extra 5 days. Also correct a few issues with the protocol. --- modules/digibug/controllers/digibug.php | 4 +- modules/digibug/helpers/digibug_task.php | 68 ++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 modules/digibug/helpers/digibug_task.php (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 609da875..3a427149 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -41,7 +41,7 @@ class Digibug_Controller extends Controller { "digibug_api_version" => "100", "company_id" => $company_id, "event_id" => $event_id, - "cmd" => "adding", + "cmd" => "addimg", "return_url" => url::abs_site("digibug/close_window"), "num_images" => "1", "image_1" => $url, @@ -50,7 +50,7 @@ class Digibug_Controller extends Controller { "image_width_1" => $item->width, "thumb_height_1" => $item->thumb_height, "thumb_width_1" => $item->thumb_width, - "title" => $item->title); + "title_1" => $item->title); print $v; } diff --git a/modules/digibug/helpers/digibug_task.php b/modules/digibug/helpers/digibug_task.php new file mode 100644 index 00000000..98f79731 --- /dev/null +++ b/modules/digibug/helpers/digibug_task.php @@ -0,0 +1,68 @@ +query( + "SELECT count(*) as print_requests + FROM {proxies} + WHERE `request_date` <= (CURDATE() - INTERVAL 10 DAY)")->current()->print_requests; + + return array(Task_Definition::factory() + ->callback("digibug_task::remove_expired") + ->name(t("Remove Digibug print requests")) + ->description($expired_request_count + ? t2("1 Digibug print request has expired", + "%count Digibug print requests have expired", + $expired_request_count) + : t("All print requests are current")) + ->severity($expired_request_count ? log::WARNING : log::SUCCESS)); + } + + static function remove_expired($task) { + $completed = $task->get("completed", 0); + $expired = ORM::factory("proxy") + ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)") + ->find_all(); + $remaining = $expired->count(); + + $start = microtime(true); + foreach ($expired as $proxy) { + if (microtime(true) - $start > 1.5) { + break; + } + $proxy->delete(); + $completed++; + $remaining--; + } + + if ($completed + $remaining > 0) { + $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); + } else { + $task->percent_complete = 100; + } + + $task->set("completed", $completed); + if ($remaining == 0) { + $task->done = true; + $task->state = "success"; + } + } +} -- 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/helpers') 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 d9e4ad79bbebb3f439df4403c668271c86c19935 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 08:14:34 -0700 Subject: 1) Move the digibug css in the default and admin_default themes 2) Remove most of the marketing cruft on the admin pages 3) Change the name of the admin settings to just Digibug 4) Remove the "switch on mouseover" approach --- modules/digibug/css/digibug.css | 91 -------------------------- modules/digibug/css/logo.png | Bin 17296 -> 0 bytes modules/digibug/helpers/digibug_menu.php | 2 +- modules/digibug/helpers/digibug_theme.php | 10 +-- modules/digibug/views/admin_digibug.html.php | 33 ++-------- themes/admin_default/css/screen.css | 93 +++++++++++++++++++++++++++ themes/admin_default/images/digibug_logo.png | Bin 0 -> 17296 bytes themes/default/css/screen.css | 25 ++++--- 8 files changed, 115 insertions(+), 139 deletions(-) delete mode 100644 modules/digibug/css/digibug.css delete mode 100644 modules/digibug/css/logo.png create mode 100644 themes/admin_default/images/digibug_logo.png (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/css/digibug.css b/modules/digibug/css/digibug.css deleted file mode 100644 index a09e4551..00000000 --- a/modules/digibug/css/digibug.css +++ /dev/null @@ -1,91 +0,0 @@ -.gAdminDigibugIntro { - background-image: url(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: 110px; - padding-top: 15px; -} - -.gDigibugTab { - width: 820px; - height: 420px; -} - -.gDigibugTab .gDigibugTitle { - font-family: Georgia; - font-size: 20px; - font-weight: bold; - padding-bottom: 10px; -} - -.gDigibugTab .gDigibugText { - font-size: 12px; - font-weight: bold; - line-height: 17px; - padding-bottom: 15px; -} - -.gDigibugListItems ul { - list-style-type: disc; - padding-left: 20px; - font-size: 12px; - font-weight: bold; - line-height: 15px; -} - -.gDigibugListItems ul li{ - padding-top: 10px; -} - -.gDigibugRounded { - background-color:#5C9CCC; - color: white; - width: 308px; - height: 45px; - text-align: center; - line-height: 15px; - margin-top: 10px; - font-weight: bold; - font-size: 12px; - margin-left: 60px; - margin-right: -50px; - margin-left: 20px; - margin-right: 0px; -} - -.gDigibugRounded a { - color: white !important; - font-weight: bold; - text-decoration: underline; -} - -.gDigibugSignIn { - width: 115px; - float: left; -} - -.gDigibugSignIn a { - color: black; - font-size: 16px; - font-weight: bold; - text-decoration: underline; -} - -.gDigibugAdvancedForm { - float: left; - padding-left: 30px; - width: 180px; -} - -.gDigibugPrintButton { - float: left; -} - - diff --git a/modules/digibug/css/logo.png b/modules/digibug/css/logo.png deleted file mode 100644 index 5eac2c7d..00000000 Binary files a/modules/digibug/css/logo.png and /dev/null differ diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php index 6c466031..d9baf59c 100644 --- a/modules/digibug/helpers/digibug_menu.php +++ b/modules/digibug/helpers/digibug_menu.php @@ -22,7 +22,7 @@ class digibug_menu { $menu->get("settings_menu") ->append(Menu::factory("link") ->id("digibug_menu") - ->label(t("Digibug Administration")) + ->label(t("Digibug")) ->url(url::site("admin/digibug"))); } diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index e52fcc7f..bd269256 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -19,15 +19,7 @@ */ class digibug_theme_Core { static function head($theme) { - $head[] = ""; - $head[] = html::script("modules/digibug/js/digibug.js");; - return implode("\n", $head); - } - - static function admin_head($theme) { - return ""; + return html::script("modules/digibug/js/digibug.js"); } static function thumb_bottom($theme, $child) { diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php index 33ce5f83..205d8b7a 100644 --- a/modules/digibug/views/admin_digibug.html.php +++ b/modules/digibug/views/admin_digibug.html.php @@ -1,16 +1,13 @@
-

- +

@@ -19,20 +16,8 @@
  • -
    - -
    - -
    - -
    -
    -
      -
    • -
    • -
    • -
    +

    @@ -45,16 +30,8 @@
    -
    - -
    - -
    -
    - -
    - +
    @@ -62,7 +39,7 @@
    -
    +
    diff --git a/themes/admin_default/css/screen.css b/themes/admin_default/css/screen.css index 862f1fc1..1653f115 100644 --- a/themes/admin_default/css/screen.css +++ b/themes/admin_default/css/screen.css @@ -9,6 +9,8 @@ * 4) Content blocks in specific layout containers * 5) Browser hacks * 6) jQuery and jQuery UI + * 7) Server Add + * 8) Digibug Print Administration */ /** ******************************************************************* @@ -436,3 +438,94 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { width: 150px; 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; +} + +.gDigibugTab { + width: 820px; + height: 420px; +} + +.gDigibugTab .gDigibugTitle { + font-family: Georgia; + font-size: 20px; + font-weight: bold; + padding-bottom: 10px; +} + +.gDigibugTab .gDigibugText { + font-size: 12px; + font-weight: bold; + line-height: 17px; + padding-bottom: 15px; +} + +.gDigibugListItems ul { + list-style-type: disc; + padding-left: 20px; + font-size: 12px; + font-weight: bold; + line-height: 15px; +} + +.gDigibugListItems ul li{ + padding-top: 10px; +} + +.gDigibugRounded { + background-color:#5C9CCC; + color: white; + width: 308px; + height: 45px; + text-align: center; + line-height: 15px; + margin-top: 10px; + font-weight: bold; + font-size: 12px; + margin-left: 60px; + margin-right: -50px; + margin-left: 20px; + margin-right: 0px; +} + +.gDigibugRounded a { + color: white !important; + font-weight: bold; + text-decoration: underline; +} + +.gDigibugSignIn { + width: 115px; + float: left; +} + +.gDigibugSignIn a { + color: black; + font-size: 16px; + font-weight: bold; + text-decoration: underline; +} + +.gDigibugAdvancedForm { + float: left; + padding-left: 30px; + width: 180px; +} + diff --git a/themes/admin_default/images/digibug_logo.png b/themes/admin_default/images/digibug_logo.png new file mode 100644 index 00000000..5eac2c7d Binary files /dev/null and b/themes/admin_default/images/digibug_logo.png differ diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index c7918fc0..671b259d 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -4,15 +4,16 @@ * @requires YUI reset, font, grids CSS * * Sheet organization: - * 1) Basic HTML elements - * 2) Reusable classes - * 3) Reusable content blocks - * 4) Page layout containers - * 5) Content blocks in specific layout containers - * 6) Navigation and menus - * 7) Browser hacks - * 8) jQuery and jQuery UI - * 9) Right-to-left language styles + * 1) Basic HTML elements + * 2) Reusable classes + * 3) Reusable content blocks + * 4) Page layout containers + * 5) Content blocks in specific layout containers + * 6) Navigation and menus + * 7) Browser hacks + * 8) jQuery and jQuery UI + * 9) Right-to-left language styles + * 10) Digibug Print */ /** ******************************************************************* @@ -1049,4 +1050,8 @@ form .gError, .rtl .gButtonSet li, .rtl .ui-icon-left .ui-icon { float: right; -} \ No newline at end of file +} + +/** ******************************************************************* + * 10) Digibug Print + **********************************************************************/ -- cgit v1.2.3 From 4502a13a5b67946e798789ff5420877391372fcd Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 08:47:16 -0700 Subject: 1) rename the model proxy to digibug proxy 2) corresponding table name change to digibug_proxies 3) change the generate of a unique id to md5(rand()) 3) Remove the helper function as digibug::uuid is no longer required. --- modules/digibug/controllers/digibug.php | 6 +-- modules/digibug/helpers/digibug.php | 57 --------------------------- modules/digibug/helpers/digibug_installer.php | 6 +-- modules/digibug/helpers/digibug_task.php | 4 +- modules/digibug/models/digibug_proxy.php | 22 +++++++++++ modules/digibug/models/proxy.php | 22 ----------- 6 files changed, 30 insertions(+), 87 deletions(-) delete mode 100644 modules/digibug/helpers/digibug.php create mode 100644 modules/digibug/models/digibug_proxy.php delete mode 100644 modules/digibug/models/proxy.php (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 3a427149..72b57242 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -23,8 +23,8 @@ class Digibug_Controller extends Controller { $item = ORM::factory("item", $id); - $proxy = ORM::factory("proxy"); - $proxy->uuid = digibug::uuid(); + $proxy = ORM::factory("digibug_proxy"); + $proxy->uuid = md5(rand()); $proxy->item_id = $item->id; $proxy->save(); @@ -56,7 +56,7 @@ class Digibug_Controller extends Controller { } public function print_proxy($id, $thumb=null) { - $proxy = ORM::factory("proxy") + $proxy = ORM::factory("digibug_proxy") ->where("uuid", $id) ->find(); diff --git a/modules/digibug/helpers/digibug.php b/modules/digibug/helpers/digibug.php deleted file mode 100644 index 46c9d945..00000000 --- a/modules/digibug/helpers/digibug.php +++ /dev/null @@ -1,57 +0,0 @@ -> 4; - $time_hi_and_version = $time_hi_and_version | 0x4000; - - /** - * Set the two most significant bits (bits 6 and 7) of the - * clock_seq_hi_and_reserved to zero and one, respectively. - */ - $clock_seq_hi_and_reserved = hexdec ( $clock_seq_hi_and_reserved ); - $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2; - $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000; - - return sprintf ('%08s-%04s-%04x-%04x-%012s', - $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node); - } -} diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index baff2075..120bd3ef 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -22,9 +22,9 @@ class digibug_installer { $version = module::get_version("digibug"); if ($version == 0) { Database::instance() - ->query("CREATE TABLE {proxies} ( + ->query("CREATE TABLE {digibug_proxies} ( `id` int(9) NOT NULL AUTO_INCREMENT, - `uuid` char(36) NOT NULL, + `uuid` char(32) NOT NULL, `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp, `item_id` int(9) NOT NULL, PRIMARY KEY (`id`)) @@ -39,7 +39,7 @@ class digibug_installer { } static function uninstall() { - Database::instance()->query("DROP TABLE IF EXISTS {proxies}"); + Database::instance()->query("DROP TABLE IF EXISTS {digibug_proxies}"); module::delete("digibug"); } } diff --git a/modules/digibug/helpers/digibug_task.php b/modules/digibug/helpers/digibug_task.php index 98f79731..08cd6feb 100644 --- a/modules/digibug/helpers/digibug_task.php +++ b/modules/digibug/helpers/digibug_task.php @@ -22,7 +22,7 @@ class digibug_task_Core { // Delete extra exif_records $expired_request_count = Database::instance()->query( "SELECT count(*) as print_requests - FROM {proxies} + FROM {digibug_proxies} WHERE `request_date` <= (CURDATE() - INTERVAL 10 DAY)")->current()->print_requests; return array(Task_Definition::factory() @@ -38,7 +38,7 @@ class digibug_task_Core { static function remove_expired($task) { $completed = $task->get("completed", 0); - $expired = ORM::factory("proxy") + $expired = ORM::factory("digibug_proxy") ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)") ->find_all(); $remaining = $expired->count(); diff --git a/modules/digibug/models/digibug_proxy.php b/modules/digibug/models/digibug_proxy.php new file mode 100644 index 00000000..c76afdae --- /dev/null +++ b/modules/digibug/models/digibug_proxy.php @@ -0,0 +1,22 @@ + Date: Thu, 25 Jun 2009 18:35:02 -0700 Subject: Refactor the digibug installer to the new structure of install and upgrade methods --- modules/digibug/helpers/digibug_installer.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 120bd3ef..83b58351 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -19,10 +19,8 @@ */ class digibug_installer { static function install() { - $version = module::get_version("digibug"); - if ($version == 0) { - Database::instance() - ->query("CREATE TABLE {digibug_proxies} ( + 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, @@ -30,12 +28,14 @@ class digibug_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_var("digibug", "basic_company_id", "3153"); - module::set_var("digibug", "basic_event_id", "8491"); - module::set_var("digibug", "mode", "basic"); + module::set_var("digibug", "basic_company_id", "3153"); + module::set_var("digibug", "basic_event_id", "8491"); + module::set_var("digibug", "mode", "basic"); - module::set_version("digibug", 1); - } + module::set_version("digibug", 1); + } + + static function upgrade($version) { } static function uninstall() { -- cgit v1.2.3 From 5d4d87e957068b54e2b12abcea5c74bb4f3c012c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 19:58:14 -0700 Subject: Remove the digibug maintenance task. Expired imges will be removed when the print_proxy is run. --- modules/digibug/controllers/digibug.php | 17 ++++++++ modules/digibug/helpers/digibug_task.php | 68 -------------------------------- 2 files changed, 17 insertions(+), 68 deletions(-) delete mode 100644 modules/digibug/helpers/digibug_task.php (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 72b57242..25a9912a 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -76,6 +76,8 @@ 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); @@ -92,4 +94,19 @@ class Digibug_Controller extends Controller { public function close_window() { print ""; } + + 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(); + } + } } \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_task.php b/modules/digibug/helpers/digibug_task.php deleted file mode 100644 index 08cd6feb..00000000 --- a/modules/digibug/helpers/digibug_task.php +++ /dev/null @@ -1,68 +0,0 @@ -query( - "SELECT count(*) as print_requests - FROM {digibug_proxies} - WHERE `request_date` <= (CURDATE() - INTERVAL 10 DAY)")->current()->print_requests; - - return array(Task_Definition::factory() - ->callback("digibug_task::remove_expired") - ->name(t("Remove Digibug print requests")) - ->description($expired_request_count - ? t2("1 Digibug print request has expired", - "%count Digibug print requests have expired", - $expired_request_count) - : t("All print requests are current")) - ->severity($expired_request_count ? log::WARNING : log::SUCCESS)); - } - - static function remove_expired($task) { - $completed = $task->get("completed", 0); - $expired = ORM::factory("digibug_proxy") - ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)") - ->find_all(); - $remaining = $expired->count(); - - $start = microtime(true); - foreach ($expired as $proxy) { - if (microtime(true) - $start > 1.5) { - break; - } - $proxy->delete(); - $completed++; - $remaining--; - } - - if ($completed + $remaining > 0) { - $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); - } else { - $task->percent_complete = 100; - } - - $task->set("completed", $completed); - if ($remaining == 0) { - $task->done = true; - $task->state = "success"; - } - } -} -- cgit v1.2.3 From e2e1aa06834125f10e03f929a41e527ec7c2f8ea Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 21:41:54 -0700 Subject: 1) Rename the basic_company_id and basic_event_id to default_*_id 2) Removed the tabs on the digibug admin page word count is now at 35. 3) Added a default link which resets the event and company id's to gallery's ids --- modules/digibug/controllers/admin_digibug.php | 34 +++++++++--------- modules/digibug/controllers/digibug.php | 14 ++++---- modules/digibug/helpers/digibug_installer.php | 4 +-- themes/admin_default/css/screen.css | 52 +++++---------------------- 4 files changed, 33 insertions(+), 71 deletions(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php index 8263fc83..9b75cb11 100644 --- a/modules/digibug/controllers/admin_digibug.php +++ b/modules/digibug/controllers/admin_digibug.php @@ -22,24 +22,14 @@ class Admin_Digibug_Controller extends Admin_Controller { print $this->_get_view(); } - public function basic() { - access::verify_csrf(); - - module::set_var("digibug", "mode", "basic"); - message::success(t("Successfully set Digibug mode to basic")); - - url::redirect("admin/digibug"); - } - - public function advanced() { + 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); - module::set_var("digibug", "mode", "advanced"); - message::success(t("Successfully set Digibug mode to advanced")); + message::success(t("Successfully updated Digibug company and event id's")); url::redirect("admin/digibug"); } @@ -47,18 +37,28 @@ class Admin_Digibug_Controller extends Admin_Controller { print $this->_get_view($form); } + public function default_settings() { + access::verify_csrf(); + + module::set_var("digibug", "company_id", module::get_var("digibug", "default_company_id")); + module::set_var("digibug", "event_id", module::get_var("digibug", "default_event_id")); + 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->mode = module::get_var("digibug", "mode", "basic"); $v->content->form = empty($form) ? $this->_get_form() : $form; return $v; } private function _get_form() { - $form = new Forge("admin/digibug/advanced", "", "post", - array("id" => "gAdminForm")); - $group = $form->group("group"); + $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") @@ -67,7 +67,7 @@ class Admin_Digibug_Controller extends Admin_Controller { ->label(t("Event Id")) ->rules("required") ->value(module::get_var("digibug", "event_id", "")); - $group->submit("submit")->value(t("Submit")); + $group->submit("")->value(t("Submit")); return $form; } diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 25a9912a..6900c65a 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -29,13 +29,11 @@ class Digibug_Controller extends Controller { $proxy->save(); $url = url::abs_site("digibug/print_proxy/{$proxy->uuid}"); - if (module::get_var("digibug", "mode", "basic")) { - $company_id = module::get_var("digibug", "basic_company_id"); - $event_id = module::get_var("digibug", "basic_event_id"); - } else { - $company_id = module::get_var("digibug", "company_id"); - $event_id = module::get_var("digibug", "event_id"); - } + $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")); + $v = new View("digibug_form.html"); $v->order_parms = array( "digibug_api_version" => "100", @@ -50,7 +48,7 @@ class Digibug_Controller extends Controller { "image_width_1" => $item->width, "thumb_height_1" => $item->thumb_height, "thumb_width_1" => $item->thumb_width, - "title_1" => $item->title); + "title_1" => p::clean($item->title)); print $v; } diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 83b58351..be2b8a6b 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -28,8 +28,8 @@ class digibug_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_var("digibug", "basic_company_id", "3153"); - module::set_var("digibug", "basic_event_id", "8491"); + module::set_var("digibug", "default_company_id", "3153"); + module::set_var("digibug", "default_event_id", "8491"); module::set_var("digibug", "mode", "basic"); module::set_version("digibug", 1); diff --git a/themes/admin_default/css/screen.css b/themes/admin_default/css/screen.css index 1653f115..d66115ef 100644 --- a/themes/admin_default/css/screen.css +++ b/themes/admin_default/css/screen.css @@ -458,18 +458,11 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { text-indent: 110px; } -.gDigibugTab { +.gDigibugAccount { width: 820px; height: 420px; } -.gDigibugTab .gDigibugTitle { - font-family: Georgia; - font-size: 20px; - font-weight: bold; - padding-bottom: 10px; -} - .gDigibugTab .gDigibugText { font-size: 12px; font-weight: bold; @@ -477,40 +470,6 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { padding-bottom: 15px; } -.gDigibugListItems ul { - list-style-type: disc; - padding-left: 20px; - font-size: 12px; - font-weight: bold; - line-height: 15px; -} - -.gDigibugListItems ul li{ - padding-top: 10px; -} - -.gDigibugRounded { - background-color:#5C9CCC; - color: white; - width: 308px; - height: 45px; - text-align: center; - line-height: 15px; - margin-top: 10px; - font-weight: bold; - font-size: 12px; - margin-left: 60px; - margin-right: -50px; - margin-left: 20px; - margin-right: 0px; -} - -.gDigibugRounded a { - color: white !important; - font-weight: bold; - text-decoration: underline; -} - .gDigibugSignIn { width: 115px; float: left; @@ -523,9 +482,14 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { text-decoration: underline; } -.gDigibugAdvancedForm { +#gDigibugForm { float: left; padding-left: 30px; - width: 180px; + width: 220px; } +.gDigibugDefault { + clear: none; + float: left; + margin: .3em 1em; +} -- cgit v1.2.3 From eee8dbe511a86967cc27d93c26718253b301bec6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 21:53:47 -0700 Subject: No longer need to set the digibug mode in the installer. --- modules/digibug/helpers/digibug_installer.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index be2b8a6b..3947f2c3 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -30,7 +30,6 @@ class digibug_installer { module::set_var("digibug", "default_company_id", "3153"); module::set_var("digibug", "default_event_id", "8491"); - module::set_var("digibug", "mode", "basic"); module::set_version("digibug", 1); } -- cgit v1.2.3 From 3ab6f2ed4bc1bf1e46174e273e18b2174e5b6ee2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Jun 2009 14:35:16 -0700 Subject: Remove unnecessary curly braces. --- modules/digibug/helpers/digibug_menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php index d9baf59c..6d127d72 100644 --- a/modules/digibug/helpers/digibug_menu.php +++ b/modules/digibug/helpers/digibug_menu.php @@ -33,7 +33,7 @@ class digibug_menu { ->append(Menu::factory("link") ->id("digibug") ->label(t("Print with Digibug")) - ->url(url::site("digibug/print_photo/{$item->id}?csrf={$csrf}")) + ->url(url::site("digibug/print_photo/$item->id?csrf=$csrf")) ->css_id("gDigibugLink")); } } -- cgit v1.2.3 From 6a8dc91f9f1f31657ca67d920283e534de15fa0f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Jun 2009 14:35:53 -0700 Subject: Remove empty upgrade(). --- modules/digibug/helpers/digibug_installer.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php index 3947f2c3..f1308fd3 100644 --- a/modules/digibug/helpers/digibug_installer.php +++ b/modules/digibug/helpers/digibug_installer.php @@ -30,13 +30,9 @@ class digibug_installer { module::set_var("digibug", "default_company_id", "3153"); module::set_var("digibug", "default_event_id", "8491"); - module::set_version("digibug", 1); } - static function upgrade($version) { - } - static function uninstall() { Database::instance()->query("DROP TABLE IF EXISTS {digibug_proxies}"); module::delete("digibug"); -- cgit v1.2.3 From f98b7dc631afc4da595aa149b21b5d38f41afd22 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Jun 2009 14:43:40 -0700 Subject: Require view_full to print photos. --- modules/digibug/controllers/digibug.php | 1 + modules/digibug/helpers/digibug_theme.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/digibug/helpers') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 7bec4b86..45d3fde4 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -22,6 +22,7 @@ class Digibug_Controller extends Controller { access::verify_csrf(); $item = ORM::factory("item", $id); + access::required("view_full", $id); $proxy = ORM::factory("digibug_proxy"); $proxy->uuid = md5(rand()); diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index bd269256..a8e7e5b2 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -23,7 +23,8 @@ class digibug_theme_Core { } static function thumb_bottom($theme, $child) { - if ($theme->page_type() == "album" && $child->type == "photo") { + 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"); -- 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/helpers') 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/helpers') 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) ?>