summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--translation/translation.module57
1 files changed, 27 insertions, 30 deletions
diff --git a/translation/translation.module b/translation/translation.module
index 5e9f44b..0af0012 100644
--- a/translation/translation.module
+++ b/translation/translation.module
@@ -420,18 +420,13 @@ function translation_node_page() {
form_set_error('language', t("You need to set a language before creating a translation."));
drupal_goto("node/$nid/edit");
}
- drupal_set_title($node->title);
+ drupal_set_title(check_plain($node->title));
$output = '';
switch($op){
case 'select':
$output .= translation_node_overview($node);
$output .= translation_node_select($node, $args[1]);
break;
- case 'remove':
- case t('Remove'):
- db_query("UPDATE {i18n_node} SET trid = 0 WHERE nid=%d", $node->nid);
- drupal_set_message("The node has been removed from the translation set");
- drupal_goto("node/$node->nid/translation");
default:
$output .= translation_node_overview($node);
}
@@ -738,12 +733,22 @@ function translation_node_remove($node) {
'#title' => t('Remove from translation'),
'#description' => t('This will just unlink the node from this translation set.')
);
+ $form['remove']['node'] = array('#type' => 'value', '#value' => $node);
$form['remove']['submit'] = array('#type' => 'submit', '#value' => t('Remove'));
- $form['#action'] = url('node/'.$node->nid.'/translation/remove');
return $form;
}
/**
+ * Form submit. Remove from translation set without confirmation.
+ */
+function translation_node_remove_submit($form_id, $form_values) {
+ $node = $form_values['node'];
+ db_query("UPDATE {i18n_node} SET trid = 0 WHERE nid = %d", $node->nid);
+ drupal_set_message(t("The node has been removed from the translation set"));
+ drupal_goto("node/$node->nid/translation");
+}
+
+/**
* Form to select a translation from existing nodes
*/
function translation_node_select($node, $lang) {
@@ -893,32 +898,24 @@ function translation_get_node_type($nid) {
* This is the callback for taxonomy translations
*
* Gets the urls:
- * admin/content/taxonomy/i18n/term/xx
- * admin/content/taxonomy/i18n/term/new/xx
- * admin/content/taxonomy/vid/translation/op/trid
+ * admin/content/taxonomy/[vid]/translation/edit/[trid]
+ * admin/content/taxonomy/[vid]/translation/new
*/
-function translation_taxonomy_admin() {
+function translation_taxonomy_admin($op = NULL, $trid = NULL) {
$vid = arg(3);
- $op = $_POST['op'] ? $_POST['op'] : arg(5);
- $edit = $_POST['edit'];
-
+ $op = arg(5);
+ $trid = arg(6);
+ $output = '';
+
switch ($op) {
- case t('Save'):
case 'edit':
+ case 'new':
drupal_set_title(t('Edit term translations'));
- $output = drupal_get_form('translation_taxonomy_term_form', $vid, arg(6), $edit);
- break;
- case t('Submit'):
- drupal_set_title(t('Submit'));
- translation_taxonomy_term_save($edit);
- $output = translation_taxonomy_overview($vid);
- break;
- case 'delete':
- //print theme('page', node_delete($edit), t('Delete'));
+ $output .= drupal_get_form('translation_taxonomy_term_form', $vid, $trid);
break;
default:
- $output = translation_taxonomy_overview($vid);
+ $output .= translation_taxonomy_overview($vid);
}
return $output;
}
@@ -947,7 +944,7 @@ function translation_taxonomy_overview($vid) {
$thisrow = array();
foreach ($languages as $lang => $name) {
if (array_key_exists($lang, $terms)) {
- $thisrow[] = $terms[$lang]->name;
+ $thisrow[] = l($terms[$lang]->name, 'taxonomy/term/'.$terms[$lang]->tid);
}
else {
$thisrow[] = '--';
@@ -957,16 +954,16 @@ function translation_taxonomy_overview($vid) {
$rows[] = $thisrow;
}
$output .= theme('table', $header, $rows);
- $output .= l(t('new translation'), "admin/content/taxonomy/$vid/translation/edit/new");
+ $output .= l(t('new translation'), "admin/content/taxonomy/$vid/translation/new");
return $output;
}
/**
* Produces a vocabulary translation form
*/
-function translation_taxonomy_term_form($vid, $trid = NULL, $edit = array()) {
+function translation_taxonomy_term_form($vid, $trid = NULL) {
$languages = i18n_supported_languages();
- if ($trid == 'new') {
+ if (!$trid) {
$translations = array();
} else {
$form['trid'] = array('#type' => 'hidden', '#value' => $trid);
@@ -990,7 +987,7 @@ function translation_taxonomy_term_form($vid, $trid = NULL, $edit = array()) {
$form[$lang]['old'] = array('#type' => 'hidden', '#value' =>$current);
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
- $form['destination'] = array('#type' => 'hidden', '#value' => 'admin/content/taxonomy/'.arg(3).'/translation');
+ $form['#redirect'] = 'admin/content/taxonomy/'.$vid.'/translation';
return $form;
}