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 ++-------- 5 files changed, 7 insertions(+), 129 deletions(-) delete mode 100644 modules/digibug/css/digibug.css delete mode 100644 modules/digibug/css/logo.png (limited to 'modules') 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 @@
    -
    +
    -- 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') 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') 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 28f496924f5e6ada3f779c096ab7f463d637760b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 18:38:43 -0700 Subject: Fix indentation in digibug_form.html.php --- modules/digibug/views/digibug_form.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php index c2cd889e..7179827f 100644 --- a/modules/digibug/views/digibug_form.html.php +++ b/modules/digibug/views/digibug_form.html.php @@ -4,7 +4,7 @@ -- cgit v1.2.3 From 93e4f14c855d3fe4c4e9cc5c7d6a58fb2e25fe99 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 19:04:45 -0700 Subject: 1) Fix potential XSS in digibug_album.html.php 2) Fix case of text --- modules/digibug/views/admin_digibug.html.php | 2 +- modules/digibug/views/digibug_album.html.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php index 205d8b7a..28d280fd 100644 --- a/modules/digibug/views/admin_digibug.html.php +++ b/modules/digibug/views/admin_digibug.html.php @@ -34,7 +34,7 @@
    - +

    diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php index c3337324..2d9cf641 100644 --- a/modules/digibug/views/digibug_album.html.php +++ b/modules/digibug/views/digibug_album.html.php @@ -2,7 +2,7 @@ \ No newline at end of file -- 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') 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 1552f0fff77125fbd31f2689154f1ac57acda83f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 21:41:09 -0700 Subject: Add XSS clean up on the title that is sent to digibug as part of the print request --- modules/digibug/views/admin_digibug.html.php | 44 ++++++---------------------- 1 file changed, 9 insertions(+), 35 deletions(-) (limited to 'modules') diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php index 28d280fd..769fd415 100644 --- a/modules/digibug/views/admin_digibug.html.php +++ b/modules/digibug/views/admin_digibug.html.php @@ -1,47 +1,21 @@

    - +

    -
    -
      -
    • -
    • -
    -
    -
    - -
    -
    -
    - - - - - - -
    -
    -
    -
    - -
    -
    - -

    - -
    -
    -
    - -
    +
    +
    + +

    +
    +
    -- 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') 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 3b873a98d7292b1c9736082fa6c27b44f4fd1018 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 25 Jun 2009 21:50:37 -0700 Subject: Oops changed my mind... when setting to the default just set the value to null and let the cpmapny and event ids be set in the print_photo controller. --- modules/digibug/controllers/admin_digibug.php | 4 ++-- modules/digibug/controllers/digibug.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php index 9b75cb11..bd9e9d95 100644 --- a/modules/digibug/controllers/admin_digibug.php +++ b/modules/digibug/controllers/admin_digibug.php @@ -40,8 +40,8 @@ class Admin_Digibug_Controller extends Admin_Controller { 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")); + 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"); diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 6900c65a..7bec4b86 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -49,6 +49,7 @@ class Digibug_Controller extends Controller { "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; } -- 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') 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 42a5bd20a550a9edb5ec84625037b9d85889ff63 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 26 Jun 2009 07:51:29 -0700 Subject: 1) Move the generation of script tags to gallery_theme::head and gallery_theme::admin_head. This allows us to potentially manage the scripts like we do in g2 (single file and compressed) 2) Change Theme_View::_call to always call the gallery_theme::$function first. --- modules/gallery/helpers/gallery_theme.php | 20 ++++++++++++++++++++ modules/gallery/libraries/Theme_View.php | 25 +++++++++++++++++++++++-- themes/admin_default/views/admin.html.php | 10 +--------- themes/default/views/page.html.php | 12 ------------ 4 files changed, 44 insertions(+), 23 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index a96c8f5b..24f4129b 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -21,6 +21,18 @@ class gallery_theme_Core { static function head($theme) { $session = Session::instance(); $buf = ""; + $buf .= html::script("lib/jquery.js"); + $buf .= html::script("lib/jquery.form.js"); + $buf .= html::script("lib/jquery-ui.js"); + $buf .= html::script("lib/gallery.common.js"); + $buf .= html::script("lib/gallery.dialog.js"); + $buf .= html::script("lib/gallery.form.js"); + $buf .= html::script("lib/superfish/js/superfish.js"); + if ($theme->page_type == 'photo') { + $buf .= html::script("lib/jquery.scrollTo.js"); + $buf .= html::script("lib/jquery.localscroll.js"); + } + $buf .= html::script($theme->url("js/ui.init.js", false, true)); if ($session->get("debug")) { $buf .= ""; @@ -79,6 +91,14 @@ class gallery_theme_Core { static function admin_head($theme) { $session = Session::instance(); $buf = ""; + $buf .= html::script("lib/jquery.js"); + $buf .= html::script("lib/jquery.form.js"); + $buf .= html::script("lib/jquery-ui.js"); + $buf .= html::script("lib/gallery.common.js"); + $buf .= html::script("lib/gallery.dialog.js"); + $buf .= html::script("lib/superfish/js/superfish.js"); + $buf .= html::script($theme->url("js/jquery.dropshadow.js", false, true)); + $buf .= html::script($theme->url("js/ui.init.js", false, true)); if ($session->get("debug")) { $buf .= ""; diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 7b2ca840..5235fabb 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -68,9 +68,9 @@ class Theme_View_Core extends View { return module::get_var("gallery", "thumb_size", 200) / 200; } - public function url($path, $absolute_url=false) { + public function url($path, $absolute_url=false, $no_root=false) { $arg = "themes/{$this->theme_name}/$path"; - return $absolute_url ? url::abs_file($arg) : url::file($arg); + return $absolute_url ? url::abs_file($arg) : $no_root ? $arg : url::file($arg); } public function item() { @@ -192,7 +192,28 @@ class Theme_View_Core extends View { case "thumb_info": case "thumb_top": $blocks = array(); + if (method_exists("gallery_theme", $function)) { + switch (count($args)) { + case 0: + $blocks[] = gallery_theme::$function($this); + break; + case 1: + $blocks[] = gallery_theme::$function($this, $args[0]); + break; + case 2: + $blocks[] = gallery_theme::$function($this, $args[0], $args[1]); + break; + default: + $blocks[] = call_user_func_array( + array("gallery_theme", $function), + array_merge(array($this), $args)); + } + + } foreach (module::active() as $module) { + if ($module->name == "gallery") { + continue; + } $helper_class = "{$module->name}_theme"; if (method_exists($helper_class, $function)) { $blocks[] = call_user_func_array( diff --git a/themes/admin_default/views/admin.html.php b/themes/admin_default/views/admin.html.php index b7cfaa40..dfbafe31 100644 --- a/themes/admin_default/views/admin.html.php +++ b/themes/admin_default/views/admin.html.php @@ -20,15 +20,7 @@ " media="screen,print,projection" /> - - - - - - - - - admin_head() ?> + admin_head() ?> body_attributes() ?>> diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index f6286f95..c74d4097 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -49,18 +49,6 @@ - - - - - - - - page_type == 'photo'): ?> - - - - head() ?> -- cgit v1.2.3 From f4778699fc52c045f60d72e20bebc000d9f6bda8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 26 Jun 2009 08:19:06 -0700 Subject: Change the movie controller to set the page type to "movie". Ticket #467 --- modules/gallery/controllers/movies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 86b0f177..d8cca825 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -44,7 +44,7 @@ class Movies_Controller extends Items_Controller { ->where("id <=", $photo->id) ->count_all(); - $template = new Theme_View("page.html", "photo"); + $template = new Theme_View("page.html", "movie"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", $photo->children_count()); -- cgit v1.2.3 From f3e45d49a3fb621d7a23fe7c24af5ad160859687 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 26 Jun 2009 23:19:06 +0800 Subject: Change the movie controller to set the page type to "movie". Ticket #467 Signed-off-by: Tim Almdal --- modules/gallery/controllers/movies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 86b0f177..d8cca825 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -44,7 +44,7 @@ class Movies_Controller extends Items_Controller { ->where("id <=", $photo->id) ->count_all(); - $template = new Theme_View("page.html", "photo"); + $template = new Theme_View("page.html", "movie"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", $photo->children_count()); -- cgit v1.2.3 From 84e98e830c4967c277dfcb5bb6d18c0ec3313355 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 26 Jun 2009 08:25:24 -0700 Subject: Move the inclusion of photo and movie specific javascript into gallery_theme --- modules/gallery/helpers/gallery_theme.php | 4 ++++ themes/default/views/movie.html.php | 1 - themes/default/views/photo.html.php | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 24f4129b..0679087e 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -31,6 +31,10 @@ class gallery_theme_Core { if ($theme->page_type == 'photo') { $buf .= html::script("lib/jquery.scrollTo.js"); $buf .= html::script("lib/jquery.localscroll.js"); + $buf .= html::script("lib/gallery.show_full_size.js"); + } + if ($theme->page_type == 'movie') { + $buf .= html::script("lib/flowplayer.js"); } $buf .= html::script($theme->url("js/ui.init.js", false, true)); if ($session->get("debug")) { diff --git a/themes/default/views/movie.html.php b/themes/default/views/movie.html.php index e8559697..134e3571 100644 --- a/themes/default/views/movie.html.php +++ b/themes/default/views/movie.html.php @@ -1,5 +1,4 @@ -
    photo_top() ?> diff --git a/themes/default/views/photo.html.php b/themes/default/views/photo.html.php index 1c3b81a7..4765a4e3 100644 --- a/themes/default/views/photo.html.php +++ b/themes/default/views/photo.html.php @@ -2,7 +2,6 @@ item())): ?> - \n"; + $theme->script("modules/comment/js/comment.js"); + return ""; } static function photo_bottom($theme) { diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 0679087e..b6b24b27 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -21,22 +21,22 @@ class gallery_theme_Core { static function head($theme) { $session = Session::instance(); $buf = ""; - $buf .= html::script("lib/jquery.js"); - $buf .= html::script("lib/jquery.form.js"); - $buf .= html::script("lib/jquery-ui.js"); - $buf .= html::script("lib/gallery.common.js"); - $buf .= html::script("lib/gallery.dialog.js"); - $buf .= html::script("lib/gallery.form.js"); - $buf .= html::script("lib/superfish/js/superfish.js"); + $theme->script("lib/jquery.js"); + $theme->script("lib/jquery.form.js"); + $theme->script("lib/jquery-ui.js"); + $theme->script("lib/gallery.common.js"); + $theme->script("lib/gallery.dialog.js"); + $theme->script("lib/gallery.form.js"); + $theme->script("lib/superfish/js/superfish.js"); if ($theme->page_type == 'photo') { - $buf .= html::script("lib/jquery.scrollTo.js"); - $buf .= html::script("lib/jquery.localscroll.js"); - $buf .= html::script("lib/gallery.show_full_size.js"); + $theme->script("lib/jquery.scrollTo.js"); + $theme->script("lib/jquery.localscroll.js"); + $theme->script("lib/gallery.show_full_size.js"); } if ($theme->page_type == 'movie') { - $buf .= html::script("lib/flowplayer.js"); + $theme->script("lib/flowplayer.js"); } - $buf .= html::script($theme->url("js/ui.init.js", false, true)); + $theme->script($theme->url("js/ui.init.js", false, true)); if ($session->get("debug")) { $buf .= ""; @@ -45,7 +45,7 @@ class gallery_theme_Core { && access::can("edit", $theme->item())) { $buf .= ""; - $buf .= html::script("modules/gallery/js/quick.js"); + $theme->script("modules/gallery/js/quick.js"); } if (module::is_active("rss")) { @@ -59,8 +59,8 @@ class gallery_theme_Core { if ($session->get("l10n_mode", false)) { $buf .= ""; - $buf .= html::script("lib/jquery.cookie.js"); - $buf .= html::script("modules/gallery/js/l10n_client.js"); + $theme->script("lib/jquery.cookie.js"); + $theme->script("modules/gallery/js/l10n_client.js"); } return $buf; @@ -95,14 +95,14 @@ class gallery_theme_Core { static function admin_head($theme) { $session = Session::instance(); $buf = ""; - $buf .= html::script("lib/jquery.js"); - $buf .= html::script("lib/jquery.form.js"); - $buf .= html::script("lib/jquery-ui.js"); - $buf .= html::script("lib/gallery.common.js"); - $buf .= html::script("lib/gallery.dialog.js"); - $buf .= html::script("lib/superfish/js/superfish.js"); - $buf .= html::script($theme->url("js/jquery.dropshadow.js", false, true)); - $buf .= html::script($theme->url("js/ui.init.js", false, true)); + $theme->script("lib/jquery.js"); + $theme->script("lib/jquery.form.js"); + $theme->script("lib/jquery-ui.js"); + $theme->script("lib/gallery.common.js"); + $theme->script("lib/gallery.dialog.js"); + $theme->script("lib/superfish/js/superfish.js"); + $theme->script($theme->url("js/jquery.dropshadow.js", false, true)); + $theme->script($theme->url("js/ui.init.js", false, true)); if ($session->get("debug")) { $buf .= ""; @@ -111,8 +111,8 @@ class gallery_theme_Core { if ($session->get("l10n_mode", false)) { $buf .= ""; - $buf .= html::script("lib/jquery.cookie.js"); - $buf .= html::script("modules/gallery/js/l10n_client.js"); + $theme->script("lib/jquery.cookie.js"); + $theme->script("modules/gallery/js/l10n_client.js"); } return $buf; diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 5235fabb..7696f3b0 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -19,6 +19,7 @@ */ class Theme_View_Core extends View { private $theme_name = null; + private $scripts = array(); /** * Attempts to load a view and pre-load view data. @@ -163,6 +164,19 @@ class Theme_View_Core extends View { return message::get(); } + public function script($file) { + $this->scripts[$file] = 1; + } + + private function _combine_script() { + $links = array(); + Kohana::log("error", Kohana::debug($this->scripts)); + foreach (array_keys($this->scripts) as $file) { + $links[] = html::script($file); + } + return empty($links) ? "" : implode("\n", $links); + } + /** * Handle all theme functions that insert module content. */ @@ -221,6 +235,11 @@ class Theme_View_Core extends View { array_merge(array($this), $args)); } } + + if ($function == "head" || $function == "admin_head") { + array_unshift($blocks, $this->_combine_script()); + } + if (Session::instance()->get("debug")) { if ($function != "head") { array_unshift( -- cgit v1.2.3 From 11f08ee4399c62cc1d2c36457a214c6db693db06 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 26 Jun 2009 21:42:02 -0700 Subject: Implement the combined javascript controller. --- modules/gallery/controllers/javascript.php | 64 ++++++++++++++++++++++++++++++ modules/gallery/libraries/Theme_View.php | 29 ++++++++++++-- 2 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 modules/gallery/controllers/javascript.php (limited to 'modules') diff --git a/modules/gallery/controllers/javascript.php b/modules/gallery/controllers/javascript.php new file mode 100644 index 00000000..d3c0ded5 --- /dev/null +++ b/modules/gallery/controllers/javascript.php @@ -0,0 +1,64 @@ +scripts)); + $key = ""; foreach (array_keys($this->scripts) as $file) { - $links[] = html::script($file); + $path = DOCROOT . $file; + if (file_exists($path)) { + $stats = stat($path); + $links[] = $path; + // 7 == size, 9 == mtime, see http://php.net/stat + $key = "{$key}$file $stats[7] $stats[9],"; + } else { + Kohana::log("warn", "Javascript file missing: " . $file); + } + } + + $key = md5($key); + $file = "tmp/CombinedJavascript_$key"; + if (!file_exists(VARPATH . $file)) { + $contents = ''; + foreach ($links as $link) { + $contents .= file_get_contents($link); + } + file_put_contents(VARPATH . $file, $contents); + if (function_exists("gzencode")) { + file_put_contents(VARPATH . "{$file}_gzip", gzencode($contents, 9, FORCE_GZIP)); + } } - return empty($links) ? "" : implode("\n", $links); + + return ""; } /** -- cgit v1.2.3 From bbba0a67c22436aa166b1a882f35ddc093faae7c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Jun 2009 14:29:24 -0700 Subject: Fix formatting. --- modules/digibug/views/digibug_form.html.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'modules') diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php index 7179827f..e18cbc18 100644 --- a/modules/digibug/views/digibug_form.html.php +++ b/modules/digibug/views/digibug_form.html.php @@ -1,16 +1,16 @@ - - - - - - - - - - \ No newline at end of file + + + + + + + + + + -- cgit v1.2.3 From e78f91c91a178f564dc845905ea4b21928e57c3c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Jun 2009 14:29:58 -0700 Subject: Fix XSS vulnerability, get rid of unnecessary curly braces. --- modules/digibug/views/digibug_album.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php index 2d9cf641..2fd8803b 100644 --- a/modules/digibug/views/digibug_album.html.php +++ b/modules/digibug/views/digibug_album.html.php @@ -1,8 +1,8 @@ \ No newline at end of file +
    -- 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') 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') 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') 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') 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') 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) ?>

    \ No newline at end of file + -- cgit v1.2.3 From c4f991bb7d7e90f8c55897f89888d9196c7e438f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 28 Jun 2009 19:45:11 -0700 Subject: Clean up the combined javascript change and refactor out the Gallery_View base class from Theme_View and Admin_View. 1) Move all the theme specific jquery stuff from gallery_theme::head() and admin_head() into the theme files. Use $theme->script() as appropriate. 2) Get rid of the extra boolean on $theme->url() that we were using so that we could call $theme->script($theme->url(...)) -- add $theme->theme_script() instead (poorly named, but still clearer than what we had before) 3) Fix the bug that combined scripts didn't work at all in the admin theme. 4) Get rid of $theme->display() in favor of new View(...) --- modules/gallery/helpers/gallery_theme.php | 24 -------- modules/gallery/libraries/Admin_View.php | 17 ++---- modules/gallery/libraries/Gallery_View.php | 89 ++++++++++++++++++++++++++++++ modules/gallery/libraries/Theme_View.php | 61 +------------------- themes/admin_default/views/admin.html.php | 10 ++++ themes/default/views/page.html.php | 24 +++++++- 6 files changed, 128 insertions(+), 97 deletions(-) create mode 100644 modules/gallery/libraries/Gallery_View.php (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index b6b24b27..cffecb12 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -21,22 +21,6 @@ class gallery_theme_Core { static function head($theme) { $session = Session::instance(); $buf = ""; - $theme->script("lib/jquery.js"); - $theme->script("lib/jquery.form.js"); - $theme->script("lib/jquery-ui.js"); - $theme->script("lib/gallery.common.js"); - $theme->script("lib/gallery.dialog.js"); - $theme->script("lib/gallery.form.js"); - $theme->script("lib/superfish/js/superfish.js"); - if ($theme->page_type == 'photo') { - $theme->script("lib/jquery.scrollTo.js"); - $theme->script("lib/jquery.localscroll.js"); - $theme->script("lib/gallery.show_full_size.js"); - } - if ($theme->page_type == 'movie') { - $theme->script("lib/flowplayer.js"); - } - $theme->script($theme->url("js/ui.init.js", false, true)); if ($session->get("debug")) { $buf .= ""; @@ -95,14 +79,6 @@ class gallery_theme_Core { static function admin_head($theme) { $session = Session::instance(); $buf = ""; - $theme->script("lib/jquery.js"); - $theme->script("lib/jquery.form.js"); - $theme->script("lib/jquery-ui.js"); - $theme->script("lib/gallery.common.js"); - $theme->script("lib/gallery.dialog.js"); - $theme->script("lib/superfish/js/superfish.js"); - $theme->script($theme->url("js/jquery.dropshadow.js", false, true)); - $theme->script($theme->url("js/ui.init.js", false, true)); if ($session->get("debug")) { $buf .= ""; diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 7a7396eb..01496c0d 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -17,9 +17,7 @@ * 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_View_Core extends View { - private $theme_name = null; - +class Admin_View_Core extends Gallery_View { /** * Attempts to load a view and pre-load view data. * @@ -46,15 +44,6 @@ class Admin_View_Core extends View { $this->set_global("user", user::active()); } - public function url($path, $absolute_url=false) { - $arg = "themes/{$this->theme_name}/$path"; - return $absolute_url ? url::abs_file($arg) : url::file($arg); - } - - public function display($page_name, $view_class="View") { - return new $view_class($page_name); - } - public function admin_menu() { $menu = Menu::factory("root"); gallery_menu::admin($menu, $this); @@ -109,6 +98,10 @@ class Admin_View_Core extends View { } } + if ($function == "admin_head") { + array_unshift($blocks, $this->combine_script()); + } + if (Session::instance()->get("debug")) { if ($function != "admin_head") { array_unshift( diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php new file mode 100644 index 00000000..f2298b7d --- /dev/null +++ b/modules/gallery/libraries/Gallery_View.php @@ -0,0 +1,89 @@ +scripts[$file] = 1; + } + + /** + * Add a script to the combined scripts list. + * @param $file the relative path to a script from the base of the active theme + * @param + */ + public function theme_script($file) { + $file = "themes/{$this->theme_name}/$file"; + $this->scripts[$file] = 1; + } + + /** + * Provide a url to a resource within the current theme. This allows us to refer to theme + * resources without naming the theme itself which makes themes easier to copy. + */ + public function url($path, $absolute_url=false) { + $arg = "themes/{$this->theme_name}/$path"; + return $absolute_url ? url::abs_file($arg) : url::file($arg); + } + + /** + * Combine a series of Javascript files into a single one and cache it in the database, then + * return a single "; + } +} \ No newline at end of file diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 25818821..8e320f44 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -17,10 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Theme_View_Core extends View { - private $theme_name = null; - private $scripts = array(); - +class Theme_View_Core extends Gallery_View { /** * Attempts to load a view and pre-load view data. * @@ -69,11 +66,6 @@ class Theme_View_Core extends View { return module::get_var("gallery", "thumb_size", 200) / 200; } - public function url($path, $absolute_url=false, $no_root=false) { - $arg = "themes/{$this->theme_name}/$path"; - return $absolute_url ? url::abs_file($arg) : $no_root ? $arg : url::file($arg); - } - public function item() { return $this->item; } @@ -86,10 +78,6 @@ class Theme_View_Core extends View { return $this->page_type; } - public function display($page_name, $view_class="View") { - return new $view_class($page_name); - } - public function site_menu() { $menu = Menu::factory("root"); if ($this->page_type != "login") { @@ -168,49 +156,6 @@ class Theme_View_Core extends View { return message::get(); } - public function script($file) { - $this->scripts[$file] = 1; - } - - /** - * Combine a series of Javascript files into a single one and cache it in the database, then - * return a single "; - } - /** * Handle all theme functions that insert module content. */ @@ -270,8 +215,8 @@ class Theme_View_Core extends View { } } - if ($function == "head" || $function == "admin_head") { - array_unshift($blocks, $this->_combine_script()); + if ($function == "head") { + array_unshift($blocks, $this->combine_script()); } if (Session::instance()->get("debug")) { diff --git a/themes/admin_default/views/admin.html.php b/themes/admin_default/views/admin.html.php index dfbafe31..2a91a76c 100644 --- a/themes/admin_default/views/admin.html.php +++ b/themes/admin_default/views/admin.html.php @@ -20,6 +20,16 @@ " media="screen,print,projection" /> + + script("lib/jquery.js") ?> + script("lib/jquery.form.js") ?> + script("lib/jquery-ui.js") ?> + script("lib/gallery.common.js") ?> + script("lib/gallery.dialog.js") ?> + script("lib/superfish/js/superfish.js") ?> + theme_script("js/jquery.dropshadow.js") ?> + theme_script("js/ui.init.js") ?> + admin_head() ?> diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index c74d4097..8b9466ac 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -49,6 +49,24 @@ + script("lib/jquery.js") ?> + script("lib/jquery.form.js") ?> + script("lib/jquery-ui.js") ?> + script("lib/gallery.common.js") ?> + script("lib/gallery.dialog.js") ?> + script("lib/gallery.form.js") ?> + script("lib/superfish/js/superfish.js") ?> + script("lib/jquery.localscroll.js") ?> + theme_script("js/ui.init.js") ?> + + head() they get combined */ ?> + page_type == "photo"): ?> + script("lib/jquery.scrollTo.js") ?> + script("lib/gallery.show_full_size.js") ?> + page_type == "movie"): ?> + script("lib/flowplayer.js") ?> + + head() ?> @@ -57,7 +75,7 @@
    site_status() ?>
    - display("header.html") ?> +
    @@ -70,12 +88,12 @@
    page_type != "login"): ?> - display("sidebar.html") ?> +
    - display("footer.html") ?> +
    page_bottom() ?> -- cgit v1.2.3 From 6e8a8c53e685a6c3f35f1426ab4dd6dcc18578e0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 28 Jun 2009 19:49:48 -0700 Subject: Rename $theme->url() to $theme->theme_url() for consistency wiht $theme->theme_script(). --- modules/comment/views/admin_block_recent_comments.html.php | 2 +- modules/comment/views/admin_comments.html.php | 2 +- modules/comment/views/comment.html.php | 2 +- modules/comment/views/comments.html.php | 2 +- modules/gallery/libraries/Gallery_View.php | 2 +- modules/user/views/admin_users.html.php | 2 +- themes/admin_default/views/admin.html.php | 4 ++-- themes/default/views/header.html.php | 2 +- themes/default/views/page.html.php | 6 +++--- 9 files changed, 12 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/comment/views/admin_block_recent_comments.html.php b/modules/comment/views/admin_block_recent_comments.html.php index edaa19ae..af4d946e 100644 --- a/modules/comment/views/admin_block_recent_comments.html.php +++ b/modules/comment/views/admin_block_recent_comments.html.php @@ -2,7 +2,7 @@
      $comment): ?>
    • "> - " + " class="gAvatar" alt="author_name()) ?>" width="32" diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php index 86585c65..453cf849 100644 --- a/modules/comment/views/admin_comments.html.php +++ b/modules/comment/views/admin_comments.html.php @@ -106,7 +106,7 @@ "> - " + " class="gAvatar" alt="author_name()) ?>" width="40" diff --git a/modules/comment/views/comment.html.php b/modules/comment/views/comment.html.php index ce52951b..6d2cc592 100644 --- a/modules/comment/views/comment.html.php +++ b/modules/comment/views/comment.html.php @@ -2,7 +2,7 @@
    • - " + " class="gAvatar" alt="author_name()) ?>" width="40" diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index 854f9554..d9405e5f 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -10,7 +10,7 @@

    • - " + " class="gAvatar" alt="author_name()) ?>" width="40" diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index f2298b7d..e21e83d8 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -43,7 +43,7 @@ class Gallery_View_Core extends View { * Provide a url to a resource within the current theme. This allows us to refer to theme * resources without naming the theme itself which makes themes easier to copy. */ - public function url($path, $absolute_url=false) { + public function theme_url($path, $absolute_url=false) { $arg = "themes/{$this->theme_name}/$path"; return $absolute_url ? url::abs_file($arg) : url::file($arg); } diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 542b8b8b..b469f82d 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -66,7 +66,7 @@ $user): ?> user admin ? "admin" : "" ?>"> - " + " title="" alt="name) ?>" width="20" diff --git a/themes/admin_default/views/admin.html.php b/themes/admin_default/views/admin.html.php index 2a91a76c..62f9761f 100644 --- a/themes/admin_default/views/admin.html.php +++ b/themes/admin_default/views/admin.html.php @@ -14,10 +14,10 @@ media="screen,projection" /> " media="screen,projection" /> - " + " media="screen,projection" /> diff --git a/themes/default/views/header.html.php b/themes/default/views/header.html.php index e1e52bda..b38cffed 100644 --- a/themes/default/views/header.html.php +++ b/themes/default/views/header.html.php @@ -4,7 +4,7 @@ "> - " src="url("images/logo.png") ?>" /> + " src="theme_url("images/logo.png") ?>" /> diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index 8b9466ac..3ae3e155 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -23,17 +23,17 @@ - " type="image/x-icon" /> + " type="image/x-icon" /> " media="screen,print,projection" /> " media="screen" /> " media="screen,print,projection" /> - " + " media="screen,print,projection" /> page_type == 'album'): ?> -- cgit v1.2.3 From 42c82ef7f081630c15a5d354205896764348a76a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 29 Jun 2009 06:08:50 -0700 Subject: Temporary checkin to allow merge with trunk... don't integrate --- modules/gallery/libraries/Theme_View.php | 29 ++++++++++++++++++++++++- modules/organize/helpers/organize_theme.php | 3 +-- modules/server_add/helpers/server_add_theme.php | 3 +-- themes/admin_default/views/admin.html.php | 16 +------------- 4 files changed, 31 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 25818821..c5888b4a 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -20,6 +20,7 @@ class Theme_View_Core extends View { private $theme_name = null; private $scripts = array(); + private $css = array(); /** * Attempts to load a view and pre-load view data. @@ -172,6 +173,10 @@ class Theme_View_Core extends View { $this->scripts[$file] = 1; } + public function css($file) { + $this->css[$file] = 1; + } + /** * Combine a series of Javascript files into a single one and cache it in the database, then * return a single "; } + /** + * Combine a series of Javascript files into a single one and cache it in the database, then + * return a single "; diff --git a/themes/admin_default/views/admin.html.php b/themes/admin_default/views/admin.html.php index dfbafe31..1361ae33 100644 --- a/themes/admin_default/views/admin.html.php +++ b/themes/admin_default/views/admin.html.php @@ -6,21 +6,7 @@ <?= t("Admin Dashboard") ?> " type="image/x-icon" /> - " - media="screen,projection" /> - " - media="screen,projection" /> - " - media="screen,projection" /> - " - media="screen,projection" /> - " - media="screen,projection" /> - - admin_head() ?> + admin_head() ?> body_attributes() ?>> -- cgit v1.2.3 From 6ec293dfe70665c528d803b78a2bb295633496ec Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 29 Jun 2009 08:24:42 -0700 Subject: *Note* work in progress. Implement the combined css functionality. Local url references and replace with absolute urls instead of relative. --- modules/gallery/controllers/combined.php | 46 +++++++++++++++++++++++++++++ modules/gallery/libraries/Gallery_View.php | 47 ++++++++++++++++++++++++++++-- themes/default/views/page.html.php | 2 +- 3 files changed, 91 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 510482db..50fe77c4 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -58,5 +58,51 @@ class Combined_Controller extends Controller { Kohana::close_buffers(false); print $content; } + + public function css($key) { + if (preg_match('/[^0-9a-f]/', $key)) { + // The key can't contain non-hex, so just terminate early + Kohana::show_404(); + } + + // We don't need to save the session for this request + Session::abort_save(); + + // Our data is immutable, so if they already have a copy then it needs no updating. + if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { + header('HTTP/1.0 304 Not Modified'); + return; + } + + $cache = Cache::instance(); + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { + $content = $cache->get("{$key}_gz"); + } + + if (empty($content)) { + $content = $cache->get($key); + } + + if (empty($content)) { + Kohana::show_404(); + } + + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { + header("Content-Encoding: gzip"); + header("Cache-Control: public"); + } + + header("Content-Type: text/css; charset=UTF-8"); + header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); + + Kohana::close_buffers(false); + print $content; + } + + public function __call($function, $args) { + array_unshift($args, $function); + print ""; + } } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 7000d3de..1c1dec38 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -113,12 +113,53 @@ class Gallery_View_Core extends View { protected function combine_css() { $links = array(); $key = ""; + static $PATTERN = "#url\(\s*['|\"]{0,1}(.*?)['|\"]{0,1}\s*\)#"; + foreach (array_keys($this->css) as $file) { - $links[] = ""; + $path = DOCROOT . $file; + if (file_exists($path)) { + $stats = stat($path); + $links[] = $path; + // 7 == size, 9 == mtime, see http://php.net/stat + $key = "{$key}$file $stats[7] $stats[9],"; + } else { + Kohana::log("alert", "CSS file missing: " . $file); + } + } + $key = md5($key); + $cache = Cache::instance(); + $contents = $cache->get($key); + $docroot_length = strlen(DOCROOT); + + if (empty($contents)) { + $contents = ""; + foreach ($links as $link) { + $css = file_get_contents($link); + if (preg_match_all($PATTERN, $css, $matches, PREG_SET_ORDER)) { + $search = $replace = array(); + foreach ($matches as $match) { + $relative = substr(realpath(dirname($link) . "/$match[1]"), $docroot_length); + if (!empty($relative)) { + $search[] = $match[1]; + $replace[] = url::abs_file($relative); + } else { + Kohana::log("alert", sprintf("Missing URL reference '%s' in CSS file '%s' ", + $match[1], $link)); + } + } + $css = str_replace($search, $replace, $css); + } + $contents .= $css; + } + $cache->set($key, $contents, array("css"), 30 * 84600); + if (function_exists("gzencode")) { + $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), + array("css", "gzip"), 30 * 84600); + } } - return implode("\n", $links); + return ""; } } \ No newline at end of file diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index f6984958..2e68f571 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -25,8 +25,8 @@ " type="image/x-icon" /> css("lib/yui/reset-fonts-grids.css") ?> - css("lib/themeroller/ui.base.css") ?> css("lib/superfish/css/superfish.css") ?> + css("lib/themeroller/ui.base.css") ?> theme_css("css/screen.css") ?> "; - } } diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 01496c0d..5e0d5feb 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -99,6 +99,7 @@ class Admin_View_Core extends Gallery_View { } if ($function == "admin_head") { + array_unshift($blocks, $this->combine_css()); array_unshift($blocks, $this->combine_script()); } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 1c1dec38..b4cfde46 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -113,7 +113,6 @@ class Gallery_View_Core extends View { protected function combine_css() { $links = array(); $key = ""; - static $PATTERN = "#url\(\s*['|\"]{0,1}(.*?)['|\"]{0,1}\s*\)#"; foreach (array_keys($this->css) as $file) { $path = DOCROOT . $file; @@ -130,27 +129,12 @@ class Gallery_View_Core extends View { $key = md5($key); $cache = Cache::instance(); $contents = $cache->get($key); - $docroot_length = strlen(DOCROOT); + $contents = ""; if (empty($contents)) { $contents = ""; foreach ($links as $link) { - $css = file_get_contents($link); - if (preg_match_all($PATTERN, $css, $matches, PREG_SET_ORDER)) { - $search = $replace = array(); - foreach ($matches as $match) { - $relative = substr(realpath(dirname($link) . "/$match[1]"), $docroot_length); - if (!empty($relative)) { - $search[] = $match[1]; - $replace[] = url::abs_file($relative); - } else { - Kohana::log("alert", sprintf("Missing URL reference '%s' in CSS file '%s' ", - $match[1], $link)); - } - } - $css = str_replace($search, $replace, $css); - } - $contents .= $css; + $contents .= $this->process_css($link); } $cache->set($key, $contents, array("css"), 30 * 84600); if (function_exists("gzencode")) { @@ -162,4 +146,38 @@ class Gallery_View_Core extends View { url::site("combined/css/$key") . "\" />"; } + private function process_css($css_file) { + static $PATTERN = "#url\(\s*['|\"]{0,1}(.*?)['|\"]{0,1}\s*\)#"; + $docroot_length = strlen(DOCROOT); + + $css = file_get_contents($css_file); + if (preg_match_all($PATTERN, $css, $matches, PREG_SET_ORDER)) { + $search = $replace = array(); + foreach ($matches as $match) { + $relative = substr(realpath(dirname($css_file) . "/$match[1]"), $docroot_length); + if (!empty($relative)) { + $search[] = $match[0]; + $replace[] = "url('" . url::abs_file($relative) . "')"; + } else { + Kohana::log("alert", sprintf("Missing URL reference '%s' in CSS file '%s' ", + $match[1], $css_file)); + } + } + $css = str_replace($search, $replace, $css); + } + $imports = preg_match_all("#@import\s*['|\"]{0,1}(.*?)['|\"]{0,1};#", + $css, $matches, PREG_SET_ORDER); + + if ($imports) { + $search = $replace = array(); + foreach ($matches as $match) { + Kohana::log("error", dirname($css_file) . "/$match[1]"); + $search[] = $match[0]; + $replace[] = $this->process_css(dirname($css_file) . "/$match[1]"); + } + $css = str_replace($search, $replace, $css); + } + + return $css; + } } \ No newline at end of file -- cgit v1.2.3 From eb82f6a64a6b4e0b4e18ca92689bd467cba6e1bd Mon Sep 17 00:00:00 2001 From: jhilden Date: Mon, 29 Jun 2009 16:02:11 -0400 Subject: added textual description of upload progress moved the cancel link to above the upload queue (where the textual upload progress also is) --- modules/gallery/views/simple_uploader.html.php | 62 ++++++++++++++++---------- 1 file changed, 38 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index f10d764c..55b4f458 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -30,17 +30,23 @@

    • title) ?>
    -

    +

    + + + " onclick="swfu.cancelQueue();"> +

    + + +
    diff --git a/themes/admin_default/css/screen.css b/themes/admin_default/css/screen.css index e68620a5..d408acf0 100644 --- a/themes/admin_default/css/screen.css +++ b/themes/admin_default/css/screen.css @@ -400,6 +400,20 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { float: left; } +#gTaskLogDialog h1 { + font-size: 1.1em; +} + +.gTaskLog { + border: 1pt solid; + font-size: .9em; + height: 400px; + margin: .5em 0; + overflow: auto; + padding: .5em +} + + /** ******************************************************************* * 7) Server Add *********************************************************************/ -- cgit v1.2.3 From f381927ec6bca75e9c588725318f6682bf74d103 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 6 Jul 2009 07:39:36 -0700 Subject: Catch exceptions that are thrown within the task and log them to the task log and then set the task to done, the state to error and the status message set to the Exception Message. --- modules/gallery/helpers/task.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php index 79a7c93b..06568887 100644 --- a/modules/gallery/helpers/task.php +++ b/modules/gallery/helpers/task.php @@ -76,9 +76,17 @@ class task_Core { throw new Exception("@todo MISSING_TASK"); } - $task->state = "running"; - call_user_func_array($task->callback, array(&$task)); - $task->save(); + try { + $task->state = "running"; + call_user_func_array($task->callback, array(&$task)); + $task->save(); + } catch (Exception $e) { + $task->log($e->__toString()); + $task->state = "error"; + $task->done = true; + $task->status = $e->getMessage(); + $task->save(); + } return $task; } -- cgit v1.2.3 From 6dbd36d1ccc482ff542884da0cdc60612436c002 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 6 Jul 2009 10:29:55 -0700 Subject: Always log the task completion status message --- modules/gallery/helpers/task.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php index 06568887..6a9f63c2 100644 --- a/modules/gallery/helpers/task.php +++ b/modules/gallery/helpers/task.php @@ -79,6 +79,9 @@ class task_Core { try { $task->state = "running"; call_user_func_array($task->callback, array(&$task)); + if ($task->done) { + $task->log($task->status); + } $task->save(); } catch (Exception $e) { $task->log($e->__toString()); -- cgit v1.2.3 From 30aa065013507c18ed64cc189e60e0959b7c4d7d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Jul 2009 12:41:54 -0700 Subject: Don't use jQuery in the error page, it interferes with the jquery lib in the outer page when we load it in a dialog context. --- modules/gallery/views/kohana_error_page.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/kohana_error_page.php b/modules/gallery/views/kohana_error_page.php index 6bf48549..9361514d 100644 --- a/modules/gallery/views/kohana_error_page.php +++ b/modules/gallery/views/kohana_error_page.php @@ -53,7 +53,6 @@ margin: 0px; } - <?= t("Something went wrong!") ?> @@ -78,8 +77,13 @@

    - + + -- cgit v1.2.3 From 2852161ca31f1a5b90bfd16a14615dd1812bd78a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 7 Jul 2009 21:49:54 -0700 Subject: Provide some clarity on the action links by formating them as buttons on the Maintenance Tasks admin page. --- modules/gallery/views/admin_maintenance.html.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index eecc045c..501daa0b 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -161,22 +161,23 @@ done): ?> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all"> get_log()): ?> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gDialogLink gButtonLink ui-state-default ui-corner-all"> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gDialogLink gButtonLink" ui-state-default ui-corner-all> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all"> + -- cgit v1.2.3 From 47fbb56fa25fc98d4e0695ed08b7fbaec916c003 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 08:22:40 -0700 Subject: Added task logging to the Rebuild Images task. --- modules/gallery/helpers/gallery_task.php | 83 ++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 35 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 1152cda2..c673411d 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -45,50 +45,63 @@ class gallery_task_Core { * @param Task_Model the task */ static function rebuild_dirty_images($task) { - $result = graphics::find_dirty_images_query(); - $completed = $task->get("completed", 0); - $ignored = $task->get("ignored", array()); - $remaining = $result->count() - count($ignored); - - $i = 0; - foreach ($result as $row) { - if (array_key_exists($row->id, $ignored)) { - continue; - } + try { + $result = graphics::find_dirty_images_query(); + $completed = $task->get("completed", 0); + $ignored = $task->get("ignored", array()); + $remaining = $result->count() - count($ignored); + + $i = 0; + foreach ($result as $row) { + if (array_key_exists($row->id, $ignored)) { + continue; + } - $item = ORM::factory("item", $row->id); - if ($item->loaded) { - $success = graphics::generate($item); - if (!$success) { - $ignored[$item->id] = 1; + $item = ORM::factory("item", $row->id); + if ($item->loaded) { + $success = graphics::generate($item); + if (!$success) { + $ignored[$item->id] = 1; + $message = t("Unable to rebuild images for '%title'", + array("title" => p::purify($item->title))); + } else { + $message = t("Successfully rebuilt images for '%title'", + array("title" => p::purify($item->title))); + } + $task->log($message); } - } - $completed++; - $remaining--; + $completed++; + $remaining--; - if (++$i == 2) { - break; + if (++$i == 2) { + break; + } } - } - $task->status = t2("Updated: 1 image. Total: %total_count.", - "Updated: %count images. Total: %total_count.", - $completed, - array("total_count" => ($remaining + $completed))); + $task->status = t2("Updated: 1 image. Total: %total_count.", + "Updated: %count images. Total: %total_count.", + $completed, + array("total_count" => ($remaining + $completed))); - if ($completed + $remaining > 0) { - $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); - } else { - $task->percent_complete = 100; - } + if ($completed + $remaining > 0) { + $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); + } else { + $task->percent_complete = 100; + } - $task->set("completed", $completed); - $task->set("ignored", $ignored); - if ($remaining == 0) { + $task->set("completed", $completed); + $task->set("ignored", $ignored); + if ($remaining == 0) { + $task->done = true; + $task->state = "success"; + site_status::clear("graphics_dirty"); + } + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("graphics_dirty"); + $task->state = "error"; + $task->status = $e->getMessage(); + $task->log($e->__toString()); } } -- cgit v1.2.3 From 9f00e734ed28f9c359fa52cfc4694ead5e4cf84e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 08:26:14 -0700 Subject: Added the button formatting to the other links on the Admin Maintenance page. --- modules/gallery/views/admin_maintenance.html.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 501daa0b..cd1cc02e 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -29,7 +29,7 @@ callback?csrf=$csrf") ?>" - class="gDialogLink"> + class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all"> @@ -94,11 +94,13 @@ state == "stalled"): ?> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>"> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" + class="gButtonLink ui-icon-left ui-state-default ui-corner-all right"> -- cgit v1.2.3 From 43c63362575264f473e8bba3345524fa7e58afe1 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 08:37:40 -0700 Subject: Add Task logging to the Extract EXIF data task --- modules/exif/helpers/exif_task.php | 65 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index 375503e3..649ad092 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -38,37 +38,48 @@ class exif_task_Core { } static function update_index($task) { - $completed = $task->get("completed", 0); + try { + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("exif_records", "items.id", "exif_records.item_id", "left") - ->where("type", "photo") - ->open_paren() - ->where("exif_records.item_id", null) - ->orwhere("exif_records.dirty", 1) - ->close_paren() - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } + $start = microtime(true); + $message = array(); + foreach (ORM::factory("item") + ->join("exif_records", "items.id", "exif_records.item_id", "left") + ->where("type", "photo") + ->open_paren() + ->where("exif_records.item_id", null) + ->orwhere("exif_records.dirty", 1) + ->close_paren() + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; + } - $completed++; - exif::extract($item); - } + $completed++; + exif::extract($item); + $message[] = t("Updated Exif meta data for '%title'", + array("title" => p::purify($item->title))); + } - list ($remaining, $total, $percent) = exif::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { + $task->log($message); + list ($remaining, $total, $percent) = exif::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { + $task->done = true; + $task->state = "success"; + site_status::clear("exif_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + } + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("exif_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + $task->state = "error"; + $task->status = $e->getMessage(); + $task->log($e->__toString()); } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); } } -- cgit v1.2.3 From ac797e609c8c319ca77f9b746a7cecad8dd69004 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 09:08:15 -0700 Subject: Add task logging to the Update translations --- modules/gallery/helpers/gallery_task.php | 150 ++++++++++++++++--------------- modules/gallery/helpers/l10n_client.php | 9 +- 2 files changed, 84 insertions(+), 75 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index c673411d..9ce2c4a0 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -45,6 +45,7 @@ class gallery_task_Core { * @param Task_Model the task */ static function rebuild_dirty_images($task) { + $message = array(); try { $result = graphics::find_dirty_images_query(); $completed = $task->get("completed", 0); @@ -62,13 +63,12 @@ class gallery_task_Core { $success = graphics::generate($item); if (!$success) { $ignored[$item->id] = 1; - $message = t("Unable to rebuild images for '%title'", + $message[] = t("Unable to rebuild images for '%title'", array("title" => p::purify($item->title))); } else { - $message = t("Successfully rebuilt images for '%title'", + $message[] = t("Successfully rebuilt images for '%title'", array("title" => p::purify($item->title))); } - $task->log($message); } $completed++; @@ -101,88 +101,98 @@ class gallery_task_Core { $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); - $task->log($e->__toString()); + $message[] = $e->__toString(); } + $task->log($message); } static function update_l10n(&$task) { - $start = microtime(true); - $dirs = $task->get("dirs"); - $files = $task->get("files"); - $cache = $task->get("cache", array()); - $i = 0; - - switch ($task->get("mode", "init")) { - case "init": // 0% - $dirs = array("gallery", "modules", "themes", "installer"); - $files = array(); - $task->set("mode", "find_files"); - $task->status = t("Finding files"); - break; - - case "find_files": // 0% - 10% - while (($dir = array_pop($dirs)) && microtime(true) - $start < 0.5) { - if (in_array(basename($dir), array("tests", "lib"))) { - continue; - } + $message = array(); + try { + $start = microtime(true); + $dirs = $task->get("dirs"); + $files = $task->get("files"); + $cache = $task->get("cache", array()); + $i = 0; - foreach (glob(DOCROOT . "$dir/*") as $path) { - $relative_path = str_replace(DOCROOT, "", $path); - if (is_dir($path)) { - $dirs[] = $relative_path; - } else { - $files[] = $relative_path; + switch ($task->get("mode", "init")) { + case "init": // 0% + $dirs = array("gallery", "modules", "themes", "installer"); + $files = array(); + $task->set("mode", "find_files"); + $task->status = t("Finding files"); + break; + + case "find_files": // 0% - 10% + while (($dir = array_pop($dirs)) && microtime(true) - $start < 0.5) { + if (in_array(basename($dir), array("tests", "lib"))) { + continue; } - } - } - $task->status = t2("Finding files: found 1 file", - "Finding files: found %count files", count($files)); + foreach (glob(DOCROOT . "$dir/*") as $path) { + $relative_path = str_replace(DOCROOT, "", $path); + if (is_dir($path)) { + $dirs[] = $relative_path; + } else { + $files[] = $relative_path; + } + } + } - if (!$dirs) { - $task->set("mode", "scan_files"); - $task->set("total_files", count($files)); - $task->status = t("Scanning files"); - $task->percent_complete = 10; - } - break; - - case "scan_files": // 10% - 90% - while (($file = array_pop($files)) && microtime(true) - $start < 0.5) { - $file = DOCROOT . $file; - switch (pathinfo($file, PATHINFO_EXTENSION)) { - case "php": - l10n_scanner::scan_php_file($file, $cache); - break; + $message[] = $task->status = t2("Finding files: found 1 file", + "Finding files: found %count files", count($files)); - case "info": - l10n_scanner::scan_info_file($file, $cache); - break; + if (!$dirs) { + $task->set("mode", "scan_files"); + $task->set("total_files", count($files)); + $task->status = t("Scanning files"); + $task->percent_complete = 10; + } + break; + + case "scan_files": // 10% - 90% + while (($file = array_pop($files)) && microtime(true) - $start < 0.5) { + $file = DOCROOT . $file; + switch (pathinfo($file, PATHINFO_EXTENSION)) { + case "php": + l10n_scanner::scan_php_file($file, $cache); + break; + + case "info": + l10n_scanner::scan_info_file($file, $cache); + break; + } } - } - $total_files = $task->get("total_files"); - $task->status = t2("Scanning files: scanned 1 file", - "Scanning files: scanned %count files", $total_files - count($files)); + $total_files = $task->get("total_files"); + $message[] = $task->status = t2("Scanning files: scanned 1 file", + "Scanning files: scanned %count files", $total_files - count($files)); - $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files; - if (empty($files)) { - $task->set("mode", "fetch_updates"); - $task->status = t("Fetching updates"); - $task->percent_complete = 90; + $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files; + if (empty($files)) { + $task->set("mode", "fetch_updates"); + $task->status = t("Fetching updates"); + $task->percent_complete = 90; + } + break; + + case "fetch_updates": // 90% - 100% + $message = array_merge($message, l10n_client::fetch_updates()); + $task->done = true; + $task->state = "success"; + $task->status = t("Translations installed/updated"); + $task->percent_complete = 100; } - break; - case "fetch_updates": // 90% - 100% - l10n_client::fetch_updates(); + $task->set("files", $files); + $task->set("dirs", $dirs); + $task->set("cache", $cache); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - $task->status = t("Translations installed/updated"); - $task->percent_complete = 100; + $task->state = "error"; + $task->status = $e->getMessage(); + $message[] = $e->__toString(); } - - $task->set("files", $files); - $task->set("dirs", $dirs); - $task->set("cache", $cache); + $task->log($message); } } \ No newline at end of file diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index e153532c..5b14abec 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -101,8 +101,7 @@ class l10n_client_Core { throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED " . $response_status); } if (empty($response_data)) { - log::info("translations", "Translations fetch request resulted in an empty response"); - return; + return array(t("Translations fetch request resulted in an empty response")); } $response = json_decode($response_data); @@ -112,9 +111,8 @@ class l10n_client_Core { // {key:, ...} // ] $count = count($response); - log::info("translations", - t2("Installed 1 new / updated translation message", - "Installed %count new / updated translation messages", $count)); + $message[] = t2("Installed 1 new / updated translation message", + "Installed %count new / updated translation messages", $count); foreach ($response as $message_data) { // @todo Better input validation @@ -152,6 +150,7 @@ class l10n_client_Core { $entry->translation = $translation; $entry->save(); } + return $message; } static function submit_translations() { -- cgit v1.2.3 From 6ac5238b83d58824eb9327406a2ee50b7e603214 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 09:27:37 -0700 Subject: Add task logging to the "Update Search Index" task --- modules/gallery/helpers/l10n_client.php | 3 ++ modules/search/helpers/search.php | 4 +++ modules/search/helpers/search_task.php | 56 +++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 5b14abec..6d4da0eb 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -67,6 +67,9 @@ class l10n_client_Core { return true; } + /** + * @return an array of messages that will be written to the task log + */ static function fetch_updates() { $request->locales = array(); $request->messages = new stdClass(); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index ea8dad81..34eaecbd 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -50,6 +50,9 @@ class search_Core { return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } + /** + * @return string An error message suitable for inclusion in the task log + */ static function check_index() { list ($remaining) = search::stats(); if ($remaining) { @@ -76,6 +79,7 @@ class search_Core { $record->data = join(" ", $data); $record->dirty = 0; $record->save(); + return t("Search index updated for '%title'", array("title" => p::purify($item->title))); } static function stats() { diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 876661e4..395bcd98 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -39,34 +39,42 @@ class search_task_Core { } static function update_index($task) { - $completed = $task->get("completed", 0); + try { + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("search_records", "items.id", "search_records.item_id", "left") - ->where("search_records.item_id", null) - ->orwhere("search_records.dirty", 1) - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } + $start = microtime(true); + foreach (ORM::factory("item") + ->join("search_records", "items.id", "search_records.item_id", "left") + ->where("search_records.item_id", null) + ->orwhere("search_records.dirty", 1) + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; + } - search::update($item); - $completed++; - } + $message[] = search::update($item); + $completed++; + } - list ($remaining, $total, $percent) = search::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { + list ($remaining, $total, $percent) = search::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { + $task->done = true; + $task->state = "success"; + site_status::clear("search_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + } + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("search_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + $task->state = "error"; + $task->status = $e->getMessage(); + $message[] = $e->__toString(); } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); + $task->log($message); } } -- cgit v1.2.3 From b1f9eb1d12fbb9acb97ece2333c21ab76d909101 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 19:37:03 +0800 Subject: ORM::Factory -> ORM::factory Signed-off-by: Tim Almdal --- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index fcf1cc54..54159294 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -82,7 +82,7 @@ class movie_Core { $movie->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::Factory("item") + while (ORM::factory("item") ->where("parent_id", $parent->id) ->where("name", $movie->name) ->find()->id) { diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index a4bc853b..e8a4f357 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -81,7 +81,7 @@ class photo_Core { $photo->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::Factory("item") + while (ORM::factory("item") ->where("parent_id", $parent->id) ->where("name", $photo->name) ->find()->id) { -- cgit v1.2.3 From 1a587fd01686cf603b2c7eefd406cf200c6e0ee1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 20:11:03 +0800 Subject: Eliminate temporary variables by passing the $item into the view and making API calls on the item. Signed-off-by: Tim Almdal --- modules/server_add/controllers/server_add.php | 4 +--- modules/server_add/views/server_add_tree_dialog.html.php | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 05ea5058..b0c47660 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -27,9 +27,7 @@ class Server_Add_Controller extends Controller { $item = ORM::factory("item", $id); $view = new View("server_add_tree_dialog.html"); - $view->action = url::abs_site("__ARGS__/{$id}__TASK_ID__?csrf=" . access::csrf_token()); - $view->parents = $item->parents(); - $view->album_title = $item->title; + $view->item = $item; $tree = new View("server_add_tree.html"); $tree->data = array(); diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8b296987..e2aa5d44 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -7,17 +7,17 @@ });
    -

    p::clean($album_title))) ?>

    +

    p::clean($item->title))) ?>

      - + parents() as $parent): ?>
    • title) ?>
    • -
    • +
    • title) ?>
    - "post")) ?> + "post")) ?>
    -- cgit v1.2.3 From 5118afc959650469874733a1060fbe22364d8c28 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:39:00 -0700 Subject: Revert "Add task logging to the "Update Search Index" task" This reverts commit 6ac5238b83d58824eb9327406a2ee50b7e603214. --- modules/gallery/helpers/l10n_client.php | 3 -- modules/search/helpers/search.php | 4 --- modules/search/helpers/search_task.php | 56 ++++++++++++++------------------- 3 files changed, 24 insertions(+), 39 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 6d4da0eb..5b14abec 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -67,9 +67,6 @@ class l10n_client_Core { return true; } - /** - * @return an array of messages that will be written to the task log - */ static function fetch_updates() { $request->locales = array(); $request->messages = new stdClass(); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 34eaecbd..ea8dad81 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -50,9 +50,6 @@ class search_Core { return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } - /** - * @return string An error message suitable for inclusion in the task log - */ static function check_index() { list ($remaining) = search::stats(); if ($remaining) { @@ -79,7 +76,6 @@ class search_Core { $record->data = join(" ", $data); $record->dirty = 0; $record->save(); - return t("Search index updated for '%title'", array("title" => p::purify($item->title))); } static function stats() { diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 395bcd98..876661e4 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -39,42 +39,34 @@ class search_task_Core { } static function update_index($task) { - try { - $completed = $task->get("completed", 0); + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("search_records", "items.id", "search_records.item_id", "left") - ->where("search_records.item_id", null) - ->orwhere("search_records.dirty", 1) - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } - - $message[] = search::update($item); - $completed++; + $start = microtime(true); + foreach (ORM::factory("item") + ->join("search_records", "items.id", "search_records.item_id", "left") + ->where("search_records.item_id", null) + ->orwhere("search_records.dirty", 1) + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; } - list ($remaining, $total, $percent) = search::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { - $task->done = true; - $task->state = "success"; - site_status::clear("search_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); - } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); - } catch (Exception $e) { + search::update($item); + $completed++; + } + + list ($remaining, $total, $percent) = search::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { $task->done = true; - $task->state = "error"; - $task->status = $e->getMessage(); - $message[] = $e->__toString(); + $task->state = "success"; + site_status::clear("search_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); } - $task->log($message); + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); } } -- cgit v1.2.3 From 703d93a1eac6d6332361067ffd74b697149c1feb Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:42:32 -0700 Subject: Revert "ORM::Factory -> ORM::factory" This reverts commit b1f9eb1d12fbb9acb97ece2333c21ab76d909101. --- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 54159294..fcf1cc54 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -82,7 +82,7 @@ class movie_Core { $movie->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::factory("item") + while (ORM::Factory("item") ->where("parent_id", $parent->id) ->where("name", $movie->name) ->find()->id) { diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index e8a4f357..a4bc853b 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -81,7 +81,7 @@ class photo_Core { $photo->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::factory("item") + while (ORM::Factory("item") ->where("parent_id", $parent->id) ->where("name", $photo->name) ->find()->id) { -- cgit v1.2.3 From 724d2af960c55b5a60b3c5e6bf68585426d46ab0 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:42:54 -0700 Subject: Revert "Eliminate temporary variables by passing the $item into the view and" This reverts commit 1a587fd01686cf603b2c7eefd406cf200c6e0ee1. --- modules/server_add/controllers/server_add.php | 4 +++- modules/server_add/views/server_add_tree_dialog.html.php | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index b0c47660..05ea5058 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -27,7 +27,9 @@ class Server_Add_Controller extends Controller { $item = ORM::factory("item", $id); $view = new View("server_add_tree_dialog.html"); - $view->item = $item; + $view->action = url::abs_site("__ARGS__/{$id}__TASK_ID__?csrf=" . access::csrf_token()); + $view->parents = $item->parents(); + $view->album_title = $item->title; $tree = new View("server_add_tree.html"); $tree->data = array(); diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index e2aa5d44..8b296987 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -7,17 +7,17 @@ });
    -

    p::clean($item->title))) ?>

    +

    p::clean($album_title))) ?>

      - parents() as $parent): ?> +
    • title) ?>
    • -
    • title) ?>
    • +
    - "post")) ?> + "post")) ?>
    -- cgit v1.2.3 From e7e2d99255259a708999727ae3a56777898a3426 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:43:42 -0700 Subject: Revert "Revert "Add task logging to the "Update Search Index" task"" This reverts commit 5118afc959650469874733a1060fbe22364d8c28. --- modules/gallery/helpers/l10n_client.php | 3 ++ modules/search/helpers/search.php | 4 +++ modules/search/helpers/search_task.php | 56 +++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 5b14abec..6d4da0eb 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -67,6 +67,9 @@ class l10n_client_Core { return true; } + /** + * @return an array of messages that will be written to the task log + */ static function fetch_updates() { $request->locales = array(); $request->messages = new stdClass(); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index ea8dad81..34eaecbd 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -50,6 +50,9 @@ class search_Core { return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } + /** + * @return string An error message suitable for inclusion in the task log + */ static function check_index() { list ($remaining) = search::stats(); if ($remaining) { @@ -76,6 +79,7 @@ class search_Core { $record->data = join(" ", $data); $record->dirty = 0; $record->save(); + return t("Search index updated for '%title'", array("title" => p::purify($item->title))); } static function stats() { diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 876661e4..395bcd98 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -39,34 +39,42 @@ class search_task_Core { } static function update_index($task) { - $completed = $task->get("completed", 0); + try { + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("search_records", "items.id", "search_records.item_id", "left") - ->where("search_records.item_id", null) - ->orwhere("search_records.dirty", 1) - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } + $start = microtime(true); + foreach (ORM::factory("item") + ->join("search_records", "items.id", "search_records.item_id", "left") + ->where("search_records.item_id", null) + ->orwhere("search_records.dirty", 1) + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; + } - search::update($item); - $completed++; - } + $message[] = search::update($item); + $completed++; + } - list ($remaining, $total, $percent) = search::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { + list ($remaining, $total, $percent) = search::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { + $task->done = true; + $task->state = "success"; + site_status::clear("search_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + } + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("search_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + $task->state = "error"; + $task->status = $e->getMessage(); + $message[] = $e->__toString(); } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); + $task->log($message); } } -- cgit v1.2.3 From b0429797fc7db5464717deffebdccc9705ca7820 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 10:00:16 -0700 Subject: Use p::purify instead of p::clean --- modules/server_add/views/server_add_tree_dialog.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8b13001f..0d56df7b 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -5,17 +5,17 @@
    -

    p::clean($item->title))) ?>

    +

    p::purify($item->title))) ?>

      parents() as $parent): ?>
    • - title) ?> + title) ?>
    • - title) ?> + title) ?>
    -- cgit v1.2.3 From 31ffb82382d76390f1206944329dde86c687349c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 01:35:51 +0800 Subject: Remove the reference to organize.css is it is no longer used and is producing errors in the log. Signed-off-by: Tim Almdal --- modules/organize/helpers/organize_theme.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules') diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index 02f1f589..1c75e819 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -22,6 +22,5 @@ class organize_theme { // @tdo remove the addition css and organize.js (just here to test) $theme->script("modules/organize/js/organize_init.js"); $theme->script("modules/organize/js/organize.js"); - $theme->css("modules/organize/css/organize.css"); } } -- cgit v1.2.3 From fad6c4783ebec8591e1b61bddcc7bd5f17d8cf0e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 10:46:27 -0700 Subject: Add status output to make it clearer what's happening when you add files. --- modules/server_add/controllers/server_add.php | 13 +++++++++++-- modules/server_add/js/server_add.js | 4 +++- modules/server_add/views/server_add_tree_dialog.html.php | 9 ++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 288e6342..638a4d63 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -86,6 +86,7 @@ class Server_Add_Controller extends Admin_Controller { print json_encode( array("result" => "started", + "status" => $task->status, "url" => url::site("server_add/run/$task->id?csrf=" . access::csrf_token()))); } @@ -99,6 +100,7 @@ class Server_Add_Controller extends Admin_Controller { $task = task::run($task_id); print json_encode(array("done" => $task->done, + "status" => $task->status, "percent_complete" => $task->percent_complete)); } @@ -117,6 +119,7 @@ class Server_Add_Controller extends Admin_Controller { case "init": $task->set("mode", "build-file-list"); $task->set("queue", array_keys($selections)); + $task->status = t("Starting up"); $task->percent_complete = 0; batch::start(); break; @@ -126,7 +129,6 @@ class Server_Add_Controller extends Admin_Controller { // Don't use an iterator here because we can't get enough control over it when we're dealing // with a deep hierarchy and we don't want to go over our time quota. $queue = $task->get("queue"); - Kohana::log("alert",print_r($queue,1)); while ($queue && microtime(true) - $start < 0.5) { $file = array_shift($queue); $entry = ORM::factory("server_add_file"); @@ -144,6 +146,10 @@ class Server_Add_Controller extends Admin_Controller { // over 10% in percent_complete. $task->set("queue", $queue); $task->percent_complete = min($task->percent_complete + 0.1, 10); + $task->status = t2("Found one file", "Found %count files", + Database::instance() + ->where("task_id", $task->id) + ->count_records("server_add_files")); if (!$queue) { $task->set("mode", "add-files"); @@ -202,6 +208,7 @@ class Server_Add_Controller extends Admin_Controller { } else if (in_array($extension, array("flv", "mp4"))) { movie::create($parent, $entry->file, $name, $title, null, user::active()->id); } else { + $task->log("Skipping unknown file type: $relative_path"); // Unsupported type // @todo: $task->log this } @@ -211,8 +218,10 @@ class Server_Add_Controller extends Admin_Controller { $entry->delete(); } $task->set("completed_files", $completed_files); + $task->status = t("Adding photos (%completed of %total)", + array("completed" => $completed_files, + "total" => $total_files)); $task->percent_complete = 10 + 100 * ($completed_files / $total_files); - Kohana::log("alert",print_r($task->as_array(),1)); break; case "done": diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index cba8c9ce..1a78d733 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -66,6 +66,7 @@ function start_add() { data: { "paths[]": paths }, dataType: "json", success: function(data, textStatus) { + $("#gStatus").html(data.status); $("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete); setTimeout(function() { run_add(data.url); }, 0); } @@ -79,9 +80,10 @@ function run_add(url) { async: false, dataType: "json", success: function(data, textStatus) { + $("#gStatus").html(data.status); $("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete); if (data.done) { - $("#gServerAdd .gProgressBar").slideUp(); + $("#gProgress").slideUp(); } else { setTimeout(function() { run_add(url); }, 0); } diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 0d56df7b..bbad4e69 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -25,7 +25,10 @@ - + -- cgit v1.2.3 From 6fbb1e2dafdaa51c1a8fd5479819ff787c758c59 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 14:03:07 -0700 Subject: Avoid blowing the task data column by only adding directories to the queue instead of directories and files. --- modules/server_add/controllers/server_add.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 638a4d63..cf7077a8 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -131,14 +131,21 @@ class Server_Add_Controller extends Admin_Controller { $queue = $task->get("queue"); while ($queue && microtime(true) - $start < 0.5) { $file = array_shift($queue); - $entry = ORM::factory("server_add_file"); - $entry->task_id = $task->id; - $entry->file = $file; - $entry->save(); - if (is_dir($file)) { - $queue = array_merge( - $queue, empty($selections[$file]) ? glob("$file/*") : $selections[$file]); + $children = empty($selections[$file]) ? glob("$file/*") : $selections[$file]; + } else { + $children = array($file); + } + + foreach ($children as $child) { + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $child; + $entry->save(); + + if (is_dir($child)) { + $queue[] = $child; + } } } // We have no idea how long this can take because we have no idea how deep the tree @@ -218,7 +225,7 @@ class Server_Add_Controller extends Admin_Controller { $entry->delete(); } $task->set("completed_files", $completed_files); - $task->status = t("Adding photos (%completed of %total)", + $task->status = t("Adding photos and albums (%completed of %total)", array("completed" => $completed_files, "total" => $total_files)); $task->percent_complete = 10 + 100 * ($completed_files / $total_files); -- cgit v1.2.3 From b1f93f358ab717ccd66ceadd51801fb0bc0db82f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 16:18:39 -0700 Subject: Fix typo in p::purify() call. --- modules/notification/views/item_added.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/notification/views/item_added.html.php b/modules/notification/views/item_added.html.php index 87ea90fa..86724927 100644 --- a/modules/notification/views/item_added.html.php +++ b/modules/notification/views/item_added.html.php @@ -8,7 +8,7 @@ - + -- cgit v1.2.3 From 1475b772bd256238e7e5e8c0985daede9e18a16f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 08:18:58 +0800 Subject: Change the tag importer to convert spaces to a dot in multi word tags. Signed-off-by: Tim Almdal --- modules/g2_import/helpers/g2_import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index d67d4c04..66787467 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -623,8 +623,10 @@ class g2_import_Core { } $tags = ""; + // Multiword tags have the space changed to dots.s foreach ($tag_names as $tag_name) { - $tags .= (strlen($tags) ? ", " : "") . tag::add($g3_item, $tag_name); + $tags .= (strlen($tags) ? ", " : "") . + tag::add($g3_item, preg_replace('/\s\s+/', '.', $tag_name)); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't -- cgit v1.2.3 From 7862e8b02ddd41eb68e858278cd909c8ff371550 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 09:59:04 +0800 Subject: Created the dynamic albums module which provides a dynamic album containing either recent updates or most viewed images. Signed-off-by: Tim Almdal --- modules/dynamic/controllers/admin_dynamic.php | 79 ++++++++++++++++++++++ modules/dynamic/controllers/dynamic.php | 94 +++++++++++++++++++++++++++ modules/dynamic/helpers/dynamic_installer.php | 46 +++++++++++++ modules/dynamic/helpers/dynamic_menu.php | 27 ++++++++ modules/dynamic/helpers/dynamic_theme.php | 39 +++++++++++ modules/dynamic/module.info | 3 + modules/dynamic/views/admin_dynamic.html.php | 5 ++ modules/dynamic/views/dynamic_block.html.php | 10 +++ 8 files changed, 303 insertions(+) create mode 100644 modules/dynamic/controllers/admin_dynamic.php create mode 100644 modules/dynamic/controllers/dynamic.php create mode 100644 modules/dynamic/helpers/dynamic_installer.php create mode 100644 modules/dynamic/helpers/dynamic_menu.php create mode 100644 modules/dynamic/helpers/dynamic_theme.php create mode 100644 modules/dynamic/module.info create mode 100644 modules/dynamic/views/admin_dynamic.html.php create mode 100644 modules/dynamic/views/dynamic_block.html.php (limited to 'modules') diff --git a/modules/dynamic/controllers/admin_dynamic.php b/modules/dynamic/controllers/admin_dynamic.php new file mode 100644 index 00000000..f559e3d2 --- /dev/null +++ b/modules/dynamic/controllers/admin_dynamic.php @@ -0,0 +1,79 @@ +_get_view(); + } + + public function handler() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + foreach (array("updates", "popular") as $album) { + $album_defn = unserialize(module::get_var("dynamic", $album)); + $album_defn->enabled = $form->$album->enabled->value; + $album_defn->description = $form->$album->description->value; + $album_defn->limit = $form->$album->limit->value === "" ? null : $form->$album->limit->value; + module::set_var("dynamic", $album, serialize($album_defn)); + } + + message::success(t("Dynamic Albums Configured")); + + url::redirect("admin/dynamic"); + } + + print $this->_get_view($form); + } + + private function _get_view($form=null) { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_dynamic.html"); + $v->content->form = empty($form) ? $this->_get_form() : $form; + return $v; + } + + private function _get_form() { + + $form = new Forge("admin/dynamic/handler", "", "post", + array("id" => "gAdminForm")); + + foreach (array("updates", "popular") as $album) { + $album_defn = unserialize(module::get_var("dynamic", $album)); + + $group = $form->group($album)->label(t($album_defn->title)); + $group->checkbox("enabled") + ->label(t("Enable")) + ->value(1) + ->checked($album_defn->enabled); + $group->input("limit") + ->label(t("Limit (leave empty for unlimited)")) + ->value(empty($updates->limit) ? "" : $updates->limit) + ->rules("valid_numeric"); + $group->textarea("description") + ->label(t("Description")) + ->rules("length[0,2048]") + ->value($album_defn->description); + } + + $form->submit("submit")->value(t("Submit")); + + return $form; + } +} \ No newline at end of file diff --git a/modules/dynamic/controllers/dynamic.php b/modules/dynamic/controllers/dynamic.php new file mode 100644 index 00000000..b1fde2ac --- /dev/null +++ b/modules/dynamic/controllers/dynamic.php @@ -0,0 +1,94 @@ +input->get("page", "1"); + + $children_count = ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->count_all(); + $offset = ($page-1) * $page_size; + print $children_count; + + $max_pages = ceil($children_count / $page_size); + print $max_pages; + + // Make sure that the page references a valid offset + if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { + Kohana::show_404(); + } + + $template = new Theme_View("page.html", "dynamic"); + $template->set_global("page_size", $page_size); + $template->set_global("children", ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->orderby("created", "DESC") + ->find_all($page_size, $offset)); + $template->set_global("children_count", $children_count); + $template->content = new View("dynamic.html"); + $template->content->title = t("Recent Updates"); + + print $template; + print $this->_show("updates"); + } + + public function popular() { + print $this->_show("popular"); + } + + private function _show($album) { + $page_size = module::get_var("gallery", "page_size", 9); + $page = $this->input->get("page", "1"); + + $album_defn = unserialize(module::get_var("dynamic", $album)); + $children_count = $album_defn->limit; + if (empty($children_count)) { + $children_count = ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->count_all(); + } + + $offset = ($page-1) * $page_size; + + $max_pages = ceil($children_count / $page_size); + + // Make sure that the page references a valid offset + if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { + Kohana::show_404(); + } + + $template = new Theme_View("page.html", "dynamic"); + $template->set_global("page_size", $page_size); + $template->set_global("children", ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->orderby($album_defn->key_field, "DESC") + ->find_all($page_size, $offset)); + $template->set_global("children_count", $children_count); + $template->content = new View("dynamic.html"); + $template->content->title = t($album_defn->title); + + print $template; + } + +} \ No newline at end of file diff --git a/modules/dynamic/helpers/dynamic_installer.php b/modules/dynamic/helpers/dynamic_installer.php new file mode 100644 index 00000000..8780864b --- /dev/null +++ b/modules/dynamic/helpers/dynamic_installer.php @@ -0,0 +1,46 @@ + false, + "limit" => null, + "description" => "", + "key_field" => "view_count", + "title" => t("Most Viewed")))); + module::set_var("dynamic", "updates", + serialize((object)array("enabled" => false, + "limit" => null, + "description" => "", + "key_field" => "created", + "title" => t("Recent Updates")))); + module::set_version("dynamic", 1); + } + } + + static function upgrade($version) { + } + + static function uninstall() { + /* @todo Put database table drops here */ + module::delete("dynamic"); + } +} diff --git a/modules/dynamic/helpers/dynamic_menu.php b/modules/dynamic/helpers/dynamic_menu.php new file mode 100644 index 00000000..b2c73d6f --- /dev/null +++ b/modules/dynamic/helpers/dynamic_menu.php @@ -0,0 +1,27 @@ +get("content_menu") + ->append(Menu::factory("link") + ->id("dynamic_menu") + ->label(t("Dynamic Albums")) + ->url(url::site("admin/dynamic"))); + } +} diff --git a/modules/dynamic/helpers/dynamic_theme.php b/modules/dynamic/helpers/dynamic_theme.php new file mode 100644 index 00000000..ba355098 --- /dev/null +++ b/modules/dynamic/helpers/dynamic_theme.php @@ -0,0 +1,39 @@ +enabled) { + $albums[$album] = $album_defn->title; + } + } + if (!empty($albums)) { + $block = new Block(); + $block->css_id = "gDynamic"; + $block->title = t("Dynamic Albums"); + $block->content = new View("dynamic_block.html"); + $block->content->albums = $albums; + return $block; + } + return ""; + } + +} diff --git a/modules/dynamic/module.info b/modules/dynamic/module.info new file mode 100644 index 00000000..4167df4b --- /dev/null +++ b/modules/dynamic/module.info @@ -0,0 +1,3 @@ +name = Dynamic +description = Dynamic album +version = 1 diff --git a/modules/dynamic/views/admin_dynamic.html.php b/modules/dynamic/views/admin_dynamic.html.php new file mode 100644 index 00000000..cd7ccfea --- /dev/null +++ b/modules/dynamic/views/admin_dynamic.html.php @@ -0,0 +1,5 @@ + +
    +

    + +
    diff --git a/modules/dynamic/views/dynamic_block.html.php b/modules/dynamic/views/dynamic_block.html.php new file mode 100644 index 00000000..d14c2900 --- /dev/null +++ b/modules/dynamic/views/dynamic_block.html.php @@ -0,0 +1,10 @@ + +
    +
      + $text): ?> +
    • + "> +
    • + +
    +
    -- cgit v1.2.3 From 4b28f7f50e0901ee3abe864a3881ff11d08a73ce Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 10:15:14 +0800 Subject: A few minor changes to add to the dynamic albums module 1) cleanun the two displays of the recent changes page 2) change the name to recent changes. 3) Change the description in module.info Not quite ready for prime time, some issues with the limit to be resolved Signed-off-by: Tim Almdal --- modules/dynamic/controllers/dynamic.php | 30 --------------------------- modules/dynamic/helpers/dynamic_installer.php | 2 +- modules/dynamic/module.info | 2 +- 3 files changed, 2 insertions(+), 32 deletions(-) (limited to 'modules') diff --git a/modules/dynamic/controllers/dynamic.php b/modules/dynamic/controllers/dynamic.php index b1fde2ac..6b5f2915 100644 --- a/modules/dynamic/controllers/dynamic.php +++ b/modules/dynamic/controllers/dynamic.php @@ -18,36 +18,6 @@ */ class Dynamic_Controller extends Controller { public function updates() { - $page_size = module::get_var("gallery", "page_size", 9); - $page = $this->input->get("page", "1"); - - $children_count = ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->count_all(); - $offset = ($page-1) * $page_size; - print $children_count; - - $max_pages = ceil($children_count / $page_size); - print $max_pages; - - // Make sure that the page references a valid offset - if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { - Kohana::show_404(); - } - - $template = new Theme_View("page.html", "dynamic"); - $template->set_global("page_size", $page_size); - $template->set_global("children", ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->orderby("created", "DESC") - ->find_all($page_size, $offset)); - $template->set_global("children_count", $children_count); - $template->content = new View("dynamic.html"); - $template->content->title = t("Recent Updates"); - - print $template; print $this->_show("updates"); } diff --git a/modules/dynamic/helpers/dynamic_installer.php b/modules/dynamic/helpers/dynamic_installer.php index 8780864b..66d6298d 100644 --- a/modules/dynamic/helpers/dynamic_installer.php +++ b/modules/dynamic/helpers/dynamic_installer.php @@ -31,7 +31,7 @@ class dynamic_installer { "limit" => null, "description" => "", "key_field" => "created", - "title" => t("Recent Updates")))); + "title" => t("Recent Changes")))); module::set_version("dynamic", 1); } } diff --git a/modules/dynamic/module.info b/modules/dynamic/module.info index 4167df4b..aa5e0432 100644 --- a/modules/dynamic/module.info +++ b/modules/dynamic/module.info @@ -1,3 +1,3 @@ name = Dynamic -description = Dynamic album +description = Adds the Recent Changes and Most Viewed dynamic albums version = 1 -- cgit v1.2.3 From e3e56827d5724c6ec5174d4186db99ab2c55e8f7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 12:33:37 +0800 Subject: Corrected a problem where the number limit value was being set the same for both popular and recent changes. Signed-off-by: Tim Almdal --- modules/dynamic/controllers/admin_dynamic.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/dynamic/controllers/admin_dynamic.php b/modules/dynamic/controllers/admin_dynamic.php index f559e3d2..50dac459 100644 --- a/modules/dynamic/controllers/admin_dynamic.php +++ b/modules/dynamic/controllers/admin_dynamic.php @@ -28,9 +28,11 @@ class Admin_Dynamic_Controller extends Admin_Controller { if ($form->validate()) { foreach (array("updates", "popular") as $album) { $album_defn = unserialize(module::get_var("dynamic", $album)); - $album_defn->enabled = $form->$album->enabled->value; - $album_defn->description = $form->$album->description->value; - $album_defn->limit = $form->$album->limit->value === "" ? null : $form->$album->limit->value; + $group = $form->inputs[$album]; + $album_defn->enabled = $group->inputs["{$album}_enabled"]->value; + $album_defn->description = $group->inputs["{$album}_description"]->value; + $album_defn->limit = $group->inputs["{$album}_limit"] === "" ? null : + $group->inputs["{$album}_limit"]->value; module::set_var("dynamic", $album, serialize($album_defn)); } @@ -58,15 +60,15 @@ class Admin_Dynamic_Controller extends Admin_Controller { $album_defn = unserialize(module::get_var("dynamic", $album)); $group = $form->group($album)->label(t($album_defn->title)); - $group->checkbox("enabled") + $group->checkbox("{$album}_enabled") ->label(t("Enable")) ->value(1) ->checked($album_defn->enabled); - $group->input("limit") + $group->input("{$album}_limit") ->label(t("Limit (leave empty for unlimited)")) - ->value(empty($updates->limit) ? "" : $updates->limit) + ->value(empty($album_defn->limit) ? "" : $album_defn->limit) ->rules("valid_numeric"); - $group->textarea("description") + $group->textarea("{$album}_description") ->label(t("Description")) ->rules("length[0,2048]") ->value($album_defn->description); -- cgit v1.2.3 From f4f6dacf7dd6f96c47db0486ab56c3ab546ba4ac Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 12:41:59 +0800 Subject: Correct the pattern match to compress multiple spaces into a single dot. Signed-off-by: Tim Almdal --- modules/g2_import/helpers/g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 66787467..7dd799c8 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -626,7 +626,7 @@ class g2_import_Core { // Multiword tags have the space changed to dots.s foreach ($tag_names as $tag_name) { $tags .= (strlen($tags) ? ", " : "") . - tag::add($g3_item, preg_replace('/\s\s+/', '.', $tag_name)); + tag::add($g3_item, preg_replace('/\s+/', '.', $tag_name)); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't -- cgit v1.2.3 From a059eff25d3e4975f39ad04181039d4544e47059 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 13:11:49 +0800 Subject: Make the tag event handle the iptc keywords consistently with other tag add mechanisms Signed-off-by: Tim Almdal --- modules/tag/helpers/tag_event.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 946326c0..7a170bf8 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -34,10 +34,13 @@ class tag_event_Core { if (!empty($iptc["2#025"])) { foreach($iptc["2#025"] as $tag) { $tag = str_replace("\0", "", $tag); - if (function_exists("mb_detect_encoding") && mb_detect_encoding($tag) != "UTF-8") { - $tag = utf8_encode($tag); + foreach (preg_split("/[,;]/", $tag) as $word) { + $word = preg_replace('/\s+/', '.', trim($word)); + if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") { + $word = utf8_encode($word); + } + $tags[$word] = 1; } - $tags[$tag] = 1; } } } -- cgit v1.2.3 From 5cf267cc4c4af79389276d786914cbb2b7a2ec25 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 08:01:32 -0700 Subject: Fix a bug where we were not properly locating the parent album when adding a new album or photo. Simplify the data structure that we pass down to server_add_tree.html.php so that we just pass a file list and let it do whatever it wants with it. --- modules/server_add/controllers/server_add.php | 44 ++++++++++++++++------- modules/server_add/views/server_add_tree.html.php | 6 ++-- 2 files changed, 35 insertions(+), 15 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index cf7077a8..446c5074 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -21,7 +21,7 @@ class Server_Add_Controller extends Admin_Controller { public function browse($id) { $paths = unserialize(module::get_var("server_add", "authorized_paths")); foreach (array_keys($paths) as $path) { - $files[$path] = basename($path); + $files[] = $path; } $item = ORM::factory("item", $id); @@ -54,7 +54,7 @@ class Server_Add_Controller extends Admin_Controller { } } - $tree->files[$file] = basename($file); + $tree->files[] = $file; } print $tree; } @@ -119,8 +119,8 @@ class Server_Add_Controller extends Admin_Controller { case "init": $task->set("mode", "build-file-list"); $task->set("queue", array_keys($selections)); - $task->status = t("Starting up"); $task->percent_complete = 0; + $task->status = t("Starting up"); batch::start(); break; @@ -132,6 +132,11 @@ class Server_Add_Controller extends Admin_Controller { while ($queue && microtime(true) - $start < 0.5) { $file = array_shift($queue); if (is_dir($file)) { + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $file; + $entry->save(); + $children = empty($selections[$file]) ? glob("$file/*") : $selections[$file]; } else { $children = array($file); @@ -187,6 +192,7 @@ class Server_Add_Controller extends Admin_Controller { $item = model_cache::get("item", $item_id); foreach ($entries as $entry) { + Kohana::log("alert",print_r($albums,1)); if (microtime(true) - $start > 0.5) { break; } @@ -195,19 +201,33 @@ class Server_Add_Controller extends Admin_Controller { $name = basename($relative_path); $title = item::convert_filename_to_title($name); if (is_dir($entry->file)) { - if (isset($albums[$relative_path]) && $parent_id = $albums[$relative_path]) { + $parent_path = dirname($relative_path); + Kohana::log("alert",print_r("rp: $relative_path -> $parent_path",1)); + if (isset($albums[$parent_path]) && $parent_id = $albums[$parent_path]) { $parent = ORM::factory("item", $parent_id); - } else { - $album = album::create($item, $name, $title, null, user::active()->id); - $albums[$relative_path] = $album->id; - $task->set("albums", $albums); - } - } else { - if (strpos($relative_path, "/") !== false) { - $parent = ORM::factory("item", $albums[dirname($relative_path)]); } else { $parent = $item; } + $album = album::create($parent, $name, $title, null, user::active()->id); + $albums[$relative_path] = $album->id; + $task->set("albums", $albums); + } else { + // Find the nearest selected parent. We check to see if any of the candidate parents + // were selected in the UI and if so, we use that. Otherwise, we fall back to making + // the parent the current item. + $parent_path = $relative_path; + $parent = null; + do { + if (strpos($parent_path, "/") !== false) { + if (array_key_exists($parent_path, $albums)) { + $parent = ORM::factory("item", $albums[$parent_path]); + } else { + $parent_path = dirname($parent_path); + } + } else { + $parent = $item; + } + } while (!$parent); $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) { diff --git a/modules/server_add/views/server_add_tree.html.php b/modules/server_add/views/server_add_tree.html.php index f8205a8b..74bc40e0 100644 --- a/modules/server_add/views/server_add_tree.html.php +++ b/modules/server_add/views/server_add_tree.html.php @@ -1,13 +1,13 @@ - $name): ?> +
  • "> -- cgit v1.2.3 From b3785e176145b10c84b3b27850679b13ab54bc81 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 08:04:37 -0700 Subject: Remove debug code. --- modules/server_add/controllers/server_add.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 446c5074..08e01858 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -192,7 +192,6 @@ class Server_Add_Controller extends Admin_Controller { $item = model_cache::get("item", $item_id); foreach ($entries as $entry) { - Kohana::log("alert",print_r($albums,1)); if (microtime(true) - $start > 0.5) { break; } @@ -202,7 +201,6 @@ class Server_Add_Controller extends Admin_Controller { $title = item::convert_filename_to_title($name); if (is_dir($entry->file)) { $parent_path = dirname($relative_path); - Kohana::log("alert",print_r("rp: $relative_path -> $parent_path",1)); if (isset($albums[$parent_path]) && $parent_id = $albums[$parent_path]) { $parent = ORM::factory("item", $parent_id); } else { -- cgit v1.2.3 From 12796ec2ca386895a713583c683348e7d02bc66b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 08:20:00 -0700 Subject: Create a new [options] submenu under the thumb menu, and move the Digibug print button into it. Right now, it doesn't display properly. --- modules/digibug/helpers/digibug_menu.php | 13 +++++++------ modules/gallery/helpers/gallery_menu.php | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php index f1d4fc1d..c95cada2 100644 --- a/modules/digibug/helpers/digibug_menu.php +++ b/modules/digibug/helpers/digibug_menu.php @@ -38,12 +38,13 @@ class digibug_menu { 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(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) - ->css_id("gDigibugLink")); + $menu->get("options_menu") + ->append( + Menu::factory("link") + ->id("digibug") + ->label(t("Print with Digibug")) + ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) + ->css_id("gDigibugLink")); } } } diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index 1f1e1ce2..bffb7696 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -95,6 +95,9 @@ class gallery_menu_Core { } static function thumb($menu, $theme, $item) { + $menu->append(Menu::factory("submenu") + ->id("options_menu") + ->label(t("Options"))); } static function photo($menu, $theme) { -- cgit v1.2.3 From 7c993387dadeb721f4c74185fc5ee0e376c4300b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 23:01:53 +0800 Subject: Move the dynamic module to gallery3-contrib Signed-off-by: Tim Almdal --- modules/dynamic/controllers/admin_dynamic.php | 81 --------------------------- modules/dynamic/controllers/dynamic.php | 64 --------------------- modules/dynamic/helpers/dynamic_installer.php | 46 --------------- modules/dynamic/helpers/dynamic_menu.php | 27 --------- modules/dynamic/helpers/dynamic_theme.php | 39 ------------- modules/dynamic/module.info | 3 - modules/dynamic/views/admin_dynamic.html.php | 5 -- modules/dynamic/views/dynamic_block.html.php | 10 ---- 8 files changed, 275 deletions(-) delete mode 100644 modules/dynamic/controllers/admin_dynamic.php delete mode 100644 modules/dynamic/controllers/dynamic.php delete mode 100644 modules/dynamic/helpers/dynamic_installer.php delete mode 100644 modules/dynamic/helpers/dynamic_menu.php delete mode 100644 modules/dynamic/helpers/dynamic_theme.php delete mode 100644 modules/dynamic/module.info delete mode 100644 modules/dynamic/views/admin_dynamic.html.php delete mode 100644 modules/dynamic/views/dynamic_block.html.php (limited to 'modules') diff --git a/modules/dynamic/controllers/admin_dynamic.php b/modules/dynamic/controllers/admin_dynamic.php deleted file mode 100644 index 50dac459..00000000 --- a/modules/dynamic/controllers/admin_dynamic.php +++ /dev/null @@ -1,81 +0,0 @@ -_get_view(); - } - - public function handler() { - access::verify_csrf(); - - $form = $this->_get_form(); - if ($form->validate()) { - foreach (array("updates", "popular") as $album) { - $album_defn = unserialize(module::get_var("dynamic", $album)); - $group = $form->inputs[$album]; - $album_defn->enabled = $group->inputs["{$album}_enabled"]->value; - $album_defn->description = $group->inputs["{$album}_description"]->value; - $album_defn->limit = $group->inputs["{$album}_limit"] === "" ? null : - $group->inputs["{$album}_limit"]->value; - module::set_var("dynamic", $album, serialize($album_defn)); - } - - message::success(t("Dynamic Albums Configured")); - - url::redirect("admin/dynamic"); - } - - print $this->_get_view($form); - } - - private function _get_view($form=null) { - $v = new Admin_View("admin.html"); - $v->content = new View("admin_dynamic.html"); - $v->content->form = empty($form) ? $this->_get_form() : $form; - return $v; - } - - private function _get_form() { - - $form = new Forge("admin/dynamic/handler", "", "post", - array("id" => "gAdminForm")); - - foreach (array("updates", "popular") as $album) { - $album_defn = unserialize(module::get_var("dynamic", $album)); - - $group = $form->group($album)->label(t($album_defn->title)); - $group->checkbox("{$album}_enabled") - ->label(t("Enable")) - ->value(1) - ->checked($album_defn->enabled); - $group->input("{$album}_limit") - ->label(t("Limit (leave empty for unlimited)")) - ->value(empty($album_defn->limit) ? "" : $album_defn->limit) - ->rules("valid_numeric"); - $group->textarea("{$album}_description") - ->label(t("Description")) - ->rules("length[0,2048]") - ->value($album_defn->description); - } - - $form->submit("submit")->value(t("Submit")); - - return $form; - } -} \ No newline at end of file diff --git a/modules/dynamic/controllers/dynamic.php b/modules/dynamic/controllers/dynamic.php deleted file mode 100644 index 6b5f2915..00000000 --- a/modules/dynamic/controllers/dynamic.php +++ /dev/null @@ -1,64 +0,0 @@ -_show("updates"); - } - - public function popular() { - print $this->_show("popular"); - } - - private function _show($album) { - $page_size = module::get_var("gallery", "page_size", 9); - $page = $this->input->get("page", "1"); - - $album_defn = unserialize(module::get_var("dynamic", $album)); - $children_count = $album_defn->limit; - if (empty($children_count)) { - $children_count = ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->count_all(); - } - - $offset = ($page-1) * $page_size; - - $max_pages = ceil($children_count / $page_size); - - // Make sure that the page references a valid offset - if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { - Kohana::show_404(); - } - - $template = new Theme_View("page.html", "dynamic"); - $template->set_global("page_size", $page_size); - $template->set_global("children", ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->orderby($album_defn->key_field, "DESC") - ->find_all($page_size, $offset)); - $template->set_global("children_count", $children_count); - $template->content = new View("dynamic.html"); - $template->content->title = t($album_defn->title); - - print $template; - } - -} \ No newline at end of file diff --git a/modules/dynamic/helpers/dynamic_installer.php b/modules/dynamic/helpers/dynamic_installer.php deleted file mode 100644 index 66d6298d..00000000 --- a/modules/dynamic/helpers/dynamic_installer.php +++ /dev/null @@ -1,46 +0,0 @@ - false, - "limit" => null, - "description" => "", - "key_field" => "view_count", - "title" => t("Most Viewed")))); - module::set_var("dynamic", "updates", - serialize((object)array("enabled" => false, - "limit" => null, - "description" => "", - "key_field" => "created", - "title" => t("Recent Changes")))); - module::set_version("dynamic", 1); - } - } - - static function upgrade($version) { - } - - static function uninstall() { - /* @todo Put database table drops here */ - module::delete("dynamic"); - } -} diff --git a/modules/dynamic/helpers/dynamic_menu.php b/modules/dynamic/helpers/dynamic_menu.php deleted file mode 100644 index b2c73d6f..00000000 --- a/modules/dynamic/helpers/dynamic_menu.php +++ /dev/null @@ -1,27 +0,0 @@ -get("content_menu") - ->append(Menu::factory("link") - ->id("dynamic_menu") - ->label(t("Dynamic Albums")) - ->url(url::site("admin/dynamic"))); - } -} diff --git a/modules/dynamic/helpers/dynamic_theme.php b/modules/dynamic/helpers/dynamic_theme.php deleted file mode 100644 index ba355098..00000000 --- a/modules/dynamic/helpers/dynamic_theme.php +++ /dev/null @@ -1,39 +0,0 @@ -enabled) { - $albums[$album] = $album_defn->title; - } - } - if (!empty($albums)) { - $block = new Block(); - $block->css_id = "gDynamic"; - $block->title = t("Dynamic Albums"); - $block->content = new View("dynamic_block.html"); - $block->content->albums = $albums; - return $block; - } - return ""; - } - -} diff --git a/modules/dynamic/module.info b/modules/dynamic/module.info deleted file mode 100644 index aa5e0432..00000000 --- a/modules/dynamic/module.info +++ /dev/null @@ -1,3 +0,0 @@ -name = Dynamic -description = Adds the Recent Changes and Most Viewed dynamic albums -version = 1 diff --git a/modules/dynamic/views/admin_dynamic.html.php b/modules/dynamic/views/admin_dynamic.html.php deleted file mode 100644 index cd7ccfea..00000000 --- a/modules/dynamic/views/admin_dynamic.html.php +++ /dev/null @@ -1,5 +0,0 @@ - -
    -

    - -
    diff --git a/modules/dynamic/views/dynamic_block.html.php b/modules/dynamic/views/dynamic_block.html.php deleted file mode 100644 index d14c2900..00000000 --- a/modules/dynamic/views/dynamic_block.html.php +++ /dev/null @@ -1,10 +0,0 @@ - -
    -
      - $text): ?> -
    • - "> -
    • - -
    -
    -- cgit v1.2.3 From 86a7b15d206d29387637864f63b7ac795fce981d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 10:39:59 -0700 Subject: Compact all menus. This fixes the problem that the new [Options] thumb menu shows up when it has nothing in it. --- modules/gallery/libraries/Theme_View.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 898574d7..75138f25 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -127,6 +127,7 @@ class Theme_View_Core extends Gallery_View { } } + $menu->compact(); print $menu; } -- cgit v1.2.3 From 09c9b1a75561881a40ada71f02710355923602e2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 11:35:28 -0700 Subject: Added the upload::required validation in order to insure that failed uploads are not treated as successful. Log any exceptions to the Kohana log and return the error message --- modules/gallery/controllers/simple_uploader.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index 713e30af..a059f986 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -1,3 +1,4 @@ + add_rules( - "Filedata", "upload::valid", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); + "Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); if ($file_validation->validate()) { // SimpleUploader.swf does not yet call /start directly, so simulate it here for now. if (!batch::in_progress()) { @@ -54,7 +55,7 @@ class Simple_Uploader_Controller extends Controller { try { $name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $title = item::convert_filename_to_title($name); - $path_info = pathinfo($temp_filename); + $path_info = @pathinfo($temp_filename); if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { $movie = movie::create($album, $temp_filename, $name, $title); @@ -66,12 +67,20 @@ class Simple_Uploader_Controller extends Controller { html::anchor("photos/$photo->id", t("view photo"))); } } catch (Exception $e) { - unlink($temp_filename); - throw $e; + Kohana::log("alert", $e->__toString()); + if (file_exists($temp_filename)) { + unlink($temp_filename); + } + header("HTTP/1.1 500 Internal Server Error"); + print "ERROR:" . $e->getMessage(); + return; } unlink($temp_filename); + print "FILEID: $photo->id"; + } else { + header("HTTP/1.1 400 Bad Request"); + print "ERROR: Invalid Upload"; } - print "File Received"; } public function finish() { -- cgit v1.2.3 From 863deab3d34359b2e33df718f3da4db1f97a7c7d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 12:54:25 -0700 Subject: Fix a bug where the task message was not being set --- modules/search/helpers/search_task.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 395bcd98..df1dfe16 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -69,6 +69,7 @@ class search_task_Core { $task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent)); + $message[] = $task->status; } catch (Exception $e) { $task->done = true; $task->state = "error"; -- cgit v1.2.3 From 15bb52a7767d141ff10179f36ea8389f461df801 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 14:12:13 -0700 Subject: Change the word "Done" to "Close" to make translations easier --- modules/gallery/views/admin_maintenance_task.html.php | 2 +- modules/gallery/views/simple_uploader.html.php | 2 +- modules/organize/views/organize_button_pane.html.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index d9aecc60..5c2c03a1 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -30,6 +30,6 @@
    - +
    diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 56b1c656..e1add7f7 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -51,7 +51,7 @@ diff --git a/modules/organize/views/organize_button_pane.html.php b/modules/organize/views/organize_button_pane.html.php index cd780d5e..c5839a44 100644 --- a/modules/organize/views/organize_button_pane.html.php +++ b/modules/organize/views/organize_button_pane.html.php @@ -46,5 +46,5 @@
    - +
    -- cgit v1.2.3 From f887fd32a46f4c5daa4c0adf8e6a297237c043c3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 14:19:33 -0700 Subject: Forgot to add this file when change "Done"'s to "Close"'s --- modules/gallery/views/admin_maintenance.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index cd1cc02e..450eb754 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -79,7 +79,7 @@ state == "cancelled"): ?> - + state == "stalled"): ?> -- cgit v1.2.3 From fabdde9bb97bc01c52de41069fed0d046717d3fe Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 17:46:33 -0700 Subject: Reference exif consistently as EXIF ticket #526. --- modules/exif/helpers/exif_task.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index 649ad092..6929b797 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -57,7 +57,7 @@ class exif_task_Core { $completed++; exif::extract($item); - $message[] = t("Updated Exif meta data for '%title'", + $message[] = t("Updated EXIF meta data for '%title'", array("title" => p::purify($item->title))); } -- cgit v1.2.3 From fe6320ef4c976df037c259c85bab26c508659ba9 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 18:11:12 -0700 Subject: Fix for ticket #341. Change the wording for the sort order from "Default" to "Order Added" --- modules/gallery/helpers/album.php | 2 +- modules/organize/helpers/organize.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 362b93d0..1197f243 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -111,7 +111,7 @@ class album_Core { $sort_order->dropdown("column", array("id" => "gAlbumSortColumn")) ->label(t("Sort by")) - ->options(array("weight" => t("Default"), + ->options(array("weight" => t("Order Added"), "captured" => t("Capture Date"), "created" => t("Creation Date"), "title" => t("Title"), diff --git a/modules/organize/helpers/organize.php b/modules/organize/helpers/organize.php index 9bf4e986..25284771 100644 --- a/modules/organize/helpers/organize.php +++ b/modules/organize/helpers/organize.php @@ -43,7 +43,7 @@ class organize_Core { $sortPane->hidden("item[]")->value($item->id); $sortPane->dropdown("column", array("id" => "gAlbumSortColumn")) ->label(t("Sort by")) - ->options(array("weight" => t("Default"), + ->options(array("weight" => t("Order Added"), "captured" => t("Capture Date"), "created" => t("Creation Date"), "title" => t("Title"), -- cgit v1.2.3 From 6320babf78deb66f0916e569b36eaeb598603997 Mon Sep 17 00:00:00 2001 From: Shai Ben-Naphtali Date: Sat, 11 Jul 2009 13:56:43 +0800 Subject: Fixes ticket #526 Signed-off-by: Tim Almdal --- modules/exif/helpers/exif.php | 2 +- modules/exif/helpers/exif_task.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index b0e7e93f..20ecd0cb 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -163,7 +163,7 @@ class exif_Core { list ($remaining) = exif::stats(); if ($remaining) { site_status::warning( - t('Your EXIF index needs to be updated. Fix this now', + t('Your Exif index needs to be updated. Fix this now', array("url" => url::site("admin/maintenance/start/exif_task::update_index?csrf=__CSRF__"))), "exif_index_out_of_date"); } diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index 6929b797..f3e77975 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -28,12 +28,12 @@ class exif_task_Core { list ($remaining, $total, $percent) = exif::stats(); return array(Task_Definition::factory() ->callback("exif_task::update_index") - ->name(t("Extract EXIF data")) + ->name(t("Extract Exif data")) ->description($remaining ? t2("1 photo needs to be scanned", "%count (%percent%) of your photos need to be scanned", $remaining, array("percent" => (100 - $percent))) - : t("EXIF data is up-to-date")) + : t("Exif data is up-to-date")) ->severity($remaining ? log::WARNING : log::SUCCESS)); } @@ -57,7 +57,7 @@ class exif_task_Core { $completed++; exif::extract($item); - $message[] = t("Updated EXIF meta data for '%title'", + $message[] = t("Updated Exif meta data for '%title'", array("title" => p::purify($item->title))); } -- cgit v1.2.3 From e0e450d90fe67ac199d82d2b8e902cff5c8b6c7d Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sat, 11 Jul 2009 00:40:57 -0600 Subject: Position gItem and gPhoto relative, then position quick and thumb menus as absolute within them. Moved css from quick.js to quick.css. --- modules/gallery/css/quick.css | 12 ++++++++++++ modules/gallery/helpers/gallery_menu.php | 3 ++- modules/gallery/js/quick.js | 11 +---------- themes/default/css/screen.css | 18 +++++++++++++++++- themes/default/js/ui.init.js | 8 ++++++++ 5 files changed, 40 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/gallery/css/quick.css b/modules/gallery/css/quick.css index 02f9953e..0e45eac2 100644 --- a/modules/gallery/css/quick.css +++ b/modules/gallery/css/quick.css @@ -1,3 +1,12 @@ +#gQuickPane { + position: absolute; + top: 0; + left: 0; + text-align: center; + width: 100%; + height: auto; +} + .gItem:hover { background-color: #cfdeff; } @@ -12,6 +21,9 @@ background: #000; border-bottom: 1px solid #ccc; opacity: 0.9; + position: absolute; + top: 0; + left: 0; } #gQuickPane a { diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index bffb7696..b6f763b8 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -97,7 +97,8 @@ class gallery_menu_Core { static function thumb($menu, $theme, $item) { $menu->append(Menu::factory("submenu") ->id("options_menu") - ->label(t("Options"))); + ->label(t("Options")) + ->css_class("gThumbMenu")); } static function photo($menu, $theme) { diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 4ebdac47..32e34ef3 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -13,16 +13,7 @@ var show_quick = function() { var quick = $(this).find(".gQuick"); $("#gQuickPane").remove(); cont.append("
    "); - var img = cont.find(".gThumbnail,.gResize"); - var pos = cont.position(); - $("#gQuickPane").css({ - "position": "absolute", - "top": pos.top, - "left": pos.left, - "text-align": "center", - "width": cont.innerWidth() + 1, - "height": "auto" - }).hide(); + $("#gQuickPane").hide(); cont.hover(function() {}, hide_quick); $.get( quick.attr("href"), diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 41e51623..d08ada17 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -460,6 +460,7 @@ form .gError, height: 240px; overflow: hidden; padding: 14px 8px; + position: relative; text-align: center; width: 213px; } @@ -487,7 +488,7 @@ form .gError, } #gContent #gPhoto { - + position: relative; } #gContent #gItem .gFullSizeLink img { @@ -581,6 +582,21 @@ form .gError, margin-bottom: 0; } +/* Thumb Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +.gItem .gMenu { + bottom: 0; + margin-bottom: -2px; + position: absolute; + right: 0; +} + +.gItem .gMenu li { + font-weight: normal !important; +} + +/* View Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #gViewMenu { margin-bottom: 1em; } diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index 9d9d3079..29e04d5e 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -36,6 +36,14 @@ $(document).ready(function() { $(dialogLinks[i]).bind("click", handleDialogEvent); } + // gThumbMenu + if ($(".gItem .gMenu").length) { + $(".gItem .gMenu").removeClass("sf-menu"); + $(".gItem .gMenu span").removeClass("sf-sub-indicator"); + $(".gItem .gMenu span").addClass("ui-icon ui-icon-triangle-1-n"); + $(".gItem .gMenu li:first-child").addClass("ui-icon-right ui-corner-top ui-state-default"); + } + // Initialize view menu if ($("#gViewMenu").length) { $("#gViewMenu ul").removeClass("gMenu").removeClass("sf-menu"); -- cgit v1.2.3 From f1b2a14f4fe1bfd9419d4023b6b6223bc39c379b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 23:45:29 -0700 Subject: Add a title attribute to the li of a menu --- modules/gallery/libraries/Menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 6d0881ce..9ede49b6 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -207,7 +207,7 @@ class Menu_Core extends Menu_Element { public function __toString() { $html = $this->is_root ? "
      " : - "
    • $this->label
        "; + "
      • label\">$this->label
          "; $html .= implode("\n", $this->elements); $html .= $this->is_root ? "
        " : "
    • "; return $html; -- cgit v1.2.3 From 954ab5a5051edb67eca8ae74283a80a226e39672 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:03:36 -0700 Subject: Further simplify server_add (and bump it to version 3). Now we don't have checkboxes, but instead we restrict you to selecting directories and albums from only one level in the hierarchy. This makes it easier for us to make sure that we properly create the hierarchy that you want and avoid confusion about what's going to wind up where. Modify Server_Add_File_Model to have a parent_id and item_id and then modify them as we go so that we can build up a tree structure there *before* we create any items. This makes it much easier to figure out where a new item is going to go and get rid of a bunch of probably buggy code in the main task. --- modules/server_add/controllers/server_add.php | 199 +++++++++------------ .../server_add/helpers/server_add_installer.php | 8 +- modules/server_add/js/server_add.js | 67 ++----- modules/server_add/module.info | 2 +- modules/server_add/views/server_add_tree.html.php | 56 ++++-- themes/default/css/screen.css | 20 +-- 6 files changed, 158 insertions(+), 194 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 08e01858..6056d7cd 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -29,51 +29,58 @@ class Server_Add_Controller extends Admin_Controller { $view->item = $item; $view->tree = new View("server_add_tree.html"); $view->tree->files = $files; + $view->tree->parents = array(); print $view; } public function children() { $path = $this->input->get("path"); - if (!server_add::is_valid_path($path)) { - throw new Exception("@todo BAD_PATH"); - } $tree = new View("server_add_tree.html"); $tree->files = array(); - $tree->tree_id = substr(md5($path), 10); + $tree->parents = array(); - foreach (glob("$path/*") as $file) { - if (!is_readable($file)) { - continue; + // Make a tree with the parents back up to the authorized path, and all the children under the + // current path. + if (server_add::is_valid_path($path)) { + $tree->parents[] = $path; + while (server_add::is_valid_path(dirname($tree->parents[0]))) { + array_unshift($tree->parents, dirname($tree->parents[0])); } - if (!is_dir($file)) { - $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); - if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + foreach (glob("$path/*") as $file) { + if (!is_readable($file)) { continue; } - } + if (!is_dir($file)) { + $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); + if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + continue; + } + } - $tree->files[] = $file; + $tree->files[] = $file; + } + } else { + // Missing or invalid path; print out the list of authorized path + $paths = unserialize(module::get_var("server_add", "authorized_paths")); + foreach (array_keys($paths) as $path) { + $tree->files[] = $path; + } } print $tree; } + /** + * Begin the task of adding photos. + */ public function start() { access::verify_csrf(); - $item = ORM::factory("item", Input::instance()->get("item_id")); - // We're an admin so this isn't necessary, but we'll eventually open this up to non-admins and - // this also verifies that the item was loaded properly. - access::required("edit", $item); - // Gather up all the paths and associate them by directory, so that we can locate any empty - // directories for the next round. foreach (Input::instance()->post("paths") as $path) { - if (is_dir($path)) { - $selections[$path] = array(); - } else if (is_file($path)) { - $selections[dirname($path)][] = $path; + if (server_add::is_valid_path($path)) { + $paths[] = array($path, null); } } @@ -81,8 +88,7 @@ class Server_Add_Controller extends Admin_Controller { ->callback("Server_Add_Controller::add") ->description(t("Add photos or movies from the local server")) ->name(t("Add from server")); - $task = task::create( - $task_def, array("item_id" => $item->id, "selections" => $selections)); + $task = task::create($task_def, array("item_id" => $item->id, "queue" => $paths)); print json_encode( array("result" => "started", @@ -90,6 +96,9 @@ class Server_Add_Controller extends Admin_Controller { "url" => url::site("server_add/run/$task->id?csrf=" . access::csrf_token()))); } + /** + * Run the task of adding photos + */ function run($task_id) { access::verify_csrf(); @@ -110,49 +119,48 @@ class Server_Add_Controller extends Admin_Controller { * them one at a time. */ static function add($task) { - $selections = $task->get("selections"); $mode = $task->get("mode", "init"); $start = microtime(true); - $item_id = $task->get("item_id"); switch ($mode) { case "init": $task->set("mode", "build-file-list"); - $task->set("queue", array_keys($selections)); $task->percent_complete = 0; $task->status = t("Starting up"); batch::start(); break; - case "build-file-list": /* 0% to 10% */ + case "build-file-list": // 0% to 10% // We can't fit an arbitrary number of paths in a task, so store them in a separate table. // Don't use an iterator here because we can't get enough control over it when we're dealing - // with a deep hierarchy and we don't want to go over our time quota. + // with a deep hierarchy and we don't want to go over our time quota. The queue is in the + // form [path, parent_id] where the parent_id refers to another Server_Add_File_Model. We + // have this extra level of abstraction because we don't know its Item_Model id yet. $queue = $task->get("queue"); while ($queue && microtime(true) - $start < 0.5) { - $file = array_shift($queue); - if (is_dir($file)) { - $entry = ORM::factory("server_add_file"); - $entry->task_id = $task->id; - $entry->file = $file; - $entry->save(); - - $children = empty($selections[$file]) ? glob("$file/*") : $selections[$file]; - } else { - $children = array($file); - } - - foreach ($children as $child) { - $entry = ORM::factory("server_add_file"); - $entry->task_id = $task->id; - $entry->file = $child; - $entry->save(); + list($file, $parent_entry_id) = array_shift($queue); + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $file; + $entry->parent_id = $parent_entry_id; + $entry->save(); + foreach (glob("$file/*") as $child) { if (is_dir($child)) { - $queue[] = $child; + $queue[] = array($child, $entry->id); + } else { + $ext = strtolower(pathinfo($child, PATHINFO_EXTENSION)); + if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + $child_entry = ORM::factory("server_add_file"); + $child_entry->task_id = $task->id; + $child_entry->file = $child; + $child_entry->parent_id = $entry->id; + $child_entry->save(); + } } } } + // We have no idea how long this can take because we have no idea how deep the tree // hierarchy rabbit hole goes. Leave ourselves room here for 100 iterations and don't go // over 10% in percent_complete. @@ -168,79 +176,67 @@ class Server_Add_Controller extends Admin_Controller { $task->set( "total_files", database::instance()->count_records( "server_add_files", array("task_id" => $task->id))); - $task->set("albums", array()); - $task->set("completed", 0); $task->percent_complete = 10; } break; - case "add-files": /* 10% to 100% */ - $completed_files = $task->get("completed_files"); + case "add-files": // 10% to 100% + $completed_files = $task->get("completed_files", 0); $total_files = $task->get("total_files"); - $albums = $task->get("albums"); // Ordering by id ensures that we add them in the order that we created the entries, which - // will create albums first. + // will create albums first. Ignore entries which already have an Item_Model attached, + // they're done. $entries = ORM::factory("server_add_file") ->where("task_id", $task->id) + ->where("item_id", null) ->orderby("id", "ASC") ->limit(10) ->find_all(); if ($entries->count() == 0) { + // Out of entries, we're done. $task->set("mode", "done"); } - $item = model_cache::get("item", $item_id); + $owner_id = user::active()->id; foreach ($entries as $entry) { if (microtime(true) - $start > 0.5) { break; } - $relative_path = self::_relative_path($entry->file); - $name = basename($relative_path); + // Look up the parent item for this entry. By now it should exist, but if none was + // specified, then this belongs as a child of the current item. + $parent_entry = ORM::factory("server_add_file", $entry->parent_id); + if (!$parent_entry->loaded) { + $parent = ORM::factory("item", $task->get("item_id")); + } else { + $parent = ORM::factory("item", $parent_entry->item_id); + } + + $name = basename($entry->file); $title = item::convert_filename_to_title($name); if (is_dir($entry->file)) { - $parent_path = dirname($relative_path); - if (isset($albums[$parent_path]) && $parent_id = $albums[$parent_path]) { - $parent = ORM::factory("item", $parent_id); - } else { - $parent = $item; - } - $album = album::create($parent, $name, $title, null, user::active()->id); - $albums[$relative_path] = $album->id; - $task->set("albums", $albums); + $album = album::create($parent, $name, $title, null, $owner_id); + $entry->item_id = $album->id; } else { - // Find the nearest selected parent. We check to see if any of the candidate parents - // were selected in the UI and if so, we use that. Otherwise, we fall back to making - // the parent the current item. - $parent_path = $relative_path; - $parent = null; - do { - if (strpos($parent_path, "/") !== false) { - if (array_key_exists($parent_path, $albums)) { - $parent = ORM::factory("item", $albums[$parent_path]); - } else { - $parent_path = dirname($parent_path); - } - } else { - $parent = $item; - } - } while (!$parent); - $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) { - photo::create($parent, $entry->file, $name, $title, null, user::active()->id); + $photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id); + $entry->item_id = $photo->id; } else if (in_array($extension, array("flv", "mp4"))) { - movie::create($parent, $entry->file, $name, $title, null, user::active()->id); + $movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id); + $entry->item_id = $movie->id; } else { - $task->log("Skipping unknown file type: $relative_path"); - // Unsupported type - // @todo: $task->log this + // This should never happen, because we don't add stuff to the list that we can't + // process. But just in, case.. set this to a non-null value so that we skip this + // entry. + $entry->item_id = 0; + $task->log("Skipping unknown file type: $entry->file"); } } $completed_files++; - $entry->delete(); + $entry->save(); } $task->set("completed_files", $completed_files); $task->status = t("Adding photos and albums (%completed of %total)", @@ -254,33 +250,10 @@ class Server_Add_Controller extends Admin_Controller { $task->done = true; $task->state = "success"; $task->percent_complete = 100; + ORM::factory("server_add_file")->where("task_id", $task->id)->delete_all(); message::info(t2("Successfully added one photo", - "Successfully added %count photos", + "Successfully added %count photos and albums", $task->get("completed_files"))); } } - - /** - * Given a path that's somewhere in our authorized_paths list, return just the part that's - * relative to the nearest authorized path. - */ - static function _relative_path($path) { - static $authorized_paths; - // @todo this doesn't deal well with overlapping authorized paths, it'll just use the first one - // that matches. If we sort $authorized_paths by length in descending order, that should take - // care of the problem. - if (!$authorized_paths) { - $authorized_paths = - array_keys(unserialize(module::get_var("server_add", "authorized_paths"))); - } - - foreach ($authorized_paths as $candidate) { - $candidate = dirname($candidate); - if (strpos($path, $candidate) === 0) { - return substr($path, strlen($candidate) + 1); - } - } - - throw new Exception("@todo BAD_PATH"); - } } diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index 6956a72c..4cc34207 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -22,8 +22,10 @@ class server_add_installer { $db = Database::instance(); $db->query("CREATE TABLE {server_add_files} ( `id` int(9) NOT NULL auto_increment, - `task_id` int(9) NOT NULL, `file` varchar(255) NOT NULL, + `item_id` int(9), + `parent_id` int(9), + `task_id` int(9) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("server_add", 2); @@ -40,6 +42,10 @@ class server_add_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("server_add", $version = 2); + } else if ($version == 2) { + $db->query("ALTER TABLE {server_add_files} ADD COLUMN `item_id` int(9)"); + $db->query("ALTER TABLE {server_add_files} ADD COLUMN `parent_id` int(9)"); + module::set_version("server_add", $version = 3); } } diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index 1a78d733..989555cc 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -1,51 +1,9 @@ /** - * We've clicked the + icon next to a directory. Load up children of this - * directory from the server and display them. + * Manage file selection state. */ -function open_close_branch(path, id) { - var parent = $("#file_" + id); - var children = $("#tree_" + id); - var icon = parent.find(".ui-icon:first"); - - if (!children.html()) { - parent.addClass("gLoadingSmall"); - $.ajax({ - url: GET_CHILDREN_URL.replace("__PATH__", path), - success: function(data, textStatus) { - children.html(data); - parent.removeClass("gLoadingSmall"); - - // Propagate checkbox value - children.find("input[type=checkbox]").attr( - "checked", parent.find("input[type=checkbox]:first").attr("checked")); - } - }); - } - - children.slideToggle("fast", function() { - if (children.is(":hidden")) { - icon.addClass("ui-icon-plus"); - icon.removeClass("ui-icon-minus"); - } else { - icon.addClass("ui-icon-minus"); - icon.removeClass("ui-icon-plus"); - parent.removeClass("gCollapsed"); - } - }); -} - -/** - * We've clicked a checkbox. Propagate the value downwards as necessary. - */ -function click_node(checkbox) { - var parent = $(checkbox).parents("li").get(0); - var checked = $(checkbox).attr("checked"); - $(parent).find("input[type=checkbox]").attr("checked", checked); - - // @todo if we uncheck all the children for a parent, we should uncheck the - // parent itself, otherwise in the code we'll add the entire parent since if - // we find an album as a leaf, we assume that it's never been expanded in the UI. - if ($("#gServerAddTree").find("input[type=checkbox]").is(":checked")) { +function select_file(li) { + $(li).toggleClass("selected"); + if ($("#gServerAdd span.selected").length) { $("#gServerAddAddButton").enable(true); $("#gServerAddAddButton").removeClass("ui-state-disabled"); } else { @@ -54,11 +12,24 @@ function click_node(checkbox) { } } +/** + * Load a new directory + */ +function open_dir(path) { + $.ajax({ + url: GET_CHILDREN_URL.replace("__PATH__", path), + success: function(data, textStatus) { + $("#gServerAddTree").html(data); + } + }); +} + function start_add() { var paths = []; - $.each($("#gServerAdd :checkbox[checked]"), function () { - paths.push(this.value); + $.each($("#gServerAdd span.selected"), function () { + paths.push($(this).attr("file")); }); + $.ajax({ url: START_URL, type: "POST", diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 1c99d280..295d3beb 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -1,3 +1,3 @@ name = Server Add description = Allows authorized users to load images directly from your web server -version = 2 +version = 3 diff --git a/modules/server_add/views/server_add_tree.html.php b/modules/server_add/views/server_add_tree.html.php index 74bc40e0..254a9da0 100644 --- a/modules/server_add/views/server_add_tree.html.php +++ b/modules/server_add/views/server_add_tree.html.php @@ -1,19 +1,41 @@ - - -
    • "> - - - - - - - +
    • + + + + +
        + + +
      • + + + + +
          + + + +
        • + "> + + ondblclick="open_dir($(this).attr('file'))" + + file="" + > + + +
        • + + +
        • + + + +
        +
      • + + +
    • - - -
    • - diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 41e51623..842a1491 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -879,24 +879,20 @@ form .gError, /* Server Add */ -.gCheckboxTree input { - display: inline; +#gServerAddTree { + cursor: pointer; } -.gCheckboxTree li { +#gServerAddTree li { padding: 0; float: none; } -.gCheckboxTree .ui-icon { - cursor: pointer; +#gServerAddTree span.selected { + background: #ddd; } -.gFile { - padding-left: 2.5em; -} - -#gServerAdd #gServerAddTree { +#gServerAddTree { border: 1px solid #ccc; height: 25em; overflow: auto; @@ -909,10 +905,6 @@ form .gError, padding-left: 1.2em; } -#gServerAdd ul li .gFile { - padding-left: 2.5em; -} - #gServerAdd .gBreadcrumbs { font-size: 1em; padding: 0; -- cgit v1.2.3 From 4132d6c55ed91ca66607680bc44775c4ba650da6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 11 Jul 2009 15:47:04 -0700 Subject: Put quotes around the href param (href="#") --- modules/gallery/libraries/Menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 9ede49b6..d37be7d3 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -207,7 +207,7 @@ class Menu_Core extends Menu_Element { public function __toString() { $html = $this->is_root ? "
        " : - "
      • label\">$this->label
          "; + "
        • label\">$this->label
            "; $html .= implode("\n", $this->elements); $html .= $this->is_root ? "
          " : "
      • "; return $html; -- cgit v1.2.3 From 22fcb4c776d8034766c861847ead8e0f18518ed0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:14:02 -0700 Subject: Forgot to bump the version up to 3 --- modules/server_add/helpers/server_add_installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index 4cc34207..67c7a377 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -28,7 +28,7 @@ class server_add_installer { `task_id` int(9) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_version("server_add", 2); + module::set_version("server_add", 3); server_add::check_config(); } -- cgit v1.2.3 From 6281ed03d54a010efdee3988a893cfcd7f3663b5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:36:31 -0700 Subject: Turn off extended inserts when creating install.sql so that it's easier to see what's changed. --- installer/install.sql | 49 ++++++++++++++++++++++++++------ modules/gallery/controllers/packager.php | 4 +-- 2 files changed, 43 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index d719d49d..bda576d1 100755 --- a/installer/install.sql +++ b/installer/install.sql @@ -88,7 +88,8 @@ CREATE TABLE {graphics_rules} ( PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','resize',100,'thumb'),(2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','resize',100,'resize'); +INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','resize',100,'thumb'); +INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','resize',100,'resize'); DROP TABLE IF EXISTS {groups}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -100,7 +101,8 @@ CREATE TABLE {groups} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {groups} VALUES (1,'Everybody',1),(2,'Registered Users',1); +INSERT INTO {groups} VALUES (1,'Everybody',1); +INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -111,7 +113,9 @@ CREATE TABLE {groups_users} ( UNIQUE KEY `user_id` (`user_id`,`group_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {groups_users} VALUES (1,1),(1,2),(2,2); +INSERT INTO {groups_users} VALUES (1,1); +INSERT INTO {groups_users} VALUES (1,2); +INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -221,7 +225,15 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {modules} VALUES (1,1,'gallery',6),(2,1,'user',1),(3,1,'comment',2),(4,1,'organize',1),(5,1,'info',1),(6,1,'rss',1),(7,1,'search',1),(8,1,'slideshow',1),(9,1,'tag',1); +INSERT INTO {modules} VALUES (1,1,'gallery',6); +INSERT INTO {modules} VALUES (2,1,'user',1); +INSERT INTO {modules} VALUES (3,1,'comment',2); +INSERT INTO {modules} VALUES (4,1,'organize',1); +INSERT INTO {modules} VALUES (5,1,'info',1); +INSERT INTO {modules} VALUES (6,1,'rss',1); +INSERT INTO {modules} VALUES (7,1,'search',1); +INSERT INTO {modules} VALUES (8,1,'slideshow',1); +INSERT INTO {modules} VALUES (9,1,'tag',1); DROP TABLE IF EXISTS {outgoing_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -248,7 +260,10 @@ CREATE TABLE {permissions} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {permissions} VALUES (1,'View','view'),(2,'View Full Size','view_full'),(3,'Edit','edit'),(4,'Add','add'); +INSERT INTO {permissions} VALUES (1,'View','view'); +INSERT INTO {permissions} VALUES (2,'View Full Size','view_full'); +INSERT INTO {permissions} VALUES (3,'Edit','edit'); +INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -313,7 +328,8 @@ CREATE TABLE {themes} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {themes} VALUES (1,'default',1),(2,'admin_default',1); +INSERT INTO {themes} VALUES (1,'default',1); +INSERT INTO {themes} VALUES (2,'admin_default',1); DROP TABLE IF EXISTS {users}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -335,7 +351,8 @@ CREATE TABLE {users} ( UNIQUE KEY `hash` (`hash`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL),(2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); +INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); +INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -348,4 +365,20 @@ CREATE TABLE {vars} ( UNIQUE KEY `module_name` (`module_name`,`name`) ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','date_format','Y-M-d'),(20,'gallery','date_time_format','Y-M-d H:i:s'),(21,'gallery','time_format','H:i:s'),(22,'gallery','show_credits','1'),(23,'gallery','credits','Powered by Gallery %version'),(25,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'); +INSERT INTO {vars} VALUES (2,'gallery','active_admin_theme','admin_default'); +INSERT INTO {vars} VALUES (3,'gallery','page_size','9'); +INSERT INTO {vars} VALUES (4,'gallery','thumb_size','200'); +INSERT INTO {vars} VALUES (5,'gallery','resize_size','640'); +INSERT INTO {vars} VALUES (6,'gallery','default_locale','en_US'); +INSERT INTO {vars} VALUES (7,'gallery','image_quality','75'); +INSERT INTO {vars} VALUES (9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'); +INSERT INTO {vars} VALUES (14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'); +INSERT INTO {vars} VALUES (17,'gallery','version','3.0 pre beta 2 (git)'); +INSERT INTO {vars} VALUES (18,'gallery','choose_default_tookit','1'); +INSERT INTO {vars} VALUES (19,'gallery','date_format','Y-M-d'); +INSERT INTO {vars} VALUES (20,'gallery','date_time_format','Y-M-d H:i:s'); +INSERT INTO {vars} VALUES (21,'gallery','time_format','H:i:s'); +INSERT INTO {vars} VALUES (22,'gallery','show_credits','1'); +INSERT INTO {vars} VALUES (23,'gallery','credits','Powered by Gallery %version'); +INSERT INTO {vars} VALUES (25,'comment','spam_caught','0'); diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php index da0a7983..7b4d68f6 100644 --- a/modules/gallery/controllers/packager.php +++ b/modules/gallery/controllers/packager.php @@ -98,7 +98,7 @@ class Packager_Controller extends Controller { print "$sql_file is not writeable"; return; } - $command = "mysqldump --compact --add-drop-table -h{$conn['host']} " . + $command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " . "-u{$conn['user']} $pass {$conn['database']} > $sql_file"; exec($command, $output, $status); if ($status) { @@ -153,7 +153,7 @@ class Packager_Controller extends Controller { $paths[] = "VARPATH . \"" . substr($name, strlen(VARPATH)) . "\""; } else { // @todo: serialize non-directories - print "Unknown file: $name"; + print "IGNORING FILE: $name\n"; return; } } -- cgit v1.2.3 From ecc7d881e3bad1dd8edf5cbd4382bda9a668fcb8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:52:50 -0700 Subject: Fix bug introduced in e0e450d90fe67ac199d82d2b8e902cff5c8b6c7d where it got rid of the 'img' var which is used when we set the click action on buttons. Partial fix for #528. --- modules/gallery/js/quick.js | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 32e34ef3..28ced3f6 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -11,6 +11,7 @@ $(document).ready(function() { var show_quick = function() { var cont = $(this); var quick = $(this).find(".gQuick"); + var img = cont.find(".gThumbnail,.gResize"); $("#gQuickPane").remove(); cont.append("
        "); $("#gQuickPane").hide(); -- cgit v1.2.3 From 6b013060aabc1d13545958fdb3c096faac2ba5a7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 06:15:44 -0700 Subject: Fix style: space after ) before {. --- modules/gallery/js/quick.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 28ced3f6..2dcb1c36 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -22,10 +22,10 @@ var show_quick = function() { function(data, textStatus) { $("#gQuickPane").html(data).slideDown("fast"); $(".ui-state-default").hover( - function(){ + function() { $(this).addClass("ui-state-hover"); }, - function(){ + function() { $(this).removeClass("ui-state-hover"); } ); -- cgit v1.2.3 From 4d0099e7165a4a1508eea58613cdc75e116464ff Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 06:24:10 -0700 Subject: Fix a bug where we're referring to $photo when we just uploaded a $movie, that causes the simpler uploader to throw an error for all movies. --- modules/gallery/controllers/simple_uploader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index a059f986..75a7b810 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -58,13 +58,13 @@ class Simple_Uploader_Controller extends Controller { $path_info = @pathinfo($temp_filename); if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { - $movie = movie::create($album, $temp_filename, $name, $title); + $item = movie::create($album, $temp_filename, $name, $title); log::success("content", t("Added a movie"), - html::anchor("movies/$movie->id", t("view movie"))); + html::anchor("movies/$item->id", t("view movie"))); } else { - $photo = photo::create($album, $temp_filename, $name, $title); + $item = photo::create($album, $temp_filename, $name, $title); log::success("content", t("Added a photo"), - html::anchor("photos/$photo->id", t("view photo"))); + html::anchor("photos/$item->id", t("view photo"))); } } catch (Exception $e) { Kohana::log("alert", $e->__toString()); @@ -76,7 +76,7 @@ class Simple_Uploader_Controller extends Controller { return; } unlink($temp_filename); - print "FILEID: $photo->id"; + print "FILEID: $item->id"; } else { header("HTTP/1.1 400 Bad Request"); print "ERROR: Invalid Upload"; -- cgit v1.2.3 From 214d977f4dc9ac78f4571a7cc89109fd95f5a2eb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 06:51:21 -0700 Subject: Don't close the dialog window after we successfully complete an action. The expectation is that we're going to reload the page (or redirect to a new url). If we close the dialog, then we can trigger the onhover for items we've just deleted causing errors. Simplify the API while we're at it by getting rid of the no-longer-used on_success argument to openDialog() This fixes #528. --- lib/gallery.dialog.js | 13 +++++-------- modules/gallery/js/quick.js | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index fc66323e..74c2f20e 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -11,23 +11,20 @@ function handleDialogEvent(event) { event.preventDefault(); } -function ajaxify_dialog(on_success) { +function ajaxify_dialog() { $("#gDialog form").ajaxForm({ dataType: "json", success: function(data) { if (data.form) { $("#gDialog form").replaceWith(data.form); - ajaxify_dialog(on_success); + ajaxify_dialog(); on_form_loaded(); if (typeof data.reset == 'function') { eval(data.reset + '()'); } } if (data.result == "success") { - $("#gDialog").dialog("close"); - if (on_success) { - on_success(); - } else if (data.location) { + if (data.location) { window.location = data.location; } else { window.location.reload(); @@ -46,7 +43,7 @@ function ajaxify_dialog(on_success) { * @see handleDialogEvent() * @see showLoading() */ -function openDialog(element, on_success) { +function openDialog(element) { var sHref = $(element).attr("href"); var sTitle = $(element).attr("title"); var eDialog = '
        '; @@ -92,7 +89,7 @@ function openDialog(element, on_success) { $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); } - ajaxify_dialog(on_success); + ajaxify_dialog(); }); return false; } diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 2dcb1c36..3ac97f8e 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -46,7 +46,7 @@ var quick_do = function(cont, pane, img) { return false; } if (pane.hasClass("gDialogLink")) { - openDialog(pane, function() { window.location.reload(); }); + openDialog(pane); } else { img.css("opacity", "0.1"); cont.addClass("gLoadingLarge"); -- cgit v1.2.3 From 245f4d39a731b60ac31a755ab4678bb83f211720 Mon Sep 17 00:00:00 2001 From: Shai Ben-Naphtali Date: Sun, 12 Jul 2009 01:37:20 +0800 Subject: This fixes ticket #513 Signed-off-by: Tim Almdal --- modules/gallery/views/simple_uploader.html.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index e1add7f7..8178ace2 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -182,8 +182,9 @@ if (num_files_selected > 0) { $("#gUploadCancel").show(); var stats = this.getStats(); - $("#gUploadQueueInfo").text("(completed " + stats.successful_uploads + - " of " + (stats.files_queued + stats.successful_uploads + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + $("#gUploadQueueInfo").text("( " + stats.successful_uploads + + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); } // Auto start the upload @@ -254,8 +255,9 @@ function upload_complete(file) { var stats = this.getStats(); - $("#gUploadQueueInfo").text("(completed " + stats.successful_uploads + - " of " + (stats.files_queued + stats.successful_uploads + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + $("#gUploadQueueInfo").text("( " + stats.successful_uploads + + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } -- cgit v1.2.3 From 30346ec84214027e5e192020ce60608e48cb9530 Mon Sep 17 00:00:00 2001 From: Shai Ben-Naphtali Date: Sun, 12 Jul 2009 01:41:24 +0800 Subject: Fixed indentation of commit 2760e119bbfc3e2d436c404de194dbeea738a735 Signed-off-by: Tim Almdal --- modules/gallery/views/simple_uploader.html.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 8178ace2..92155434 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -183,8 +183,8 @@ $("#gUploadCancel").show(); var stats = this.getStats(); $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); } // Auto start the upload @@ -256,8 +256,8 @@ function upload_complete(file) { var stats = this.getStats(); $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } -- cgit v1.2.3 From f2a3fa46f5a5cc31d251c1557f8b1cfbb6f46027 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:10:05 -0700 Subject: Change 'completed' status message to be a full sentence with javascript placeholders. --- modules/gallery/views/simple_uploader.html.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 92155434..bf3d7c57 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -255,9 +255,11 @@ function upload_complete(file) { var stats = this.getStats(); - $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + var msg = "()"; + msg = msg.replace("__COMPLETED__", stats.successful_uploads); + msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors; + $("#gUploadQueueInfo").text(msg); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } -- cgit v1.2.3 From 8c6c3801bb6b9f9d4d68aef0cf808abcc667d342 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:12:29 -0700 Subject: Fix a typo in the last commit. I left off a closing paren. --- modules/gallery/views/simple_uploader.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index bf3d7c57..06a2eaff 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -258,7 +258,7 @@ var msg = "()"; msg = msg.replace("__COMPLETED__", stats.successful_uploads); msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors; + stats.upload_errors + stats.upload_cancelled + stats.queue_errors); $("#gUploadQueueInfo").text(msg); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); -- cgit v1.2.3 From 171522bf231e4fca13dd522e8f755e65a8d48b3b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:23:31 -0700 Subject: Add a "close" button. --- modules/server_add/views/server_add_tree_dialog.html.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules') diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index bbad4e69..8e9c1c01 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -46,4 +46,8 @@ }); }); + + -- cgit v1.2.3 From cbd80b5ff948e23a1fa8b0994291953d38f6a7bd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:37:49 -0700 Subject: Get rid of the form from server_add, we're not using it. Turn the cancel link into a themed close button which triggers a page reload. Add some padding to the left of the tree. --- .../server_add/views/server_add_tree_dialog.html.php | 17 +++++++++-------- themes/default/css/screen.css | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8e9c1c01..21952849 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -19,8 +19,6 @@
      - id"), array("method" => "post")) ?> -
      @@ -31,10 +29,16 @@ - "> + + + - + - diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index c4670a4d..0c65cd96 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -899,8 +899,14 @@ form .gError, /* Server Add */ +#gServerAdd button { + float: left; + margin-bottom: .5em; +} + #gServerAddTree { cursor: pointer; + padding-left: 4px; } #gServerAddTree li { -- cgit v1.2.3 From e2967aa1c1a0232e1a1f162db46e6f6db7154dac Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:45:41 -0700 Subject: Fix a problem in delete() where we were referencing $parent without saving its value before $item got deleted. Further fix for #528. --- modules/gallery/controllers/quick.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 53af2ba6..de027c1b 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -127,6 +127,7 @@ class Quick_Controller extends Controller { $msg = t("Deleted photo %title", array("title" => p::purify($item->title))); } + $parent = $item->parent(); $item->delete(); message::success($msg); -- cgit v1.2.3 From b4c279ebb453459a37550b6413a830bed6c74b17 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 17:40:32 -0700 Subject: Fix whitespace typo. --- modules/gallery/libraries/Menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index d37be7d3..162cd3b0 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -136,7 +136,7 @@ class Menu_Core extends Menu_Element { return new Menu_Element_Dialog($type); case "root": - return new Menu("root"); + return new Menu("root"); case "submenu": return new Menu("submenu"); -- cgit v1.2.3 From 895fbfd95b5e7a42dd865f4a18401fd2e1491bc2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 17:59:55 -0700 Subject: Get the thumbnail menu working. 1) Stop changing the menu classes in JS, instead allow us to specify it in the Menu class itself and then set it to be gThumbMenu in Theme_View 2) Move the gThumbMenu init code to the bottom of the $(document).ready() block; something in there was interfering with it. --- modules/gallery/libraries/Menu.php | 9 ++++-- modules/gallery/libraries/Theme_View.php | 11 ++++---- themes/default/css/screen.css | 8 +++--- themes/default/js/ui.init.js | 47 ++++++++++++++++---------------- 4 files changed, 38 insertions(+), 37 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 162cd3b0..a39b59a5 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -136,7 +136,9 @@ class Menu_Core extends Menu_Element { return new Menu_Element_Dialog($type); case "root": - return new Menu("root"); + $menu = new Menu("root"); + $menu->css_class("gMenu"); + return $menu; case "submenu": return new Menu("submenu"); @@ -156,6 +158,7 @@ class Menu_Core extends Menu_Element { } } } + return $this; } public function __construct($type) { @@ -206,8 +209,8 @@ class Menu_Core extends Menu_Element { } public function __toString() { - $html = $this->is_root ? "
        " : - "
      • label\">$this->label
          "; + $html = $this->is_root ? "
            css_class\">" : + "
          • label\">$this->label
              "; $html .= implode("\n", $this->elements); $html .= $this->is_root ? "
            " : "
          "; return $html; diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 75138f25..fa45ec89 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -99,19 +99,19 @@ class Theme_View_Core extends Gallery_View { } public function album_menu() { - $this->_menu("album"); + print $this->_menu("album"); } public function tag_menu() { - $this->_menu("tag"); + print $this->_menu("tag"); } public function photo_menu() { - $this->_menu("photo"); + print $this->_menu("photo"); } public function thumb_menu($item) { - $this->_menu("thumb", $item); + print $this->_menu("thumb", $item)->css_class("gThumbMenu"); } private function _menu($type, $item=null) { @@ -127,8 +127,7 @@ class Theme_View_Core extends Gallery_View { } } - $menu->compact(); - print $menu; + return $menu->compact(); } public function pager() { diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 93b68e68..c0954690 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -582,21 +582,21 @@ form .gError, margin-bottom: 0; } -/* Photo Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* Thumb Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#gContent .gPhotoMenu { +#gContent .gThumbMenu { bottom: 0; left: 0; position: absolute; width: 100%; } -#gContent .gPhotoMenu li { +#gContent .gThumbMenu li { border-left: none; border-right: none; } -#gContent .gPhotoMenu a:hover { +#gContent .gThumbMenu a:hover { text-decoration: none; } diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index 37261727..ac7ef8d2 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -15,8 +15,6 @@ $(document).ready(function() { // Remove .gMenu from thumb menu's before initializing Superfish // @todo gallery_menu should only apply gMenu to top-level menus, submenus should be gSubMenu-N - $("#gContent .gItem .gMenu").removeClass("gMenu"); - $("#gContent .gQuick + ul").addClass("gPhotoMenu"); // Initialize Superfish menus $("ul.gMenu").addClass("sf-menu"); @@ -41,28 +39,6 @@ $(document).ready(function() { $(dialogLinks[i]).bind("click", handleDialogEvent); } - // Initialize photo menus - if ($("#gContent .gPhotoMenu").length) { - $("#gContent .gPhotoMenu li").addClass("ui-state-default"); - $("#gContent .gPhotoMenu li a") - .not('[class]') - .addClass("gButtonLink ui-icon") - .css({ - "height":"10px", - "margin":"0", - "padding":"0" - }); - //$(".gPhotoMenu ul").hide(); - $(".gPhotoMenu").hover( - function(){ - $(this + " ul").show(); - }, - function(){ - $(this + " ul").hide(); - } - ); - } - // Initialize view menu if ($("#gViewMenu").length) { $("#gViewMenu ul").removeClass("gMenu").removeClass("sf-menu"); @@ -118,6 +94,29 @@ $(document).ready(function() { } ); + // Initialize thumbnail menus + if ($("#gContent .gThumbMenu").length) { + $("#gContent .gThumbMenu li").addClass("ui-state-default"); + $("#gContent .gThumbMenu li a") + .not('[class]') + .addClass("gButtonLink ui-icon") + .css({ + height: "10px", + margin: "0", + padding: "0" + }); + + $(".gThumbMenu ul").hide(); + $(".gThumbMenu").hover( + function() { + $(this).find("ul").slideDown("fast"); + }, + function() { + $(this).find("ul").slideUp("slow"); + } + ); + } + }); /** -- cgit v1.2.3 From 980923839930fde45120872dcadd437abfbbc09d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 19:17:12 -0700 Subject: Unescape ' also (single quote) --- modules/gallery/controllers/file_proxy.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 0d64bcd9..03303d66 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -32,8 +32,9 @@ class File_Proxy_Controller extends Controller { $request_uri = $this->input->server("REQUEST_URI"); $request_uri = preg_replace("/\?.*/", "", $request_uri); - // Unescape %7E ("~") and %20 (" ") - $request_uri = str_replace(array("%7E", "%20"), array("~", " "), $request_uri); + // Unescape %7E (~), %20 ( ) and ' (') + // @todo: figure out why we have to do this and unescape everything appropriate + $request_uri = str_replace(array("%7E", "%20", "'"), array("~", " ", "'"), $request_uri); // var_uri: http://example.com/gallery3/var/ $var_uri = url::file("var/"); -- cgit v1.2.3 From ac181d6227f77cfa33585704fdbc1b041a129e6a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 20:12:32 -0700 Subject: Whitespace fixes. --- modules/gallery/helpers/MY_remote.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/MY_remote.php b/modules/gallery/helpers/MY_remote.php index 4abf5bf1..af2a05d8 100644 --- a/modules/gallery/helpers/MY_remote.php +++ b/modules/gallery/helpers/MY_remote.php @@ -21,11 +21,11 @@ class remote extends remote_Core { static function post($url, $post_data_array, $extra_headers=array()) { $post_data_raw = self::_encode_post_data($post_data_array, $extra_headers); - + /* Read the web page into a buffer */ list ($response_status, $response_headers, $response_body) = self::do_request($url, 'POST', $extra_headers, $post_data_raw); - + return array($response_body, $response_status, $response_headers); } @@ -49,22 +49,23 @@ class remote extends remote_Core { } $post_data_raw .= urlencode($key) . '=' . urlencode($value); } - + $extra_headers['Content-Type'] = 'application/x-www-form-urlencoded'; $extra_headers['Content-Length'] = strlen($post_data_raw); - + return $post_data_raw; } /** * A single request, without following redirects * - * @todo: Handle redirects? If so, only for GET (i.e. not for POST), and use G2's WebHelper_simple::_parseLocation logic. + * @todo: Handle redirects? If so, only for GET (i.e. not for POST), and use G2's + * WebHelper_simple::_parseLocation logic. */ static function do_request($url, $method='GET', $headers=array(), $body='') { /* Convert illegal characters */ $url = str_replace(' ', '%20', $url); - + $url_components = self::_parse_url_for_fsockopen($url); $handle = fsockopen( $url_components['fsockhost'], $url_components['port'], $errno, $errstr, 5); @@ -72,12 +73,12 @@ class remote extends remote_Core { // log "Error $errno: '$errstr' requesting $url"; return array(null, null, null); } - + $header_lines = array('Host: ' . $url_components['host']); foreach ($headers as $key => $value) { $header_lines[] = $key . ': ' . $value; } - + $success = fwrite($handle, sprintf("%s %s HTTP/1.0\r\n%s\r\n\r\n%s", $method, $url_components['uri'], @@ -89,7 +90,7 @@ class remote extends remote_Core { return array(null, null, null); } fflush($handle); - + /* * Read the status line. fgets stops after newlines. The first line is the protocol * version followed by a numeric status code and its associated textual phrase. @@ -99,7 +100,7 @@ class remote extends remote_Core { // 'Empty http response code, maybe timeout' return array(null, null, null); } - + /* Read the headers */ $response_headers = array(); while (!feof($handle)) { @@ -107,10 +108,10 @@ class remote extends remote_Core { if (empty($line)) { break; } - + /* Normalize the line endings */ $line = str_replace("\r", '', $line); - + list ($key, $value) = explode(':', $line, 2); if (isset($response_headers[$key])) { if (!is_array($response_headers[$key])) { @@ -121,7 +122,7 @@ class remote extends remote_Core { $response_headers[$key] = trim($value); } } - + /* Read the body */ $response_body = ''; while (!feof($handle)) { -- cgit v1.2.3 From 9588e8604d46e548dc4ac8788589f9f89b1992ab Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 12 Jul 2009 20:08:02 -0700 Subject: Use %27 instead of ' (the latter is the wrong form of escaping for urls). --- modules/gallery/controllers/file_proxy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 03303d66..c5b34033 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -32,9 +32,9 @@ class File_Proxy_Controller extends Controller { $request_uri = $this->input->server("REQUEST_URI"); $request_uri = preg_replace("/\?.*/", "", $request_uri); - // Unescape %7E (~), %20 ( ) and ' (') + // Unescape %7E (~), %20 ( ) and %27 (') // @todo: figure out why we have to do this and unescape everything appropriate - $request_uri = str_replace(array("%7E", "%20", "'"), array("~", " ", "'"), $request_uri); + $request_uri = str_replace(array("%7E", "%20", "%27"), array("~", " ", "'"), $request_uri); // var_uri: http://example.com/gallery3/var/ $var_uri = url::file("var/"); -- cgit v1.2.3 From ff0b66a1a4ed189c3e02a8ad50a63f4d65b3bfa7 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 12 Jul 2009 22:53:47 -0600 Subject: Put owner's url into user link. Seems better than displaying email until we have something like a user profile page. --- modules/info/helpers/info_theme.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/info/helpers/info_theme.php b/modules/info/helpers/info_theme.php index 863317a8..51378e54 100644 --- a/modules/info/helpers/info_theme.php +++ b/modules/info/helpers/info_theme.php @@ -37,7 +37,11 @@ class info_theme_Core { } if ($item->owner) { $results .= "
        • "; - $results .= t("By: %owner_name", array("owner_name" => "{$item->owner->full_name}")); + if ($item->owner->url) { + $results .= t("By: %owner_name", array("owner_name" => "owner->url}\">{$item->owner->full_name}")); + } else { + $results .= t("By: %owner_name", array("owner_name" => "{$item->owner->full_name}")); + } $results .= "
        • "; } return $results; -- cgit v1.2.3 From a944bf4259a6ff31ac647a3d8336bd5175c3640a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 13 Jul 2009 06:43:44 -0700 Subject: Avoid using the bare word "on" in a value; it breaks PHP 5.3. Fixes ticket #540. --- modules/comment/module.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/comment/module.info b/modules/comment/module.info index 946f1d39..55997317 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ name = Comments -description = Allows users and guests to leave comments on photos and albums. +description = "Allows users and guests to leave comments on photos and albums." version = 2 -- cgit v1.2.3 From e2a9a1d28459b96e412004df4d4ec010fb9b30e2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 13 Jul 2009 10:36:55 -0700 Subject: Add quotes around all values that contain spaces in them, and add a test to make sure that we continue to do so. This makes sure that we don't have problems with 5.3 which treats the literal "on" as a boolean. --- modules/akismet/module.info | 2 +- modules/comment/module.info | 2 +- modules/digibug/module.info | 4 +-- modules/exif/module.info | 2 +- modules/g2_import/module.info | 4 +-- modules/gallery/module.info | 4 +-- modules/gallery/tests/File_Structure_Test.php | 37 +++++++++++++++++++++++++++ modules/image_block/module.info | 4 +-- modules/info/module.info | 4 +-- modules/notification/module.info | 2 +- modules/organize/module.info | 4 +-- modules/recaptcha/module.info | 2 +- modules/rss/module.info | 4 +-- modules/search/module.info | 4 +-- modules/server_add/module.info | 4 +-- modules/slideshow/module.info | 4 +-- modules/tag/module.info | 4 +-- modules/user/module.info | 4 +-- modules/watermark/module.info | 4 +-- themes/admin_default/theme.info | 6 ++--- themes/default/theme.info | 6 ++--- 21 files changed, 74 insertions(+), 37 deletions(-) (limited to 'modules') diff --git a/modules/akismet/module.info b/modules/akismet/module.info index d45d8a7b..b61ed107 100644 --- a/modules/akismet/module.info +++ b/modules/akismet/module.info @@ -1,3 +1,3 @@ -name = Akismet +name = "Akismet" description = "Filter comments through the Akismet web service to detect and eliminate spam (http://akismet.com). You'll need a WordPress.com API key to use it." version = 1 diff --git a/modules/comment/module.info b/modules/comment/module.info index 55997317..c371cf27 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ -name = Comments +name = "Comments" description = "Allows users and guests to leave comments on photos and albums." version = 2 diff --git a/modules/digibug/module.info b/modules/digibug/module.info index c25a2454..be4e880a 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -1,3 +1,3 @@ -name = Digibug -description = Digibug Photo Printing Module +name = "Digibug" +description = "Digibug Photo Printing Module" version = 2 diff --git a/modules/exif/module.info b/modules/exif/module.info index 1e16a5ff..c8ae688e 100644 --- a/modules/exif/module.info +++ b/modules/exif/module.info @@ -1,3 +1,3 @@ -name = Exif Data +name = "Exif Data" description = "Extract Exif data and display it on photo pages." version = 1 diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info index 9e04f49b..554cf33b 100644 --- a/modules/g2_import/module.info +++ b/modules/g2_import/module.info @@ -1,3 +1,3 @@ -name = Gallery2 Import -description = Import your Gallery 2 content into Gallery 3 +name = "Gallery2 Import" +description = "Import your Gallery 2 content into Gallery 3" version = 1 diff --git a/modules/gallery/module.info b/modules/gallery/module.info index c184aba7..64a30b1f 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ -name = Gallery 3 -description = Gallery core application +name = "Gallery 3" +description = "Gallery core application" version = 6 diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 06f456ff..8a97e00b 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -213,6 +213,43 @@ class File_Structure_Test extends Unit_Test_Case { } } } + + public function module_info_is_well_formed_test() { + $info_files = array_merge( + glob("modules/*/module.info"), + glob("themes/*/module.info")); + + $errors = array(); + foreach ($info_files as $file) { + foreach (file($file) as $line) { + $parts = explode("=", $line, 2); + $values[trim($parts[0])] = trim($parts[1]); + } + + $module = dirname($file); + // Certain keys must exist + foreach (array("name", "description", "version") as $key) { + if (!array_key_exists($key, $values)) { + $errors[] = "$module: missing key $key"; + } + } + + // Any values containing spaces must be quoted + foreach ($values as $key => $value) { + if (strpos($value, " ") !== false && !preg_match('/^".*"$/', $value)) { + $errors[] = "$module: value for $key must be quoted"; + } + } + + // The file must parse + if (!is_array(parse_ini_file($file))) { + $errors[] = "$module: info file is not parseable"; + } + } + if ($errors) { + $this->assert_true(false, $errors); + } + } } class PhpCodeFilterIterator extends FilterIterator { diff --git a/modules/image_block/module.info b/modules/image_block/module.info index 8852d33c..e6d85048 100644 --- a/modules/image_block/module.info +++ b/modules/image_block/module.info @@ -1,3 +1,3 @@ -name = Image Block -description = Display a random image in the sidebar +name = "Image Block" +description = "Display a random image in the sidebar" version = 1 diff --git a/modules/info/module.info b/modules/info/module.info index ce03473e..e352213c 100644 --- a/modules/info/module.info +++ b/modules/info/module.info @@ -1,3 +1,3 @@ -name = Info -description = Display extra information about photos and albums +name = "Info" +description = "Display extra information about photos and albums" version = 1 diff --git a/modules/notification/module.info b/modules/notification/module.info index d4dc34e0..31684ccf 100644 --- a/modules/notification/module.info +++ b/modules/notification/module.info @@ -1,3 +1,3 @@ -name = Notification +name = "Notification" description = "Send notifications to users when changes are made to watched albums." version = 1 diff --git a/modules/organize/module.info b/modules/organize/module.info index b3ae94a3..5c6b1de0 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -1,3 +1,3 @@ -name = Organize -description = Organize your gallery by apply tags or moving images +name = "Organize" +description = "Organize your gallery by apply tags or moving images" version = 1 diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info index 9f44648a..cfa1bf7a 100644 --- a/modules/recaptcha/module.info +++ b/modules/recaptcha/module.info @@ -1,3 +1,3 @@ -name = reCAPTCHA +name = "reCAPTCHA" description = "reCAPTCHA displays a graphical verification that protects the input form from abuse from 'bots,' or automated programs usually written to generate spam (http://recaptcha.net)." version = 1 diff --git a/modules/rss/module.info b/modules/rss/module.info index ffd26192..81ee7848 100644 --- a/modules/rss/module.info +++ b/modules/rss/module.info @@ -1,3 +1,3 @@ -name = RSS -description = Provide a RSS feeds +name = "RSS" +description = "Provide a RSS feeds" version = 1 diff --git a/modules/search/module.info b/modules/search/module.info index b286ab6c..f417c4fa 100644 --- a/modules/search/module.info +++ b/modules/search/module.info @@ -1,3 +1,3 @@ -name = Search -description = Allows users to search their Gallery +name = "Search" +description = "Allows users to search their Gallery" version = 1 diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 295d3beb..23acab94 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -1,3 +1,3 @@ -name = Server Add -description = Allows authorized users to load images directly from your web server +name = "Server Add" +description = "Allows authorized users to load images directly from your web server" version = 3 diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index 5eb69ce3..6841199a 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -1,3 +1,3 @@ -name = Slideshow -description = Allows users to view a slideshow of photos +name = "Slideshow" +description = "Allows users to view a slideshow of photos" version = 1 diff --git a/modules/tag/module.info b/modules/tag/module.info index 562d5c32..e505dd81 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -1,3 +1,3 @@ -name = Tags -description = Allows users to tag photos and albums +name = "Tags" +description = "Allows users to tag photos and albums" version = 1 diff --git a/modules/user/module.info b/modules/user/module.info index 2dba517d..8a9af407 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -1,3 +1,3 @@ -name = Users and Groups -description = Provides user and group management +name = "Users and Groups" +description = "Provides user and group management" version = 1 diff --git a/modules/watermark/module.info b/modules/watermark/module.info index 7f866695..abd4a3cf 100644 --- a/modules/watermark/module.info +++ b/modules/watermark/module.info @@ -1,3 +1,3 @@ -name = Watermarks -description = Allows users to watermark their photos +name = "Watermarks" +description = "Allows users to watermark their photos" version = 1 diff --git a/themes/admin_default/theme.info b/themes/admin_default/theme.info index d21b0ff5..b3d9741d 100644 --- a/themes/admin_default/theme.info +++ b/themes/admin_default/theme.info @@ -1,6 +1,6 @@ -name = Gallery Default -description = A crisp Site Administration theme with soft colors and drop down menus. +name = "Gallery Default" +description = "A crisp Site Administration theme with soft colors and drop down menus." version = 1 -author = Gallery Team +author = "Gallery Team" admin = 1 site = 0 diff --git a/themes/default/theme.info b/themes/default/theme.info index 71e8a740..5f19d0d7 100644 --- a/themes/default/theme.info +++ b/themes/default/theme.info @@ -1,6 +1,6 @@ -name = Gallery Default -description = A crisp and distinctive theme that uses large fonts and icons for easy navigation and an enjoyable browsing experience. +name = "Gallery Default" +description = "A crisp and distinctive theme that uses large fonts and icons for easy navigation and an enjoyable browsing experience." version = 1 -author = Gallery Team +author = "Gallery Team" site = 1 admin = 0 -- cgit v1.2.3 From 2a40f48d659c5b0ac3ab90e25aaaef12dce99c39 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 06:36:48 -0700 Subject: Add /opt/bin as a binary path. --- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/movie.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index bbae0602..db9b2ef5 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -331,7 +331,7 @@ class graphics_Core { if (!isset($gd["GD Version"])) { $gd["GD Version"] = false; } - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin"); + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin"); return array("gd" => $gd, "imagemagick" => $exec ? dirname(exec("which convert")) : false, "graphicsmagick" => $exec ? dirname(exec("which gm")) : false); diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 54159294..d62ead76 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -145,7 +145,7 @@ class movie_Core { static function find_ffmpeg() { if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) { - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin"); + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin"); if (function_exists("exec")) { $ffmpeg_path = exec("which ffmpeg"); } -- cgit v1.2.3 From 94e33c821f28601b60d51581c632ba1e10288298 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 14 Jul 2009 06:42:50 -0700 Subject: Removed unnecessary contructor from the HTMLPurifier.php library class --- modules/gallery/libraries/HtmlPurifier.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/HtmlPurifier.php b/modules/gallery/libraries/HtmlPurifier.php index f9d5353b..daa5896e 100644 --- a/modules/gallery/libraries/HtmlPurifier.php +++ b/modules/gallery/libraries/HtmlPurifier.php @@ -20,11 +20,6 @@ class HtmlPurifier_Core { private static $_instance; - public function __construct($name = NULL, $data = NULL, $type = NULL) { - parent::__construct($name, $data, $type); - $this->set_global("csrf", access::csrf_token()); - } - static function instance($config=null) { require_once(dirname(__file__) . "/HTMLPurifier/HTMLPurifier.auto.php"); if (self::$_instance == NULL) { -- cgit v1.2.3 From cc05d279ea9c7317f6393b0336df724dbb4a898f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 14 Jul 2009 07:55:30 -0700 Subject: Update HTMLPurifier to version 4.4.0 --- modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php | 2 +- modules/gallery/lib/HTMLPurifier/HTMLPurifier.php | 6 +++--- modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php | 2 +- modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php | 2 +- modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php | 4 ++++ 5 files changed, 10 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php index 6ea32f72..e57f2ab3 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php @@ -7,7 +7,7 @@ * primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS * FILE, changes will be overwritten the next time the script is run. * - * @version 3.3.0 + * @version 4.0.0 * * @warning * You must *not* include any other HTML Purifier files before this file, diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php index 0b53d1b4..71e90632 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php @@ -19,7 +19,7 @@ */ /* - HTML Purifier 3.3.0 - Standards Compliant HTML Filtering + HTML Purifier 4.0.0 - Standards Compliant HTML Filtering Copyright (C) 2006-2008 Edward Z. Yang This library is free software; you can redistribute it and/or @@ -55,10 +55,10 @@ class HTMLPurifier { /** Version of HTML Purifier */ - public $version = '3.3.0'; + public $version = '4.0.0'; /** Constant with version of HTML Purifier */ - const VERSION = '3.3.0'; + const VERSION = '4.0.0'; /** Global configuration object */ public $config; diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php index 5b2592b5..28529e7f 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php @@ -20,7 +20,7 @@ class HTMLPurifier_Config /** * HTML Purifier's version */ - public $version = '3.3.0'; + public $version = '4.0.0'; /** * Bool indicator whether or not to automatically finalize diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php index 3d8010f4..9f20a412 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php @@ -285,7 +285,7 @@ class HTMLPurifier_Lexer */ public function extractBody($html) { $matches = array(); - $result = preg_match('!]*>(.+?)!is', $html, $matches); + $result = preg_match('!]*>(.*)!is', $html, $matches); if ($result) { return $matches[1]; } else { diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php index 19676e51..16969bed 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php @@ -23,6 +23,10 @@ class HTMLPurifier_URIFilter_Munge extends HTMLPurifier_URIFilter if (is_null($uri->host) || empty($scheme_obj->browsable)) { return true; } + // don't redirect if target host is our host + if ($uri->host === $config->getDefinition('URI')->host) { + return true; + } $this->makeReplace($uri, $config, $context); $this->replace = array_map('rawurlencode', $this->replace); -- cgit v1.2.3 From c3f93957d7af6c6058582fcb1acbe5b8374a70ed Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 10:56:10 -0700 Subject: Move the gallery version out of a module variable and into a constant in the gallery helper. This will let us bump the version without having to bump the gallery module number. --- modules/gallery/helpers/gallery.php | 2 ++ modules/gallery/helpers/gallery_installer.php | 9 ++++++--- modules/gallery/helpers/gallery_theme.php | 3 +-- modules/gallery/module.info | 2 +- modules/gallery/views/admin_block_stats.html.php | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index e22cc17f..a32ac484 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_Core { + const VERSION = "3.0 beta 2"; + /** * If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is * down for maintenance" page. diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 0e5d29b9..28c1990f 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -251,7 +251,6 @@ class gallery_installer { block_manager::add("dashboard_center", "gallery", "photo_stream"); block_manager::add("dashboard_center", "gallery", "log_entries"); - module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); module::set_var("gallery", "choose_default_tookit", 1); module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); @@ -259,7 +258,7 @@ class gallery_installer { module::set_var("gallery", "show_credits", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by Gallery %version"); - module::set_version("gallery", 6); + module::set_version("gallery", 7); } static function upgrade($version) { @@ -268,7 +267,6 @@ class gallery_installer { module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); module::set_var("gallery", "time_format", "H:i:s"); - module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); module::set_version("gallery", $version = 2); } @@ -302,6 +300,11 @@ class gallery_installer { $db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY"); module::set_version("gallery", $version = 6); } + + if ($version == 6) { + module::clear_var("gallery", "version"); + module::set_version("gallery", $version = 7); + } } static function uninstall() { diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 0e3150bc..226b8a42 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -116,8 +116,7 @@ class gallery_theme_Core { static function credits() { return "
        • " . t(module::get_var("gallery", "credits"), - array("url" => "http://gallery.menalto.com", - "version" => module::get_var("gallery", "version"))) . + array("url" => "http://gallery.menalto.com", "version" => gallery::VERSION)) . "
        • "; } diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 64a30b1f..cefcaa08 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 6 +version = 7 diff --git a/modules/gallery/views/admin_block_stats.html.php b/modules/gallery/views/admin_block_stats.html.php index 395ed71d..1dec8ccd 100644 --- a/modules/gallery/views/admin_block_stats.html.php +++ b/modules/gallery/views/admin_block_stats.html.php @@ -1,7 +1,7 @@
          • - module::get_var("gallery", "version"))) ?> + gallery::VERSION)) ?>
          • $album_count)) ?> -- cgit v1.2.3 From 8cfb0677091a6bc7e666338fc15f2e23d8934f7c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:03:31 -0700 Subject: Revert "Remove the reference to organize.css is it is no longer used and is" This reverts commit 31ffb82382d76390f1206944329dde86c687349c. --- modules/organize/helpers/organize_theme.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index 1c75e819..02f1f589 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -22,5 +22,6 @@ class organize_theme { // @tdo remove the addition css and organize.js (just here to test) $theme->script("modules/organize/js/organize_init.js"); $theme->script("modules/organize/js/organize.js"); + $theme->css("modules/organize/css/organize.css"); } } -- cgit v1.2.3 From 768a1485e19021f4a4b3b0b529f3df36167a7881 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:07:29 -0700 Subject: Remove references to missing organize_edit_drawer.png --- modules/organize/css/organize.css | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules') diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css index 1e608beb..e58cd5a5 100644 --- a/modules/organize/css/organize.css +++ b/modules/organize/css/organize.css @@ -163,7 +163,6 @@ } #gOrganizeEditHandleLeft { - background-image: url(organize_edit_drawer.png); background-color: #FFF; float: left; height: 30px; @@ -200,7 +199,6 @@ #gOrganizeEditHandleRight { background-color: #FFF; - background-image: url(organize_edit_drawer.png); background-position: -15px 0; float: right; height: 30px; -- cgit v1.2.3 From c4a30930112e9ab14678fe96f21741f1832c20f7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:36:57 -0700 Subject: 3rd attempt to fix localization messages. Last time around I didn't dig deep enough, but now we form the complete message using t() style semantics to replace % placeholders with __ style JS placeholders. Also, stop appending the (completed) text to existing messages.. roll it together. --- modules/gallery/views/simple_uploader.html.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 06a2eaff..38ac518c 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -32,8 +32,9 @@

          - - + + + " onclick="swfu.cancelQueue();">

          @@ -181,10 +182,7 @@ function file_dialog_complete(num_files_selected, num_files_queued) { if (num_files_selected > 0) { $("#gUploadCancel").show(); - var stats = this.getStats(); - $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + $("#gUploadQueueInfo").text(get_completed_status_msg(this.getStats())); } // Auto start the upload @@ -255,16 +253,20 @@ function upload_complete(file) { var stats = this.getStats(); - var msg = "()"; - msg = msg.replace("__COMPLETED__", stats.successful_uploads); - msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors); - $("#gUploadQueueInfo").text(msg); + $("#gUploadQueueInfo").text(get_completed_status_msg(stats)); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } } + function get_completed_status_msg(stats) { + var msg = " "__COMPLETED__", "total" => "__TOTAL__")) ?>"; + msg = msg.replace("__COMPLETED__", stats.successful_uploads); + msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors); + return msg; + } + // This event comes from the Queue Plugin function queue_complete(num_files_uploaded) { var status_msg = ""; -- cgit v1.2.3 From 4720e456418f5b3933a6fdfc9e3b88372792dab1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:55:03 -0700 Subject: Don't use "else" clauses in upgrade() -- it prevents multiple version bumps at once. --- modules/server_add/helpers/server_add_installer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index 67c7a377..cd278eb7 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -42,7 +42,9 @@ class server_add_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("server_add", $version = 2); - } else if ($version == 2) { + } + + if ($version == 2) { $db->query("ALTER TABLE {server_add_files} ADD COLUMN `item_id` int(9)"); $db->query("ALTER TABLE {server_add_files} ADD COLUMN `parent_id` int(9)"); module::set_version("server_add", $version = 3); -- cgit v1.2.3 From 7de339a676f32ed445f3e4215c994a5fe16c1188 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 16:10:37 -0700 Subject: Remove extra debug statements. --- modules/g2_import/helpers/g2_import.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 7dd799c8..8b4169dd 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -471,8 +471,6 @@ class g2_import_Core { $corrupt = 1; } try { - Kohana::log("error", "description: " . self::extract_description($g2_item)); - Kohana::log("error", "title: " . $g2_item->getTitle()); $item = photo::create( $parent, $g2_path, -- cgit v1.2.3 From 2cba5d93956ce38f6d08ca350124d9bd21270be6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 15 Jul 2009 07:56:52 +0800 Subject: Fix 542 by changing the wording from you to your, thanks Floridave Signed-off-by: Tim Almdal --- modules/gallery/controllers/admin_languages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index 4639de89..d1b805da 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -119,7 +119,7 @@ class Admin_Languages_Controller extends Admin_Controller { private function _share_translations_form() { $form = new Forge("admin/languages/share", "", "post", array("id" => "gShareTranslationsForm")); $group = $form->group("sharing") - ->label(t("Sharing you own translations with the Gallery community is easy. Please do!")); + ->label(t("Sharing your own translations with the Gallery community is easy. Please do!")); $api_key = l10n_client::api_key(); $server_link = l10n_client::server_api_key_url(); $group->input("api_key") -- cgit v1.2.3 From c4fce2cc680c3257cf6ea7844b8ee9e61c02db09 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 15 Jul 2009 20:32:53 -0700 Subject: Remove a completed @todo. --- modules/gallery/controllers/albums.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index d141d157..e6d01b90 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -181,10 +181,6 @@ class Albums_Controller extends Items_Controller { } } - // @todo - // @todo we need to make sure that filename / dirname components can't contain a / - // @todo - if ($valid) { $orig = clone $album; $album->title = $form->edit_album->title->value; -- cgit v1.2.3 From 5cb2f42628bdfa66a1a0821efb5f9d8e78f06626 Mon Sep 17 00:00:00 2001 From: Kevin Nehls Date: Wed, 15 Jul 2009 11:41:10 +0800 Subject: Fix backslashes in relative URLs of combined css files. Signed-off-by: Bharat Mediratta --- modules/gallery/libraries/Gallery_View.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 8a0be7f2..4715be09 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -135,6 +135,7 @@ class Gallery_View_Core extends View { $relative = substr(realpath(dirname($css_file) . "/$match[1]"), $docroot_length); if (!empty($relative)) { $search[] = $match[0]; + $relative = str_replace(DIRECTORY_SEPARATOR, "/", $relative); $replace[] = "url('" . url::abs_file($relative) . "')"; } else { Kohana::log("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'"); -- cgit v1.2.3 From 85b0f580291e375a2c5ec21b8210e59023ee24c2 Mon Sep 17 00:00:00 2001 From: Kevin Nehls Date: Thu, 16 Jul 2009 12:28:00 +0800 Subject: move fix for backslashes on windows outside of loop per bharat's suggestion Signed-off-by: Bharat Mediratta --- modules/gallery/libraries/Gallery_View.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 4715be09..133066d7 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -135,12 +135,12 @@ class Gallery_View_Core extends View { $relative = substr(realpath(dirname($css_file) . "/$match[1]"), $docroot_length); if (!empty($relative)) { $search[] = $match[0]; - $relative = str_replace(DIRECTORY_SEPARATOR, "/", $relative); $replace[] = "url('" . url::abs_file($relative) . "')"; } else { Kohana::log("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'"); } } + $replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace); $css = str_replace($search, $replace, $css); } $imports = preg_match_all("#@import\s*['|\"]{0,1}(.*?)['|\"]{0,1};#", -- cgit v1.2.3
  • title) ?>title) ?>