';
// State
$Filter['State'] = GetParameter('state', 0, true, true);
$Output .= ' | ';
// Translation group
if ($GroupId == 0)
{
$Filter['Group'] = GetParameter('group', 0, true, true);
if ($Filter['Group'] != 0)
{
if (isset($TranslationTree[$Filter['Group']]) == false)
ErrorMessage('Překladová skupina dle zadaného Id neexistuje.');
$Table = $TranslationTree[$Filter['Group']]['TablePrefix'];
}
} else
{
$Filter['Group'] = $GroupId;
$Table = $TranslationTree[$Filter['Group']]['TablePrefix'];
}
$Output .= ' | ';
if ($User->Licence(LICENCE_USER))
$Filter['Version'] = GetParameter('version', $User->PreferredVersion, true, true);
else
$Filter['Version'] = GetParameter('version', 0, true, true);
if ($Filter['Version'] != 0)
{
$DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')');
if ($DbResult->num_rows > 0)
{
$DbRow = $DbResult->fetch_assoc();
$Filter['BuildNumber'] = $DbRow['BuildNumber'];
} else ErrorMessage('Zadaná verze klienta nenalezena');
}
$Output .= ' | ';
if ($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')';
else $VersionFilter = '';
//else $Filter['SQL'] .= ' AND '; DISTINCT(Entry)
// Language
$Filter['Language'] = GetParameter('lang', 0, true, true);
$Output .= ' | ';
$LanguageFilter = '';
$LanguageFilterSub = '';
if ($Filter['Language'] != 0) {
$LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')';
$LanguageFilterSub = ' AND (`Sub`.`Language` = '.$Filter['Language'].')';
}
// User
$Filter['User'] = GetParameter('user', 0, true, true);
$Output .= ' | ';
if ($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')';
else $UserFilter = '';
// Words
$Filter['Text'] = GetParameter('text', '', false, true);
$Output .= ' | ';
if ($Filter['Text'] != '')
{
$Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")');
if ($Filter['Group'] != 0)
foreach ($TranslationTree[$Filter['Group']]['Items'] as $GroupItem)
if ($GroupItem['Visible'] == 1)
$Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")';
$Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')';
}
// Entry
$Filter['Entry'] = GetParameter('entry', '', false, true);
$Output .= ' | ';
if ($Filter['Entry'] != '')
{
$Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")';
}
if ($Filter['Group'] != 0)
{
$WithoutAlter = ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
'(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$LanguageFilterSub.
' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '.
'(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) ';
foreach ($TranslationTree[$Filter['Group']]['Items'] as $GroupItem)
if ($GroupItem['Visible'] == 1) {
$ItemsVar[] = 'LENGTH(`T`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `T`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) '.
' < ('.
'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '.
' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].' AND '.
'`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '.
')';
}
if ($Filter['State'] == CompletionState::All) {
$Filter['SQL'] .= $UserFilter.$VersionFilter;
} else
if ($Filter['State'] == CompletionState::NotTranslated) {
$Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
'(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.
' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '.
'(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))';
} else
if ($Filter['State'] == CompletionState::Translated) {
$Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)';
} else
if ($Filter['State'] == CompletionState::NotFinished) {
$Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
') AND (`T`.`Complete` = 0)';
} else
if ($Filter['State'] == CompletionState::Original) {
$Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')';
} else
if ($Filter['State'] == CompletionState::NotFinishedNotTranslated) {
$Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter.
' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
') AND (`T`.`Complete` = 0)';
} else
if ($Filter['State'] == CompletionState::Missing1) {
$Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
$Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
} else
if ($Filter['State'] == CompletionState::Missing2) {
$Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
$Filter['SQL'] .= ' '. $WithoutAlter;
$Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
}
}
/*
// Ownership
if (array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner'];
else $Filter['Owner'] = 0;
$Output .= ' | ';
if (($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')';
*/
$Output .= ' | ';
$Output .= '