theme.inc 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * @file
  4. * The functions.
  5. */
  6. /**
  7. * Theme function for the translation table.
  8. *
  9. * @ingroup themeable
  10. */
  11. function theme_translation_table($variables) {
  12. $form = $variables['form'];
  13. $rows = array();
  14. $header = $form['header']['#value'];
  15. $languages = $form['languages']['#value'];
  16. foreach (element_children($form['strings']) as $key) {
  17. // Build the table row.
  18. $row = array();
  19. $row['data'][] = array('data' => drupal_render($form['strings'][$key]['source']), 'class' => 'translation-source');
  20. foreach ($languages as $lang_code => $lang_name) {
  21. $row['data'][] = array('data' => drupal_render($form['strings'][$key][$lang_code]), 'class' => 'translation-'. $lang_code);
  22. };
  23. $location = explode(':', $form['strings'][$key]['location']['#value']);
  24. if (count($location) == 4) {
  25. switch ($location[1]) {
  26. case 'term':
  27. $row['data'][] = l(t('Edit source'), 'admin/content/taxonomy/edit/term/'. $location[1], array('attributes' => array('title' => t('Edit term (@property)', array('@property' => t($location[2]))))));
  28. break;
  29. case 'vocabulary':
  30. $row['data'][] = l(t('Edit source'), 'admin/content/taxonomy/edit/vocabulary/'. $location[1], array('attributes' => array('title' => t('Edit vocabulary (@property)', array('@property' => t($location[2]))))));
  31. break;
  32. case 'item':
  33. $row['data'][] = l(t('Edit source'), 'admin/build/menu/item/'. $location[1] .'/edit', array('attributes' => array('title' => t('Edit menu item (@property)', array('@property' => t($location[2]))))));
  34. break;
  35. case 'type':
  36. $node_types = node_type_get_names();
  37. $node_type = isset($node_types[$location[1]]) ? $node_types[$location[1]] : $location[1];
  38. $row['data'][] = l(t('Edit source'), 'admin/content/node-type/'. $location[1], array('attributes' => array('title' => t('Edit @node_type (@property)', array('@node_type' => $node_type, '@property' => t($location[2]))))));
  39. break;
  40. default:
  41. $row['data'][] = '';
  42. }
  43. }
  44. else {
  45. $row['data'][] = '';
  46. }
  47. $row['data'][] = l(t('Translate'), 'admin/config/regional/translate/edit/'. $key);
  48. $row['data'][] = l(t('Delete string'), 'admin/config/regional/translate/delete/'. $key);
  49. $rows[] = $row;
  50. }
  51. $output = theme('table', array(
  52. 'header' => $header,
  53. 'rows' => $rows,
  54. 'attributes' => array('id' => 'translation-table')
  55. ));
  56. if ($form['pager']['#markup']) {
  57. $output .= drupal_render($form['pager']);
  58. }
  59. $output .= drupal_render_children($form);
  60. drupal_add_css(drupal_get_path('module', 'translation_table') .'/css/translation-table-admin.css');
  61. return $output;
  62. }
  63. /**
  64. * Theme function for the basic filter form.
  65. *
  66. * @ingroup themeable
  67. */
  68. function theme_translation_table_filter($variables) {
  69. $form = $variables['form'];
  70. $output = '<div id="translation-table-filter">';
  71. foreach (element_children($form) as $key) {
  72. $attributes = drupal_attributes(array(
  73. 'id' => 'translation-table-'. str_replace('_', '-', $key) .'-filter',
  74. 'class' => 'translation-table-filter',
  75. ));
  76. $output .= "<div $attributes>";
  77. $output .= drupal_render($form[$key]);
  78. $output .= '</div>';
  79. }
  80. $output .= '</div>';
  81. return $output;
  82. }