--- imagefield_import/imagefield_import.module 2008-07-28 15:28:38.000000000 -0600
+++ /var/www/drupal5/drupal-5.9/sites/all/modules/imagefield_import/imagefield_import.module 2008-09-18 09:56:29.000000000 -0600
@@ -17,7 +17,7 @@ function imagefield_import_help($section
case 'admin/content/imagefield_import':
return '
'. t('This is where the Import Magic happens. If there are images currently in the Directory you set up for import you will see them in the list below. You can customize the Title and body text of each of the nodes before submitting them all for creation. Do not forget to click the checkbox on the left that indicates you want to import this image into an imagefield node, or click the top checkbox to select or deslect all.') .'
';
case 'admin/settings/imagefield_import':
- return ''. t('The Imagefield Import Path is where you want to transfer -likely FTP or SSH- your images that are in need of uploading, then select the targe field. You will be creating one node for each image. So here you are choosing what field you want your imported image to populate') .'
';
+ return ''. t('The Imagefield Import Path is where you want to transfer -likely FTP- your images that are in need of uploading, then select the targe field. You will be creating one node for each image. So here you are choosing what field you want your imported image to populate') .'
';
}
}
@@ -87,7 +87,7 @@ function imagefield_import_form() {
$form['type'] = array('#type' => 'value', '#value' => $type);
$form['#node'] = new stdClass();
$form['#node']->type = $type;
- $form_id = $type . '_node_form';
+ $form_id = $type .'_node_form';
taxonomy_form_alter($form_id, $form);
unset($form['type']);
unset($form['#node']);
@@ -98,7 +98,13 @@ function imagefield_import_form() {
// there's no 0th element, because a checkbox with a zero value is seen as
// unchecked and won't be imported.
// a $fields multidimentional array for each of the files will need these elements
- $fields = array('filesize', 'dimensions', 'title', 'body');
+ //new section
+ if (variable_get('imagefield_import_thumb', 0)) {
+ $fields = array('filesize', 'dimensions', 'thumb', 'title', 'body');
+ }
+ else {
+ $fields = array('filesize', 'dimensions', 'title', 'body');
+ }
foreach ($fields as $field) {
$form['files'][$field][0] = NULL; //$form['files'][filesize][0], etc. = null
}
@@ -119,6 +125,12 @@ function imagefield_import_form() {
'#type' => 'item',
'#value' => $info['width'] .'x'. $info['height'],
);
+ if (variable_get('imagefield_import_thumb', 0)) {
+ $form['files']['thumb'][] = array(
+ '#type' => 'item',
+ '#value' => '
',
+ );
+ }
$form['files']['title'][] = array(
'#type' => 'textfield',
'#size' => 20,
@@ -153,12 +165,12 @@ function imagefield_import_form() {
'#type' => 'submit',
'#value' => t('Import'),
);
- $targetsetting = variable_get('imagefield_import_fieldname', FALSE);
- list($type, $field) = split(":::", $targetsetting);
- $form['conf_message'] = array(
+ $targetsetting = variable_get('imagefield_import_fieldname', FALSE);
+ list($type, $field) = split(":::", $targetsetting);
+ $form['conf_message'] = array(
'#type' => 'item',
'#value' => t("Will import images into content type '$type', field '$field'. To configure this visit the !settings page.", array('!settings' => l("Imagefield import settings", "admin/settings/imagefield_import"))),
- );
+ );
}
else {
$form['import_file'] = array(
@@ -176,19 +188,46 @@ function theme_imagefield_import_form($f
$output .= drupal_render($form['conf_message']);
if (isset($form['import_file']) && $form['import_file']['#type'] == 'checkboxes') {
- $header = array(theme('table_select_header_cell'), t('Name'), t('Size'), t('Dimensions'), t('Title'), t('Body'));
+ if (variable_get('imagefield_import_thumb', 0)) {
+ $header = array(theme('table_select_header_cell'), t('Name'), t('Size'), t('Dimensions'), t('Photo'), t('Title'), t('Body'));
+ }
+ else {
+ $header = array(theme('table_select_header_cell'), t('Name'), t('Size'), t('Dimensions'), t('Title'), t('Body'));
+ }
+
$rows = array();
- foreach (element_children($form['import_file']) as $key) {
- $filename = $form['import_file'][$key]['#title'];
- unset($form['import_file'][$key]['#title']);
- $rows[] = array(
- drupal_render($form['import_file'][$key]),
- $filename,
- drupal_render($form['files']['filesize'][$key]),
- drupal_render($form['files']['dimensions'][$key]),
- drupal_render($form['files']['title'][$key]),
- drupal_render($form['files']['body'][$key]),
- );
+ $thumbnails = variable_get('imagefield_import_thumb', 0);
+
+ switch ($thumbnails) {
+ case 0:
+ foreach (element_children($form['import_file']) as $key) {
+ $filename = $form['import_file'][$key]['#title'];
+ unset($form['import_file'][$key]['#title']);
+ $rows[] = array(
+ drupal_render($form['import_file'][$key]),
+ $filename,
+ drupal_render($form['files']['filesize'][$key]),
+ drupal_render($form['files']['dimensions'][$key]),
+ drupal_render($form['files']['title'][$key]),
+ drupal_render($form['files']['body'][$key]),
+ );
+ }
+ break;
+ case 1:
+ foreach (element_children($form['import_file']) as $key) {
+ $filename = $form['import_file'][$key]['#title'];
+ unset($form['import_file'][$key]['#title']);
+ $rows[] = array(
+ drupal_render($form['import_file'][$key]),
+ $filename,
+ drupal_render($form['files']['filesize'][$key]),
+ drupal_render($form['files']['dimensions'][$key]),
+ drupal_render($form['files']['thumb'][$key]),
+ drupal_render($form['files']['title'][$key]),
+ drupal_render($form['files']['body'][$key]),
+ );
+ }
+ break;
}
$output .= theme('table', $header, $rows);
}
@@ -255,7 +294,7 @@ function imagefield_import_admin_setting
'#description' => t("The directory to import image nodes from. Drupal will need to have write access to this directory so we can move and remove the file.") .'
'. t("
Note: a path begining with a / indicates the path is relative to the server's root, not the website's root. One starting without a / specifies a path relative to Drupal's root. For example: /tmp/image would be the temp directory off the root of the server while tmp/image would be a path relative to the Drupal's directory."),
'#required' => TRUE,
);
-
+
//examine the node types they have available and find ones that have an imagefield associated with them
$types = content_types();
$matches = array();
@@ -290,6 +329,13 @@ function imagefield_import_admin_setting
'#required' => TRUE
);
}
+ $form['imagefield_import_thumb'] = array(
+ '#type' => 'radios',
+ '#title' => t('Display thumbnail images on the Import form?'),
+ '#description' => t('This will help when giving your images title and body text, but might slow down a large import'),
+ '#options' => array(t('No'), t('Yes')),
+ '#default_value' => variable_get('imagefield_import_thumb', 0),
+ );
return system_settings_form($form);
}
@@ -357,14 +403,14 @@ function imagefield_create_node_from($fi
$node->status = in_array('status', $node_options);
$node->promote = in_array('promote', $node_options);
if (module_exists('comment')) {
- $node->comment = variable_get("comment_{$node->type}", COMMENT_NODE_READ_WRITE);
+ $node->comment = variable_get("comment_{$node->type}", COMMENT_NODE_READ_WRITE);
}
if (module_exists('taxonomy')) {
- $node->taxonomy = $taxonomy;
+ $node->taxonomy = $taxonomy;
}
$node->new_file = TRUE;
$node->$field = array(
- array(
+ array(
'fid' => 'upload',
'title' => basename($filepath),
'filename' => basename($filepath),