? image-d6upgrade-181809-30.patch ? image-d6upgrade-181809-31.patch Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/README.txt,v retrieving revision 1.6 diff -u -p -r1.6 README.txt --- README.txt 18 Jul 2007 17:04:02 -0000 1.6 +++ README.txt 13 Dec 2007 09:59:19 -0000 @@ -7,4 +7,4 @@ other nodes, or used on their own to dis diagrams. Author: -James Walker +James Walker Index: image.imagemagick.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/image.imagemagick.inc,v retrieving revision 1.19 diff -u -p -r1.19 image.imagemagick.inc --- image.imagemagick.inc 28 Oct 2007 19:55:05 -0000 1.19 +++ image.imagemagick.inc 13 Dec 2007 09:59:19 -0000 @@ -13,7 +13,7 @@ function image_imagemagick_info() { */ function image_imagemagick_settings() { $form['#after_build'] = array('_image_imagemagick_build_version'); - + $form['imagemagick_binary'] = array( '#type' => 'fieldset', '#title' => t('ImageMagick Binary'), Index: image.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/image.info,v retrieving revision 1.4 diff -u -p -r1.4 image.info --- image.info 18 Jul 2007 17:04:02 -0000 1.4 +++ image.info 13 Dec 2007 09:59:19 -0000 @@ -2,3 +2,4 @@ name = Image description = Allows uploading, resizing and viewing of images. package = Image +core = 6.x Index: image.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/image.install,v retrieving revision 1.14 diff -u -p -r1.14 image.install --- image.install 10 Oct 2007 04:10:07 -0000 1.14 +++ image.install 13 Dec 2007 09:59:20 -0000 @@ -2,37 +2,48 @@ // $Id: image.install,v 1.14 2007/10/10 04:10:07 drewish Exp $ /** - * Installing and updating image.module. + * Implementation of hook_schema(). + */ +function image_schema() { + $schema['image'] = array( + 'description' => t('Stores image files information.'), + 'fields' => array( + 'nid' => array( + 'description' => t('Primary Key: The {node}.nid of the image node.'), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'fid' => array( + 'description' => t('Index: The {files}.fid of the image file.'), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'image_size' => array( + 'description' => t('Primary Key: The {files}.filename of the image file. For image module this indicates the file size.'), + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + ), + ), + ); + return $schema; +} + +/** + * Implementation of hook_install(). */ function image_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {image} ( - `nid` INTEGER UNSIGNED NOT NULL, - `fid` INTEGER UNSIGNED NOT NULL, - `image_size` VARCHAR(32) NOT NULL, - PRIMARY KEY (`nid`, `image_size`), - INDEX image_fid(`fid`) - ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); - break; - case 'pgsql': - db_query("CREATE TABLE {image} ( - nid int_unsigned NOT NULL, - fid int_unsigned NOT NULL, - image_size VARCHAR(32) NOT NULL, - PRIMARY KEY (nid, image_size) - ); - CREATE INDEX {image_fid} on {image}(fid);"); - break; - } + drupal_install_schema('image'); } /** * Implementation of hook_uninstall(). */ function image_uninstall() { - db_query('DROP TABLE {image}'); + drupal_uninstall_schema('image'); variable_del('image_max_upload_size'); variable_del('image_updated'); @@ -41,34 +52,59 @@ function image_uninstall() { } /** - * Update 4.5 to 4.6 or later. + * Implementation of hook_requirements(). */ -function image_update_1() { - if (db_table_exists('image')) { - if ($result = db_query("SELECT * FROM {image}")) { - $fields = array('thumb_path' => 'thumbnail', - 'preview_path' => 'preview', - 'image_path' => '_original'); - - while ($old_image = db_fetch_object($result)) { - foreach ($fields as $old => $new) { - $old_file = ''; - if (file_exists($old_image->$old)) { - $old_file = $old_image->$old; - } - else { - $old_file = file_create_path($old_image->$old); - } - if ($old_file && $old_image->$old != '' && db_num_rows(db_query("SELECT fid FROM {files} WHERE nid=%d and filename='%s'", $old_image->nid, $new)) == 0) { - _image_insert($old_image, $new, $old_file); - } - } - } +function image_requirements($phase) { + $requirements = array(); + + if ($phase == 'runtime') { + // Make sure we've got a working toolkit + if ($toolkit = image_get_toolkit()) { + $requirements['image_toolkit'] = array( + 'value' => t('The %toolkit-name toolkit is installed', array('%toolkit-name' => $toolkit)), + 'severity' => REQUIREMENT_OK, + ); + } + else { + $requirements['image_toolkit'] = array( + 'value' => t('Not installed'), + 'severity' => REQUIREMENT_ERROR, + 'description' => t('No image toolkit is currently enabled. Without one the image module will not be able to resize your images. You can select one from the image toolkit settings page.', array('!link' => url('admin/settings/image-toolkit'))), + ); } + $requirements['image_toolkit']['title'] = t('Image toolkit'); + + + // File paths + $image_path = file_create_path(rtrim(variable_get('image_default_path', 'images'))); + $temp_path = rtrim($image_path, '/') .'/temp'; + if (!file_check_directory($image_path, FILE_CREATE_DIRECTORY)) { + $requirements['image_dirs'] = array( + 'value' => t('Missing directory'), + 'severity' => REQUIREMENT_ERROR, + 'description' => t("The image module's image directory %image-dir is missing.", array('%image-dir' => $image_path)), + ); + } + else if (!file_check_directory($temp_path, FILE_CREATE_DIRECTORY)) { + $requirements['image_dirs'] = array( + 'value' => t('Missing temp directory'), + 'severity' => REQUIREMENT_ERROR, + 'description' => t("The image module's temp directory %temp-dir is missing.", array('%temp-dir' => $temp_path)), + ); + } + else { + $requirements['image_dirs'] = array( + 'value' => t('Exists (%path)', array('%path' => $image_path)), + 'severity' => REQUIREMENT_OK, + ); + } + $requirements['image_dirs']['title'] = t('Image module directories'); } - return array(); + + return $requirements; } + /** * Upgrade to the new image_sizes variable format. */ Index: image.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/image.module,v retrieving revision 1.259 diff -u -p -r1.259 image.module --- image.module 13 Nov 2007 03:21:53 -0000 1.259 +++ image.module 13 Dec 2007 09:59:22 -0000 @@ -16,8 +16,8 @@ if (module_exists('views')) { /** * Implementation of hook_help */ -function image_help($section) { - switch ($section) { +function image_help($path, $arg) { + switch ($path) { case 'admin/help#image': $output = '

'. t('The image module is used to create and administer images for your site. Each image is stored as a post, with thumbnails of the original generated automatically. There are two default thumbnail sizes, thumbnail and preview. The thumbnail size is shown as the preview for image posts and when browsing image galleries. The preview is the default size when first displaying an image node.') .'

'; $output .= '

'. t('Image administration allows the image directory and the image sizes to be set.

@@ -34,6 +34,31 @@ Image galleries are used to organize and } /** + * Implementation of hook_theme(). + */ +function image_theme() { + return array( + 'image_settings_sizes_form' => array( + 'arguments' => array('form' => NULL), + ), + 'image_teaser' => array( + 'arguments' => array('node' => NULL, 'size' => IMAGE_THUMBNAIL), + ), + 'image_body' => array( + 'arguments' => array('node' => NULL, 'size' => IMAGE_PREVIEW), + ), + 'image_display' => array( + 'arguments' => array( + 'node' => NULL, + 'label' => NULL, + 'url' => NULL, + 'attributes' => NULL, + ), + ), + ); +} + +/** * Implementation of hook_node_info */ function image_node_info() { @@ -79,7 +104,7 @@ function image_access($op, $node) { function image_admin_settings() { _image_check_settings(); - $form['#submit'] = array('image_settings_sizes_submit' => array()); + $form['#submit'][] = 'image_settings_sizes_submit'; $form['image_updated'] = array( '#type' => 'hidden', '#value' => variable_get('image_updated', time()), @@ -141,8 +166,11 @@ function image_admin_settings() { '#size' => 25, '#maxlength' => 32, ); + + // For required sizes, set the value and disable the field. if (_image_is_required_size($key)) { - $form['image_sizes'][$key]['label']['#attributes'] = array('disabled' => 'disabled'); + $form['image_sizes'][$key]['label']['#disabled'] = TRUE; + $form['image_sizes'][$key]['label']['#value'] = $size['label']; $form['image_sizes'][$key]['label']['#required'] = TRUE; } $form['image_sizes'][$key]['operation'] = array( @@ -175,7 +203,7 @@ function image_admin_settings() { /** * Check that the sizes provided have the required amount of information. */ -function image_settings_sizes_validate(&$form) { +function image_settings_sizes_validate($form, &$form_state) { foreach (element_children($form) as $key) { // If there's a label they must provide at either a height or width. if ($key != IMAGE_ORIGINAL && !empty($form[$key]['label']['#value'])) { @@ -192,13 +220,13 @@ function image_settings_sizes_validate(& * * Remove deleted sizes, and use the label as indexes for new sizes. */ -function image_settings_sizes_submit($form_id, &$form_values) { +function image_settings_sizes_submit($form, &$form_state) { $old_sizes = image_get_sizes(); // If the size's operation, or dimensions change we need to rebuild. $rebuild = FALSE; - foreach ($form_values['image_sizes'] as $key => $size) { + foreach ($form_state['values']['image_sizes'] as $key => $size) { // Changed to the original setting only affect new images and they // shouldn't be able to add or remove it. if ($key == IMAGE_ORIGINAL) { @@ -207,25 +235,25 @@ function image_settings_sizes_submit($fo // Remove sizes without labels. if (empty($size['label'])) { - unset($form_values['image_sizes'][$key]); + unset($form_state['values']['image_sizes'][$key]); } // Check if only one is set, indicating an addition or removal. - if (isset($form_values['image_sizes'][$key]) ^ isset($old_sizes[$key])) { + if (isset($form_state['values']['image_sizes'][$key]) ^ isset($old_sizes[$key])) { $rebuild |= TRUE; // When adding a new size, we need to assign a key. - if (isset($form_values['image_sizes'][$key])) { - unset($form_values['image_sizes'][$key]); + if (isset($form_state['values']['image_sizes'][$key])) { + unset($form_state['values']['image_sizes'][$key]); $new_key = drupal_strtolower(drupal_substr($size['label'], 0, 32)); - $form_values['image_sizes'][$new_key] = $size; + $form_state['values']['image_sizes'][$new_key] = $size; } } // Check for changes. - else if (isset($form_values['image_sizes'][$key]) && isset($old_sizes[$key])) { + else if (isset($form_state['values']['image_sizes'][$key]) && isset($old_sizes[$key])) { // Did the operation, height or width change? foreach (array('operation', 'height', 'width') as $field) { - $rebuild |= ($form_values['image_sizes'][$key][$field] != $old_sizes[$key][$field]); + $rebuild |= ($form_state['values']['image_sizes'][$key][$field] != $old_sizes[$key][$field]); } } } @@ -234,10 +262,8 @@ function image_settings_sizes_submit($fo // derivative images are rebuilt. if ($rebuild) { drupal_set_message(t('Changes to the images sizes mean that the derivative images will need to be regenerated.')); - $form_values['image_updated'] = time(); + $form_state['values']['image_updated'] = time(); } - - return system_settings_form_submit($form_id, $form_values); } function theme_image_settings_sizes_form(&$form) { @@ -251,7 +277,7 @@ function theme_image_settings_sizes_form $row[] = drupal_render($form[$key]['link']); $rows[] = $row; } - $output .= theme('table', $header, $rows); + $output = theme('table', $header, $rows); $output .= drupal_render($form); return $output; @@ -260,32 +286,23 @@ function theme_image_settings_sizes_form /** * Implementation of hook_menu */ -function image_menu($may_cache) { +function image_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'node/add/image', - 'title' => t('Image'), - 'access' => user_access('create images'), - ); - $items[] = array( - 'path' => 'image/view', - 'title' => t('image'), - 'access' => user_access('access content'), - 'type' => MENU_CALLBACK, - 'callback' => 'image_fetch', - ); - $items[] = array( - 'path' => 'admin/settings/image', - 'title' => t('Image'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('image_admin_settings'), - 'access' => user_access('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, - 'description' => t('Image module settings.'), - ); - } + $items['image/view'] = array( + 'title' => 'image', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + 'page callback' => 'image_fetch', + ); + $items['admin/settings/image'] = array( + 'title' => 'Image', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + 'description' => 'Image module settings.', + ); return $items; } @@ -328,13 +345,13 @@ function image_operations_rebuild($nids) } /** - * Implementation of hook_prepare(). + * TODO: document me... */ -function image_prepare(&$node, $field_name = NULL) { +function image_node_form_submit($form, &$form_state) { // We need to be aware that a user may try to edit multiple image nodes at // once. By using the $nid variable each node's files can be stored separately // in the session. - $nid = ($node->nid) ? $node->nid : 'new_node'; + $nid = $form_state['values']['nid'] ? $form_state['values']['nid'] : 'new_node'; // When you enter the edit view the first time we need to clear our files in // session for this node. This is so if you upload a file, then decide you // don't want it and reload the form (without posting), the files will be @@ -342,26 +359,15 @@ function image_prepare(&$node, $field_na if (count($_POST) == 0) { unset($_SESSION['image_new_files'][$nid]); } + + // Validators for file_save_upload(). + $validators = array( + 'file_validate_is_image' => array(), + ); - if (is_null($field_name)) { - $field_name = 'image'; - } - - if ($file = file_check_upload($field_name)) { - // Ensure the file is an image. - $image_info = image_get_info($file->filepath); - if (!$image_info || empty($image_info['extension'])) { - form_set_error($field_name, t('Uploaded file is not a valid image. Only JPG, PNG and GIF files are allowed.')); - return; - } - - // Save the file to the temp directory. - $file = file_save_upload($field_name, _image_filename($file->filename, IMAGE_ORIGINAL, TRUE)); - if (!$file) { - return; - } - + if ($file = file_save_upload('image', $validators)) { // Resize the original. + $image_info = image_get_info($file->filepath); $aspect_ratio = $image_info['height'] / $image_info['width']; $original_size = image_get_sizes(IMAGE_ORIGINAL, $aspect_ratio); if (!empty($original_size['width']) && !empty($original_size['height'])) { @@ -375,26 +381,26 @@ function image_prepare(&$node, $field_na // Check the file size limit. if ($file->filesize > variable_get('image_max_upload_size', 800) * 1024) { - form_set_error($field_name, t('The image you uploaded was too big. You are only allowed upload files less than %max_size but your file was %file_size.', array('%max_size' => format_size(variable_get('image_max_upload_size', 800) * 1024), '%file_size' => format_size($file->filesize)))); + form_set_error('image', t('The image you uploaded was too big. You are only allowed upload files less than %max_size but your file was %file_size.', array('%max_size' => format_size(variable_get('image_max_upload_size', 800) * 1024), '%file_size' => format_size($file->filesize)))); file_delete($file->filepath); return; } // We're good to go. - $node->images[IMAGE_ORIGINAL] = $file->filepath; - $node->rebuild_images = FALSE; - $node->new_file = TRUE; + $form_state['values']['images'][IMAGE_ORIGINAL] = $file->filepath; + $form_state['values']['rebuild_images'] = FALSE; + $form_state['values']['new_file'] = TRUE; // Call hook to allow other modules to modify the original image. - module_invoke_all('image_alter', $node, $file->filepath, IMAGE_ORIGINAL); - _image_build_derivatives($node, TRUE); + module_invoke_all('image_alter', $form_state['values'], $file->filepath, IMAGE_ORIGINAL); + $form_state['values']['images'] = _image_build_derivatives((object) $form_state['values'], TRUE); // Store the new file into the session. - $_SESSION['image_new_files'][$nid] = $node->images; + $_SESSION['image_new_files'][$nid] = $form_state['values']['images']; } // Reload new files uploaded in a previous preview. else if (isset($_SESSION['image_new_files'][$nid])) { - $node->images = $_SESSION['image_new_files'][$nid]; + $form_state['values']['images'] = $_SESSION['image_new_files'][$nid]; } } @@ -437,7 +443,7 @@ function image_link($type, $node, $main $links = array(); if ($type == 'node' && $node->type == 'image' && !$main) { - $request = ($_GET['size']) ? $_GET['size'] : IMAGE_PREVIEW; + $request = isset($_GET['size']) ? $_GET['size'] : IMAGE_PREVIEW; foreach (image_get_sizes() as $key => $size) { if ($size['link']) { // For smaller images some derivative images may not have been created. @@ -487,12 +493,12 @@ function image_block($op = 'list', $delt case 0: $images = image_get_latest(); $block['subject'] = t('Latest image'); - $block['content'] = l(image_display($images[0], IMAGE_THUMBNAIL), 'node/'. $images[0]->nid, array(), NULL, NULL, FALSE, TRUE); + $block['content'] = l(image_display($images[0], IMAGE_THUMBNAIL), 'node/'. $images[0]->nid, array('html' => TRUE)); break; case 1: $images = image_get_random(); $block['subject'] = t('Random image'); - $block['content'] = l(image_display($images[0], IMAGE_THUMBNAIL), 'node/'. $images[0]->nid, array(), NULL, NULL, FALSE, TRUE); + $block['content'] = l(image_display($images[0], IMAGE_THUMBNAIL), 'node/'. $images[0]->nid, array('html' => TRUE)); break; } } @@ -500,9 +506,9 @@ function image_block($op = 'list', $delt } } -function image_form_add_thumbnail($form, $form_values) { - if ($form_values['images']['thumbnail']) { - $node = (object)($form_values); +function image_form_add_thumbnail($form, &$form_state) { + if ($form_state['values']['images'][IMAGE_THUMBNAIL]) { + $node = (object)($form_state['values']); $form['#title'] = t('Thumbnail'); $form['#value'] = image_display($node, IMAGE_THUMBNAIL); } @@ -517,6 +523,8 @@ function image_form(&$node, &$param) { $type = node_get_types('type', $node); + $form['#submit'][] = 'image_node_form_submit'; + $form['title'] = array( '#type' => 'textfield', '#title' => check_plain($type->title_label), @@ -530,7 +538,7 @@ function image_form(&$node, &$param) { foreach (image_get_sizes() as $key => $size) { $form['images'][$key] = array( '#type' => 'value', - '#value' => $node->images[$key] + '#value' => isset($node->images[$key]) ? $node->images[$key] : '', ); } @@ -540,6 +548,10 @@ function image_form(&$node, &$param) { '#after_build' => array('image_form_add_thumbnail'), ); + $form['new_file'] = array( + '#type' => 'value', + '#default_value' => isset($node->new_file) ? $node->new_file : FALSE, + ); $form['rebuild_images'] = array( '#type' => 'checkbox', '#title' => t('Rebuild derivative images.'), @@ -576,6 +588,7 @@ function image_validate($node) { } function image_submit($node) { +dsm("image_submit..."); $nid = ($node->nid) ? $node->nid : 'new_node'; if (isset($_SESSION['image_new_files'][$nid])) { $node->new_file = TRUE; @@ -608,6 +621,7 @@ function image_view($node, $teaser = 0, '#value' => theme($teaser ? 'image_teaser' : 'image_body', $node, $size), '#weight' => 0, ); + return $node; } @@ -664,7 +678,7 @@ function image_load(&$node) { // Correct any problems with the derivative images. if ($node->rebuild_images) { image_update($node); - watchdog('image', t('Derivative images were regenerated for %title.', array('%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); + watchdog('image', 'Derivative images were regenerated for %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); } } @@ -736,7 +750,7 @@ function image_update(&$node) { db_query("DELETE FROM {image} WHERE fid = %d", $file->fid); } - _image_build_derivatives($node, FALSE); + $node->images = _image_build_derivatives($node, FALSE); // Display a message to the user if they're be able to modify the node // (this might have been called as part of a rebuild by a visitor). @@ -815,8 +829,8 @@ function image_fetch($nid = 0, $size = I /** * Theme a teaser */ -function theme_image_teaser($node) { - return l(image_display($node, IMAGE_THUMBNAIL), 'node/'. $node->nid, array(), NULL, NULL, TRUE, TRUE); +function theme_image_teaser($node, $size) { + return l(image_display($node, IMAGE_THUMBNAIL), 'node/'. $node->nid, array('html' => TRUE)); } /** @@ -927,22 +941,27 @@ function image_get_derivative_sizes($ima /** * Generate image derivatives. + * + * @param $node + * The node. + * @param $temp + * Boolean indicating if the derivatives should be saved to the temp + * directory. + * @return + * New array of images for the node. */ -function _image_build_derivatives(&$node, $temp = FALSE) { - // sanity check: - if (!_image_check_settings()) { - return FALSE; - } +function _image_build_derivatives($node, $temp = FALSE) { $original_path = file_create_path($node->images[IMAGE_ORIGINAL]); - + // Figure out which sizes we need to generate. $all_sizes = image_get_sizes(); $needed_sizes = image_get_derivative_sizes($original_path); $unneeded_sizes = array_diff(array_keys($all_sizes), array_keys($needed_sizes)); // Images that don't need a derivative image get set to the original. + $images[IMAGE_ORIGINAL] = $original_path; foreach ($unneeded_sizes as $key) { - $node->images[$key] = $original_path; + $images[$key] = $original_path; } // Resize for the necessary sizes. @@ -958,16 +977,7 @@ function _image_build_derivatives(&$node break; case 'scale_crop': - // This is based on Drupal 6's image_scale_and_crop(). Scales the - // image so that the image's smaller dimension matches the - // requested size and the crops any overlap on the image's larger - // dimension. - $scale = max($size['width'] / $image_info['width'], $size['height'] / $image_info['height']); - $x = round(($image_info['width'] * $scale - $size['width']) / 2); - $y = round(($image_info['height'] * $scale - $size['height']) / 2); - if (image_resize($original_path, $destination, $image_info['width'] * $scale, $image_info['height'] * $scale)) { - $status = image_crop($destination, $destination, $x, $y, $size['width'], $size['height']); - } + $status = image_scale_and_crop($destination, $destination, $size['width'], $size['height']); break; } @@ -975,9 +985,11 @@ function _image_build_derivatives(&$node drupal_set_message(t('Unable to create scaled %label image', array('%label' => $size['label'])), 'error'); return FALSE; } - $node->images[$key] = $destination; + $images[$key] = $destination; module_invoke_all('image_alter', $node, $destination, $key); } + + return $images; } /** @@ -1088,11 +1100,22 @@ function _image_insert(&$node, $size, $i $node->images[$size] = $image_path; $image_info = image_get_info($image_path); - $fid = db_next_id('{files}_fid'); - db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', '%s')", - $fid, $node->nid, $size, $image_path, $image_info['mime_type'], $image_info['file_size']); - db_query("INSERT INTO {image} (nid, image_size, fid) VALUES (%d, '%s', %d)", - $node->nid, $size, $fid); + $file = array( + 'uid' => $node->uid, + 'filename' => $size, + 'filepath' => $image_path, + 'filemime' => $image_info['mime_type'], + 'filesize' => $image_info['file_size'], + 'status' => FILE_STATUS_PERMANENT, + 'timestamp' => time(), + ); + drupal_write_record('files', $file); + $image = array( + 'fid' => $file['fid'], + 'nid' => $node->nid, + 'image_size' => $size, + ); + drupal_write_record('image', $image); } } @@ -1158,7 +1181,7 @@ function image_create_node_from($filepat $node->new_file = TRUE; $node->images[IMAGE_ORIGINAL] = $filepath; - _image_build_derivatives($node, TRUE); + $node->images = _image_build_derivatives($node, TRUE); // Save the node. $node = node_submit($node); Index: views.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/views.inc,v retrieving revision 1.4 diff -u -p -r1.4 views.inc --- views.inc 27 Aug 2007 22:50:39 -0000 1.4 +++ views.inc 13 Dec 2007 09:59:22 -0000 @@ -99,7 +99,7 @@ function image_views_handler_image_img($ */ function image_views_handler_image_img_link($fieldinfo, $fielddata, $value, $data) { $node = node_load($data->nid); - return l(image_display($node, $fielddata['options']), "node/{$node->nid}", array(), NULL, NULL, FALSE, TRUE); + return l(image_display($node, $fielddata['options']), "node/{$node->nid}", array('html' => TRUE)); } /** Index: contrib/image_attach/image_attach.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach.info,v retrieving revision 1.3 diff -u -p -r1.3 image_attach.info --- contrib/image_attach/image_attach.info 18 Jul 2007 17:04:24 -0000 1.3 +++ contrib/image_attach/image_attach.info 13 Dec 2007 09:59:22 -0000 @@ -2,4 +2,5 @@ name = Image Attach description = Allows easy attaching of image nodes to other content types. package = Image -dependencies = image \ No newline at end of file +dependencies[] = image +core = 6.x \ No newline at end of file Index: contrib/image_attach/image_attach.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach.install,v retrieving revision 1.11 diff -u -p -r1.11 image_attach.install --- contrib/image_attach/image_attach.install 18 Nov 2007 21:28:46 -0000 1.11 +++ contrib/image_attach/image_attach.install 13 Dec 2007 09:59:22 -0000 @@ -1,31 +1,42 @@ t('Stores the image/node relationship.'), + 'fields' => array( + 'nid' => array( + 'description' => t('Primary Key: The {node}.nid of the node.'), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'iid' => array( + 'description' => t('TODO'), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + ); + return $schema; +} - case 'pgsql': - db_query("CREATE TABLE {image_attach} ( - nid integer NOT NULL default '0', - iid integer NOT NULL default '0', - PRIMARY KEY (nid) - )"); - db_query("CREATE INDEX {image_attach}_iid_idx ON {image_attach}(iid)"); - break; - } +/** + * Implementation of hook_install(). + */ +function image_attach_install() { + drupal_install_schema('image_attach'); } +/** + * Implementation of hook_uninstall(). + */ function image_attach_uninstall() { - db_query('DROP TABLE {image_attach}'); + drupal_uninstall_schema('image_attach'); variable_del('image_attach_existing'); variable_del('image_attach_block_0_size'); } @@ -56,11 +67,11 @@ function image_attach_update_2() { switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': - $ret[] = update_sql("DELETE FROM {image_attach} USING {image_attach} LEFT JOIN {node} n ON {image_attach}.iid = n.nid WHERE n.nid IS NULL OR n.type != 'image'"); + $ret[] = update_sql("DELETE FROM {image_attach} USING {image_attach} LEFT JOIN {node} n ON {image_attach}.iid = n.nid WHERE n.nid IS NULL OR n.type <> 'image'"); break; case 'pgsql': - $ret[] = update_sql("DELETE FROM {image_attach} USING {node} n WHERE {image_attach}.iid = n.nid AND (n.nid IS NULL OR n.type != 'image')"); + $ret[] = update_sql("DELETE FROM {image_attach} USING {node} n WHERE {image_attach}.iid = n.nid AND (n.nid IS NULL OR n.type <> 'image')"); break; } return $ret; Index: contrib/image_attach/image_attach.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach.module,v retrieving revision 1.32 diff -u -p -r1.32 image_attach.module --- contrib/image_attach/image_attach.module 18 Nov 2007 21:28:46 -0000 1.32 +++ contrib/image_attach/image_attach.module 13 Dec 2007 09:59:23 -0000 @@ -10,8 +10,8 @@ define('IMAGE_ATTACH_HIDDEN', 'hidden'); /** * Implementation of hook_help(). */ -function image_attach_help($section) { - switch ($section) { +function image_attach_help($path, $arg) { + switch ($path) { case 'admin/settings/modules#description': return t('Allows easy attaching of image nodes to other content types.'); } @@ -20,27 +20,23 @@ function image_attach_help($section) { /** * Implementation of hook_menu() */ -function image_attach_menu($may_cache) { +function image_attach_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'image_attach', - 'title' => t('Image Attachment View'), - 'callback' => 'image_attach_view_image', - 'access' => user_access('access content'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'admin/settings/image_attach', - 'title' => t('Image attach'), - 'description' => t('Enable image attach for content'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('image_attach_admin_settings'), - 'access' => user_access('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, - ); - } + $items['image_attach'] = array( + 'title' => 'Image Attachment View', + 'page callback' => 'image_attach_view_image', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + $items['admin/settings/image_attach'] = array( + 'title' => 'Image attach', + 'description' => 'Enable image attach for content', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_attach_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + ); return $items; } @@ -84,7 +80,7 @@ function image_attach_block($op = 'list' $img = image_display($image, variable_get('image_attach_block_0_size', IMAGE_THUMBNAIL)); return array( 'subject' => t('Attached Images'), - 'content' => l($img, "node/$node->iid", array(), NULL, NULL, FALSE, TRUE), + 'content' => l($img, "node/$node->iid", array('html' => TRUE)), ); } } @@ -122,7 +118,7 @@ function image_attach_block($op = 'list' /** * implementation of hook_form_alter() */ -function image_attach_form_alter($form_id, &$form) { +function image_attach_form_alter(&$form, $form_state, $form_id) { // Content type settings form. if ($form_id == 'node_type_form' && $form['#node_type']->type != 'image') { _image_check_settings(); @@ -433,6 +429,20 @@ function image_attach_views_handler_filt } /** + * Implementation of hook_theme() registry. + **/ +function image_attach_theme() { + return array( + 'image_attach_teaser' => array( + 'arguments' => array('node' => new stdClass()), + ), + 'image_attach_body' => array( + 'arguments' => array('node' => new stdClass()), + ), + ); +} + +/** * Theme the teaser. * * Override this in template.php to include a case statement if you want different node types to appear differently. @@ -452,7 +462,7 @@ function theme_image_attach_teaser($node $info = image_get_info(file_create_path($image->images[$img_size])); $output = '

'; - $output .= l(image_display($image, $img_size), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE); + $output .= l(image_display($image, $img_size), "node/$node->nid", array('html' => TRUE)); $output .= '
'."\n"; return $output; @@ -476,7 +486,7 @@ function theme_image_attach_body($node) $info = image_get_info(file_create_path($image->images[$img_size])); $output = '
'; - $output .= l(image_display($image, $img_size), "node/$node->iid", array(), NULL, NULL, FALSE, TRUE); + $output .= l(image_display($image, $img_size), "node/$node->iid", array('html' => TRUE)); $output .= '
'."\n"; return $output; Index: contrib/image_gallery/image_gallery.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_gallery/image_gallery.info,v retrieving revision 1.4 diff -u -p -r1.4 image_gallery.info --- contrib/image_gallery/image_gallery.info 18 Jul 2007 17:04:31 -0000 1.4 +++ contrib/image_gallery/image_gallery.info 13 Dec 2007 09:59:23 -0000 @@ -2,5 +2,6 @@ name = Image Gallery description = Allows sorting and displaying of image galleries based on categories. package = Image -dependencies = image taxonomy - +dependencies[] = image +dependencies[] = taxonomy +core = 6.x Index: contrib/image_gallery/image_gallery.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_gallery/image_gallery.module,v retrieving revision 1.20 diff -u -p -r1.20 image_gallery.module --- contrib/image_gallery/image_gallery.module 7 Sep 2007 19:26:24 -0000 1.20 +++ contrib/image_gallery/image_gallery.module 13 Dec 2007 09:59:24 -0000 @@ -1,8 +1,8 @@ '. t('Image galleries can be used to organize and present groups of images. Galleries may be nested. To add a new gallery click the "add gallery" tab.') .'

'; } @@ -12,59 +12,47 @@ function image_gallery_perm() { return array('administer images'); } -function image_gallery_menu($may_cache) { +function image_gallery_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'image', - 'title' => t('Image galleries'), - 'access' => user_access('access content'), - 'type' => MENU_SUGGESTED_ITEM, - 'callback' => 'image_gallery_page', - ); - $items[] = array( - 'path' => 'admin/content/image', - 'title' => t('Image galleries'), - 'access' => user_access('administer images'), - 'callback' => 'image_gallery_admin', - 'description' => t('Create and manage image galleries.'), - ); - $items[] = array( - 'path' => 'admin/content/image/list', - 'title' => t('List'), - 'access' => user_access('administer images'), - 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, - ); - $items[] = array( - 'path' => 'admin/content/image/add', - 'title' => t('Add gallery'), - 'access' => user_access('administer images'), - 'callback' => 'image_gallery_admin_add', - 'type' => MENU_LOCAL_TASK, - ); - $items[] = array( - 'path' => 'admin/settings/image_gallery', - 'title' => t('Image gallery'), - 'access' => user_access('administer site configuration'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('image_gallery_admin_settings'), - 'description' => t('Configure appearance of image galleries.'), - ); - } - elseif (is_numeric(arg(4))) { - $term = taxonomy_get_term(arg(4)); - if ($term) { - $items[] = array( - 'path' => 'admin/content/image/edit', - 'title' => t('Edit image gallery'), - 'callback' => 'image_gallery_admin_add', - 'callback arguments' => array((array)$term), - 'access' => user_access('administer images'), - 'type' => MENU_CALLBACK, - ); - } - } + $items['image'] = array( + 'title' => 'Image galleries', + 'access arguments' => array('access content'), + 'type' => MENU_SUGGESTED_ITEM, + 'page callback' => 'image_gallery_page', + ); + $items['admin/content/image'] = array( + 'title' => 'Image galleries', + 'access arguments' => array('administer images'), + 'page callback' => 'image_gallery_admin', + 'description' => 'Create and manage image galleries.', + ); + $items['admin/content/image/list'] = array( + 'title' => 'List', + 'access arguments' => array('administer images'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + $items['admin/content/image/add'] = array( + 'title' => 'Add gallery', + 'access arguments' => array('administer images'), + 'page callback' => 'image_gallery_admin_add', + 'type' => MENU_LOCAL_TASK, + ); + $items['admin/settings/image_gallery'] = array( + 'title' => 'Image gallery', + 'access arguments' => array('administer site configuration'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_gallery_admin_settings'), + 'description' => 'Configure appearance of image galleries.', + ); + $items['admin/content/image/edit/%gallery_vocabulary'] = array( + 'title' => 'Edit image gallery', + 'page callback' => 'image_gallery_admin_add', + 'page arguments' => array(4), + 'access arguments' => array('administer images'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -114,21 +102,21 @@ function image_gallery_nodeapi(&$node, $ case 'view': if ($page && !$teaser && $node->type == 'image') { $vid = _image_gallery_get_vid(); - $terms = taxonomy_node_get_terms_by_vocabulary($node->nid, $vid); + $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid); $term = array_pop($terms); if ($term) { - $vocabulary = taxonomy_get_vocabulary($vid); + $vocabulary = taxonomy_vocabulary_load($vid); // Breadcrumb navigation $breadcrumb = array(); - $breadcrumb[] = array('path' => 'image', 'title' => $vocabulary->name); + $breadcrumb[] = l(t('Home'), NULL); + $breadcrumb[] = l($vocabulary->name, 'image'); if ($parents = taxonomy_get_parents_all($term->tid)) { $parents = array_reverse($parents); - foreach ($parents as $p) { - $breadcrumb[] = array('path' => 'image/tid/'. $p->tid, 'title' => $p->name); + foreach ($parents as $parent) { + $breadcrumb[] = l($parent->name, 'image/tid/'. $parent->tid); } } - $breadcrumb[] = array('path' => 'node/'. $node->nid); - menu_set_location($breadcrumb); + drupal_set_breadcrumb($breadcrumb); } } break; @@ -147,7 +135,7 @@ function image_gallery_page($type = NULL // The values of $descendant_tids should be safe for raw inclusion in the // SQL since they're all loaded from integer fields in the database. $sql = 'SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. implode(',', $descendant_tids) .') AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'; - if ($nid = db_result(db_query_range(db_rewrite_sql($sql), 0, 1))) { + if ($nid = db_result(db_query_range(db_rewrite_sql($sql)))) { $galleries[$i]->latest = node_load(array('nid' => $nid)); } } @@ -161,16 +149,18 @@ function image_gallery_page($type = NULL $gallery = taxonomy_get_term($tid); $parents = taxonomy_get_parents($tid); + + $breadcrumb = array(); + $breadcrumb[] = l(t('Home'), NULL); + $breadcrumb[] = l(t('Image galleries'), 'image'); foreach ($parents as $parent) { - $breadcrumb[] = array('path' => 'image/tid/'. $parent->tid, 'title' => $parent->name); + // Add parents to breadcrumb navigation + $breadcrumb[] = l($parent->name, 'image/tid/'. $parent->tid); } - $breadcrumb[] = array('path' => 'image', 'title' => t('Image galleries')); - $breadcrumb = array_reverse($breadcrumb); + drupal_set_breadcrumb($breadcrumb); drupal_set_title($gallery->name); } - - $breadcrumb[] = array('path' => $_GET['q']); - menu_set_location($breadcrumb); + $content = theme('image_gallery', $galleries, $images); return $content; } @@ -178,10 +168,9 @@ function image_gallery_page($type = NULL function image_gallery_admin() { _image_check_settings(); - $header = array(t('Name'), t('Operations')); - $tree = taxonomy_get_tree(_image_gallery_get_vid()); if ($tree) { + $header = array(t('Name'), t('Operations')); foreach ($tree as $term) { $rows[] = array(str_repeat(' -- ', $term->depth) .' '. l($term->name, "image/tid/$term->tid"), l(t('edit gallery'), "admin/content/image/edit/$term->tid")); } @@ -249,22 +238,22 @@ function image_gallery_admin_form($edit '#value' => $edit['tid'], ); } - - $form['#base'] = 'image_gallery_admin'; + $form['#submit'][] = 'image_gallery_admin_submit'; + $form['#theme'][] = 'image_gallery_admin'; return $form; } -function image_gallery_admin_submit($form_id, $form_values) { - $status = taxonomy_save_term($form_values); +function image_gallery_admin_submit($form, &$form_state) { + $status = taxonomy_save_term($form_state['values']); switch ($status) { case SAVED_NEW: - drupal_set_message(t('Created new gallery %term.', array('%term' => $form_values['name']))); + drupal_set_message(t('Created new gallery %term.', array('%term' => $form_state['values']['name']))); break; case SAVED_UPDATED: - drupal_set_message(t('The gallery %term has been updated.', array('%term' => $form_values['name']))); + drupal_set_message(t('The gallery %term has been updated.', array('%term' => $form_state['values']['name']))); break; case SAVED_DELETED: - drupal_set_message(t('The gallery %term has been deleted.', array('%term' => $form_values['name']))); + drupal_set_message(t('The gallery %term has been deleted.', array('%term' => $form_state['values']['name']))); break; } return 'admin/content/image'; @@ -279,9 +268,9 @@ function image_gallery_confirm_delete($t return confirm_form($form, t('Are you sure you want to delete the image gallery %name?', array('%name' => $term->name)), 'admin/content/image', t('Deleting an image gallery will delete all sub-galleries. This action cannot be undone.'), t('Delete'), t('Cancel')); } -function image_gallery_confirm_delete_submit($form_id, $form_values) { - taxonomy_del_term($form_values['tid']); - drupal_set_message(t('The image gallery %term and all sub-galleries have been deleted.', array('%term' => $form_values['name']))); +function image_gallery_confirm_delete_submit($form, &$form_state) { + taxonomy_del_term($form_state['values']['tid']); + drupal_set_message(t('The image gallery %term and all sub-galleries have been deleted.', array('%term' => $form_state['values']['name']))); return 'admin/content/image'; } @@ -326,6 +315,20 @@ function _image_gallery_parent_select($t } /** + * Implementation of hook_theme() registry. + **/ +function image_gallery_theme() { + return array( + 'image_gallery' => array( + 'arguments' => array('galleries' => NULL, 'images' => NULL), + ), + 'image_gallery_img' => array( + 'arguments' => array('image' => NULL, 'size' => NULL), + ), + ); +} + +/** * Theme a gallery page */ function theme_image_gallery($galleries, $images) { @@ -364,7 +367,7 @@ function theme_image_gallery($galleries, $content .= $pager; } - If (count($images) + count($galleries) == 0) { + if (count($images) + count($galleries) == 0) { $content .= '

'. format_plural(0, 'There is 1 image in this gallery', 'There are @count images in this gallery') ."

\n"; } @@ -381,7 +384,7 @@ function theme_image_gallery_img($image, $content .= ' class="sticky"'; } $content .= " style='height : {$height}px; width : {$width}px;'>\n"; - $content .= l(image_display($image, IMAGE_THUMBNAIL), 'node/'. $image->nid, array(), NULL, NULL, FALSE, TRUE); + $content .= l(image_display($image, IMAGE_THUMBNAIL), 'node/'. $image->nid, array('html' => TRUE)); $content .= '

'. l($image->title, 'node/'. $image->nid) .'

'; if (variable_get('image_gallery_node_info', 0)) { $content .= '
'. t('Posted by: !name', array('!name' => theme('username', $image))) ."
\n"; @@ -399,7 +402,7 @@ function theme_image_gallery_img($image, */ function _image_gallery_get_vid() { $vid = variable_get('image_gallery_nav_vocabulary', ''); - if (empty($vid) || !taxonomy_get_vocabulary($vid)) { + if (empty($vid) || !taxonomy_get_vocabularies($vid)) { // Check to see if an image gallery vocabulary exists $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='image_gallery'")); if (!$vid) { Index: contrib/image_im_advanced/image_im_advanced.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_im_advanced/image_im_advanced.info,v retrieving revision 1.1 diff -u -p -r1.1 image_im_advanced.info --- contrib/image_im_advanced/image_im_advanced.info 26 Aug 2007 21:30:02 -0000 1.1 +++ contrib/image_im_advanced/image_im_advanced.info 13 Dec 2007 09:59:25 -0000 @@ -2,3 +2,4 @@ name = ImageMagick Advanced Options description = Adds advanced options to the ImageMagick image toolkit. package = Image +core = 6.x Index: contrib/image_im_advanced/image_im_advanced.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_im_advanced/image_im_advanced.module,v retrieving revision 1.3 diff -u -p -r1.3 image_im_advanced.module --- contrib/image_im_advanced/image_im_advanced.module 27 Aug 2007 15:03:41 -0000 1.3 +++ contrib/image_im_advanced/image_im_advanced.module 13 Dec 2007 09:59:25 -0000 @@ -24,7 +24,7 @@ function image_im_advanced_options() { * * Add options to the Image toolkit settings form. */ -function image_im_advanced_form_alter($form_id, &$form) { +function image_im_advanced_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'system_image_toolkit_settings' && 'imagemagick' == image_get_toolkit()) { $options = image_im_advanced_options(); @@ -158,7 +158,7 @@ function image_im_advanced_imagemagick_a // Add sharpening filter. if ($options['unsharp']['amount'] && $options['unsharp']['radius']) { // 0.7 and 0.02 are reasonable values for Sigma and Threshold. - $args['unsharp'] = '-unsharp ' . $options['unsharp']['radius'] . 'x0.7+' . round($options['unsharp']['amount'] / 100, 2) . '+0.02'; + $args['unsharp'] = '-unsharp '. $options['unsharp']['radius'] .'x0.7+'. round($options['unsharp']['amount'] / 100, 2) .'+0.02'; } break; @@ -177,7 +177,7 @@ function image_im_advanced_imagemagick_a // Convert to specified color profile. if (!empty($options['profile']['path']) && is_readable($options['profile']['path'])) { - $args['profile'] = '-profile ' . $options['profile']['path']; + $args['profile'] = '-profile '. $options['profile']['path']; } // Assign a color space. Skip this if a color profile has been provided, @@ -195,7 +195,7 @@ function image_im_advanced_imagemagick_a // Set JPEG quality. if ($image['mime_type'] == 'image/jpeg') { if (empty($args['quality']) && $options['jpeg_quality']) { - $args['quality'] = '-quality ' . $options['jpeg_quality']; + $args['quality'] = '-quality '. $options['jpeg_quality']; } } Index: contrib/image_import/image_import.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_import/image_import.info,v retrieving revision 1.3 diff -u -p -r1.3 image_import.info --- contrib/image_import/image_import.info 18 Jul 2007 17:04:37 -0000 1.3 +++ contrib/image_import/image_import.info 13 Dec 2007 09:59:25 -0000 @@ -2,5 +2,6 @@ name = Image Import description = Allows batches of images to be imported from a directory on the server. package = Image -dependencies = image +dependencies[] = image +core = 6.x Index: contrib/image_import/image_import.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_import/image_import.module,v retrieving revision 1.11 diff -u -p -r1.11 image_import.module --- contrib/image_import/image_import.module 24 Jul 2007 17:33:42 -0000 1.11 +++ contrib/image_import/image_import.module 13 Dec 2007 09:59:26 -0000 @@ -4,8 +4,8 @@ /** * Implementation of hook_help(). */ -function image_import_help($section = '') { - switch ($section) { +function image_import_help($path, $arg) { + switch ($path) { case 'admin/content/image_import': $output = '

'. t("Import multiple image files and save them as image nodes. The files will be moved from their location into the image module's files directory. ") . t("Searching for image files in %dirpath.", array('%dirpath' => realpath(variable_get('image_import_path', '')))) .'

'; @@ -27,28 +27,25 @@ function image_import_perm() { /** * Implementation of hook_menu(). */ -function image_import_menu($may_cache) { +function image_import_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/content/image_import', - 'title' => t('Image import'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('image_import_form'), - 'access' => user_access('import images'), - 'type' => MENU_NORMAL_ITEM, - 'description' => t('Import images from the filesystem.') - ); - $items[] = array( - 'path' => 'admin/settings/image_import', - 'title' => t('Image import'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('image_import_admin_settings'), - 'access' => user_access('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, - 'description' => t('Change settings for the Image Import module.') - ); - } + + $items['admin/content/image_import'] = array( + 'title' => 'Image import', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_import_form'), + 'access arguments' => array('import images'), + 'type' => MENU_NORMAL_ITEM, + 'description' => 'Import images from the filesystem.', + ); + $items['admin/settings/image_import'] = array( + 'title' => 'Image import', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_import_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + 'description' => 'Change settings for the Image Import module.', + ); return $items; } @@ -67,11 +64,11 @@ function image_import_form() { if ($files) { if (module_exists('taxonomy')) { - // here's a little hack to get the taxonmy controls onto our form + // here's a little hack to get the taxonomy controls onto our form $form['type'] = array('#type' => 'value', '#value' => 'image'); $form['#node'] = new stdClass(); $form['#node']->type = 'image'; - taxonomy_form_alter('image_node_form', $form); + taxonomy_form_alter(&$form, $form_state, 'image_node_form'); unset($form['type']); unset($form['#node']); } @@ -146,6 +143,17 @@ function image_import_form() { return $form; } +/** + * Implementation of hook_theme() registry. + **/ +function image_import_form_theme() { + return array( + 'image_import_form' => array( + 'arguments' => array($form), + ), + ); +} + function theme_image_import_form($form) { $output = ''; if (isset($form['import_file']) && $form['import_file']['#type'] == 'checkboxes') { @@ -168,27 +176,27 @@ function theme_image_import_form($form) return $output . drupal_render($form); } -function image_import_form_submit($form_id, $form_values) { - $op = isset($form_values['op']) ? $form_values['op'] : ''; +function image_import_form_submit($form, &$form_state) { + $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; if ($op == t('Import')) { $dirpath = variable_get('image_import_path', ''); if (file_check_directory($dirpath)) { $nodes = array(); $files = array(); - foreach (array_filter($form_values['import_file']) as $index) { + foreach (array_filter($form_state['values']['import_file']) as $index) { // try to avoid php's script timeout with a bunch of large files or // a slow machine if (!ini_get('safe_mode')) { set_time_limit(0); } - $origname = $form_values['file_list'][$index]; + $origname = $form_state['values']['file_list'][$index]; $filename = file_check_location($dirpath .'/'. $origname, $dirpath); if ($filename) { $node = image_create_node_from( $filename, - $form_values['title'][$index], - $form_values['body'][$index], - $form_values['taxonomy'] + $form_state['values']['title'][$index], + $form_state['values']['body'][$index], + $form_state['values']['taxonomy'] ); if ($node) {