You are here

function theme_translation_overview_translation_link in Translation Overview 6.2

Same name and namespace in other branches
  1. 6 translation_overview.module \theme_translation_overview_translation_link()
2 theme calls to theme_translation_overview_translation_link()
translation_overview_help in ./translation_overview.module
Implementation of hook_help().
translation_overview_translation_link in ./translation_overview.module
Build a link to the translated node.

File

./translation_overview.module, line 305

Code

function theme_translation_overview_translation_link($state, $link = array(), $properties = array()) {

  // Merge in defaults.
  $properties += array(
    'priority' => TRANSLATION_OVERVIEW_NORMAL,
    'has_note' => FALSE,
    'published' => TRUE,
    'show_long' => TRUE,
  );
  $long = ' ';
  $link['options']['html'] = TRUE;
  $priorities = array(
    TRANSLATION_OVERVIEW_HIGH => array(
      'display' => t('High priority'),
      'css' => 'trov-priority-high',
    ),
    TRANSLATION_OVERVIEW_NORMAL => array(
      'display' => t('Normal'),
      'css' => 'trov-priority-normal',
    ),
    TRANSLATION_OVERVIEW_IGNORE => array(
      'display' => t('Ignored'),
      'css' => 'trov-priority-ignore',
    ),
  );
  $link_title = array();
  if (!empty($priorities[$properties['priority']]['display'])) {
    $link_title[] = $priorities[$properties['priority']]['display'];
  }
  if (empty($properties['published'])) {
    $link_title[] = t('unpublished');
  }
  switch ($state) {
    case 'original':
      $long = t('Original');
      $link_title[] = t('original');
      break;
    case 'current':
      $long = t('Complete');
      $link_title[] = t('completed translation');
      break;
    case 'outofdate':
      $long = t('Out-of-date');
      $link_title[] = t('out-of-date translation');
      break;
    case 'missing':
      $long = t('Untranslated');
      $link_title[] = t('untranslated content');
      break;
  }
  if (!empty($properties['has_note'])) {
    $link_title[] = t('with a note');
  }
  if (isset($link['path'])) {
    if (preg_match('/node\\/\\d*\\/edit/', $link['path'])) {
      $action = t('Click to edit it.');
    }
    else {
      if (preg_match('/node\\/add/', $link['path'])) {
        $action = t('Click to add it.');
      }
      else {
        if (preg_match('/node\\/\\d*/', $link['path'])) {
          $action = t('Click to view it.');
        }
      }
    }
    $link['options']['attributes'] = array(
      'title' => drupal_ucfirst(trim(implode(', ', $link_title))) . '. ' . $action,
    );
  }
  $class_note = $properties['has_note'] ? 'trov-has-note' : '';
  $class_state = $properties['published'] ? "trov-{$state}" : "trov-{$state}-unpublished";
  $class_priority = $priorities[$properties['priority']]['css'];
  $output = "<span class='trov-node {$class_note}'><span class='{$class_state} {$class_priority}'></span>";
  $output .= "</span>";
  if ($properties['show_long']) {
    $output .= "<span class='trov-description'>{$long}</span>";
  }
  if (!empty($link['path'])) {
    $output = l($output, $link['path'], $link['options']);
  }
  return $output;
}