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/controllers/admin_digibug.php | 73 +++++++++++++++++++++ modules/digibug/controllers/digibug.php | 51 +++++++++++++++ modules/digibug/css/digibug.css | 88 ++++++++++++++++++++++++++ modules/digibug/css/logo.png | Bin 0 -> 17296 bytes modules/digibug/helpers/digibug_installer.php | 43 +++++++++++++ modules/digibug/helpers/digibug_menu.php | 42 ++++++++++++ modules/digibug/helpers/digibug_theme.php | 25 ++++++++ modules/digibug/module.info | 3 + modules/digibug/views/admin_digibug.html.php | 70 ++++++++++++++++++++ 9 files changed, 395 insertions(+) create mode 100644 modules/digibug/controllers/admin_digibug.php create mode 100644 modules/digibug/controllers/digibug.php create mode 100644 modules/digibug/css/digibug.css create mode 100644 modules/digibug/css/logo.png 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 create mode 100644 modules/digibug/module.info create mode 100644 modules/digibug/views/admin_digibug.html.php (limited to 'modules') diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php new file mode 100644 index 00000000..86338f6b --- /dev/null +++ b/modules/digibug/controllers/admin_digibug.php @@ -0,0 +1,73 @@ +_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() { + 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")); + + url::redirect("admin/digibug"); + } + + print $this->_get_view($form); + } + + 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"); + $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("submit")->value(t("Submit")); + + return $form; + } +} \ No newline at end of file diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php new file mode 100644 index 00000000..1e968d74 --- /dev/null +++ b/modules/digibug/controllers/digibug.php @@ -0,0 +1,51 @@ +_get_form(); + } + + public function handler() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + // @todo process the admin form + + message::success(t("Digibug Processing Successfully")); + + print json_encode( + array("result" => "success")); + } else { + print json_encode( + array("result" => "error", + "form" => $form->__toString())); + } + } + + 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")); + + return $form; + } +} \ No newline at end of file diff --git a/modules/digibug/css/digibug.css b/modules/digibug/css/digibug.css new file mode 100644 index 00000000..f5cd6717 --- /dev/null +++ b/modules/digibug/css/digibug.css @@ -0,0 +1,88 @@ +.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; +} + + + diff --git a/modules/digibug/css/logo.png b/modules/digibug/css/logo.png new file mode 100644 index 00000000..5eac2c7d Binary files /dev/null and b/modules/digibug/css/logo.png differ 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 @@ +"; + } +} diff --git a/modules/digibug/module.info b/modules/digibug/module.info new file mode 100644 index 00000000..58602c0d --- /dev/null +++ b/modules/digibug/module.info @@ -0,0 +1,3 @@ +name = Digibug +description = Digibug Photo Printing Module +version = 1 diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php new file mode 100644 index 00000000..33ce5f83 --- /dev/null +++ b/modules/digibug/views/admin_digibug.html.php @@ -0,0 +1,70 @@ + + +
+

+
+

+ +

+
+
+
    +
  • +
  • +
+
+
+ +
+ +
+
+ +
+
+
    +
  • +
  • +
  • +
+
+
+
+ + + + + + +
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +

