? 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 '. 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.') .' '. 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 = '
'. 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 .= ''. 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) {