Changeset 816 for trunk/Modules/Translation/TranslationList.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/TranslationList.php
r791 r816 3 3 class CompletionState 4 4 { 5 6 7 8 9 10 11 12 5 const All = 0; 6 const NotTranslated = 1; 7 const Translated = 2; 8 const NotFinished = 3; 9 const Original = 4; 10 const NotFinishedNotTranslated = 5; 11 const Missing1 = 6; 12 const Missing2 = 7; 13 13 } 14 14 … … 16 16 class PageTranslationList extends Page 17 17 { 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 18 function ShowFilter($GroupId = 0) 19 { 20 global $TranslationTree; 21 22 $Filter = array('SQL' => ''); 23 24 $Output = '<form action="?" method="post">'. 25 '<table class="BaseTable"><tr>'. 26 '<th>Zpracování</th>'. 27 '<th>Skupina</th>'. 28 '<th>Verze</th>'. 29 '<th>Jazyk</th>'. 30 '<th>Překladatel</th>'. 31 '<th>Slova</th>'. 32 '<th>Položka</th>'. 33 '<th></th></tr><tr>'; 34 35 // State 36 $Filter['State'] = GetParameter('state', 0, true, true); 37 $Output .= '<td><select name="state">'; 38 $StateTypes = array( 39 CompletionState::All => 'Všechny', 40 40 CompletionState::NotTranslated => 'Nepřeložené', 41 41 CompletionState::Translated => 'Přeložené', … … 46 46 CompletionState::Missing2 => 'Chybějící $-Neopravený' 47 47 ); 48 49 50 51 52 } 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 48 foreach ($StateTypes as $index=>$StateType) { 49 if($Filter['State'] == $index) $Selected = ' selected="selected"'; 50 else $Selected = ''; 51 $Output .= '<option value="'.$index.'"'.$Selected.'>'.$StateType.'</option>'; 52 } 53 $Output .= '</select></td>'; 54 55 // Translation group 56 if($GroupId == 0) 57 { 58 $Filter['Group'] = GetParameter('group', 0, true, true); 59 if($Filter['Group'] != 0) 60 { 61 if(isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 62 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 63 } 64 } else 65 { 66 $Filter['Group'] = $GroupId; 67 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 68 } 69 70 $Output .= '<td><select name="group" style="width: 80px">'; 71 if($Filter['Group'] == 0) $Selected = ' selected="selected"'; 72 else $Selected = ''; 73 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 74 $DbResult = $this->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`'); 75 while($Group = $DbResult->fetch_assoc()) 76 { 77 if($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"'; 78 else $Selected = ''; 79 $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.$Group['Name'].'</option>'; 80 } 81 $Output .= '</select></td>'; 82 82 83 83 if ($this->System->User->Licence(LICENCE_USER)) 84 85 else 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 84 $Filter['Version'] = GetParameter('version', $this->System->User->PreferredVersion, true, true); 85 else 86 $Filter['Version'] = GetParameter('version', 0, true, true); 87 if($Filter['Version'] != 0) 88 { 89 $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); 90 if($DbResult->num_rows > 0) 91 { 92 $DbRow = $DbResult->fetch_assoc(); 93 $Filter['BuildNumber'] = $DbRow['BuildNumber']; 94 } else ErrorMessage('Zadaná verze klienta nenalezena'); 95 } 96 $Output .= '<td><select name="version">'; 97 if($Filter['Version'] == 0) $Selected = ' selected="selected"'; 98 else $Selected = ''; 99 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 100 $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC'); 101 while($Version = $DbResult->fetch_assoc()) 102 { 103 if($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"'; 104 else $Selected = ''; 105 $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>'; 106 } 107 $Output .= '</select></td>'; 108 if($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; 109 else $VersionFilter = ''; 110 //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) 111 112 // Language 113 $Filter['Language'] = GetParameter('lang', 0, true, true); 114 $Output .= '<td><select name="lang">'; 115 if($Filter['Language'] == 0) $Selected = ' selected="selected"'; 116 else $Selected = ''; 117 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 118 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`'); 119 while($Language = $DbResult->fetch_assoc()) 120 { 121 if($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"'; 122 else $Selected = ''; 123 $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.$Language['Name'].'</option>'; 124 } 125 $Output .= '</select></td>'; 126 $LanguageFilter = ''; 127 $LanguageFilterSub = ''; 128 if($Filter['Language'] != 0) { 129 129 $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; 130 130 $LanguageFilterSub = ' AND (`Sub`.`Language` = '.$Filter['Language'].')'; 131 131 } 132 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 133 // User 134 $Filter['User'] = GetParameter('user', 0, true, true); 135 $Output .= '<td><select name="user" style="width: 80px">'; 136 if($Filter['User'] == 0) $Selected = ' selected="selected"'; 137 else $Selected = ''; 138 $Output .= '<option value="0"'.$Selected.'>Všichni</option>'; 139 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`'); 140 while($User = $DbResult->fetch_assoc()) 141 { 142 if($User['Id'] == $Filter['User']) $Selected = ' selected="selected"'; 143 else $Selected = ''; 144 $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>'; 145 } 146 $Output .= '</select></td>'; 147 if($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; 148 else $UserFilter = ''; 149 150 // Words 151 $Filter['Text'] = GetParameter('text', '', false, true); 152 $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.htmlentities($Filter['Text']).'"></td>'; 153 if($Filter['Text'] != '') 154 { 155 $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); 156 if($Filter['Group'] != 0) 157 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 158 if($GroupItem['Visible'] == 1) 159 $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; 160 $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; 161 } 162 163 // Entry 164 $Filter['Entry'] = GetParameter('entry', '', false, true); 165 $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.htmlentities($Filter['Entry']).'"></td>'; 166 if($Filter['Entry'] != '') 167 { 168 $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; 169 } 170 171 if($Filter['Group'] != 0) 172 { 173 $WithoutAlter = ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 174 '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].')'.$LanguageFilterSub. 175 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '. 176 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) '; 177 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 178 if($GroupItem['Visible'] == 1) { 179 $ItemsVar[] = 'LENGTH(`T`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `T`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) '. 180 180 ' < ('. 181 181 'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '. 182 183 182 ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.$this->System->Config['OriginalLanguage'].' AND '. 183 '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '. 184 184 ')'; 185 186 187 188 189 190 191 192 193 194 195 196 185 } 186 if($Filter['State'] == CompletionState::All) $Filter['SQL'] .= $UserFilter.$VersionFilter.''; 187 else if($Filter['State'] == CompletionState::NotTranslated) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].') '. 188 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 189 '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter. 190 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 191 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; 192 else if($Filter['State'] == CompletionState::Translated) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; 193 else if($Filter['State'] == CompletionState::NotFinished) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage']. 194 ') AND (`T`.`Complete` = 0)'; 195 else if($Filter['State'] == CompletionState::Original) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].')'; 196 else if($Filter['State'] == CompletionState::NotFinishedNotTranslated) $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter. 197 197 ' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage']. 198 198 ') AND (`T`.`Complete` = 0)'. 199 199 ''; 200 200 else if($Filter['State'] == CompletionState::Missing1) { 201 201 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage']; 202 202 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; 203 204 203 } 204 else if($Filter['State'] == CompletionState::Missing2) { 205 205 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage']; 206 206 $Filter['SQL'] .= ' '. $WithoutAlter; 207 207 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 208 } 209 } 210 211 /* 212 // Ownership 213 if(array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; 214 else $Filter['Owner'] = 0; 215 $Output .= ' <td><select name="owner">'; 216 if($Filter['Owner'] == 0) $Selected = ' selected="selected"'; 217 else $Selected = ''; 218 $Output .= '<option value="0"'.$Selected.'>Všech</option>'; 219 if($Filter['Owner'] == 1) $Selected = ' selected="selected"'; 220 else $Selected = ''; 221 $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>'; 222 if($Filter['Owner'] == 2) $Selected = ' selected="selected"'; 223 else $Selected = ''; 224 $Output .= '<option value="2"'.$Selected.'>Překladatele</option>'; 225 $Output .= '</select></td>'; 226 if(($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; 227 */ 228 229 $Output .= '<td><input type="submit" value="Filtrovat"/></td>'; 230 $Output .= '</tr></table>'; 231 $Output .= '</form><br/>'; 232 $Filter['Output'] = $Output; 233 return($Filter); 234 } 235 236 function ShowTranslationList($Filter) 237 { 238 global $TranslationTree; 239 240 $Output = $Filter['Output']; 241 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 242 243 $Query = 'SELECT `T`.`ModifyTime`, `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '. 244 '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '. 245 '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '. 246 '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '. 247 'FROM `'.$Table.'` AS `T` '. 248 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '. 249 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '. 250 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '. 251 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '. 252 'WHERE 1 '.$Filter['SQL']; 253 254 // Get total item count 255 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`'); 256 $DbRow = $DbResult->fetch_row(); 257 $PageList = GetPageList($DbRow[0]); 258 259 $Output .= $PageList['Output']; 260 $TableColumns = array( 261 array('Name' => 'ID', 'Title' => 'Číslo'), 262 array('Name' => 'Entry', 'Title' => 'Položka'), 263 array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'), 264 array('Name' => 'VersionStart', 'Title' => 'Verze'), 265 array('Name' => 'LanguageName', 'Title' => 'Jazyk'), 266 array('Name' => 'UserName', 'Title' => 'Překladatel'), 267 array('Name' => 'ModifyTime', 'Title' => 'Datum'), 268 ); 269 270 $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1); 271 $Output .= '<table class="BaseTable">'. 272 $Order['Output']; 273 274 $DbResult = $this->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']); 275 while($Line = $DbResult->fetch_assoc()) 276 { 277 $Output .= '<tr><td><a href="form.php?group='.$Filter['Group'].'&ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['Entry'].'</td>'. 278 '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'. 279 '<td>'.$Line['VersionStartText'].'-'.$Line['VersionEndText'].'</td>'. 280 '<td>'.$Line['LanguageName'].'</td>'. 281 '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>'. 282 '<td>'.HumanDate($Line['ModifyTime']).'</td>' 283 283 ; 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 284 '</tr>'; 285 } 286 $Output .= '</table>'. 287 $PageList['Output']; 288 return($Output); 289 } 290 291 function ShowGroupList($Filter) 292 { 293 global $TranslationTree; 294 295 $Output = $Filter['Output']; 296 297 $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>'; 298 $Total = 0; 299 foreach($TranslationTree as $Group) 300 if($Group['TablePrefix'] != '') 301 { 302 $Filter = $this->ShowFilter($Group['Id']); 303 $ID = $this->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']); 304 $Line = $ID->fetch_row(); 305 if ($Line[0] <> '0') 306 $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>'; 307 $Total += $Line[0]; 308 } 309 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'. 310 '</table>'; 311 return($Output); 312 } 313 314 function ShowGroupTypeList() 315 { 316 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`'); 317 $DbRow = $DbResult->fetch_row(); 318 $PageList = GetPageList($DbRow[0]); 319 $Output = '<h3>Seznam překladových skupin</h3>'. 320 $PageList['Output']; 321 322 $Output .= '<table class="BaseTable">'; 323 $TableColumns = array( 324 array('Name' => 'Name', 'Title' => 'Jméno'), 325 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 326 array('Name' => '', 'Title' => 'Zdroje'), 327 array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'), 328 array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'), 329 ); 330 if($this->System->User->Licence(LICENCE_ADMIN)) 331 $TableColumns[] = array('Name' => '', 'Title' => 'Akce'); 332 333 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 334 $Output .= $Order['Output']; 335 336 $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 337 while($Group = $DbResult->fetch_assoc()) 338 { 339 $Output .= '<tr><td><a href="?group='.$Group['Id'].'&action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>'; 340 if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; 341 if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; 342 if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; 343 $Output .= '</td>'; 344 344 if($this->System->User->Licence(LICENCE_ADMIN)) 345 345 $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='. 346 346 $Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td>'; 347 347 else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>'; 348 348 $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&id='. 349 349 GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>'; 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 350 if($this->System->User->Licence(LICENCE_ADMIN)) 351 $Output .= '<td><a href="?action=groupdelete&id='.$Group['Id'].'">Smazat</a></td>'; 352 $Output .= '</tr>'; 353 354 } 355 $Output .= '</table>'. 356 '<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/>'; 357 if($this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">Přidat překladovou skupinu</a>'; 358 return($Output); 359 } 360 361 function ShowMenu() 362 { 363 global $TranslationTree; 364 365 $GroupId = GetParameter('group', 0, true); 366 if($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL); 367 else { 368 $Table = $TranslationTree[$GroupId]['TablePrefix']; 369 370 $Output = '<h3>Základní filtrování textů</h3><br/>'. 371 '<table class="BaseTable"><tr><th>Odkaz</th><th>Popis</th></tr>'. 372 '<tr><td><a title="Všechny dostupné texty ve skupině" href="?group='.$GroupId.'&state=4">Všechny</a></td>'. 373 '<td>Zobrazit všechny dostupné anglické texty ve skupině.</td></tr>'. 374 '<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>'. 375 '<td>Zobrazit pouze již přeložené texty.</td></tr>'. 376 '<tr><td><a title="Nepřeložené texty" href="?group='.$GroupId.'&state=1">Nepřeložené</a></td>'. 377 '<td>Dosud nepřeložené texty, které je potřeba přeložit.</td></tr>'. 378 '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3">Nedokončené</a></td>'. 379 '<td>Texty označené jako rozpracované.</td></tr>'; 380 381 if($this->System->User->Licence(LICENCE_USER)) 382 { 383 $Output .= '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3&user='.$this->System->User->Id.'">Moje nedokončené</a></td> 384 <td>Nedokončené texty přihlášeného uživatele</td></tr> 385 <tr><td><a title="Přeložené texty přihlášeného uživatele" href="?group='.$GroupId.'&state=2&user='.$this->System->User->Id.'">Moje přeložené</a></td> 386 <td>Přeložené texty přihlášeného uživatele</td></tr>'; 387 } 388 389 $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'. 390 '<input type="text" name="text" size="8" />'. 391 '<input type="submit" value="Hledat" />'. 392 '</div></form>'. 393 '</td><td>Vyhledat pomocí textu</td></tr>'; 394 395 $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'. 396 '<input type="text" name="entry" size="8" />'. 397 '<input type="submit" value="Hledat" />'. 398 '</div></form>'. 399 '</td><td>Zobrazit podle ID textu v databázi MaNGOSu</td></tr>'; 400 401 $Output .= '</table>'; 402 } 403 return($Output); 404 } 405 406 function ShowGroupAdd() 407 { 408 if($this->System->User->Licence(LICENCE_ADMIN)) 409 { 410 $Output = '<h3>Vložení nové překladové skupiny</h3>'. 411 '<form action="?action=groupaddfinish" method="post">'. 412 '<table>'. 413 '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'. 414 '<tr><td>Název tabulky v databázi:</td><td>Text<input type="text" name="TablePrefix"/></td></tr>'. 415 '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'. 416 '</table></form>'; 417 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 418 return($Output); 419 } 420 421 function ShowGroupAddFinish() 422 { 423 if($this->System->User->Licence(LICENCE_ADMIN)) 424 { 425 $TableName = 'Text'.$_POST['TablePrefix']; 426 $DbResult = $this->System->Database->select('Group', 'Id', 'TablePrefix="'.$TableName.'"'); 427 if($DbResult->num_rows == 0) 428 { 429 430 $this->System->Database->query('CREATE TABLE IF NOT EXISTS `'.$TableName.'` ( 431 431 `ID` int(11) NOT NULL AUTO_INCREMENT, 432 432 `Entry` int(11) NOT NULL, … … 455 455 ADD CONSTRAINT `'.$TableName.'_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`ID`), 456 456 ADD CONSTRAINT `'.$TableName.'_ibfk_3` FOREIGN KEY (`Take`) REFERENCES `'.$TableName.'` (`ID`);'); 457 458 459 460 457 $DbResult = $this->System->Database->insert('Group', array('Name' => $_POST['Name'], 458 'TablePrefix' => $TableName, 'PrimaryKeyItem' => 'Entry')); 459 $Group = $this->System->Database->insert_id; 460 $this->System->Database->insert('GroupItem', array('Group' => $Group, 461 461 'Name' => 'Jméno', 'Column' => 'Name', 'Visible' => 1)); 462 462 $Output = ShowMessage('Překladová skupina vytvořena', MESSAGE_INFORMATION); 463 463 } else $Output = ShowMessage('Překladová skupina '.$TableName.' již existuje', MESSAGE_CRITICAL); 464 464 $Output .= $this->ShowGroupTypeList(); 465 466 return($Output); 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 465 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 466 return($Output); 467 } 468 469 function ShowGroupDelete() 470 { 471 if($this->System->User->Licence(LICENCE_ADMIN)) 472 { 473 $DbResult = $this->System->Database->select('Group', '*', 'Id='.$_GET['id']); 474 if($DbResult->num_rows == 1) 475 { 476 $Group = $DbResult->fetch_assoc(); 477 $this->Database->query('DROP TABLE `'.$Group['TablePrefix'].'`'); 478 $this->Database->query('DELETE FROM `GroupItem` WHERE `Group`='.$Group['Id']); 479 $this->Database->query('DELETE FROM `Group` WHERE `Id`='.$Group['Id']); 480 $Output = ShowMessage('Překladová skupina '.$Group['Name'].' smazána', MESSAGE_INFORMATION); 481 } else $Output = ShowMessage('Překladová skupina nenalezena', MESSAGE_CRITICAL); 482 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 483 $Output .= $this->ShowGroupTypeList(); 484 return($Output); 485 } 486 487 function Show() 488 { 489 $this->Title = T('Translation groups'); 490 $Action = GetParameter('action', ''); 491 if($Action == 'filter') $Output = $this->ShowMenu(); 492 else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList(); 493 else if($Action == 'groupadd') $Output = $this->ShowGroupAdd(); 494 else if($Action == 'groupdelete') $Output = $this->ShowGroupDelete(); 495 else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish(); 496 else 497 { 498 $Filter = $this->ShowFilter(); 499 if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter); 500 else $Output = $this->ShowGroupList($Filter); 501 } 502 return($Output); 503 } 504 504 }
Note:
See TracChangeset
for help on using the changeset viewer.