+ +
+
+
+ +
+
+
+
-- cgit v1.2.3 From ee8887045e8f6702b13565173ba80330fcdb4572 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 05:46:40 -0700 Subject: Change the quick pan from static to dynamic. This allows modules to add buttons to the quick pane. The quick pane is now divided into 4 sections: left, center, right and additional. Additional items appear in the drop down box. Buttons are not sorted within the groupings. In addition, the quick pane will overflow onto the "additional" dropdown if there is not enough room to display all the buttons. The use case is the digibug printing module needed to add a button to the quick pane, and I don't like putting code into core that says if module is active... That's another one of those code smells :-) --- modules/gallery/controllers/quick.php | 2 + modules/gallery/helpers/gallery_quick.php | 146 ++++++++++++++++++++++++++++++ modules/gallery/views/quick_pane.html.php | 103 +++------------------ 3 files changed, 160 insertions(+), 91 deletions(-) create mode 100644 modules/gallery/helpers/gallery_quick.php (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index cff6686b..6203728c 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -25,6 +25,8 @@ class Quick_Controller extends Controller { } $view = new View("quick_pane.html"); + $view->button_list = + gallery_quick::get_quick_buttons($item, Input::instance()->get("page_type")); $view->item = $item; $view->page_type = Input::instance()->get("page_type"); print $view; diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php new file mode 100644 index 00000000..19ed23dc --- /dev/null +++ b/modules/gallery/helpers/gallery_quick.php @@ -0,0 +1,146 @@ +name == "gallery") { + continue; + } + $class_name = "{$module->name}_quick"; + if (method_exists($class_name, "buttons")) { + $module_buttons = call_user_func(array($class_name, "buttons"), $item, $page_type); + foreach (array("left", "center", "right", "additional") as $position) { + if (!empty($module_buttons[$position])) { + $buttons[$position] = array_merge($buttons[$position], $module_buttons[$position]); + } + } + } + } + + $sorted_buttons->main = array(); + foreach (array("left", "center", "right") as $position) { + $sorted_buttons->main = array_merge($sorted_buttons->main, $buttons[$position]); + } + + $sorted_buttons->additional = $buttons["additional"]; + $max_display = empty($sorted_buttons->additional) ? 6 : 5; + if (count($sorted_buttons->main) >= $max_display) { + $to_move = array_slice($sorted_buttons->main, 5); + $sorted_buttons->additional = array_merge($to_move, $sorted_buttons->additional); + for ($i = count($sorted_buttons->main); $i >= 5; $i--) { + unset($sorted_buttons->main[$i]); + } + } + + Kohana::log("error", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + Kohana::log("error", Kohana::debug($sorted_buttons)); + Kohana::log("error", "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + return $sorted_buttons; + } + + static function buttons($item, $page_type) { + $elements = array("left" => array(), "center" => array(), "right" => array(), + "additional" => array()); + switch ($item->type) { + case "movie": + $edit_title = t("Edit this movie"); + $move_title = t("Move this movie to another album"); + $cover_title = t("Choose this movie as the album cover"); + $delete_title = t("Delete this movie"); + break; + case "album": + $edit_title = t("Edit this album"); + $move_title = t("Move this album to another album"); + $cover_title = t("Choose this album as the album cover"); + $delete_title = t("Delete this album"); + break; + default: + $edit_title = t("Edit this photo"); + $move_title = t("Move this photo to another album"); + $cover_title = t("Choose this photo as the album cover"); + $delete_title = t("Delete this photo"); + break; + } + + $csrf = access::csrf_token(); + $elements["left"][] = (object)array( + "title" => $edit_title, + "class" => "gDialogLink gButtonLink", + "icon" => "ui-icon-pencil", + "href" => url::site("quick/form_edit/$item->id?page_type=$page_type")); + if ($item->is_photo() && graphics::can("rotate")) { + $elements["left"][] = + (object)array( + "title" => t("Rotate 90 degrees counter clockwise"), + "class" => "gButtonLink", + "icon" => "ui-icon-rotate-ccw", + "href" => url::site("quick/form_edit/$item->id/ccw?csrf=$csrf&?page_type=$page_type")); + $elements["left"][] = + (object)array( + "title" => t("Rotate 90 degrees clockwise"), + "class" => "gButtonLink", + "icon" => "ui-icon-rotate-cw", + "href" => url::site("quick/form_edit/$item->id/cw?csrf=$csrf&page_type=$page_type")); + } + + // Don't move photos from the photo page; we don't yet have a good way of redirecting after move + if ($page_type == "album") { + $elements["left"][] = (object)array( + "title" => $move_title, + "class" => "gDialogLink gButtonLink", + "icon" => "ui-icon-folder-open", + "href" => url::site("move/browse/$item->id")); + } + + if (access::can("edit", $item->parent())) { + $disabledState = + $item->type == "album" && empty($item->album_cover_item_id) ? " ui-state-disabled" : ""; + $elements["right"][] = (object)array( + "title" => $cover_title, + "class" => "gButtonLink{$disabledState}", + "icon" => "ui-icon-star", + "href" => url::site("quick/make_album_cover/$item->id?csrf=$csrf&page_type=$page_type")); + + $elements["right"][] = (object)array( + "title" => $delete_title, + "class" => "gButtonLink", + "icon" => "ui-icon-trash", + "id" => "gQuickDelete", + "href" => url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")); + } + + if ($item->is_album()) { + $elements["additional"][] = (object)array( + "title" => t("Add a photo"), + "class" => "add_item gDialogLink", + "href" => url::site("simple_uploader/app/$item->id")); + $elements["additional"][] = (object)array( + "title" => t("Add an album"), + "class" => "add_album gDialogLink", + "href" => url::site("form/add/albums/$item->id?type=album")); + $elements["additional"][] = (object)array( + "title" => t("Edit permissions"), + "class" => "permissions gDialogLink", + "href" => url::site("permissions/browse/$item->id")); + } + return $elements; + } +} diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php index f50e1abe..eabf4a67 100644 --- a/modules/gallery/views/quick_pane.html.php +++ b/modules/gallery/views/quick_pane.html.php @@ -1,85 +1,14 @@ -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> - - -id?page_type=$page_type") ?>" - title=""> - - - - - -is_photo() && graphics::can("rotate")): ?> -id/ccw?csrf=$csrf&page_type=$page_type") ?>" - title=""> - - - - - -id/cw?csrf=$csrf&page_type=$page_type") ?>" - title=""> - - +main as $button): ?> + + + title ?> - + - - -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> - - -id") ?>" - title=""> - - - - - - - -parent())): ?> -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> -album_cover_item_id)): ?> -album_cover_item_id) ? " ui-state-disabled" : "" ?> - - - -id?csrf=$csrf&page_type=$page_type") ?>" - title=""> - - - - - -type == "photo"): ?> - -type == "movie"): ?> - -type == "album"): ?> - - -id?page_type=$page_type") ?>" id="gQuickDelete" title=""> - - - - - - -is_album()): ?> +additional)): ?> "> @@ -87,19 +16,11 @@ -- 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') 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') 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 6b552fb07c8a162c9755895c132c6985c9dd1ddc Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 22 Jun 2009 06:27:31 -0700 Subject: Remove debugging output that was overlooked --- modules/gallery/helpers/gallery_quick.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php index 19ed23dc..bb791c33 100644 --- a/modules/gallery/helpers/gallery_quick.php +++ b/modules/gallery/helpers/gallery_quick.php @@ -50,9 +50,6 @@ class gallery_quick_Core { } } - Kohana::log("error", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - Kohana::log("error", Kohana::debug($sorted_buttons)); - Kohana::log("error", "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); return $sorted_buttons; } -- 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') 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 05:26:44 -0700 Subject: Extract the html for the Print button on the album page into a seperate view --- modules/digibug/views/digibug_album.html.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 modules/digibug/views/digibug_album.html.php (limited to 'modules') diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php new file mode 100644 index 00000000..0f1537e9 --- /dev/null +++ b/modules/digibug/views/digibug_album.html.php @@ -0,0 +1,8 @@ + + \ No newline at end of file -- cgit v1.2.3 From 8f443cef3e304c12f9e3555332880395051e7e3d Mon Sep 17 00:00:00 2001 From: Tim Almdal 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') 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 e44053f692109069977c097ecd24c45ab8e2f228 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 21:42:25 -0700 Subject: Cache the page_type in pane() instead of looking it up twice. --- modules/gallery/controllers/quick.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 6203728c..e89d9701 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -25,10 +25,10 @@ class Quick_Controller extends Controller { } $view = new View("quick_pane.html"); - $view->button_list = - gallery_quick::get_quick_buttons($item, Input::instance()->get("page_type")); + $page_type = Input::instance()->get("page_type"); + $view->button_list = gallery_quick::get_quick_buttons($item, $page_type); $view->item = $item; - $view->page_type = Input::instance()->get("page_type"); + $view->page_type = $page_type; print $view; } -- 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') 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') 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') 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