View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000758 | CATS.cacert.org | Database | public | 2009-07-24 18:45 | 2013-03-21 07:16 |
Reporter | J Steijlen | Assigned To | Ted | ||
Priority | low | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Summary | 0000758: Any addition of an UI language would require a redesign of the DB table "questiontype". I.e. adding a column. | ||||
Description | Any addition of an UI language would require a redesign of the DB table "questiontype". I.e. adding a column. For example. CREATE TABLE `questiontype` ( `qt_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Fragetypenschlüssel', `DE` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT 'Fragetyp', `EN` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '', + `NL` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '', PRIMARY KEY (`qt_id`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci COMMENT='Fragetypen' I've redefined the table as CREATE TABLE `questiontype_v2` ( `qt_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Fragetypenschlüssel', `lang` varchar(5) COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT 'Sprache', `qt_desc` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT 'Fragetyp', PRIMARY KEY (`qt_id`,`lang`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci COMMENT='Fragetypen' Which lets you add rows for each language you want. The new table is quickly prefilled using: INSERT INTO questiontype_v2 select qt_id, 'DE' AS lang, DE AS qt_desc FROM questiontype INSERT INTO questiontype_v2 select qt_id, 'EN' AS lang, EN AS qt_desc FROM questiontype I've upgraded both of the functions dealing with this table. I've also taken the liberty to use sprintf. This way it's a bit easier to see what is in the query to be executed. | ||||
Tags | No tags attached. | ||||
Attached Files | UI_translation_-_remove_DB_hardcoding.patch (3,043 bytes)
Any addition of an UI language would require a redesign of the DB table "questiontype". I.e. adding a column. For example. CREATE TABLE `questiontype` ( `qt_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Fragetypenschlüssel', `DE` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT 'Fragetyp', `EN` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '', + `NL` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '', PRIMARY KEY (`qt_id`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci COMMENT='Fragetypen' I've redefined the table as CREATE TABLE `questiontype_v2` ( `qt_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Fragetypenschlüssel', `lang` varchar(5) COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT 'Sprache', `qt_desc` varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '' COMMENT 'Fragetyp', PRIMARY KEY (`qt_id`,`lang`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci COMMENT='Fragetypen' Which lets you add rows for each language you want. The new table is quickly prefilled using: INSERT INTO questiontype_v2 select qt_id, 'DE' AS lang, DE AS qt_desc FROM questiontype INSERT INTO questiontype_v2 select qt_id, 'EN' AS lang, EN AS qt_desc FROM questiontype I've upgraded both of the functions dealing with this table. I've also taken the liberty to use sprintf. This way it's a bit easier to see what is in the query to be executed. CATS/database/create_db.sql has yet to be updated. Index: classes/Question.class.php =================================================================== --- CATS/classes/Question.class.php (revision 1641) +++ CATS/classes/Question.class.php (working copy) @@ -179,7 +179,7 @@ function returnTypeName($type){ // if($type==0)$type=$_SESSION ['values']['question']['qt']; - $sql="SELECT ".mysql_real_escape_string($_SESSION['profile']['language'])." as type FROM questiontype WHERE qt_id='".intval($type)."'"; + $sql=sprintf("SELECT qt_desc as type FROM questiontype_v2 WHERE qt_id='%d' AND lang='%s'", intval($type), mysql_real_escape_string($_SESSION['profile']['language'])); $query = mysql_query($sql); $type = mysql_fetch_assoc($query); $this->typeName="321 ".$type['type']; --- CATS/functions/showQuestionForm.php (revision 1641) +++ CATS/functions/showQuestionForm.php (working copy) @@ -30,7 +30,7 @@ echo"<td class='left_point'> : </td>"; echo "<td class='text'>123 "; - $sql_qtypes ="SELECT qt_id, ".mysql_real_escape_string($_SESSION['profile']['language'])." as type FROM questiontype "; + $sql_qtypes=sprintf("SELECT qt_id, qt_desc as type FROM questiontype_v2 WHERE lang='%s'", mysql_real_escape_string($_SESSION['profile']['language'])); $query_qtypes = mysql_query($sql_qtypes) or die(mysql_error()); if($_SESSION['values']['question']['qt']==null && $error=='missing')echo"<select size='1' class='dropdown_right marked' name='qt' > "; | ||||
|
Analysis is correct and fix looks good. Though I must admit that additional languages for the user interface are currently not my primary concern I'll verify and apply the patch. |
|
If we travel the gettext path 758 & 759/760 will become obsolete. Let's discuss that route before you spend too much time and energy on these. (I can see CATS striking out on it's own, and become a larger, more used project.) |
|
Checked in to SVN revision 2240 |
|
Update installed at testsystem https://secure.test1.cacert.at/training |
|
Update of database and scripts installed |
|
More than 3 month solved |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-07-24 18:45 | J Steijlen | New Issue | |
2009-07-24 18:45 | J Steijlen | Status | new => needs work |
2009-07-24 18:45 | J Steijlen | Assigned To | => Ted |
2009-07-24 18:45 | J Steijlen | File Added: UI_translation_-_remove_DB_hardcoding.patch | |
2009-07-28 19:13 | Ted | Note Added: 0001463 | |
2009-07-28 19:13 | Ted | Priority | high => low |
2009-07-28 19:13 | Ted | Severity | major => feature |
2009-07-28 20:27 | Ted | Relationship added | related to 0000759 |
2009-07-29 05:31 | J Steijlen | Note Added: 0001470 | |
2011-05-11 15:43 | Ted | Note Added: 0001957 | |
2011-05-12 19:05 | Ted | Note Added: 0001960 | |
2012-11-18 22:50 | Ted | Note Added: 0003342 | |
2012-11-18 22:50 | Ted | Status | needs work => solved? |
2012-11-18 22:50 | Ted | Resolution | open => fixed |
2012-12-27 17:23 | Werner Dworak | Relationship added | related to 0001107 |
2013-03-21 07:16 | Werner Dworak | Note Added: 0003829 | |
2013-03-21 07:16 | Werner Dworak | Status | solved? => closed |