There are cases where it could be useful to expose the entity translation table to views, especially if you create UI:s for translators.

The attached patch adds the entity translation table as a base table, provides handlers for showing a link to the translation overview page for each entity and showing the entity label.

There is also a relationship which makes it possible to join any entity table to the entity translation table.

This can live safely side by side with #1330332: Entity translation: Views field language filter since that probably is going into views.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fabsor’s picture

Here is an updated patch that adds the following:

* I added the possibility of using "Empty" for language filters, the column is never NULL, so I had to create a handler for that.
* I realized while developing a UI for translators that you need to be able to filter out everything that hasn't been translated yet. This is a bit complicated due to the structure of the entity translation table, but I managed to get it working with a subquery. This functionality is in the entity_translation_handler_filter_translation_exists.inc.

plach’s picture

Thanks a lot! Hope to be able to review this soon.

fabsor’s picture

There were some bugs with the boolean values when using them as filters. This patch should resolve that.

fabsor’s picture

Oops, forgot the actual views stuff.

plach’s picture

FileSize
4.8 KB

@fabsor:

Great patch! There were some coding standard issues and a small bug that I fixed myself (see below).

I created the "Views integration" component for the issue queue. I'd like to create a mantainers team (like the core one) whose components will focus on single sub systems to help me scale myself. If you are interested and willing to adhere to the best practices (rules!) described in http://drupal.org/node/363367, I'll be glad to give you commit access and make you the maintainer of the "Views integration" subsystem.

Please note the following excerpt from the link above ;)

If you've been granted limited commit access to maintain a certain part of the project only, then you will not commit any changes that affect other parts of the project.

See the current MAINTAINERS.txt file.

+++ b/views/entity_translation.views.inc
@@ -0,0 +1,227 @@
+          // We add our information here in the definition,
+          // so we can copy it later.

+++ b/views/entity_translation_handler_field_translate_link.inc
@@ -0,0 +1,96 @@
+    // We use the entity info here to avoid having to call entity_load()
+    // for all entities.

+++ b/views/entity_translation_handler_filter_language.inc
@@ -0,0 +1,27 @@
+ * Extends the locale language filter in order for it to work
+ * with the entity translation table structure.

Wrong comment wrapping (see http://drupal.org/coding-standards).

+++ b/views/entity_translation_handler_field_label.inc
@@ -0,0 +1,72 @@
+  function render(&$values) {

$values should not be passed by argument as per the parent method definition.

+++ b/views/entity_translation_handler_field_translate_link.inc
@@ -0,0 +1,96 @@
+  /**

Missing empty line here.

+++ b/views/entity_translation_handler_filter_entity_type.inc
@@ -0,0 +1,30 @@
+ * handler shows all available entity types
+ * that are enabled for entity translation as options.

Bogus PHP doc wrapping/text

+++ b/views/entity_translation_handler_relationship.inc
@@ -0,0 +1,32 @@
+    // use a short alias for the table.

Comments should start with a capital letter.

Component: Base system » Views integration
Status: Needs review » Needs work

The last submitted patch, et_views-1524210-5.patch, failed testing.

plach’s picture

Status: Needs work » Needs review
FileSize
22.65 KB
4.8 KB

Hm, in #5 I posted the interdiff instead of the full patch.

Status: Needs review » Needs work

The last submitted patch, et_views-1524210-6.patch, failed testing.

plach’s picture

Status: Needs work » Needs review
FileSize
22.45 KB

Let's try again. The interdiff should be the same as in #5 and #7.

fabsor’s picture

@plach This is awesome! Thanks for taking time to review and fix my stupid mistakes. The last submitted patch looks good.

This is really a critical part of NodeStream, which I maintain 50% of my time at NodeOne. I can definitely use time from there to ensure the quality of the views integration. I will be happy to help out as co-maintainer of the views component of this module.

plach’s picture

Status: Needs review » Reviewed & tested by the community

Welcome to the Entity Translation team! You are welcome to use your new superpowers, remember the changelog entry :)

Dreditor, if you are not already using it, will assist you in creating commit messages.

fabsor’s picture

Status: Reviewed & tested by the community » Fixed

Commited and done!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit d0b14b7 on master, et-permissions-1829630, factory, et-fc, revisions by fabsor:
    Issue #1524210 by fabsor, plach: Expose entity translation table to...

  • Commit d0b14b7 on master, et-permissions-1829630, factory, et-fc, revisions, workbench by fabsor:
    Issue #1524210 by fabsor, plach: Expose entity translation table to...