From 6f9638a4f0b8ffbc8fef33f507ef18d2eac9a0be Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 5 Sep 2021 15:28:15 +0000 Subject: [PATCH] changed the language loading behavior of codeigniter 2.2.6. it loads english if the requested language is not available --- codepot/sbin/codepot-user.in | 3 ++- codepot/src/system/core/Lang.php | 12 ++++++++++++ codepot/src/system/database/DB_driver.php | 9 ++++++++- codepot/src/system/libraries/Form_validation.php | 7 +------ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/codepot/sbin/codepot-user.in b/codepot/sbin/codepot-user.in index 82622d28..40a3d336 100644 --- a/codepot/sbin/codepot-user.in +++ b/codepot/sbin/codepot-user.in @@ -193,7 +193,8 @@ sub toggle_user $dbh->begin_work (); my $query = $dbh->prepare("UPDATE ${QC}${prefix}user_account${QC} SET ${QC}enabled${QC}=? WHERE ${QC}userid${QC}=?"); - if (!$query || !(my $execok = $query->execute($enabled, $userid)) || $query->rows() <= 0) + my $execok = undef; + if (!$query || !($execok = $query->execute($enabled, $userid)) || $query->rows() <= 0) { my $errstr = $execok? "user not found": $dbh->errstr(); $dbh->rollback (); diff --git a/codepot/src/system/core/Lang.php b/codepot/src/system/core/Lang.php index 28497034..d4c21d47 100755 --- a/codepot/src/system/core/Lang.php +++ b/codepot/src/system/core/Lang.php @@ -65,6 +65,10 @@ class CI_Lang { */ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { + $first = true; + $orglangfile = $langfile; + + RETRY: $langfile = str_replace('.php', '', $langfile); if ($add_suffix == TRUE) @@ -108,6 +112,14 @@ class CI_Lang { if ($found !== TRUE) { + if ($first && $idiom != 'english') + { + // HYUNG-HWAN: load the english file if the given language is not available + $first = false; + $idiom = 'english'; + $langfile = $orglangfile; + goto RETRY; + } show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile); } } diff --git a/codepot/src/system/database/DB_driver.php b/codepot/src/system/database/DB_driver.php index b6c1e34b..a9b0a643 100644 --- a/codepot/src/system/database/DB_driver.php +++ b/codepot/src/system/database/DB_driver.php @@ -154,6 +154,13 @@ class CI_DB_driver { } } + // HYUNG-HWAN - hack to enable foreign keys support in sqlite + if (preg_match("/^sqlite/", $this->dbdriver) || + ($this->dbdriver == 'pdo' && preg_match("/^sqlite/", $this->hostname))) + { + $this->_execute('PRAGMA foreign_keys=ON'); + } + return TRUE; } @@ -1408,4 +1415,4 @@ class CI_DB_driver { } /* End of file DB_driver.php */ -/* Location: ./system/database/DB_driver.php */ \ No newline at end of file +/* Location: ./system/database/DB_driver.php */ diff --git a/codepot/src/system/libraries/Form_validation.php b/codepot/src/system/libraries/Form_validation.php index 4973b05b..893f7f15 100644 --- a/codepot/src/system/libraries/Form_validation.php +++ b/codepot/src/system/libraries/Form_validation.php @@ -318,12 +318,7 @@ class CI_Form_validation { } // Load the language file containing error messages - - // HYUNG-HWAN: codepot doesn't ship the other language files for form validation - // let's hard-code it to english - //$this->CI->lang->load('form_validation'); - $this->CI->lang->load('form_validation', 'english'); - + $this->CI->lang->load('form_validation'); // Cycle through the rules for each field, match the // corresponding $_POST item and test for errors