changed the language loading behavior of codeigniter 2.2.6. it loads english if the requested language is not available

This commit is contained in:
hyung-hwan 2021-09-05 15:28:15 +00:00
parent a39ea1339a
commit 6f9638a4f0
4 changed files with 23 additions and 8 deletions

View File

@ -193,7 +193,8 @@ sub toggle_user
$dbh->begin_work (); $dbh->begin_work ();
my $query = $dbh->prepare("UPDATE ${QC}${prefix}user_account${QC} SET ${QC}enabled${QC}=? WHERE ${QC}userid${QC}=?"); 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(); my $errstr = $execok? "user not found": $dbh->errstr();
$dbh->rollback (); $dbh->rollback ();

View File

@ -65,6 +65,10 @@ class CI_Lang {
*/ */
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{ {
$first = true;
$orglangfile = $langfile;
RETRY:
$langfile = str_replace('.php', '', $langfile); $langfile = str_replace('.php', '', $langfile);
if ($add_suffix == TRUE) if ($add_suffix == TRUE)
@ -108,6 +112,14 @@ class CI_Lang {
if ($found !== TRUE) 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); show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
} }
} }

View File

@ -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; return TRUE;
} }
@ -1408,4 +1415,4 @@ class CI_DB_driver {
} }
/* End of file DB_driver.php */ /* End of file DB_driver.php */
/* Location: ./system/database/DB_driver.php */ /* Location: ./system/database/DB_driver.php */

View File

@ -318,12 +318,7 @@ class CI_Form_validation {
} }
// Load the language file containing error messages // Load the language file containing error messages
$this->CI->lang->load('form_validation');
// 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');
// Cycle through the rules for each field, match the // Cycle through the rules for each field, match the
// corresponding $_POST item and test for errors // corresponding $_POST item and test for errors