For admin pages (especially), i think, it could be very useful to have some information (and some links maybe) about the translations available.
For examples:
- Translations Languages available
- Edit translations links
- Or Languages with view links.

This field handler togheter with the solution from #1330332: Entity translation: Views field language filter, i think, will complete the basic needs for admin pages for Entities with Entity translation.

Comments

vasike created an issue. See original summary.

vasike’s picture

Status: Active » Needs review
StatusFileSize
new8.01 KB

Here is a first patch on this.
It tries to cover the examples from the issue description.

Extra: it moves "_entity_translation_label" callback from admin to module file.
This looks like a helper function that should be available for other modules too.

joseph.olstad’s picture

not sure why the testbot said that because it applies on my cloned copy of entity_translation 7.x-1.x dev branch latest code

I just triggered retests

ciss’s picture

Status: Needs review » Needs work

Needs a reroll.

ciss’s picture

Status: Needs work » Needs review
StatusFileSize
new8.12 KB

Rerolled.

ciss’s picture

Status: Needs review » Needs work
+++ b/views/entity_translation.views.inc
@@ -222,6 +222,13 @@ function entity_translation_views_data_alter(&$data) {
+      $table['entity_translations'] = array(
+        'title' => t('Entity translations'),
+        'help' => t('Information and links for entity translations available.'),
+        'field' => array(
+          'handler' => 'entity_translation_handler_field_entity_translations',
+        ),
+      );

This overwrites the previous table definition.

ciss’s picture

  1. +++ b/views/entity_translation_handler_field_entity_translations.inc
    @@ -0,0 +1,147 @@
    +      '#options' => array(
    +        'no' => t('No link provided'),
    +        'view' => t('View link'),
    +        'edit' => t('Edit link'),
    +      ),
    

    I case of "edit", could we provide an optional fallback to "add"?

  2. +++ b/views/entity_translation_handler_field_entity_translations.inc
    @@ -0,0 +1,147 @@
    +            case 'language_native':
    +              $text = $languages[$langcode]->native;
    +              break;
    +            case 'language_name':
    +              $text = $languages[$langcode]->native;
    +              break;
    +            case 'language_code':
    +              $text = $languages[$langcode]->native;
    +              break;
    +          }
    

    Not much of a choice, is it? :D

  3. +++ b/views/entity_translation_handler_field_entity_translations.inc
    @@ -0,0 +1,147 @@
    +            $link_options = array(
    +              'language' => $languages[$langcode],
    +            );
    

    It might make sense to add a class here that indicates the language, so that the links can be themed properly. We can probably resuse the classes from an entity's translations overview.

  4. +++ b/views/entity_translation_handler_field_entity_translations.inc
    @@ -0,0 +1,147 @@
    +            $items[$langcode] = l($text, $path, $link_options);
    

    Can we do an access check here?

  5. +++ b/views/entity_translation_handler_field_entity_translations.inc
    @@ -0,0 +1,147 @@
    +      $output = !empty($this->options['no_translations_text']) ? $this->options['no_translations_text'] : t('No translations available');
    

    It might be desirable to completely suppress this text. Maybe we should allow ? Or initially set the default message and allow users to remove it?

ciss’s picture

Status: Needs work » Needs review
StatusFileSize
new10.64 KB
new8.08 KB

This is a rather heavy rewrite of the handler that addresses #6 and #7 (except for 4. and 5.). I'm not sure how I feel about the entity label option, to be honest, since it seems somewhat out of place and requires the title module to even work properly.