Skip to content

Commit

Permalink
Fixed an issue where the fields would not parse if language is set to…
Browse files Browse the repository at this point in the history
… something different than the node language.
  • Loading branch information
travist committed Sep 17, 2011
1 parent c940968 commit 3893954
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions mediafront.module
Expand Up @@ -569,7 +569,7 @@ function mediafront_views_pre_render($view) {
// Get the class of the first field.
$fields = array_keys($view->field);
$id = in_array('title', $fields) ? 'title' : (in_array('nid', $fields) ? 'nid' : array_shift($fields));
$class = 'views-field-' . drupal_clean_css_identifier($id);
$class = '.views-field-' . drupal_clean_css_identifier($id);
$view_id = '.view-' . $view->name . '.' . 'view-display-id-' . $view->current_display;
$js .= 'jQuery.media.fieldSelector = "' . $view_id . ' ' . $class . '";';
$js .= 'jQuery.media.playerId = "mediafront_' . $preset . '";';
Expand Down Expand Up @@ -702,27 +702,27 @@ function mediafront_add_media( &$additions, $file ) {
* Returns the field if it exists.
*/
function _mediafront_get_field( $node, $field_name, $index = -1 ) {
$lang = $node->language;
if( isset($node->{$field_name}) &&
is_array($node->{$field_name}) &&
isset($node->{$field_name}[$lang]) &&
is_array($node->{$field_name}[$lang]) &&
isset($node->{$field_name}[$lang][0]) ) {
if( $index >= 0 ) {
$field = (array)$node->{$field_name}[$lang][$index];
return $field;
}
else {
$fields = array();
foreach( $node->{$field_name}[$lang] as $index => $field ) {
$fields[$index] = (array)$field;
$langs = array($node->language, 'und');
foreach ($langs as $lang) {
if( isset($node->{$field_name}) &&
is_array($node->{$field_name}) &&
isset($node->{$field_name}[$lang]) &&
is_array($node->{$field_name}[$lang]) &&
isset($node->{$field_name}[$lang][0]) ) {
if( $index >= 0 ) {
$field = (array)$node->{$field_name}[$lang][$index];
return $field;
}
else {
$fields = array();
foreach( $node->{$field_name}[$lang] as $index => $field ) {
$fields[$index] = (array)$field;
}
return $fields;
}
return $fields;
}
}
else {
return null;
}
return null;
}

/**
Expand Down

0 comments on commit 3893954

Please sign in to comment.