diff options
-rw-r--r-- | modules/digibug/controllers/admin_digibug.php | 74 | ||||
-rw-r--r-- | modules/digibug/controllers/digibug.php | 74 | ||||
-rw-r--r-- | modules/digibug/css/digibug.css | 91 | ||||
-rw-r--r-- | modules/digibug/css/logo.png | bin | 0 -> 17296 bytes | |||
-rw-r--r-- | modules/digibug/helpers/digibug.php | 57 | ||||
-rw-r--r-- | modules/digibug/helpers/digibug_installer.php | 44 | ||||
-rw-r--r-- | modules/digibug/helpers/digibug_menu.php | 43 | ||||
-rw-r--r-- | modules/digibug/helpers/digibug_theme.php | 48 | ||||
-rw-r--r-- | modules/digibug/js/digibug.js | 24 | ||||
-rw-r--r-- | modules/digibug/models/proxy.php | 22 | ||||
-rw-r--r-- | modules/digibug/module.info | 3 | ||||
-rw-r--r-- | modules/digibug/views/admin_digibug.html.php | 70 |
12 files changed, 550 insertions, 0 deletions
diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php new file mode 100644 index 00000000..8263fc83 --- /dev/null +++ b/modules/digibug/controllers/admin_digibug.php @@ -0,0 +1,74 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Admin_Digibug_Controller extends Admin_Controller { + public function index() { + 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() { + 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..f90b88e2 --- /dev/null +++ b/modules/digibug/controllers/digibug.php @@ -0,0 +1,74 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Digibug_Controller extends Controller { + public function print_photo($id) { + access::verify_csrf(); + + $item = ORM::factory("item", $id); + + $proxy = ORM::factory("proxy"); + $proxy->uuid = digibug::uuid(); + $proxy->item_id = $item->id; + $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"); + } + $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)); + } + + public function print_proxy($id, $thumb=null) { + + // We don't need to save the session for this request + Session::abort_save(); + + // 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 new file mode 100644 index 00000000..a09e4551 --- /dev/null +++ b/modules/digibug/css/digibug.css @@ -0,0 +1,91 @@ +.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 Binary files differnew file mode 100644 index 00000000..5eac2c7d --- /dev/null +++ b/modules/digibug/css/logo.png 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 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class digibug_Core { + /** + * Get a unique id for a print request. + * Its a good thing we only support linux as this won't work on Windows + */ + static function uuid() { + $fp = @fopen("/dev/urandom", "rb"); + $bits = @fread($fp, 16); + @fclose($fp); + + $time_low = bin2hex(substr($bits, 0, 4)); + $time_mid = bin2hex(substr($bits, 4, 2)); + $time_hi_and_version = bin2hex(substr($bits, 6, 2)); + $clock_seq_hi_and_reserved = bin2hex(substr($bits, 8, 2)); + $node = bin2hex ( substr ( $bits, 10, 6 ) ); + + /** + * Set the four most significant bits (bits 12 through 15) of the + * time_hi_and_version field to the 4-bit version number from + * Section 4.1.3. + * @see http://tools.ietf.org/html/rfc4122#section-4.1.3 + */ + $time_hi_and_version = hexdec ( $time_hi_and_version ); + $time_hi_and_version = $time_hi_and_version >> 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 new file mode 100644 index 00000000..73645eb7 --- /dev/null +++ b/modules/digibug/helpers/digibug_installer.php @@ -0,0 +1,44 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class digibug_installer { + static function install() { + $version = module::get_version("digibug"); + if ($version == 0) { + Database::instance() + ->query("CREATE TABLE {proxies} ( + `id` int(9) NOT NULL auto_increment, + `uuid` char(32) 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 {proxys}"); + 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..1ff0f6bf --- /dev/null +++ b/modules/digibug/helpers/digibug_menu.php @@ -0,0 +1,43 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class digibug_menu { + static function admin($menu, $theme) { + $menu->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..2e44b115 --- /dev/null +++ b/modules/digibug/helpers/digibug_theme.php @@ -0,0 +1,48 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class digibug_theme_Core { + static function head($theme) { + $head[] = "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" . + url::file("modules/digibug/css/digibug.css") . "\" />"; + $head[] = html::script("modules/digibug/js/digibug.js");; + return implode("\n", $head); + } + + static function admin_head($theme) { + return "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" . + url::file("modules/digibug/css/digibug.css") . "\" />"; + } + + 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 "<div class=\"gDigibugPrintButton\"> + <a class=\"gButtonLink ui-corner-all ui-state-default ui-icon-left\" href=\"$href\" + title=\"$title\"> + <span class=\"ui-icon ui-icon-print\">$title</span> + </a> + </div>"; + } + 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 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Proxy_Model extends ORM { + protected $has_one = array("item"); +} 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 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<script type="text/javascript"> + $("#gDigibugTabs").ready(function() { + $("#gDigibugTabs").tabs({ + event: "mouseover" + }); + }); +</script> +<div id="gAdminDigibug"> + <h2><?= t("Digibug Adminstration") ?> </h2> + <div class="gAdminDigibugIntro"> + <p> + <?= t("Digibug offers you two options for turning your photos into a wide variety of prints, gifts and games. Choose your solution and get started today!") ?> + </p> + </div> + <div id="gDigibugTabs"> + <ul> + <li><a href="#gDigibugTabBasic"><?= t("Basic") ?></a></li> + <li><a href="#gDigibugTabAdvanced"><?= t("Advanced") ?></a></li> + </ul> + <div id="gDigibugTabBasic" class="gDigibugTab"> + <div class="gDigibugTitle"> + <?= t("Digibug Basic") ?> + <br/> + <?= t("Fast Easy Photo Fulfillment") ?> + </div> + <div class="gDigibugText"> + <?= t("Power up your Gallery with professional level fulfillment from Kodak. Just use Digibug Basic and there's nothing else to do - no registration, no administration, no hassles.") ?> + </div> + <div class="gDigibugListItems"> + <ul> + <li><?= t("Matte and Glossy prints, from 4x6 to as big as 30x40") ?></li> + <li><?= t("Great photo gifts like canvases, apparel, bags, puzzles, mugs and sports memorabilia and more") ?></li> + <li><?= t("Outstanding quality and customer service") ?></li> + </ul> + </div> + <div class="gDigibugRounded ui-corner-all"> + <br/> + <? if ($mode == "basic"): ?> + <?= t("You are currently using Basic mode!") ?> + <? else: ?> + <a href='<?= url::site("admin/digibug/basic?csrf=$csrf") ?>'><?= t("Click Here") ?></a> + <?= t(" to switch back to basic") ?> + <? endif ?> + </div> + </div> + <div id="gDigibugTabAdvanced" class="gDigibugTab"> + <div class="gDigibugTitle"> + <?= t("Digibug ADVANCED") ?> + <br/> + <?= t("The Pro\'s Solution") ?> + </div> + <div class="gDigibugText"> + <?= t("Digibug ADVANCED allows you to set your own price for photos and gifts. Simply provide us with your account information and we'll send you a check each month with your profits. It's the perfect online retail business solution for a photographer - no inventory, no overhead... just profits!") ?> + </div> + <div class="gDigibugText"> + <?= t("Enjoy the same range of professional level photo prints and gifts, but set your own price and charge what you believe your photos are worth. We'll take care of the rest.") ?> + </div> + <div style="width: 120px;" class="gDigibugText gDigibugSignIn"> + <?= t("New to Digibug ADVANCED?") ?> + <br/> <br/> + <a href="http://www.digibug.com/signup.php" style=""><?= t("Sign up") ?></a><?= t(" to get started") ?> + </div> + <div class="gDigibugAdvancedForm"> + <div class="gDigibugText"><?= t("Do you have a Digibug Company ID and Event ID?") ?></div> + <?= $form ?> + </div> + </div> + </div> +</div> |