Index: contrib/select_translation/select_translation_filter_handler.inc =================================================================== --- contrib/select_translation/select_translation_filter_handler.inc (revision 570) +++ contrib/select_translation/select_translation_filter_handler.inc (working copy) @@ -7,7 +7,7 @@ $options = parent::option_definition(); $options['value']['default'] = 'default'; - + $options['fallback']['default'] = 1; return $options; } @@ -32,17 +32,22 @@ '#description' => t('If selection mode is set to "Choose language priorities", you can enter here a comma separated list of language codes. The filter will then return the node in the first available langauge - in that list ; and the original version if no match were found.

+ in that list.

The special value "current" will be replaced with the current language, "default" will be replaced witht the default language, and "original" with the original language of each node.

Example:
en,fr,current,default,original
This will return the version in english if available, if not in french, - if not in the current language, if not in the default language. - If none are available it will return the original version.'), + if not in the current language, if not in the default language.'), '#default_value' => !empty($this->options['priorities']) ? $this->options['priorities'] : '', ); + $form['fallback'] = array( + '#type' => 'checkbox', + '#title' => t('Fallback to original translation'), + '#description' => t('If you specify language priorities above and this option is checked, the view will fallback to displaying the original language if none of the other priorities are found.'), + '#default_value' => !empty($this->options['fallback']) ? $this->options['fallback'] : 1 + ); } function query() { @@ -50,15 +55,20 @@ $list = array(); if ($this->value == 'original') { $list = array('current'); + $list[] = 'original'; } else if ($this->value == 'default') { $list = array('current', 'default'); + $list[] = 'original'; } else if (!empty($this->options['priorities'])) { $list = explode(',', $this->options['priorities']); foreach ($list as $i => $v) { $list[$i] = strtolower(trim($v)); } + if ($this->options['fallback']) { + $list[] = 'original'; + } } - $list[] = 'original'; + foreach ($list as $i => $v) { if ($list[$i] == 'current') { $list[$i] = '***CURRENT_LANGUAGE***'; @@ -71,7 +81,12 @@ // Now build the query. For every option, we need to exclude // the previous ones to ensure only one node gets selected in the end. $alias = $this->query->ensure_table('node'); - $query = "node.tnid = 0"; + if (in_array('original', $list)) { + $query = "node.tnid = 0"; + } + else { + $exclude[] = 'lmfh_node.tnid = lmfh_node.nid'; + } $exclude = array(); foreach ($list as $i => $v) { if ($v == 'original') { @@ -91,7 +106,8 @@ } $exclude[] = $exc; - $query = $query."\n OR ($add)"; + $query .= $query ? "\n OR " : ''; + $query .= " ($add) "; } $this->query->add_where($this->options['group'], $query);