From 8021c167f6d7db325b3beba48205cfad479bce6d Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Wed, 10 Aug 2011 20:33:48 +0200 Subject: [PATCH 1/7] Fix regex --- application/controllers/users.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/users.php b/application/controllers/users.php index e5acb80..70b735b 100644 --- a/application/controllers/users.php +++ b/application/controllers/users.php @@ -67,7 +67,7 @@ class Users extends MY_Controller { array( 'field' => 'phone', 'label' => 'lang:field_phone', - 'rules' => 'trim|regex_match[/^\+\d{2,4}\w\d{2,4}\w\d{3,10}+$/i]', + 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', ) ); $this->form_validation->set_rules($config); @@ -127,7 +127,7 @@ class Users extends MY_Controller { array( 'field' => 'phone', 'label' => 'lang:field_phone', - //'rules' => 'trim|regex_match[/^\+\d{2,4}\w\d{2,4}\w\d{3,10}+$/i]', + 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', ) ); $this->form_validation->set_rules($config); From 4fa5a6d5a66fa43197610d6898b91af0fc5cf594 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Wed, 10 Aug 2011 20:34:24 +0200 Subject: [PATCH 2/7] Add link for user management to sidebar --- application/views/header.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/application/views/header.php b/application/views/header.php index 71adf1f..8899ab5 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -64,7 +64,10 @@ ?>
  • Administration +
  • Date: Wed, 10 Aug 2011 20:43:46 +0200 Subject: [PATCH 3/7] Seperate admin and actions menus --- application/views/header.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/application/views/header.php b/application/views/header.php index 8899ab5..871912e 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -59,9 +59,14 @@
  • Neues Projekt
  • + + + session->userdata('group') == 'admins'): ?> + - - - From 2ea23a78652f3dcf8740419677dc1415f1b75256 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Wed, 10 Aug 2011 21:02:08 +0200 Subject: [PATCH 4/7] Add delete confirmation --- application/controllers/users.php | 14 ++++++++------ application/views/admin/users/index.php | 2 +- assets/js/scattport.js | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/application/controllers/users.php b/application/controllers/users.php index 70b735b..c710934 100644 --- a/application/controllers/users.php +++ b/application/controllers/users.php @@ -156,12 +156,14 @@ class Users extends MY_Controller { * @param integer $id */ public function delete($id = '') { - if (!is_array($this->user->getUserByID())) { - show_404(); - } + $user = $this->user->getUserByID($id); - $this->user->delete($id); - $this->messages->add('The selected user was deleted', 'success'); - redirect('users', 200); + if (!isset($user) || !is_array($user) || !isset($user['id'])) { + show_404(); + } else { + $this->user->delete($user['id']); + $this->messages->add('The selected user was deleted', 'success'); + redirect('users', 200); + } } } \ No newline at end of file diff --git a/application/views/admin/users/index.php b/application/views/admin/users/index.php index 50ee331..2ff968b 100644 --- a/application/views/admin/users/index.php +++ b/application/views/admin/users/index.php @@ -22,7 +22,7 @@ foreach ($users as $user): - | + | Date: Wed, 10 Aug 2011 22:01:21 +0200 Subject: [PATCH 5/7] Add stuff for testing gettext --- application/core/MY_Lang.php | 36 +++++++++++++ .../language/locale/en_EN/LC_MESSAGES/lang.po | 53 +++++++++++++++++++ application/views/admin/users/index.php | 8 +-- 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 application/language/locale/en_EN/LC_MESSAGES/lang.po diff --git a/application/core/MY_Lang.php b/application/core/MY_Lang.php index bede557..d13f71d 100644 --- a/application/core/MY_Lang.php +++ b/application/core/MY_Lang.php @@ -7,11 +7,47 @@ */ class MY_Lang extends CI_Lang { + var $_gettext_language; + var $_gettext_domain; + var $_gettext_path; + /** * Calls the parent constructor. */ public function __construct() { parent::__construct(); + $this->_gettext_domain = 'lang'; + log_message('debug', "Gettext Class Initialized"); + + $this->load_gettext(); + } + + /** + * This method overides the original load method. It's duty is loading the + * domain files by config or by default internal settings. + * + * @param string $user_lang + */ + public function load_gettext($user_lang = false) { + if ($user_lang) { + $this->_gettext_language = $user_lang; + } else { + $this->_gettext_language = 'en_EN'; + } + log_message('debug', 'The gettext language was set by parameter: ' . $this->_gettext_language); + + putenv("LANG=$this->_gettext_language"); + setlocale(LC_ALL, $this->_gettext_language); + + // set the path of .po files + $this->_gettext_path = APPPATH . 'language/locale'; + log_message('debug', 'Gettext Class path chosen is: ' . $this->_gettext_path); + + bindtextdomain($this->_gettext_domain, $this->_gettext_path); + textdomain($this->_gettext_domain); + log_message('debug', 'The gettext domain chosen is: '. $this->_gettext_domain); + + return true; } /** diff --git a/application/language/locale/en_EN/LC_MESSAGES/lang.po b/application/language/locale/en_EN/LC_MESSAGES/lang.po new file mode 100644 index 0000000..dfd678f --- /dev/null +++ b/application/language/locale/en_EN/LC_MESSAGES/lang.po @@ -0,0 +1,53 @@ +msgid "users" +msgstr "Users" + +msgid "available_users" +msgstr "Available users" + +msgid "username" +msgstr "Username" + +msgid "realname" +msgstr "Name" + +msgid "options" +msgstr "Options" + +msgid "user_edit" +msgstr "Edit" + +msgid "user_create" +msgstr "Create new user" + +msgid "user_delete" +msgstr "Delete" + +msgid "create_user" +msgstr "Create a new user" + +msgid "edit_user" +msgstr "Edit user" + +msgid "field_username" +msgstr "Username" + +msgid "field_password" +msgstr "Password" + +msgid "field_password_confirm" +msgstr "Confirm password" + +msgid "field_firstname" +msgstr "First name" + +msgid "field_lastname" +msgstr "Last name" + +msgid "field_email" +msgstr "Email address" + +msgid "field_institution" +msgstr "Institution" + +msgid "field_phone" +msgstr "Phone number" diff --git a/application/views/admin/users/index.php b/application/views/admin/users/index.php index 2ff968b..9857848 100644 --- a/application/views/admin/users/index.php +++ b/application/views/admin/users/index.php @@ -3,7 +3,7 @@
    -

    +

    @@ -17,15 +17,15 @@ - | + | From 5c29fdba9e93295b09bdef993d625cecf0276e6c Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 02:14:11 +0200 Subject: [PATCH 6/7] Add *.mo files to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 953d1a5..493397e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ application/config/config.php application/config/database.php application/logs/* uploads/* +*.mo From 2daa1a6fadcfd4c3e4fbe6af0e59f6867035500b Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 11 Aug 2011 02:16:01 +0200 Subject: [PATCH 7/7] Fix language stuff --- application/core/MY_Lang.php | 38 ++++++++-- .../language/locale/de_DE/LC_MESSAGES/lang.po | 74 +++++++++++++++++++ .../{en_EN => en_US}/LC_MESSAGES/lang.po | 14 ++++ 3 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 application/language/locale/de_DE/LC_MESSAGES/lang.po rename application/language/locale/{en_EN => en_US}/LC_MESSAGES/lang.po (63%) diff --git a/application/core/MY_Lang.php b/application/core/MY_Lang.php index d13f71d..5716079 100644 --- a/application/core/MY_Lang.php +++ b/application/core/MY_Lang.php @@ -32,22 +32,43 @@ class MY_Lang extends CI_Lang { if ($user_lang) { $this->_gettext_language = $user_lang; } else { - $this->_gettext_language = 'en_EN'; + $this->_gettext_language = 'en_US'; } log_message('debug', 'The gettext language was set by parameter: ' . $this->_gettext_language); - putenv("LANG=$this->_gettext_language"); - setlocale(LC_ALL, $this->_gettext_language); + putenv("LC_ALL=$this->_gettext_language"); + setlocale(LC_ALL, $this->_gettext_language . ".utf8"); // set the path of .po files $this->_gettext_path = APPPATH . 'language/locale'; log_message('debug', 'Gettext Class path chosen is: ' . $this->_gettext_path); - bindtextdomain($this->_gettext_domain, $this->_gettext_path); - textdomain($this->_gettext_domain); + $filename = $this->_gettext_path . '/' . $this->_gettext_language . '/LC_MESSAGES/' . $this->_gettext_domain . '.mo'; + $mtime = filemtime($filename); + + $newFilename = $this->_gettext_path . '/' . $this->_gettext_language . '/LC_MESSAGES/' . $this->_gettext_domain . '_' . $mtime . '.mo'; + + if (!file_exists($newFilename)) { + $dir = scandir(dirname($filename)); + foreach ($dir as $file) { + // remove all the old files + if (!in_array($file, array('.', '..', $this->_gettext_domain . '.po', $this->_gettext_domain . '.mo'))) { + @unlink(dirname($filename) . '/' . $file); + } + } + + @copy($filename, $newFilename); + } + + $newDomain = $this->_gettext_domain . '_' . $mtime; + + bindtextdomain($newDomain, $this->_gettext_path); + bind_textdomain_codeset($newDomain, "UTF-8"); + textdomain($newDomain); + log_message('debug', 'The gettext domain chosen is: '. $this->_gettext_domain); - return true; + return true; } /** @@ -115,4 +136,7 @@ class MY_Lang extends CI_Lang { log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile); return true; } -} \ No newline at end of file +} + +/* End of file MY_Lang.php */ +/* Location: ./application/libraries/MY_Lang.php */ diff --git a/application/language/locale/de_DE/LC_MESSAGES/lang.po b/application/language/locale/de_DE/LC_MESSAGES/lang.po new file mode 100644 index 0000000..6584152 --- /dev/null +++ b/application/language/locale/de_DE/LC_MESSAGES/lang.po @@ -0,0 +1,74 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-08-10 21:25+0200\n" +"PO-Revision-Date: 2011-08-10 22:00+0200\n" +"Last-Translator: Karsten Heiken \n" +"Language-Team: German <>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n!=1);\n" + +msgid "Users" +msgstr "Benutzer" + +msgid "Available users" +msgstr "Alle verfügbaren Benutzer" + +msgid "Username" +msgstr "Benutzername" + +msgid "Full name" +msgstr "Vollständiger Name" + +msgid "Actions" +msgstr "Aktionen" + +msgid "Edit" +msgstr "Bearbeiten" + +msgid "Delete" +msgstr "Löschen" + +msgid "Create new user" +msgstr "Neuen Benutzer erstellen" + +msgid "Edit user '%s'" +msgstr "Benutzer »%s« bearbeiten" + +msgid "Required information" +msgstr "Erforderliche Angaben" + +msgid "Optional information" +msgstr "Optionale Angaben" + +msgid "Email address" +msgstr "E-Mail-Adresse" + +msgid "First name" +msgstr "Vorname" + +msgid "Last name" +msgstr "Nachname" + +msgid "Institution" +msgstr "Institution" + +msgid "Phone number" +msgstr "Telefonnummer" + +msgid "Language" +msgstr "Sprache" + +msgid "Example" +msgstr "Beispiel" + +msgid "Save" +msgstr "Speichern" + +msgid "Cancel" +msgstr "Abbrechen" + diff --git a/application/language/locale/en_EN/LC_MESSAGES/lang.po b/application/language/locale/en_US/LC_MESSAGES/lang.po similarity index 63% rename from application/language/locale/en_EN/LC_MESSAGES/lang.po rename to application/language/locale/en_US/LC_MESSAGES/lang.po index dfd678f..cba01f1 100644 --- a/application/language/locale/en_EN/LC_MESSAGES/lang.po +++ b/application/language/locale/en_US/LC_MESSAGES/lang.po @@ -1,3 +1,17 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-08-10 21:25+0200\n" +"PO-Revision-Date: 2011-08-10 22:00+0200\n" +"Last-Translator: Karsten Heiken \n" +"Language-Team: English <>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n!=1);\n" + msgid "users" msgstr "Users"