Index: node_images.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/node_images/node_images.module,v retrieving revision 1.11.2.13 diff -u -r1.11.2.13 node_images.module --- node_images.module 3 Nov 2008 14:35:51 -0000 1.11.2.13 +++ node_images.module 17 Jan 2009 12:46:19 -0000 @@ -1,5 +1,5 @@ Internationalization package).', array('@i18n' => url('http://drupal.org/project/i18n'))); + } + $output = '
'.$output.'
'; + break; + } + return $output; +} + +/** * Implementation of hook_perm(). */ function node_images_perm() { @@ -171,10 +199,11 @@ case 'delete': // Delete image and thumbnail files - $sql = db_query('SELECT filepath, thumbpath FROM {node_images} WHERE nid=%d', $node->nid); + $sql = db_query('SELECT id, filepath, thumbpath FROM {node_images} WHERE nid=%d', $node->nid); while ($r = db_fetch_object($sql)) { file_delete($r->filepath); file_delete($r->thumbpath); + module_invoke('i18nstrings', 'remove_string', _node_images_build_i18nstrings_context($r)); } // Delete all images associated with the node db_query('DELETE FROM {node_images} WHERE nid=%d', $node->nid); @@ -301,8 +330,8 @@ $size = $file->thumbsize; } else { - $name = mime_header_encode($file->filename); - $size = $file->filesize; + $name = mime_header_encode($file->filename); + $size = $file->filesize; } $type = mime_header_encode($file->filemime); return array( @@ -317,6 +346,16 @@ } } +/** + * Implementation of hook_locale(). + */ +function node_images_locale($op = 'groups', $group = NULL) { + switch ($op) { + case 'groups': + return array('node_images' => t('Node images')); + } +} + /************************************************************ * Upload functions @@ -751,10 +790,11 @@ if ($teaser === FALSE && $page === FALSE) return; // load node images for the current node + $nid = ($node->tnid && $node->tnid != $node->nid ? $node->tnid : $node->nid); $images = array(); $where = 'WHERE nid=%d'; if ($teaser || $page) $where .= ' AND status=1 AND list=1'; - $sql = db_query('SELECT * FROM {node_images} ' .$where. ' ORDER BY weight', $node->nid); + $sql = db_query('SELECT * FROM {node_images} ' .$where. ' ORDER BY weight', $nid); while ($r = db_fetch_object($sql)) { $images[$r->id] = $r; } @@ -912,4 +952,31 @@ 'file_size' => variable_get('node_images_file_limit', 1) * 1024 * 1024, 'resolution' => variable_get('node_images_large_resolution', 0), ); +} + +function _node_images_is_translation_source($node) { + global $language; + if ($node->tnid) return $node->nid == $node->tnid; + + if (module_exists('i18n')) { + $current = i18n_get_lang(); + $default = i18n_default_language(); + return $current == $default; + } + + return ($language->language == language_default('language')); + + $lang = ($node->language ? $node->language : language_default('language')); + return $lang == $language->language; +} + +function _node_images_translate(&$file, $update = FALSE) { + global $language; + + //$current_language = $language->language; + //$default_language = language_default('language'); + $context = 'node_images:node_image:'.$file->id.':description'; + if (module_exists('i18nstrings') && function_exists('tt')) { + $file->description = tt($context, $file->description, NULL, $update); + } } \ No newline at end of file Index: node_images.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/node_images/node_images.pages.inc,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 node_images.pages.inc --- node_images.pages.inc 3 Nov 2008 13:41:25 -0000 1.1.2.5 +++ node_images.pages.inc 17 Jan 2009 00:19:18 -0000 @@ -1,5 +1,5 @@ TRUE, ); - if (_node_images_access('create', $node)) { + if (_node_images_access('create', $node) && $is_translation_source) { $form['new'] = array( '#type' => 'fieldset', '#title' => t('Upload a new image'), @@ -115,10 +116,10 @@ // set an appropriate value for delta in weight selectbox $delta = db_result(db_query('SELECT MAX(ABS(weight)) FROM {node_images} WHERE nid=%d', $node->nid)); $delta += count($node_images); - $authors = array(); $submit = FALSE; - + $form['node_images']['is_translation_source'] = array('#type' => 'value', '#value' => $is_translation_source); + foreach ($node_images as $key => $file) { $file = (object)$file; $update_access = _node_images_access('update', $node, $file); @@ -128,22 +129,28 @@ if (!isset($authors[$file->uid])) { $authors[$file->uid] = user_load(array('uid' => $file->uid)); } - $author = $authors[$file->uid]; - $url = file_create_url($file->filepath); $thumb = file_create_url($file->thumbpath); - $description = file_create_url($file->filepath); - $description = "". check_plain($description) .""; $row = array(); $row['id'] = array('#type' => 'value', '#value' => $file->id); - $row['delete'] = array('#type' => 'checkbox', '#attributes' => ($delete_access ? array() : array('disabled' => 'true'))); - $row['list'] = array('#type' => 'checkbox', '#default_value' => $file->list, '#attributes' => ($update_access ? array() : array('disabled' => 'true'))); $row['thumbnail'] = array('#value' => '