From 0494244e8068198707bf602199413cd216b0d515 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 3 Feb 2013 18:48:30 -0500 Subject: Super first pass: - jQuery 1.90 - jQuery UI 1.10 - Superfish 1.5.1 (minus all plugins) - jQuery Form 3.26.0-2013.01.28 Deleted all other jQuery plugins for now. - Reworked autocomplete to use the latest jQuery code. - Deleted references to $.browser.msie, no longer supported - Basic CSS support for autocomplete - lots more work needed there --- modules/tag/controllers/tags.php | 9 ++++----- modules/tag/helpers/tag_event.php | 3 +-- modules/tag/views/tag_block.html.php | 16 +++++++--------- 3 files changed, 12 insertions(+), 16 deletions(-) (limited to 'modules') diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index 77d45a95..32e857c6 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -48,18 +48,17 @@ class Tags_Controller extends Controller { public function autocomplete() { $tags = array(); - $tag_parts = explode(",", Input::instance()->get("q")); - $limit = Input::instance()->get("limit"); + $tag_parts = explode(",", Input::instance()->get("term")); $tag_part = ltrim(end($tag_parts)); $tag_list = ORM::factory("tag") ->where("name", "LIKE", Database::escape_for_like($tag_part) . "%") ->order_by("name", "ASC") - ->limit($limit) + ->limit(100) ->find_all(); foreach ($tag_list as $tag) { - $tags[] = html::clean($tag->name); + $tags[] = (string)html::clean($tag->name); } - ajax::response(implode("\n", $tags)); + ajax::response(json_encode($tags)); } } diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index d62ae36e..79d6e0bc 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -72,8 +72,7 @@ class tag_event_Core { $url = url::site("tags/autocomplete"); $form->script("") ->text("$('form input[name=tags]').ready(function() { - $('form input[name=tags]').gallery_autocomplete( - '$url', {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1}); + $('form input[name=tags]').gallery_autocomplete('$url', {multiple: true}); });"); $tag_names = array(); diff --git a/modules/tag/views/tag_block.html.php b/modules/tag/views/tag_block.html.php index d25b8dcb..afa61b15 100644 --- a/modules/tag/views/tag_block.html.php +++ b/modules/tag/views/tag_block.html.php @@ -2,15 +2,13 @@ "; - } - - private function _clean_expired() { - db::build() - ->delete("digibug_proxies") - ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 90 DAY)")) - ->limit(20) - ->execute(); - } -} \ No newline at end of file diff --git a/modules/digibug/helpers/digibug_event.php b/modules/digibug/helpers/digibug_event.php deleted file mode 100644 index eaebc87b..00000000 --- a/modules/digibug/helpers/digibug_event.php +++ /dev/null @@ -1,52 +0,0 @@ -get("settings_menu") - ->append(Menu::factory("link") - ->id("digibug_menu") - ->label(t("Digibug")) - ->url(url::site("admin/digibug"))); - } - - static function site_menu($menu, $theme) { - $item = $theme->item(); - if ($item && $item->type == "photo") { - $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("g-print-digibug-link") - ->css_class("g-print-digibug-link ui-icon-print")); - } - } - - static function context_menu($menu, $theme, $item) { - if ($item->type == "photo") { - $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_class("g-print-digibug-link ui-icon-print")); - } - } -} diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php deleted file mode 100644 index be88b5ec..00000000 --- a/modules/digibug/helpers/digibug_installer.php +++ /dev/null @@ -1,51 +0,0 @@ -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`)) - DEFAULT CHARSET=utf8;"); - - module::set_var("digibug", "company_id", "3153"); - module::set_var("digibug", "event_id", "8491"); - } - - 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() { - Database::instance()->query("DROP TABLE IF EXISTS {digibug_proxies}"); - module::delete("digibug"); - } -} diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php deleted file mode 100644 index e3795c3b..00000000 --- a/modules/digibug/helpers/digibug_theme.php +++ /dev/null @@ -1,24 +0,0 @@ -script("digibug.js"); - } -} diff --git a/modules/digibug/images/digibug_logo.png b/modules/digibug/images/digibug_logo.png deleted file mode 100644 index 5eac2c7d..00000000 Binary files a/modules/digibug/images/digibug_logo.png and /dev/null differ diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js deleted file mode 100644 index 46ddac52..00000000 --- a/modules/digibug/js/digibug.js +++ /dev/null @@ -1,43 +0,0 @@ -$(document).ready(function() { - $(".g-print-digibug-link").click(function(e) { - e.preventDefault(); - return digibug_popup(e.currentTarget.href, { width: 800, height: 600 } ); - }); -}); - -function digibug_popup(url, options) { - options = $.extend({ - /* default options */ - width: '800', - height: '600', - target: 'dbPopWin', - scrollbars: 'yes', - resizable: 'no', - menuBar: 'no', - addressBar: 'yes' - }, options); - - // center the window by default. - if (!options.winY) { - options.winY = screen.height / 2 - options.height / 2; - }; - if (!options.winX) { - options.winX = screen.width / 2 - options.width / 2; - }; - - open( - url, - options['target'], - 'width= ' + options.width + - ',height=' + options.height + - ',top=' + options.winY + - ',left=' + options.winX + - ',scrollbars=' + options.scrollbars + - ',resizable=' + options.resizable + - ',menubar=' + options.menuBar + - ',location=' + options.addressBar - ); - - return false; - -} diff --git a/modules/digibug/models/digibug_proxy.php b/modules/digibug/models/digibug_proxy.php deleted file mode 100644 index 18c77d49..00000000 --- a/modules/digibug/models/digibug_proxy.php +++ /dev/null @@ -1,22 +0,0 @@ -_server = $_SERVER; - } - - public function teardown() { - $_SERVER = $this->_server; - } - - private function _get_proxy() { - $album = test::random_album(); - $photo = test::random_photo($album); - - access::deny(identity::everybody(), "view_full", $album); - access::deny(identity::registered_users(), "view_full", $album); - - $proxy = ORM::factory("digibug_proxy"); - $proxy->uuid = random::hash(); - $proxy->item_id = $photo->id; - return $proxy->save(); - } - - public function digibug_request_thumb_test() { - $proxy = $this->_get_proxy(); - - $controller = new Digibug_Controller(); - $controller->print_proxy("thumb", $proxy->uuid); - } - - public function digibug_request_full_malicious_ip_test() { - $_SERVER["REMOTE_ADDR"] = "123.123.123.123"; - try { - $controller = new Digibug_Controller(); - $controller->print_proxy("full", $this->_get_proxy()->uuid); - $this->assert_true(false, "Should have failed with an 404 exception"); - } catch (Kohana_404_Exception $e) { - // expected behavior - } - } - - public function digibug_request_full_authorized_ip_test() { - $config = Kohana::config("digibug"); - $this->assert_true(!empty($config), "The Digibug config is empty"); - - $ranges = array_values($config["ranges"]); - $low = ip2long($ranges[0]["low"]); - $high = ip2long($ranges[0]["high"]); - - $_SERVER["REMOTE_ADDR"] = long2ip(rand($low, $high)); - $controller = new Digibug_Controller(); - $controller->print_proxy("full", $this->_get_proxy()->uuid); - } -} diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php deleted file mode 100644 index d673b116..00000000 --- a/modules/digibug/views/admin_digibug.html.php +++ /dev/null @@ -1,20 +0,0 @@ - -
- " alt="Digibug logo" class="g-right"/> -

-
-

- -

-
    -
  • - -
  • -
-

- 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" => html::mark_clean(url::site("admin/advanced_settings")))) ?> -

-
-
diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php deleted file mode 100644 index af5a88b4..00000000 --- a/modules/digibug/views/digibug_form.html.php +++ /dev/null @@ -1,13 +0,0 @@ - - - - - $value): ?> - - - - - - -- cgit v1.2.3 From 8b0088fd8d1774f4bdf5ae345ab5ad2da1eaedaf Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 15 Feb 2013 13:23:05 -0500 Subject: Change gallery/bin -> gallery3/bin in the comment since I suspect most people don't change the name of the directory. Follow-on to 1d7f5e3ab117a6cce8f2a1d3de5e311b74dbee81 for #1935 --- modules/gallery/views/admin_movies.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_movies.html.php b/modules/gallery/views/admin_movies.html.php index e7810711..242a4349 100644 --- a/modules/gallery/views/admin_movies.html.php +++ b/modules/gallery/views/admin_movies.html.php @@ -8,7 +8,7 @@

static build of FFmpeg from one of the links here.", array("url" => "http://ffmpeg.org/download.html")) ?> - +

-- cgit v1.2.3 From 4dd7b708b24a40ed90ed324d9853aa87b3ec46a0 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Fri, 15 Feb 2013 19:31:20 +0100 Subject: Dialog sizing, titles, and z-index. This should ensure the small <500px dialogs are correct, all titles are correctly sized, and the dialog boxes go to the top for older themes, too. --- lib/gallery.dialog.js | 11 +++++------ modules/gallery/css/gallery.css | 9 +++++++++ themes/wind/css/screen.css | 4 ---- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index b4557493..a771adcb 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -28,9 +28,6 @@ $("#g-dialog").dialog("close"); } $("body").append(eDialog); - if (!self.options.zIndex) { - self.options.zIndex = 9999; - } if (!self.options.close) { self.options.close = self.close_dialog; @@ -79,8 +76,7 @@ _layout: function() { var dialogWidth; var dialogHeight = $("#g-dialog").height(); - var cssWidth = new String($("#g-dialog form").css("width")); - var childWidth = cssWidth.replace(/[^0-9]/g,""); + var childWidth = $("#g-dialog form").width(); var size = $.gallery_get_viewport_size(); if ($("#g-dialog iframe").length) { dialogWidth = size.width() - 100; @@ -89,8 +85,10 @@ } else if ($("#g-dialog .g-dialog-panel").length) { dialogWidth = size.width() - 100; $("#g-dialog").dialog("option", "height", size.height() - 100); - } else { + } else if (childWidth <= 150 || childWidth > 300) { dialogWidth = 500; + } else { + dialogWidth = 300; } $("#g-dialog").dialog('option', 'width', dialogWidth); }, @@ -183,6 +181,7 @@ } else if ($("#g-dialog fieldset legend").length) { $("#g-dialog").dialog('option', 'title', $("#g-dialog fieldset legend:eq(0)").html()); } + $(".ui-dialog-title").width('auto'); }, form_closing: function(event, ui) {}, diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 7e711156..d3f7dcca 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -149,6 +149,15 @@ text-align: center; } +/* Dialogs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/** + * Newer Themeroller-based themes do this on their own, but older + * themes need help ensuring that dialogs and overlays are on top + */ +.ui-front { + z-index: 1000 +} + /** ******************************************************************* * 2) Admin **********************************************************************/ diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index e19427f3..6f98cbba 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -886,10 +886,6 @@ ul.sf-menu li li li.sfHover ul { opacity: .7; } -.ui-dialog { - z-index: 9999; -} - /* Buttons ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ .g-button { -- cgit v1.2.3 From 7bdccade98e76df3a7830bc45bc42321a77c709a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 15 Feb 2013 19:09:06 -0500 Subject: Every 500th request prune a single old file from var/tmp and var/logs. Might not be aggressive enough. Fixes #2005. --- modules/gallery/helpers/gallery_event.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 54c60296..eb54e521 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -36,6 +36,34 @@ class gallery_event_Core { locales::set_request_locale(); } + static function gallery_shutdown() { + // Every 500th request, do a pass over var/logs and var/tmp and delete old files. + // Limit ourselves to deleting a single file so that we don't spend too much CPU + // time on it. As long as servers call this at least twice a day they'll eventually + // wind up with a clean var/logs directory because we only create 1 file a day there. + // var/tmp might be stickier because theoretically we could wind up spamming that + // dir with a lot of files. But let's start with this and refine as we go. + if (!(rand() % 500)) { + // Note that this code is roughly duplicated in gallery_event::gallery_shutdown + $threshold = time() - 1209600; // older than 2 weeks + foreach(array("logs", "tmp") as $dir) { + $dir = VARPATH . $dir; + if ($dh = opendir($dir)) { + while (($file = readdir($dh)) !== false) { + if ($file[0] == ".") { + continue; + } + + if (filemtime("$dir/$file") <= $threshold) { + unlink("$dir/$file"); + break; + } + } + } + } + } + } + static function user_deleted($user) { $admin = identity::admin_user(); if (!empty($admin)) { // could be empty if there is not identity provider -- cgit v1.2.3 From 0dd12caa6f4c0452167b0e621a01bee28e71b0af Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 15 Feb 2013 19:12:08 -0500 Subject: Follow-on to 7bdccade98e76df3a7830bc45bc42321a77c709a - point out that there's duplicated code in gallery_event. --- modules/gallery/helpers/gallery_task.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 856d2639..37de2f93 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -281,6 +281,7 @@ class gallery_task_Core { switch ($task->get("mode", "init")) { case "init": $threshold = time() - 1209600; // older than 2 weeks + // Note that this code is roughly duplicated in gallery_event::gallery_shutdown foreach(array("logs", "tmp") as $dir) { $dir = VARPATH . $dir; if ($dh = opendir($dir)) { -- cgit v1.2.3 From 96ad7789c84b5b81320f9cb94b4c8cb4e10ad92f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 15 Feb 2013 16:15:40 -0800 Subject: Follow-on to 7bdccade98e76df3a7830bc45bc42321a77c709a to exclude directories for now. --- modules/gallery/helpers/gallery_event.php | 5 +++++ modules/gallery/helpers/gallery_task.php | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index eb54e521..26432ef5 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -54,6 +54,11 @@ class gallery_event_Core { continue; } + // Ignore directories for now, but we should really address them in the long term. + if (is_dir("$dir/$file")) { + continue; + } + if (filemtime("$dir/$file") <= $threshold) { unlink("$dir/$file"); break; diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 37de2f93..a79cb2d5 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -290,6 +290,11 @@ class gallery_task_Core { continue; } + // Ignore directories for now, but we should really address them in the long term. + if (is_dir("$dir/$file")) { + continue; + } + if (filemtime("$dir/$file") <= $threshold) { $files[] = "$dir/$file"; } -- cgit v1.2.3 From d632ef3e50252d388c272cacd29e8cc6e4949cec Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 17 Feb 2013 00:23:50 -0500 Subject: Fix up autocomplete for admin_server_add - found and fixed some bugs in gallery_autocomplete when "multiple" isn't set. Fixed some harmless syntax issues that js2-mode helpfully pointed out. --- lib/gallery.common.js | 26 ++++++++++++---------- .../server_add/controllers/admin_server_add.php | 6 ++--- modules/server_add/views/admin_server_add.html.php | 5 +---- modules/tag/helpers/tag_event.php | 2 +- 4 files changed, 19 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 95988573..548aa29a 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -229,11 +229,11 @@ source: function(request, response) { var split = function(val) { return val.split(/,\s*/); - } + }; var extract_last = function(term) { return split(term).pop(); - } + }; var ajax_options = { dataType: "json", @@ -241,15 +241,17 @@ success: function(data) { response(data); }, + data: { + term: request.term + }, + dataFilter: function(data, dataType) { + // Drop the tag + return data.substring(data.indexOf("\n") + 1); + } }; - if (options.multiple) { - + if ("multiple" in options) { $.extend(ajax_options, { - dataFilter: function(data, dataType) { - // Drop the tag - return data.substring(data.indexOf("\n") + 1); - }, data: { term: extract_last(request.term) } @@ -258,12 +260,12 @@ $.ajax(ajax_options, response); } - } + }; - if (options.multiple) { + if ("multiple" in options) { var split = function(val) { return val.split(/,\s*/); - } + }; $.extend(autocomplete_options, { focus: function(event, ui) { var terms = split(this.value); @@ -280,7 +282,7 @@ this.value = terms.join(", "); return false; } - }) + }); } $(this).autocomplete(autocomplete_options); diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php index ba2b9b3f..4e522702 100644 --- a/modules/server_add/controllers/admin_server_add.php +++ b/modules/server_add/controllers/admin_server_add.php @@ -73,14 +73,14 @@ class Admin_Server_Add_Controller extends Admin_Controller { public function autocomplete() { $directories = array(); - $path_prefix = Input::instance()->get("q"); + $path_prefix = Input::instance()->get("term"); foreach (glob("{$path_prefix}*") as $file) { if (is_dir($file) && !is_link($file)) { - $directories[] = html::clean($file); + $directories[] = (string)html::clean($file); } } - ajax::response(implode("\n", $directories)); + ajax::response(json_encode($directories)); } private function _get_admin_form() { diff --git a/modules/server_add/views/admin_server_add.html.php b/modules/server_add/views/admin_server_add.html.php index f59e327f..b2421c7c 100644 --- a/modules/server_add/views/admin_server_add.html.php +++ b/modules/server_add/views/admin_server_add.html.php @@ -6,10 +6,7 @@ $("document").ready(function() { $("#g-path").gallery_autocomplete( "".replace("__ARGS__", "admin/server_add/autocomplete"), - { - max: 256, - loadingClass: "g-loading-small", - }); + {multiple: true}); }); diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 79d6e0bc..08d5d53a 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -124,7 +124,7 @@ class tag_event_Core { ->text("$('input[name=tags]') .gallery_autocomplete( '$autocomplete_url', - {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1} + {multiple: true} ); $('input[name=tags]') .change(function (event) { -- cgit v1.2.3 From a000540565dacd0c83418d88dfda63e8e255dbc3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 17 Feb 2013 00:30:56 -0500 Subject: Updated for the new jQuery tabs API. --- modules/g2_import/views/admin_g2_import.html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index 22e19f5b..09aa6fae 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -25,9 +25,9 @@ $("document").ready(function() { .tabs("disable", 1) .tabs("disable", 2) .9 * $g2_resource_count): ?> - .tabs("select", 2) + .tabs({active: 2}) - .tabs("select", 1) + .tabs({active: 1}) ; -- cgit v1.2.3 From 9345dde83e1f092a9309c45282dc21e3fd408875 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 17 Feb 2013 00:39:30 -0500 Subject: Fix autocomplete for admin_g2_import. --- modules/g2_import/controllers/admin_g2_import.php | 6 +++--- modules/g2_import/views/admin_g2_import.html.php | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index c4f03907..08007b85 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -101,10 +101,10 @@ class Admin_g2_import_Controller extends Admin_Controller { public function autocomplete() { $directories = array(); - $path_prefix = Input::instance()->get("q"); + $path_prefix = Input::instance()->get("term"); foreach (glob("{$path_prefix}*") as $file) { if (is_dir($file) && !is_link($file)) { - $file = html::clean($file); + $file = (string)html::clean($file); $directories[] = $file; // If we find an embed.php, include it as well @@ -114,7 +114,7 @@ class Admin_g2_import_Controller extends Admin_Controller { } } - ajax::response(implode("\n", $directories)); + ajax::response(json_encode($directories)); } private function _get_import_form() { diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index 09aa6fae..fd9487e4 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -5,10 +5,7 @@ $("document").ready(function() { $("form input[name=embed_path]").gallery_autocomplete( "".replace("__ARGS__", "admin/g2_import/autocomplete"), - { - max: 256, - loadingClass: "g-loading-small", - }); + {}); }); -- cgit v1.2.3 From fd0051dab7258c817ff01877bd4324530ce79398 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sun, 17 Feb 2013 23:19:35 +0100 Subject: #2006 - Add system::mark_file_for_delete API to delete files at shutdown. - added system::mark_file_for_delete to be called to mark a file - added system::delete_marked_files to be called at shutdown to delete the list - amended system::temp_filename to, by default, add the temp name to the list - updated a few other places in code where this should be used --- modules/gallery/controllers/quick.php | 1 - modules/gallery/controllers/uploader.php | 2 +- modules/gallery/helpers/gallery_event.php | 4 ++- modules/gallery/helpers/system.php | 32 ++++++++++++++++++++-- modules/rest/controllers/rest.php | 2 +- modules/watermark/controllers/admin_watermarks.php | 6 ++-- 6 files changed, 38 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 2ddf2a4b..4b21d9ee 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -41,7 +41,6 @@ class Quick_Controller extends Controller { gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item); $item->set_data_file($tmpfile); $item->save(); - unlink($tmpfile); } if (Input::instance()->get("page_type") == "collection") { diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php index 78437071..8e09dbed 100644 --- a/modules/gallery/controllers/uploader.php +++ b/modules/gallery/controllers/uploader.php @@ -55,7 +55,7 @@ class Uploader_Controller extends Controller { if ($form->validate() && $file_validation->validate()) { $temp_filename = upload::save("Filedata"); - Event::add("system.shutdown", create_function("", "unlink(\"$temp_filename\");")); + system::delete_later($temp_filename); try { $item = ORM::factory("item"); $item->name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 26432ef5..a319b9c6 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -44,7 +44,7 @@ class gallery_event_Core { // var/tmp might be stickier because theoretically we could wind up spamming that // dir with a lot of files. But let's start with this and refine as we go. if (!(rand() % 500)) { - // Note that this code is roughly duplicated in gallery_event::gallery_shutdown + // Note that this code is roughly duplicated in gallery_task::file_cleanup $threshold = time() - 1209600; // older than 2 weeks foreach(array("logs", "tmp") as $dir) { $dir = VARPATH . $dir; @@ -67,6 +67,8 @@ class gallery_event_Core { } } } + // Delete all files marked using system::delete_later. + system::delete_marked_files(); } static function user_deleted($user) { diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index e1398103..7d56466e 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class system_Core { + private static $files_marked_for_deletion = array(); + /** * Return the path to an executable version of the named binary, or null. * The paths are traversed in the following order: @@ -66,8 +68,10 @@ class system_Core { * This helper is similar to the built-in tempnam. * It allows the caller to specify a prefix and an extension. * It always places the file in TMPPATH. + * Unless specified with the $delete_later argument, it will be marked + * for deletion at shutdown using system::delete_later. */ - static function temp_filename($prefix="", $extension="") { + static function temp_filename($prefix="", $extension="", $delete_later=true) { do { $basename = tempnam(TMPPATH, $prefix); if (!$basename) { @@ -79,6 +83,30 @@ class system_Core { @unlink($basename); } } while (!$success); + + if ($delete_later) { + system::delete_later($filename); + } + return $filename; } -} \ No newline at end of file + + /** + * Mark a file for deletion at shutdown time. This is useful for temp files, where we can delay + * the deletion time until shutdown to keep page load time quick. + */ + static function delete_later($filename) { + self::$files_marked_for_deletion[] = $filename; + } + + /** + * Delete all files marked using system::delete_later. This is called at gallery shutdown. + */ + static function delete_marked_files() { + foreach (self::$files_marked_for_deletion as $filename) { + // We want to suppress all errors, as it's possible that some of these + // files may have been deleted/moved before we got here. + @unlink($filename); + } + } +} diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index bd03b334..54ca6fe9 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -69,7 +69,7 @@ class Rest_Controller extends Controller { $request->params = (object) $input->post(); if (isset($_FILES["file"])) { $request->file = upload::save("file"); - Event::add("system.shutdown", create_function("", "unlink(\"{$request->file}\");")); + system::delete_later($request->file); } break; } diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php index b058d6a5..222279e8 100644 --- a/modules/watermark/controllers/admin_watermarks.php +++ b/modules/watermark/controllers/admin_watermarks.php @@ -67,7 +67,7 @@ class Admin_Watermarks_Controller extends Admin_Controller { $form = watermark::get_delete_form(); if ($form->validate()) { if ($name = basename(module::get_var("watermark", "name"))) { - @unlink(VARPATH . "modules/watermark/$name"); + system::delete_later(VARPATH . "modules/watermark/$name"); module::clear_var("watermark", "name"); module::clear_var("watermark", "width"); @@ -108,7 +108,7 @@ class Admin_Watermarks_Controller extends Admin_Controller { $name = legal_file::sanitize_filename($name, $extension, "photo"); } catch (Exception $e) { message::error(t("Invalid or unidentifiable image file")); - @unlink($file); + system::delete_later($file); return; } @@ -120,7 +120,7 @@ class Admin_Watermarks_Controller extends Admin_Controller { module::set_var("watermark", "position", $form->add_watermark->position->value); module::set_var("watermark", "transparency", $form->add_watermark->transparency->value); $this->_update_graphics_rules(); - @unlink($file); + system::delete_later($file); message::success(t("Watermark saved")); log::success("watermark", t("Watermark saved")); -- cgit v1.2.3 From 4f779e90831e9746083564ac82d4105dfc994262 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Mon, 18 Feb 2013 18:09:29 +0100 Subject: Password strength indicator fixed for new jQuery. Also cleaned up formatting. --- modules/user/js/password_strength.js | 71 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'modules') diff --git a/modules/user/js/password_strength.js b/modules/user/js/password_strength.js index 2442b8de..5764e332 100644 --- a/modules/user/js/password_strength.js +++ b/modules/user/js/password_strength.js @@ -1,39 +1,38 @@ (function($) { - // Based on the Password Strength Indictor By Benjamin Sterling - // http://benjaminsterling.com/password-strength-indicator-and-generator/ - $.widget("ui.user_password_strength", { - _init: function() { - var self = this; - $(this.element).keyup(function() { - var strength = self.calculateStrength (this.value); - var index = Math.min(Math.floor( strength / 10 ), 10); - $("#g-password-gauge") - .removeAttr('class') - .addClass( "g-password-strength0" ) - .addClass( self.options.classes[ index ] ); - }).after("

"); - }, + // Based on the Password Strength Indictor By Benjamin Sterling + // http://benjaminsterling.com/password-strength-indicator-and-generator/ + $.widget("ui.user_password_strength", { + options: { + classes: ['g-password-strength10', 'g-password-strength20', 'g-password-strength30', + 'g-password-strength40', 'g-password-strength50', 'g-password-strength60', + 'g-password-strength70', 'g-password-strength80', 'g-password-strength90', + 'g-password-strength100'] + }, - calculateStrength: function(value) { - // Factor in the length of the password - var strength = Math.min(5, value.length) * 10 - 20; - // Factor in the number of numbers - strength += Math.min(3, value.length - value.replace(/[0-9]/g,"").length) * 10; - // Factor in the number of non word characters - strength += Math.min(3, value.length - value.replace(/\W/g,"").length) * 15; - // Factor in the number of Upper case letters - strength += Math.min(3, value.length - value.replace(/[A-Z]/g,"").length) * 10; + _init: function() { + var self = this; + $(this.element).keyup(function() { + var strength = self.calculateStrength(this.value); + var index = Math.min(Math.floor(strength / 10), 10); + $("#g-password-gauge") + .removeAttr("class") + .addClass("g-password-strength0") + .addClass(self.options.classes[index]); + }).after("
"); + }, - // Normalizxe between 0 and 100 - return Math.max(0, Math.min(100, strength)); - } - }); - $.extend($.ui.user_password_strength, { - defaults: { - classes : ['g-password-strength10', 'g-password-strength20', 'g-password-strength30', - 'g-password-strength40', 'g-password-strength50', 'g-password-strength60', - 'g-password-strength70',' g-password-strength80',' g-password-strength90', - 'g-password-strength100'] - } - }); - })(jQuery); + calculateStrength: function(value) { + // Factor in the length of the password + var strength = Math.min(5, value.length) * 10 - 20; + // Factor in the number of numbers + strength += Math.min(3, value.length - value.replace(/[0-9]/g,"").length) * 10; + // Factor in the number of non word characters + strength += Math.min(3, value.length - value.replace(/\W/g,"").length) * 15; + // Factor in the number of Upper case letters + strength += Math.min(3, value.length - value.replace(/[A-Z]/g,"").length) * 10; + + // Normalize between 0 and 100 + return Math.max(0, Math.min(100, strength)); + } + }); +})(jQuery); -- cgit v1.2.3 From 4bf41377b8aca8dff15ccce398662e428268fa09 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Mon, 18 Feb 2013 18:29:31 +0100 Subject: Moved autocomplete CSS to gallery.css to ensure it works for all themes (including admin_wind). --- modules/gallery/css/gallery.css | 6 ++++++ themes/wind/css/screen.css | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index d3f7dcca..73b8ab4e 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -158,6 +158,12 @@ z-index: 1000 } +/* Autocomplete ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +.ui-autocomplete { + text-align: left; +} + /** ******************************************************************* * 2) Admin **********************************************************************/ diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index 6f98cbba..0ece722e 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -948,12 +948,6 @@ button { display: inline-block; } -/* Autocomplete */ - -.ui-autocomplete { - text-align: left; -} - /* Status and validation messages ~~~~ */ .g-message-block { -- cgit v1.2.3 From 58c137c98183377c8bacaad83c9b32caa9925fa2 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Mon, 18 Feb 2013 18:55:03 +0100 Subject: #2007 - Change search box text when only looking in the current album. - search.html.php - updated to use new labels. - search_link.html.php - updated to use new labels. Moved code that determines current album to top, then used it for both the new label and the hidden album input. Resulting form code looks more symmetric to search.html.php. --- modules/search/views/search.html.php | 6 +++++- modules/search/views/search_link.html.php | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/search/views/search.html.php b/modules/search/views/search.html.php index f1906744..a42c31dd 100644 --- a/modules/search/views/search.html.php +++ b/modules/search/views/search.html.php @@ -7,7 +7,11 @@