From adac97b5372322be5154996974a6496198105d16 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 7 Feb 2010 08:28:32 -0800 Subject: Add prefix support for the target of RENAME TABLE. --- modules/gallery/libraries/MY_Database.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules/gallery/libraries') diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php index e2ef68cd..cb70104a 100644 --- a/modules/gallery/libraries/MY_Database.php +++ b/modules/gallery/libraries/MY_Database.php @@ -54,11 +54,18 @@ abstract class Database extends Database_Core { */ return $sql; } else if (strpos($sql, "CREATE TABLE") === 0) { - // Creating a new table add it to the table cache. + // Creating a new table; add it to the table cache. $open_brace = strpos($sql, "{") + 1; $close_brace = strpos($sql, "}", $open_brace); $name = substr($sql, $open_brace, $close_brace - $open_brace); $this->_table_names["{{$name}}"] = "{$prefix}$name"; + } else if (strpos($sql, "RENAME TABLE") === 0) { + // Renaming a table; add it to the table cache. + // You must use the form "TO {new_table_name}" exactly for this to work. + $open_brace = strpos($sql, "TO {") + 4; + $close_brace = strpos($sql, "}", $open_brace); + $name = substr($sql, $open_brace, $close_brace - $open_brace); + $this->_table_names["{{$name}}"] = "{$prefix}$name"; } if (!isset($this->_table_names)) { -- cgit v1.2.3 From b6c0d3a48ca4fa9296b23a1c4d73fb0573f1b92f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 7 Feb 2010 13:55:17 -0800 Subject: Refactor the is_rtl() helper into the Gallery_I18n class. This allows checking for a config value "force_rtl" which will layout the gallery pages in rtl mode without having to change to an language that is no longer understandable to the developer. Adding the line "$config['force_rtl'] = true;" to the config/locales.php file will make it happen. --- modules/gallery/helpers/locales.php | 4 +--- modules/gallery/libraries/Gallery_I18n.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'modules/gallery/libraries') diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index d209d414..4af750a3 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -131,9 +131,7 @@ class locales_Core { } static function is_rtl($locale=null) { - $locale or $locale = Gallery_I18n::instance()->locale(); - list ($language, $territory) = explode('_', $locale . "_"); - return in_array($language, array("he", "fa", "ar")); + return Gallery_I18n::instance()->is_rtl($locale); } /** diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index 4e0c1f82..1eacad5b 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -87,6 +87,16 @@ class Gallery_I18n_Core { return $this->_config['default_locale']; } + public function is_rtl($locale=null) { + $is_rtl = !empty($this->_config["force_rtl"]) and $this->_config["force_rtl"]; + if (empty($is_rtl)) { + $locale or $locale = $this->locale(); + list ($language, $territory) = explode('_', $locale . "_"); + $is_rtl = in_array($language, array("he", "fa", "ar")); + } + return $is_rtl; + } + /** * Translates a localizable message. * -- cgit v1.2.3 From 6783de24572eb3a84dd43d125686b5f1df33f305 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 7 Feb 2010 14:17:58 -0800 Subject: Remove the redundant reference to ["force_rtl". --- modules/gallery/libraries/Gallery_I18n.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/libraries') diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index 1eacad5b..cfed046a 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -88,7 +88,7 @@ class Gallery_I18n_Core { } public function is_rtl($locale=null) { - $is_rtl = !empty($this->_config["force_rtl"]) and $this->_config["force_rtl"]; + $is_rtl = !empty($this->_config["force_rtl"]); if (empty($is_rtl)) { $locale or $locale = $this->locale(); list ($language, $territory) = explode('_', $locale . "_"); -- cgit v1.2.3 From 6dfab72922bf20104d6032eb292d59c6bd6578ba Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 8 Feb 2010 15:37:11 -0800 Subject: Override Input::clean_input_keys() to sanitize malicious values out of strings instead of dying. This at least gives us graceful degradation. Fixes ticket #764, patch thanks to djnz. --- modules/gallery/libraries/MY_Input.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/gallery/libraries/MY_Input.php (limited to 'modules/gallery/libraries') diff --git a/modules/gallery/libraries/MY_Input.php b/modules/gallery/libraries/MY_Input.php new file mode 100644 index 00000000..dce569fd --- /dev/null +++ b/modules/gallery/libraries/MY_Input.php @@ -0,0 +1,31 @@ +