Changeset 561 for trunk/Modules/Translation/TranslationList.php
- Timestamp:
- Aug 13, 2013, 11:31:34 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/TranslationList.php
r550 r561 3 3 class PageTranslationList extends Page 4 4 { 5 function ShowFilter($GroupId = 0) 6 { 7 global $System, $TranslationTree, $Config; 8 9 $Filter = array('SQL' => ''); 10 11 $Output = '<form action="?" method="post">'. 12 '<table class="BaseTable"><tr>'. 13 '<th>Zpracování</th>'. 14 '<th>Skupina</th>'. 15 '<th>Verze</th>'. 16 '<th>Jazyk</th>'. 17 '<th>Překladatel</th>'. 18 '<th>Slova</th>'. 19 '<th>Položka</th>'. 20 '<th></th></tr><tr>'; 21 22 // State 23 $Filter['State'] = GetParameter('state', 0, true, true); 24 $Output .= '<td><select name="state">'; 25 if($Filter['State'] == 0) $Selected = ' selected="selected"'; 26 else $Selected = ''; 27 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 28 if($Filter['State'] == 1) $Selected = ' selected="selected"'; 29 else $Selected = ''; 30 $Output .= '<option value="1"'.$Selected.'>Nepřeložené</option>'; 31 if($Filter['State'] == 2) $Selected = ' selected="selected"'; 32 else $Selected = ''; 33 $Output .= '<option value="2"'.$Selected.'>Přeložené</option>'; 34 if($Filter['State'] == 3) $Selected = ' selected="selected"'; 35 else $Selected = ''; 36 $Output .= '<option value="3"'.$Selected.'>Rozpracované</option>'; 37 if($Filter['State'] == 4) $Selected = ' selected="selected"'; 38 else $Selected = ''; 39 $Output .= '<option value="4"'.$Selected.'>Anglické</option>'; 40 $Output .= '</select></td>'; 41 42 // Translation group 43 if($GroupId == 0) 44 { 45 $Filter['Group'] = GetParameter('group', 0, true, true); 46 if($Filter['Group'] != 0) 47 { 48 if(isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 49 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 50 } 51 } else 52 { 53 $Filter['Group'] = $GroupId; 54 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 55 } 56 57 $Output .= '<td><select name="group" style="width: 80px">'; 58 if($Filter['Group'] == 0) $Selected = ' selected="selected"'; 59 else $Selected = ''; 60 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 61 $DbResult = $System->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`'); 62 while($Group = $DbResult->fetch_assoc()) 63 { 64 if($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"'; 65 else $Selected = ''; 66 $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.$Group['Name'].'</option>'; 67 } 68 $Output .= '</select></td>'; 69 70 // Version 71 $Filter['Version'] = GetParameter('version', 0, true, true); 72 if($Filter['Version'] != 0) 73 { 74 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); 75 if($DbResult->num_rows > 0) 76 { 77 $DbRow = $DbResult->fetch_assoc(); 78 $Filter['BuildNumber'] = $DbRow['BuildNumber']; 79 } else ErrorMessage('Zadaná verze klienta nenalezena'); 80 } 81 $Output .= '<td><select name="version">'; 82 if($Filter['Version'] == 0) $Selected = ' selected="selected"'; 83 else $Selected = ''; 84 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 85 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC'); 86 while($Version = $DbResult->fetch_assoc()) 87 { 88 if($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"'; 89 else $Selected = ''; 90 $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>'; 91 } 92 $Output .= '</select></td>'; 93 if($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; 94 else $VersionFilter = ''; 95 //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) 96 97 // Language 98 $Filter['Language'] = GetParameter('lang', 0, true, true); 99 $Output .= '<td><select name="lang">'; 100 if($Filter['Language'] == 0) $Selected = ' selected="selected"'; 101 else $Selected = ''; 102 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 103 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`'); 104 while($Language = $DbResult->fetch_assoc()) 105 { 106 if($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"'; 107 else $Selected = ''; 108 $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.$Language['Name'].'</option>'; 109 } 110 $Output .= '</select></td>'; 111 if($Filter['Language'] != 0) $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; 112 else $LanguageFilter = ''; 113 114 // User 115 $Filter['User'] = GetParameter('user', 0, true, true); 116 $Output .= '<td><select name="user" style="width: 80px">'; 117 if($Filter['User'] == 0) $Selected = ' selected="selected"'; 118 else $Selected = ''; 119 $Output .= '<option value="0"'.$Selected.'>Všichni</option>'; 120 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`'); 121 while($User = $DbResult->fetch_assoc()) 122 { 123 if($User['Id'] == $Filter['User']) $Selected = ' selected="selected"'; 124 else $Selected = ''; 125 $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>'; 126 } 127 $Output .= '</select></td>'; 128 if($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; 129 else $UserFilter = ''; 130 131 // Words 132 $Filter['Text'] = GetParameter('text', '', false, true); 133 $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.$Filter['Text'].'"></td>'; 134 if($Filter['Text'] != '') 135 { 136 $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); 137 if($Filter['Group'] != 0) 138 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 139 if($GroupItem['Visible'] == 1) 140 $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; 141 $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; 142 } 143 144 // Entry 145 $Filter['Entry'] = GetParameter('entry', '', false, true); 146 $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.$Filter['Entry'].'"></td>'; 147 if($Filter['Entry'] != '') 148 { 149 $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; 150 } 151 152 if($Filter['Group'] != 0) 153 { 154 if($Filter['State'] == 0) $Filter['SQL'] .= $UserFilter.$VersionFilter.''; 155 else if($Filter['State'] == 1) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].') '. 156 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 157 '(`Sub`.`Language` <> '.$Config['OriginalLanguage'].')'.$LanguageFilter.$UserFilter. 158 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 159 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; 160 else if($Filter['State'] == 2) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; 161 else if($Filter['State'] == 3) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$Config['OriginalLanguage']. 162 ') AND (`T`.`Complete` = 0)'; 163 else if($Filter['State'] == 4) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].')'; 164 } 165 166 /* 167 // Ownership 168 if(array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; 169 else $Filter['Owner'] = 0; 170 $Output .= ' <td><select name="owner">'; 171 if($Filter['Owner'] == 0) $Selected = ' selected="selected"'; 172 else $Selected = ''; 173 $Output .= '<option value="0"'.$Selected.'>Všech</option>'; 174 if($Filter['Owner'] == 1) $Selected = ' selected="selected"'; 175 else $Selected = ''; 176 $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>'; 177 if($Filter['Owner'] == 2) $Selected = ' selected="selected"'; 178 else $Selected = ''; 179 $Output .= '<option value="2"'.$Selected.'>Překladatele</option>'; 180 $Output .= '</select></td>'; 181 if(($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; 182 */ 183 184 $Output .= '<td><input type="submit" value="Filtrovat"/></td>'; 185 $Output .= '</tr></table>'; 186 $Output .= '</form><br/>'; 187 $Filter['Output'] = $Output; 188 return($Filter); 5 function ShowFilter($GroupId = 0) 6 { 7 global $System, $TranslationTree, $Config; 8 9 $Filter = array('SQL' => ''); 10 11 $Output = '<form action="?" method="post">'. 12 '<table class="BaseTable"><tr>'. 13 '<th>Zpracování</th>'. 14 '<th>Skupina</th>'. 15 '<th>Verze</th>'. 16 '<th>Jazyk</th>'. 17 '<th>Překladatel</th>'. 18 '<th>Slova</th>'. 19 '<th>Položka</th>'. 20 '<th></th></tr><tr>'; 21 22 // State 23 $Filter['State'] = GetParameter('state', 0, true, true); 24 $Output .= '<td><select name="state">'; 25 if($Filter['State'] == 0) $Selected = ' selected="selected"'; 26 else $Selected = ''; 27 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 28 if($Filter['State'] == 1) $Selected = ' selected="selected"'; 29 else $Selected = ''; 30 $Output .= '<option value="1"'.$Selected.'>Nepřeložené</option>'; 31 if($Filter['State'] == 2) $Selected = ' selected="selected"'; 32 else $Selected = ''; 33 $Output .= '<option value="2"'.$Selected.'>Přeložené</option>'; 34 if($Filter['State'] == 3) $Selected = ' selected="selected"'; 35 else $Selected = ''; 36 $Output .= '<option value="3"'.$Selected.'>Rozpracované</option>'; 37 if($Filter['State'] == 4) $Selected = ' selected="selected"'; 38 else $Selected = ''; 39 $Output .= '<option value="4"'.$Selected.'>Anglické</option>'; 40 $Output .= '</select></td>'; 41 42 // Translation group 43 if($GroupId == 0) 44 { 45 $Filter['Group'] = GetParameter('group', 0, true, true); 46 if($Filter['Group'] != 0) 47 { 48 if(isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 49 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 50 } 51 } else 52 { 53 $Filter['Group'] = $GroupId; 54 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 55 } 56 57 $Output .= '<td><select name="group" style="width: 80px">'; 58 if($Filter['Group'] == 0) $Selected = ' selected="selected"'; 59 else $Selected = ''; 60 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 61 $DbResult = $System->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`'); 62 while($Group = $DbResult->fetch_assoc()) 63 { 64 if($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"'; 65 else $Selected = ''; 66 $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.$Group['Name'].'</option>'; 67 } 68 $Output .= '</select></td>'; 69 70 // Version 71 $Filter['Version'] = GetParameter('version', 0, true, true); 72 if($Filter['Version'] != 0) 73 { 74 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); 75 if($DbResult->num_rows > 0) 76 { 77 $DbRow = $DbResult->fetch_assoc(); 78 $Filter['BuildNumber'] = $DbRow['BuildNumber']; 79 } else ErrorMessage('Zadaná verze klienta nenalezena'); 80 } 81 $Output .= '<td><select name="version">'; 82 if($Filter['Version'] == 0) $Selected = ' selected="selected"'; 83 else $Selected = ''; 84 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 85 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC'); 86 while($Version = $DbResult->fetch_assoc()) 87 { 88 if($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"'; 89 else $Selected = ''; 90 $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>'; 91 } 92 $Output .= '</select></td>'; 93 if($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; 94 else $VersionFilter = ''; 95 //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) 96 97 // Language 98 $Filter['Language'] = GetParameter('lang', 0, true, true); 99 $Output .= '<td><select name="lang">'; 100 if($Filter['Language'] == 0) $Selected = ' selected="selected"'; 101 else $Selected = ''; 102 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 103 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`'); 104 while($Language = $DbResult->fetch_assoc()) 105 { 106 if($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"'; 107 else $Selected = ''; 108 $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.$Language['Name'].'</option>'; 109 } 110 $Output .= '</select></td>'; 111 if($Filter['Language'] != 0) $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; 112 else $LanguageFilter = ''; 113 114 // User 115 $Filter['User'] = GetParameter('user', 0, true, true); 116 $Output .= '<td><select name="user" style="width: 80px">'; 117 if($Filter['User'] == 0) $Selected = ' selected="selected"'; 118 else $Selected = ''; 119 $Output .= '<option value="0"'.$Selected.'>Všichni</option>'; 120 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`'); 121 while($User = $DbResult->fetch_assoc()) 122 { 123 if($User['Id'] == $Filter['User']) $Selected = ' selected="selected"'; 124 else $Selected = ''; 125 $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>'; 126 } 127 $Output .= '</select></td>'; 128 if($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; 129 else $UserFilter = ''; 130 131 // Words 132 $Filter['Text'] = GetParameter('text', '', false, true); 133 $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.$Filter['Text'].'"></td>'; 134 if($Filter['Text'] != '') 135 { 136 $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); 137 if($Filter['Group'] != 0) 138 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 139 if($GroupItem['Visible'] == 1) 140 $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; 141 $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; 142 } 143 144 // Entry 145 $Filter['Entry'] = GetParameter('entry', '', false, true); 146 $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.$Filter['Entry'].'"></td>'; 147 if($Filter['Entry'] != '') 148 { 149 $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; 150 } 151 152 if($Filter['Group'] != 0) 153 { 154 if($Filter['State'] == 0) $Filter['SQL'] .= $UserFilter.$VersionFilter.''; 155 else if($Filter['State'] == 1) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].') '. 156 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 157 '(`Sub`.`Language` <> '.$Config['OriginalLanguage'].')'.$LanguageFilter.$UserFilter. 158 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 159 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; 160 else if($Filter['State'] == 2) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; 161 else if($Filter['State'] == 3) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$Config['OriginalLanguage']. 162 ') AND (`T`.`Complete` = 0)'; 163 else if($Filter['State'] == 4) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].')'; 164 } 165 166 /* 167 // Ownership 168 if(array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; 169 else $Filter['Owner'] = 0; 170 $Output .= ' <td><select name="owner">'; 171 if($Filter['Owner'] == 0) $Selected = ' selected="selected"'; 172 else $Selected = ''; 173 $Output .= '<option value="0"'.$Selected.'>Všech</option>'; 174 if($Filter['Owner'] == 1) $Selected = ' selected="selected"'; 175 else $Selected = ''; 176 $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>'; 177 if($Filter['Owner'] == 2) $Selected = ' selected="selected"'; 178 else $Selected = ''; 179 $Output .= '<option value="2"'.$Selected.'>Překladatele</option>'; 180 $Output .= '</select></td>'; 181 if(($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; 182 */ 183 184 $Output .= '<td><input type="submit" value="Filtrovat"/></td>'; 185 $Output .= '</tr></table>'; 186 $Output .= '</form><br/>'; 187 $Filter['Output'] = $Output; 188 return($Filter); 189 } 190 191 function ShowTranslationList($Filter) 192 { 193 global $System, $TranslationTree; 194 195 $Output = $Filter['Output']; 196 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 197 198 $Query = 'SELECT `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '. 199 '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '. 200 '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '. 201 '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '. 202 'FROM `'.$Table.'` AS `T` '. 203 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '. 204 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '. 205 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '. 206 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '. 207 'WHERE 1 '.$Filter['SQL']; 208 209 // Get total item count 210 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`'); 211 $DbRow = $DbResult->fetch_row(); 212 $PageList = GetPageList($DbRow[0]); 213 214 $Output .= $PageList['Output']; 215 $TableColumns = array( 216 array('Name' => 'ID', 'Title' => 'Číslo'), 217 array('Name' => 'Entry', 'Title' => 'Položka'), 218 array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'), 219 array('Name' => 'VersionStart', 'Title' => 'Verze'), 220 array('Name' => 'LanguageName', 'Title' => 'Jazyk'), 221 array('Name' => 'UserName', 'Title' => 'Překladatel'), 222 ); 223 224 $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1); 225 $Output .= '<table class="BaseTable">'. 226 $Order['Output']; 227 228 $DbResult = $System->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']); 229 while($Line = $DbResult->fetch_assoc()) 230 { 231 $Output .= '<tr><td><a href="form.php?group='.$Filter['Group'].'&ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['Entry'].'</td>'. 232 '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'. 233 '<td>'.$Line['VersionStartText'].'-'.$Line['VersionEndText'].'</td>'. 234 '<td>'.$Line['LanguageName'].'</td>'. 235 '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>'; 236 '</tr>'; 237 } 238 $Output .= '</table>'. 239 $PageList['Output']; 240 return($Output); 241 } 242 243 function ShowGroupList($Filter) 244 { 245 global $System, $TranslationTree; 246 247 $Output = $Filter['Output']; 248 249 $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>'; 250 $Total = 0; 251 foreach($TranslationTree as $Group) 252 if($Group['TablePrefix'] != '') 253 { 254 $Filter = $this->ShowFilter($Group['Id']); 255 $ID = $System->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']); 256 $Line = $ID->fetch_row(); 257 $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>'; 258 $Total += $Line[0]; 259 } 260 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'. 261 '</table>'; 262 return($Output); 263 } 264 265 function ShowGroupTypeList() 266 { 267 global $System, $User; 268 269 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Group`'); 270 $DbRow = $DbResult->fetch_row(); 271 $PageList = GetPageList($DbRow[0]); 272 $Output = '<h3>Seznam překladových skupin</h3>'. 273 $PageList['Output']; 274 275 $Output .= '<table class="BaseTable">'; 276 $TableColumns = array( 277 array('Name' => 'Name', 'Title' => 'Jméno'), 278 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 279 array('Name' => '', 'Title' => 'Zdroje'), 280 array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'), 281 array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'), 282 ); 283 284 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 285 $Output .= $Order['Output']; 286 287 $DbResult = $System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 288 while($Group = $DbResult->fetch_assoc()) 289 { 290 $Output .= '<tr><td><a href="?group='.$Group['Id'].'&action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>'; 291 if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; 292 if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; 293 if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; 294 $Output .= '</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='. 295 $Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td></tr>'; 296 } 297 $Output .= '</table>'. 298 '<br /><a title="Záznam změn po importu" href="log.php?type=11">Záznam změn v textech při importu</a><br/>'; 299 if($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">Přidat překladovou skupinu</a>'; 300 return($Output); 301 } 302 303 function ShowMenu() 304 { 305 global $User, $TranslationTree; 306 307 $GroupId = GetParameter('group', 0, true); 308 if($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL); 309 else { 310 $Table = $TranslationTree[$GroupId]['TablePrefix']; 311 312 $Output = '<h3>Základní filtrování textů</h3><br/>'. 313 '<table class="BaseTable"><tr><th>Odkaz</th><th>Popis</th></tr>'. 314 '<tr><td><a title="Všechny dostupné texty ve skupině" href="?group='.$GroupId.'&state=4">Všechny</a></td>'. 315 '<td>Zobrazit všechny dostupné anglické texty ve skupině.</td></tr>'. 316 '<tr><td><a title="Přeložené texty, můžete zde hlasovat, nebo text opravovat" href="?group='.$GroupId.'&state=2">Přeložené</a></td>'. 317 '<td>Zobrazit pouze již přeložené texty.</td></tr>'. 318 '<tr><td><a title="Nepřeložené texty" href="?group='.$GroupId.'&state=1">Nepřeložené</a></td>'. 319 '<td>Dosud nepřeložené texty, které je potřeba přeložit.</td></tr>'. 320 '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3">Nedokončené</a></td>'. 321 '<td>Texty označené jako rozpracované.</td></tr>'; 322 323 if($User->Licence(LICENCE_USER)) 324 { 325 $Output .= '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3&user='.$User->Id.'">Moje nedokončené</a></td> 326 <td>Nedokončené texty přihlášeného uživatele</td></tr> 327 <tr><td><a title="Přeložené texty přihlášeného uživatele" href="?group='.$GroupId.'&state=2&user='.$User->Id.'">Moje přeložené</a></td> 328 <td>Přeložené texty přihlášeného uživatele</td></tr>'; 329 } 330 331 $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'. 332 '<input type="text" name="text" size="8" />'. 333 '<input type="submit" value="Hledat" />'. 334 '</div></form>'. 335 '</td><td>Vyhledat pomocí textu</td></tr>'; 336 337 $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'. 338 '<input type="text" name="entry" size="8" />'. 339 '<input type="submit" value="Hledat" />'. 340 '</div></form>'. 341 '</td><td>Zobrazit podle ID textu v databázi MaNGOSu</td></tr>'; 342 343 $Output .= '</table>'; 344 } 345 return($Output); 346 } 347 348 function ShowGroupAdd() 349 { 350 global $User; 351 352 if($User->Licence(LICENCE_ADMIN)) 353 { 354 $Output = '<h3>Vložení nové překladové skupiny</h3>'. 355 '<form action="?action=groupaddfinish" method="post">'. 356 '<table>'. 357 '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'. 358 '<tr><td>Název tabulky v databázi:</td><td><input type="text" name="TablePrefix"/></td></tr>'. 359 '<tr><td>Typ zdroje:</td><td><input type="text" name="SourceType"/></td></tr>'. 360 '<tr><td>Mangos databáze:</td><td><input type="text" name="MangosDatabase"/></td></tr>'. 361 '<tr><td>Mangos tabulka:</td><td><input type="text" name="MangosTable"/></td></tr>'. 362 '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'. 363 '</table></form>'; 364 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 365 return($Output); 366 } 367 368 function ShowGroupAddFinish() 369 { 370 global $User; 371 372 if($User->Licence(LICENCE_ADMIN)) 373 { 374 // TODO: Add group items manipulation oprations 375 } 376 } 377 378 function Show() 379 { 380 $Action = GetParameter('action', ''); 381 if($Action == 'filter') $Output = $this->ShowMenu(); 382 else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList(); 383 else if($Action == 'groupadd') $Output = $this->ShowGroupAdd(); 384 else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish(); 385 else 386 { 387 $Filter = $this->ShowFilter(); 388 if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter); 389 else $Output = $this->ShowGroupList($Filter); 390 } 391 return($Output); 392 } 189 393 } 190 191 function ShowTranslationList($Filter)192 {193 global $System, $TranslationTree;194 195 $Output = $Filter['Output'];196 $Table = $TranslationTree[$Filter['Group']]['TablePrefix'];197 198 $Query = 'SELECT `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '.199 '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '.200 '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '.201 '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '.202 'FROM `'.$Table.'` AS `T` '.203 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '.204 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '.205 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '.206 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '.207 'WHERE 1 '.$Filter['SQL'];208 209 // Get total item count210 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`');211 $DbRow = $DbResult->fetch_row();212 $PageList = GetPageList($DbRow[0]);213 214 $Output .= $PageList['Output'];215 $TableColumns = array(216 array('Name' => 'ID', 'Title' => 'Číslo'),217 array('Name' => 'Entry', 'Title' => 'Položka'),218 array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'),219 array('Name' => 'VersionStart', 'Title' => 'Verze'),220 array('Name' => 'LanguageName', 'Title' => 'Jazyk'),221 array('Name' => 'UserName', 'Title' => 'Překladatel'),222 );223 224 $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1);225 $Output .= '<table class="BaseTable">'.226 $Order['Output'];227 228 $DbResult = $System->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']);229 while($Line = $DbResult->fetch_assoc())230 {231 $Output .= '<tr><td><a href="form.php?group='.$Filter['Group'].'&ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['Entry'].'</td>'.232 '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'.233 '<td>'.$Line['VersionStartText'].'-'.$Line['VersionEndText'].'</td>'.234 '<td>'.$Line['LanguageName'].'</td>'.235 '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>';236 '</tr>';237 }238 $Output .= '</table>'.239 $PageList['Output'];240 return($Output);241 }242 243 function ShowGroupList($Filter)244 {245 global $System, $TranslationTree;246 247 $Output = $Filter['Output'];248 249 $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>';250 $Total = 0;251 foreach($TranslationTree as $Group)252 if($Group['TablePrefix'] != '')253 {254 $Filter = $this->ShowFilter($Group['Id']);255 $ID = $System->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']);256 $Line = $ID->fetch_row();257 $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>';258 $Total += $Line[0];259 }260 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'.261 '</table>';262 return($Output);263 }264 265 function ShowGroupTypeList()266 {267 global $System, $User;268 269 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Group`');270 $DbRow = $DbResult->fetch_row();271 $PageList = GetPageList($DbRow[0]);272 $Output = '<h3>Seznam překladových skupin</h3>'.273 $PageList['Output'];274 275 $Output .= '<table class="BaseTable">';276 $TableColumns = array(277 array('Name' => 'Name', 'Title' => 'Jméno'),278 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'),279 array('Name' => '', 'Title' => 'Zdroje'),280 array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'),281 array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'),282 );283 284 $Order = GetOrderTableHeader($TableColumns, 'Name', 0);285 $Output .= $Order['Output'];286 287 $DbResult = $System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);288 while($Group = $DbResult->fetch_assoc())289 {290 $Output .= '<tr><td><a href="?group='.$Group['Id'].'&action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>';291 if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';292 if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';293 if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';294 $Output .= '</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='.295 $Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td></tr>';296 }297 $Output .= '</table>'.298 '<br /><a title="Záznam změn po importu" href="log.php?type=11">Záznam změn v textech při importu</a><br/>';299 if($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">Přidat překladovou skupinu</a>';300 return($Output);301 }302 303 function ShowMenu()304 {305 global $User, $TranslationTree;306 307 $GroupId = GetParameter('group', 0, true);308 if($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL);309 else {310 $Table = $TranslationTree[$GroupId]['TablePrefix'];311 312 $Output = '<h3>Základní filtrování textů</h3><br/>'.313 '<table class="BaseTable"><tr><th>Odkaz</th><th>Popis</th></tr>'.314 '<tr><td><a title="Všechny dostupné texty ve skupině" href="?group='.$GroupId.'&state=4">Všechny</a></td>'.315 '<td>Zobrazit všechny dostupné anglické texty ve skupině.</td></tr>'.316 '<tr><td><a title="Přeložené texty, můžete zde hlasovat, nebo text opravovat" href="?group='.$GroupId.'&state=2">Přeložené</a></td>'.317 '<td>Zobrazit pouze již přeložené texty.</td></tr>'.318 '<tr><td><a title="Nepřeložené texty" href="?group='.$GroupId.'&state=1">Nepřeložené</a></td>'.319 '<td>Dosud nepřeložené texty, které je potřeba přeložit.</td></tr>'.320 '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3">Nedokončené</a></td>'.321 '<td>Texty označené jako rozpracované.</td></tr>';322 323 if($User->Licence(LICENCE_USER))324 {325 $Output .= '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3&user='.$User->Id.'">Moje nedokončené</a></td>326 <td>Nedokončené texty přihlášeného uživatele</td></tr>327 <tr><td><a title="Přeložené texty přihlášeného uživatele" href="?group='.$GroupId.'&state=2&user='.$User->Id.'">Moje přeložené</a></td>328 <td>Přeložené texty přihlášeného uživatele</td></tr>';329 }330 331 $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'.332 '<input type="text" name="text" size="8" />'.333 '<input type="submit" value="Hledat" />'.334 '</div></form>'.335 '</td><td>Vyhledat pomocí textu</td></tr>';336 337 $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'.338 '<input type="text" name="entry" size="8" />'.339 '<input type="submit" value="Hledat" />'.340 '</div></form>'.341 '</td><td>Zobrazit podle ID textu v databázi MaNGOSu</td></tr>';342 343 $Output .= '</table>';344 }345 return($Output);346 }347 348 function ShowGroupAdd()349 {350 global $User;351 352 if($User->Licence(LICENCE_ADMIN))353 {354 $Output = '<h3>Vložení nové překladové skupiny</h3>'.355 '<form action="?action=groupaddfinish" method="post">'.356 '<table>'.357 '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'.358 '<tr><td>Název tabulky v databázi:</td><td><input type="text" name="TablePrefix"/></td></tr>'.359 '<tr><td>Typ zdroje:</td><td><input type="text" name="SourceType"/></td></tr>'.360 '<tr><td>Mangos databáze:</td><td><input type="text" name="MangosDatabase"/></td></tr>'.361 '<tr><td>Mangos tabulka:</td><td><input type="text" name="MangosTable"/></td></tr>'.362 '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'.363 '</table></form>';364 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL);365 return($Output);366 }367 368 function ShowGroupAddFinish()369 {370 global $User;371 372 if($User->Licence(LICENCE_ADMIN))373 {374 // TODO: Add group items manipulation oprations375 }376 }377 378 function Show()379 {380 $Action = GetParameter('action', '');381 if($Action == 'filter') $Output = $this->ShowMenu();382 else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList();383 else if($Action == 'groupadd') $Output = $this->ShowGroupAdd();384 else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish();385 else386 {387 $Filter = $this->ShowFilter();388 if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter);389 else $Output = $this->ShowGroupList($Filter);390 }391 return($Output);392 }393 }
Note:
See TracChangeset
for help on using the changeset viewer.