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 6 Dec 2007 01:52:18 -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 6 Dec 2007 01:52: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 6 Dec 2007 01:52: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 6 Dec 2007 01:52:19 -0000 @@ -4,35 +4,46 @@ /** * Installing and updating image.module. */ +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; +} + +/** + * Installing and updating image.module. + */ 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'); 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 6 Dec 2007 01:52:19 -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), + ), + 'image_body' => array( + 'arguments' => array('node' => NULL), + ), + 'image_display' => array( + 'arguments' => array( + 'node' => NULL, + 'label' => NULL, + 'url' => NULL, + 'attributes' => NULL, + ), + ), + ); +} + +/** * Implementation of hook_node_info */ function image_node_info() { @@ -141,8 +166,12 @@ function image_admin_settings() { '#size' => 25, '#maxlength' => 32, ); + // TODO: currently getting "notice: Array to string conversion in /Users/addi/Sites/upgrade6/includes/form.inc on line 715." on this screen when saving the configs. + + // 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 +204,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 +221,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 +236,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 +263,10 @@ 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); + return system_settings_form_submit($form, $form_state); } function theme_image_settings_sizes_form(&$form) { @@ -251,7 +280,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 +289,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; } @@ -346,8 +366,13 @@ function image_prepare(&$node, $field_na if (is_null($field_name)) { $field_name = 'image'; } + + // Validators for file_save_upload(). + $validators = array( + 'file_validate_is_image' => array(), + ); - if ($file = file_check_upload($field_name)) { + if ($file = file_save_upload($field_name, $validators)) { // Ensure the file is an image. $image_info = image_get_info($file->filepath); if (!$image_info || empty($image_info['extension'])) { @@ -356,10 +381,7 @@ function image_prepare(&$node, $field_na } // Save the file to the temp directory. - $file = file_save_upload($field_name, _image_filename($file->filename, IMAGE_ORIGINAL, TRUE)); - if (!$file) { - return; - } + file_copy($file, _image_filename($file->filename, IMAGE_ORIGINAL, TRUE)); // Resize the original. $aspect_ratio = $image_info['height'] / $image_info['width']; @@ -664,7 +686,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)); } } @@ -958,16 +980,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; } @@ -1088,11 +1101,13 @@ 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); + $fid = db_last_insert_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); } } 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 6 Dec 2007 01:52:19 -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 6 Dec 2007 01:52:19 -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 6 Dec 2007 01:52:19 -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_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 6 Dec 2007 01:52:19 -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_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 6 Dec 2007 01:52:19 -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_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 6 Dec 2007 01:52:19 -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 6 Dec 2007 01:52:19 -0000 @@ -67,11 +67,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']); }