function _locale_translate_seek in Drupal 6
Same name and namespace in other branches
- 7 includes/locale.inc \_locale_translate_seek()
Perform a string search and display results in a table
Related topics
1 call to _locale_translate_seek()
- locale_translate_seek_screen in includes/
locale.inc - String search screen.
File
- includes/
locale.inc, line 1999 - Administration functions for locale.module.
Code
function _locale_translate_seek() {
$output = '';
// We have at least one criterion to match
if ($query = _locale_translate_seek_query()) {
$join = "SELECT s.source, s.location, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid ";
$arguments = array();
$limit_language = FALSE;
// Compute LIKE section
switch ($query['translation']) {
case 'translated':
$where = "WHERE (t.translation LIKE '%%%s%%')";
$orderby = "ORDER BY t.translation";
$arguments[] = $query['string'];
break;
case 'untranslated':
$where = "WHERE (s.source LIKE '%%%s%%' AND t.translation IS NULL)";
$orderby = "ORDER BY s.source";
$arguments[] = $query['string'];
break;
case 'all':
default:
$where = "WHERE (s.source LIKE '%%%s%%' OR t.translation LIKE '%%%s%%')";
$orderby = '';
$arguments[] = $query['string'];
$arguments[] = $query['string'];
break;
}
$grouplimit = '';
if (!empty($query['group']) && $query['group'] != 'all') {
$grouplimit = " AND s.textgroup = '%s'";
$arguments[] = $query['group'];
}
switch ($query['language']) {
// Force search in source strings
case "en":
$sql = $join . " WHERE s.source LIKE '%%%s%%' {$grouplimit} ORDER BY s.source";
$arguments = array(
$query['string'],
);
// $where is not used, discard its arguments
if (!empty($grouplimit)) {
$arguments[] = $query['group'];
}
break;
// Search in all languages
case "all":
$sql = "{$join} {$where} {$grouplimit} {$orderby}";
break;
// Some different language
default:
$sql = "{$join} AND t.language = '%s' {$where} {$grouplimit} {$orderby}";
array_unshift($arguments, $query['language']);
// Don't show translation flags for other languages, we can't see them with this search.
$limit_language = $query['language'];
}
$result = pager_query($sql, 50, 0, NULL, $arguments);
$groups = module_invoke_all('locale', 'groups');
$header = array(
t('Text group'),
t('String'),
$limit_language ? t('Language') : t('Languages'),
array(
'data' => t('Operations'),
'colspan' => '2',
),
);
$arr = array();
while ($locale = db_fetch_object($result)) {
$arr[$locale->lid]['group'] = $groups[$locale->textgroup];
$arr[$locale->lid]['languages'][$locale->language] = $locale->translation;
$arr[$locale->lid]['location'] = $locale->location;
$arr[$locale->lid]['source'] = $locale->source;
}
$rows = array();
foreach ($arr as $lid => $value) {
$rows[] = array(
$value['group'],
array(
'data' => check_plain(truncate_utf8($value['source'], 150, FALSE, TRUE)) . '<br /><small>' . $value['location'] . '</small>',
),
array(
'data' => _locale_translate_language_list($value['languages'], $limit_language),
'align' => 'center',
),
array(
'data' => l(t('edit'), "admin/build/translate/edit/{$lid}"),
'class' => 'nowrap',
),
array(
'data' => l(t('delete'), "admin/build/translate/delete/{$lid}"),
'class' => 'nowrap',
),
);
}
if (count($rows)) {
$output .= theme('table', $header, $rows);
if ($pager = theme('pager', NULL, 50)) {
$output .= $pager;
}
}
else {
$output .= t('No strings found for your search.');
}
}
return $output;
}