*** po/image_attach-module.pot Wed Dec 31 14:00:00 1969 --- po/image_attach-module.pot Wed Feb 14 13:24:55 2007 *************** *** 0 **** --- 1,121 ---- + # LANGUAGE translation of Drupal (image_attach.module) + # Copyright YEAR NAME + # Generated from file: image_attach.module,v 1.6 2006/10/25 14:03:04 walkah + # + #, fuzzy + msgid "" + msgstr "" + "Project-Id-Version: PROJECT VERSION\n" + "POT-Creation-Date: 2007-02-14 13:24+0100\n" + "PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n" + "Last-Translator: NAME \n" + "Language-Team: LANGUAGE \n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=utf-8\n" + "Content-Transfer-Encoding: 8bit\n" + "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" + + #: image_attach.module:31 + msgid "Allows easy attaching of image nodes to other content types." + msgstr "" + + #: image_attach.module:59 + msgid "No-image image" + msgstr "" + + #: image_attach.module:62 + msgid "Choose an image to be used when there are no attach images." + msgstr "" + + #: image_attach.module:91 + msgid "Attach uploaded images" + msgstr "" + + #: image_attach.module:93;100 + msgid "Disabled" + msgstr "" + + #: image_attach.module:93;100 + msgid "Enabled" + msgstr "" + + #: image_attach.module:94 + msgid "Should this node allows users to attach uploaded images?" + msgstr "" + + #: image_attach.module:98 + msgid "Attach existing images" + msgstr "" + + #: image_attach.module:101 + msgid "Should this node allows users to attach existing images?" + msgstr "" + + #: image_attach.module:104 + msgid "The image module is not installed. The image_attach module will not function without it." + msgstr "" + + #: image_attach.module:120 + msgid "Attached Images" + msgstr "" + + #: image_attach.module:123 + msgid "Changes made to the attachments are not permanent until you save this post. The first \"listed\" image will be included in RSS feeds." + msgstr "" + + #: image_attach.module:186 + msgid "Attach an existing Image" + msgstr "" + + #: image_attach.module:188 + msgid "Choose an image already existing on the server and attach it." + msgstr "" + + #: image_attach.module:195 + msgid "-or-" + msgstr "" + + #: image_attach.module:204 + msgid "Upload and attach new image" + msgstr "" + + #: image_attach.module:206 + msgid "Upload a new image and attach it." + msgstr "" + + #: image_attach.module:210 + msgid "Image title" + msgstr "" + + #: image_attach.module:212 + msgid "The title the image will be shown with." + msgstr "" + + #: image_attach.module:219 + msgid "Attach" + msgstr "" + + #: image_attach.module:335 + msgid "Attached image with node id %iid not found" + msgstr "" + + #: image_attach.module:484 + msgid "Click to see larger image" + msgstr "" + + #: image_attach.module:573 + msgid "Attached Image: Display Image" + msgstr "" + + #: image_attach.module:575 + msgid "Image" + msgstr "" + + #: image_attach.module:576 + msgid "Image with link" + msgstr "" + + #: image_attach.module:0 + msgid "image_attach" + msgstr "" + *** po/it.po Wed Dec 31 14:00:00 1969 --- po/it.po Wed Feb 14 13:37:49 2007 *************** *** 0 **** --- 1,121 ---- + msgid "" + msgstr "" + "Project-Id-Version: image_attach\n" + "POT-Creation-Date: \n" + "PO-Revision-Date: 2007-02-14 13:37+0100\n" + "Last-Translator: Danny van der Weide \n" + "Language-Team: Logomatica \n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=utf-8\n" + "Content-Transfer-Encoding: 8bit\n" + "X-Poedit-Country: ITALY\n" + "X-Poedit-SourceCharset: utf-8\n" + "X-Poedit-Language: Italian\n" + "Plural-Forms: nplurals=2; plural=(n != 1);\n" + + #: image_attach.module:31 + msgid "Allows easy attaching of image nodes to other content types." + msgstr "Permette l'allegamento semplice dei nodi del tipo immagine ai altri tipi di contenuto." + + #: image_attach.module:59 + msgid "No-image image" + msgstr "Immagine di no-immagini" + + #: image_attach.module:62 + msgid "Choose an image to be used when there are no attach images." + msgstr "Scegli un'immagine da usare quando non ci sono allegati delle immagine." + + #: image_attach.module:91 + msgid "Attach uploaded images" + msgstr "Allega immagini caricati" + + #: image_attach.module:93 + #: ;100 + msgid "Disabled" + msgstr "Disattivato" + + #: image_attach.module:93 + #: ;100 + msgid "Enabled" + msgstr "Attivo" + + #: image_attach.module:94 + msgid "Should this node allows users to attach uploaded images?" + msgstr "Questo node dovrebbe permettere ai utenti di allegare dei immagini caricati?" + + #: image_attach.module:98 + msgid "Attach existing images" + msgstr "Allega immagini già esistente" + + #: image_attach.module:101 + msgid "Should this node allows users to attach existing images?" + msgstr "Questo node dovrebbe permettere ai utenti di allegare dei immagini già esistente?" + + #: image_attach.module:104 + msgid "The image module is not installed. The image_attach module will not function without it." + msgstr "Il modulo image non è installato. Il modulo image_attach non funzionerà senza." + + #: image_attach.module:120 + msgid "Attached Images" + msgstr "Immagini Allegati" + + #: image_attach.module:123 + msgid "Changes made to the attachments are not permanent until you save this post. The first \"listed\" image will be included in RSS feeds." + msgstr "I cambiamenti effettuati sull'allegato non sono permanenti finché non salvi questo contenuto. Il primo immagine \"elencato\" verrà includo nelle fonti RSS." + + #: image_attach.module:186 + msgid "Attach an existing Image" + msgstr "Allega un immagine già esistente" + + #: image_attach.module:188 + msgid "Choose an image already existing on the server and attach it." + msgstr "Scegli un'immagine già esistente sul server e allegalo." + + #: image_attach.module:195 + msgid "-or-" + msgstr "-oppure-" + + #: image_attach.module:204 + msgid "Upload and attach new image" + msgstr "Carica ed allega un nuovo immagine." + + #: image_attach.module:206 + msgid "Upload a new image and attach it." + msgstr "Carica ed allega un nuovo immagine." + + #: image_attach.module:210 + msgid "Image title" + msgstr "Titolo dell'imagine" + + #: image_attach.module:212 + msgid "The title the image will be shown with." + msgstr "Il titolo da mostrare con l'immagine." + + #: image_attach.module:219 + msgid "Attach" + msgstr "Allega" + + #: image_attach.module:335 + msgid "Attached image with node id %iid not found" + msgstr "L'immagine allegato con id nodo %iid non risulta" + + #: image_attach.module:484 + msgid "Click to see larger image" + msgstr "Click per vedere l'immagine più grande" + + #: image_attach.module:573 + msgid "Attached Image: Display Image" + msgstr "Immagine Allegato: Mostra Immagine" + + #: image_attach.module:575 + msgid "Image" + msgstr "Immagine" + + #: image_attach.module:576 + msgid "Image with link" + msgstr "Immagine con collegamento" + + #: image_attach.module:0 + msgid "image_attach" + msgstr "image_attach" + *** po/nl.po Wed Dec 31 14:00:00 1969 --- po/nl.po Wed Feb 14 13:39:40 2007 *************** *** 0 **** --- 1,121 ---- + msgid "" + msgstr "" + "Project-Id-Version: image_attach\n" + "POT-Creation-Date: \n" + "PO-Revision-Date: 2007-02-14 13:39+0100\n" + "Last-Translator: Danny van der Weide \n" + "Language-Team: Logomatica S.r.l. \n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=utf-8\n" + "Content-Transfer-Encoding: 8bit\n" + "Plural-Forms: nplurals=2; plural=(n != 1);\n" + "X-Poedit-Language: Dutch\n" + "X-Poedit-Country: NETHERLANDS\n" + "X-Poedit-SourceCharset: utf-8\n" + + #: image_attach.module:31 + msgid "Allows easy attaching of image nodes to other content types." + msgstr "Hiermee kan men op eenvoudige wijze afbeeldingen bijvoegen aan andere berichttypen." + + #: image_attach.module:59 + msgid "No-image image" + msgstr "Geen-afbeelding afbeelding" + + #: image_attach.module:62 + msgid "Choose an image to be used when there are no attach images." + msgstr "Kies een afbeelding voor wanneer er geen afbeeldingen zijn bijgevoegd." + + #: image_attach.module:91 + msgid "Attach uploaded images" + msgstr "Upgeloade afbeeldingen bijvoegen." + + #: image_attach.module:93 + #: ;100 + msgid "Disabled" + msgstr "Uitgeschakeld" + + #: image_attach.module:93 + #: ;100 + msgid "Enabled" + msgstr "Ingeschakeld" + + #: image_attach.module:94 + msgid "Should this node allows users to attach uploaded images?" + msgstr "Mogen er upgeloade afbeeldingen worden bijgevoegd aan dit berichttype?" + + #: image_attach.module:98 + msgid "Attach existing images" + msgstr "Bestaande afbeeldingen bijvoegen" + + #: image_attach.module:101 + msgid "Should this node allows users to attach existing images?" + msgstr "Mogen er bestaande afbeeldingen worden bijgevoegd aan dit berichttype?" + + #: image_attach.module:104 + msgid "The image module is not installed. The image_attach module will not function without it." + msgstr "De image module is nit geïnstalleerd. De image_attach module zal funtioneren zonder deze module." + + #: image_attach.module:120 + msgid "Attached Images" + msgstr "Bijgevoegde afbeeldingen" + + #: image_attach.module:123 + msgid "Changes made to the attachments are not permanent until you save this post. The first \"listed\" image will be included in RSS feeds." + msgstr "Veranderingen aan bijlagen zijn niet permanent totdat u dit bericht bewaard. De eerst \"vermelde\" afbeelding zal in de RSS-feed opgenomen worden." + + #: image_attach.module:186 + msgid "Attach an existing Image" + msgstr "Voeg een bestaande afbeelding bij" + + #: image_attach.module:188 + msgid "Choose an image already existing on the server and attach it." + msgstr "Kies een reeds op de serverbestaande afbeelding en voeg het bij." + + #: image_attach.module:195 + msgid "-or-" + msgstr "-of-" + + #: image_attach.module:204 + msgid "Upload and attach new image" + msgstr "Upload een nieuwe afbeelding en voeg het bij." + + #: image_attach.module:206 + msgid "Upload a new image and attach it." + msgstr "Upload een nieuwe afbeelding en voeg het bij." + + #: image_attach.module:210 + msgid "Image title" + msgstr "Afbeelding titel" + + #: image_attach.module:212 + msgid "The title the image will be shown with." + msgstr "De titel waarmee de afbeelding wordt weergegeven." + + #: image_attach.module:219 + msgid "Attach" + msgstr "Bijvoegen" + + #: image_attach.module:335 + msgid "Attached image with node id %iid not found" + msgstr "Bijgevoegde afbeelding met node id %iid is niet gevonden" + + #: image_attach.module:484 + msgid "Click to see larger image" + msgstr "Klik om een grotere afbeelding te zien" + + #: image_attach.module:573 + msgid "Attached Image: Display Image" + msgstr "Bijgevoegde afbeelding: Afbeelding weergeven" + + #: image_attach.module:575 + msgid "Image" + msgstr "Afbeelding" + + #: image_attach.module:576 + msgid "Image with link" + msgstr "Afbeelding met link" + + #: image_attach.module:0 + msgid "image_attach" + msgstr "image_attach" + *** image_attach.css 7 May 2006 00:54:00 -0000 1.1 --- image_attach.css 2 Oct 2006 16:25:00 -0000 *************** *** 9,14 **** --- 9,54 ---- .image-attach-preview { margin-bottom: 1em; } + .image-attach-preview a { + display: block; + } .node { clear: both; + } + #attach_image-wrapper { + padding: 5px; + } + #attach_image-wrapper .image-item { + float: left; + width: 170px; + height: 130px; + padding: 5px; + margin: 5px; + border: 1px solid #ccc; + position: relative; + } + #attach_image-wrapper .image-item .picture { + height: 106px; + text-align: center; + vertical-align: middle; + } + #attach_image-wrapper .image-item .form-radio { + position: absolute; + top: 0; + left: 0; + } + #attach_image-wrapper .image-item .form-textfield { + position: absolute; + left: 5px; + bottom: 5px; + width: 165px; + height: 14px; + } + #attach_image-hide { + float: left; + width: 100%; + } + #attach_image-wrapper #uploadprogress { + float: left; + clear: both; } \ No newline at end of file *** image_attach.install 3 May 2006 20:04:25 -0000 1.1 --- image_attach.install 26 Oct 2006 15:24:00 -0000 *************** *** 11,24 **** switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': ! db_query(" ! CREATE TABLE {image_attach} ( ! nid int(10) unsigned NOT NULL default '0', ! iid int(10) unsigned NOT NULL default '0', ! PRIMARY KEY (nid) ! ) TYPE=MyISAM ! /*!40100 DEFAULT CHARACTER SET utf8 */;"); break; } } \ No newline at end of file --- 11,75 ---- switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': ! // modified the original database to accommodate multiple images per node. ! // drop the old table if it happens to be present (just incase). ! db_query("CREATE TABLE {image_attach} ( ! nid int(10) unsigned NOT NULL default '0', ! vid int(10) unsigned NOT NULL default '0', ! iid int(10) unsigned NOT NULL default '0', ! PRIMARY KEY (vid, iid) ! ) TYPE=MyISAM; ! "); break; } + } + + function image_attach_update_1() { + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + // Save data in a temp table for later reconstruction, and empty the table + $ret[] = update_sql( " + CREATE TEMPORARY TABLE {tmp_image_attach} ( + nid int(10) unsigned, + iid int(10) unsigned + );" ); + $ret[] = update_sql( " + INSERT INTO {tmp_image_attach} + SELECT nid, iid FROM {image_attach}; + " ); + $ret[] = update_sql( " + DELETE FROM {image_attach}; + " ); + + // add `vid` column to the table, recreate primary key and add a second index + $ret[] = update_sql( " + ALTER TABLE {image_attach} + ADD COLUMN `vid` int(10) unsigned NOT NULL default '0' AFTER `nid`, + DROP PRIMARY KEY, + ADD PRIMARY KEY (vid, iid), + ADD INDEX `nid_iid` (nid, iid); + " ); + + // reconstruction of the image_attach table. + /* + // OPTION 1: Attach images to the current node revision only + $ret[] = update_sql( " + INSERT INTO {image_attach} (nid, vid, iid) + SELECT tmp.nid, n.vid, tmp.iid + FROM {tmp_image_attach} tmp INNER JOIN {node} n ON n.nid = tmp.nid; + " ); + */ + // OPTION 2: Attach images to all node revisions + $ret[] = update_sql( " + INSERT INTO {image_attach} (nid, vid, iid) + SELECT tmp.nid, r.vid, tmp.iid + FROM {tmp_image_attach} tmp INNER JOIN {node_revisions} r ON r.nid = tmp.nid; + " ); + + break; + } + + return $ret; } \ No newline at end of file *** image_attach.module 25 Oct 2006 14:38:06 -0000 1.2.2.3 --- image_attach.module 14 Feb 2007 08:34:00 -0000 *************** *** 1,38 **** 'radios', ! '#title' => t('Attach existing images.'), ! '#default_value' => variable_get('image_attach_existing', 1), ! '#options' => array(0 => 'Disabled', 1 => 'Enabled'), ! '#description' => t('When enabled, will allow existing image nodes to be attached instead of uploading new images.') ! ); ! return $form; } /** * implementation of hook_form_alter() */ --- 1,71 ---- 'upload/image_js', ! 'callback' => 'image_attach_js', ! 'access' => user_access('create images'), ! 'type' => MENU_CALLBACK ! ); ! } ! ! return $items; ! } ! ! /** ! * implementation of hook_settings() */ function image_attach_settings() { ! $form['image_attach_noimage_iid'] = array( ! '#type' => 'select', ! '#title' => t('No-image image'), ! '#options' => _image_attach_get_image_nodes(), ! '#default_value' => variable_get('image_attach_noimage_iid', null), ! '#description' => t('Choose an image to be used when there are no attach images.') ! ); ! return $form; } + /** * implementation of hook_form_alter() */ *************** *** 42,191 **** } // Make a copy of the type to shorten up the code $type = $form['type']['#value']; ! $enabled = variable_get('image_attach_'. $type, 0); switch ($form_id) { // checkbox in the node's content type configuration page. case $type .'_node_settings': ! if(function_exists('_image_check_settings')){ _image_check_settings(); ! $form['workflow']['image_attach_'. $type] = array( '#type' => 'radios', ! '#title' => t('Attach Images'), ! '#default_value' => $enabled, '#options' => array(0 => t('Disabled'), 1 => t('Enabled')), ! '#description' => t('Should this node allows users to upload an image?'), ); } else { drupal_set_message(t('The image module is not installed. The image_attach module will not function without it.'), 'error'); } break; ! // if enabled adjust the form case $type .'_node_form': ! if ($enabled == 1 && function_exists('_image_check_settings')) { ! _image_check_settings(); $node = $form['#node']; ! $existing = variable_get('image_attach_existing', 1); ! $value = ($node->new_image) ? '#value' : '#default_value'; ! $form['#attributes'] = array("enctype" => "multipart/form-data"); ! ! $form['image_attach'] = array( ! '#type' => 'fieldset', ! '#title' => t('Attached Images'), ! '#collapsible' => TRUE, ! '#collapsed' => !$node->iid ! ); ! if ($node->iid) { ! $image = node_load($node->iid); ! $form['image_attach']['image_thumbnail'] = array( ! '#type' => 'item', ! '#title' => t('Thumbnail'), ! '#value' => image_display($image, 'thumbnail') ! ); ! } ! if ($existing && user_access('access content')) { ! $form['image_attach']['iid'] = array( ! '#type' => 'select', ! '#title' => t('Existing Image'), ! '#options' => _image_attach_get_image_nodes(), ! $value => $node->iid, ! '#description' => t('Choose an image already existing on the server if you do not upload a new one.') ! ); ! $form['image_attach'][] = array( ! '#type' => 'item', ! '#value' => t('-or-'), ! '#attributes' => array('class' => 'either-choice') ! ); ! } ! else { ! $form['image_attach']['iid'] = array( ! '#type' => 'hidden', ! '#value' => $node->iid ! ); ! } ! $form['image_attach']['image'] = array( ! '#type' => 'file', ! '#title' => t('Upload Image') ! ); ! $form['image_attach']['image_title'] = array( ! '#type' => 'textfield', ! '#title' => t('Image title'), ! $value => '', ! '#description' => t('The title the image will be shown with.') ! ); } break; } } ! /** ! * Implementation of hook_menu() ! */ ! function image_attach_menu($may_cache) { ! $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, ! ); } ! return $items; } /** * Implementation of hook_nodeapi(). */ ! function image_attach_nodeapi(&$node, $op, $teaser, $page) { ! if(variable_get('image_attach_'. $node->type, 0) == 0){ ! return; } switch ($op) { case 'prepare': ! $image->title = $_POST['edit']['image_title']; ! $image->uid = $node->uid; ! $image->name = $node->name; ! $image->created = $node->created; ! $image->type = 'image'; ! image_prepare($image, 'image'); ! if ($image->images) { ! node_validate($image); ! if (!form_get_errors()) { ! $image = node_submit($image); ! node_save($image); ! $node->iid = $image->nid; ! $node->new_image = TRUE; ! } ! } ! elseif (variable_get('image_attach_existing', 1) && $_POST['edit']['iid']) { ! $node->iid = $_POST['edit']['iid']; ! } break; case 'insert': case 'update': ! if ($node->iid) { ! db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid); ! db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $node->iid); ! } break; case 'delete': ! db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid); break; case 'load': ! $iid = db_result(db_query("SELECT iid FROM {image_attach} WHERE nid=%d", $node->nid)); ! return array('iid' => $iid); // Pass the body and teaser objects to the theme again to add the images case 'view': ! if($node->iid && function_exists('image_display')){ ! $node->body = theme('image_attach_body', $node); if ($teaser){ ! $node->teaser = theme('image_attach_teaser', $node); } ! } } } --- 75,420 ---- } // Make a copy of the type to shorten up the code $type = $form['type']['#value']; ! ! $upload = variable_get('image_attach_'. $type .'_upload', 0); ! $existing = variable_get('image_attach_'. $type .'_existing', 0); ! $enabled = $existing || $upload; ! switch ($form_id) { // checkbox in the node's content type configuration page. case $type .'_node_settings': ! if (function_exists('_image_check_settings')){ _image_check_settings(); ! $form['workflow']['image_attach_'. $type .'_upload'] = array( '#type' => 'radios', ! '#title' => t('Attach uploaded images'), ! '#default_value' => $upload, '#options' => array(0 => t('Disabled'), 1 => t('Enabled')), ! '#description' => t('Should this node allows users to attach uploaded images?'), ! ); ! $form['workflow']['image_attach_'. $type .'_existing'] = array( ! '#type' => 'radios', ! '#title' => t('Attach existing images'), ! '#default_value' => $existing, ! '#options' => array(0 => t('Disabled'), 1 => t('Enabled')), ! '#description' => t('Should this node allows users to attach existing images?'), ); } else { drupal_set_message(t('The image module is not installed. The image_attach module will not function without it.'), 'error'); } break; ! // if enabled adjust the form case $type .'_node_form': ! if ($enabled && function_exists('_image_check_settings')) { ! _image_check_settings(); $node = $form['#node']; ! ! drupal_add_js('misc/progress.js'); ! drupal_add_js('misc/upload.js'); ! ! // Attachments fieldset ! $form['image_attach'] = array( ! '#type' => 'fieldset', ! '#title' => t('Attached Images'), ! '#collapsible' => TRUE, ! '#collapsed' => empty($node->images), ! '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" image will be included in RSS feeds.'), ! '#prefix' => '
', ! '#suffix' => '
', ! '#weight' => 30, ! ); ! ! // Wrapper for fieldset contents (used by upload JS). ! $form['image_attach']['wrapper'] = array( ! '#prefix' => '
', ! '#suffix' => '
', ! ); ! $form['image_attach']['wrapper'] += _image_attach_form($node, $upload, $existing); ! $form['#attributes']['enctype'] = 'multipart/form-data'; } break; } } ! function _image_attach_form($node, $upload, $existing) { ! $form['#theme'] = 'image_attach_form_new'; ! if (count($node->images)) { ! $form['images']['#theme'] = 'image_attach_form_current'; ! $form['images']['#tree'] = TRUE; ! foreach ($node->images as $iid => $image) { ! $description = file_create_url($image->images['_original']); ! $description = "". check_plain($description) .""; ! $form['images'][$iid]['title'] = array('#type' => 'textfield', '#default_value' => (strlen($image->title)) ? $image->title : $image->images['_original'], '#maxlength' => 256, '#description' => $description ); ! if ($group = image_display($image, 'thumbnail')) ! $form['images'][$iid]['thumbnail'] = array('#type' => 'markup', '#value' => $group); ! ! if (file_exists($image->images['_original'])) ! $filesize = filesize($image->images['_original']); ! else ! $filesize = filesize(file_directory_path() . '/' . $image->images['_original']); ! ! $form['images'][$iid]['size'] = array('#type' => 'markup', '#value' => format_size($filesize)); ! $form['images'][$iid]['remove'] = array('#type' => 'checkbox', '#default_value' => $image->remove); ! $form['images'][$iid]['filepath'] = array('#type' => 'value', '#value' => $image->images['_original']); ! $form['images'][$iid]['filesize'] = array('#type' => 'value', '#value' => $filesize); ! $form['images'][$iid]['nid'] = array('#type' => 'value', '#value' => $image->nid); ! } } ! ! $upload = user_access('create images') && $upload; ! $existing = user_access('access content') && $existing; ! ! ! if ($upload || $existing) { ! // This div is hidden when the user uploads through JS. ! $form['new'] = array( ! '#prefix' => '
', ! '#suffix' => '
', ! ); ! $form['new']['image_attach_node_type'] = array( ! '#type' => 'hidden', ! '#value' => $node->type ! ); ! ! if ($existing) { ! // The existing image chooser ! $form['new']['iid'] = array( ! '#type' => 'select', ! '#title' => t('Attach an existing Image'), ! '#options' => _image_attach_get_image_nodes(), ! '#description' => t('Choose an image already existing on the server and attach it.') ! ); ! } ! ! if ($existing && $upload) { ! $form['new']['or'] = array( ! '#type' => 'item', ! '#value' => t('-or-'), ! '#attributes' => array('class' => 'either-choice') ! ); ! } ! ! if ($upload) { ! // The upload file name field ! $form['new']['image'] = array( ! '#type' => 'file', ! '#title' => t('Upload and attach new image'), ! '#size' => 40, ! '#description' => t('Upload a new image and attach it.') ! ); ! $form['new']['image_title'] = array( ! '#type' => 'textfield', ! '#title' => t('Image title'), ! $value => '', ! '#description' => t('The title the image will be shown with.') ! ); ! } ! ! // The submit button ! $form['new']['attach_image'] = array( ! '#type' => 'button', ! '#value' => t('Attach'), ! '#name'=> 'attach_image', ! '#attributes' => array('id' => 'attach_image') ! ); ! // The class triggers the js upload behaviour. ! $form['attach_image'] = array( ! '#type' => 'hidden', ! '#value' => url('upload/image_js', NULL, NULL, TRUE), ! '#attributes' => array('class' => 'upload') ! ); ! // Needed for JS ! $form['current']['vid'] = array( ! '#type' => 'hidden', ! '#value' => $node->vid ! ); ! } ! ! return $form; } /** * Implementation of hook_nodeapi(). */ ! function image_attach_nodeapi(&$node, $op, $teaser = FALSE, $page = FALSE) { ! $upload = variable_get('image_attach_'. $node->type .'_upload', 0); ! $existing = variable_get('image_attach_'. $node->type .'_existing', 0); ! ! if ($upload == 0 && $existing == 0) { ! return; } switch ($op) { + case 'validate': + _image_attach_validate($node); + break; case 'prepare': ! _image_attach_prepare($node, $upload, $existing); break; case 'insert': case 'update': ! _image_attach_save($node); break; case 'delete': ! _image_attach_delete($node); ! break; ! case 'delete revision': ! _image_attach_delete_revision($node); break; case 'load': ! return array('images' => _image_attach_load($node)); ! break; // Pass the body and teaser objects to the theme again to add the images case 'view': ! //if (count($node->images) && function_exists('image_display')){ if ($teaser){ ! $node->teaser = theme('image_attach_teaser', $node) . $node->teaser; ! } else { ! $node->body = theme('image_attach_body', $node) . $node->body; } ! //} ! break; ! ! } ! ! } ! ! function _image_attach_validate(&$node) { ! } ! ! function _image_attach_prepare(&$node, $upload, $existing) { ! global $user; ! ! if(count($_POST) == 0) { ! if (is_array($_SESSION['image_attach_uploaded']) && count($_SESSION['image_attach_uploaded'])) { ! foreach($_SESSION['image_attach_uploaded'] as $iid => $image) { ! node_delete($iid); ! } ! unset($_SESSION['image_attach_uploaded']); ! unset($_SESSION['image_attach_existing']); ! } ! } ! ! unset($_SESSION['image_attach_current_upload']); ! if ($upload && ($file = file_check_upload('image'))) { ! $image->uid = $user->uid; ! $image->name = $user->name; ! $image->type = 'image'; ! ! node_object_prepare($image, 'image'); ! if ($image->images) { ! $image->title = trim($node->image_title) ? $node->image_title : $file->filename; ! node_validate($image); ! if (!form_get_errors()) { ! $image = node_submit($image); ! node_save($image); ! //$image->new_image = TRUE; ! $_SESSION['image_attach_uploaded'][$image->nid] = $image; ! $_SESSION['image_attach_current_upload'] = $image->nid; ! } ! } ! } ! ! // Attach image previews to node object. ! if (is_array($_SESSION['image_attach_uploaded']) && count($_SESSION['image_attach_uploaded'])) { ! foreach($_SESSION['image_attach_uploaded'] as $iid => $image) { ! $node->images[$iid] = $image; ! } ! } ! ! if ($existing && ($iid = $_POST['edit']['iid'])) { ! $image = node_load($iid); ! ! // Check if we really loaded an image ! if ($image->nid && $image->type == 'image') { ! $_SESSION['image_attach_existing'][$image->nid] = $image; ! } else { ! drupal_set_message(t('Attached image with node id %iid not found', array('%iid' => $iid))); ! } ! } ! ! // Attach image previews to node object. ! if (is_array($_SESSION['image_attach_existing']) && count($_SESSION['image_attach_existing'])) { ! foreach($_SESSION['image_attach_existing'] as $iid => $image) { ! $node->images[$iid] = $image; ! } ! } ! ! } ! ! function _image_attach_load($node) { ! $images = array(); ! ! $result = db_query("SELECT n.* FROM {image_attach} a, {node} n WHERE a.iid = n.nid AND a.vid = %d AND n.type = 'image'", $node->vid); ! while ($row = db_fetch_object($result)) { ! if ($image = node_load($row->nid)) { ! $images[$row->nid] = $image; ! } ! } ! ! return $images; ! } ! ! function _image_attach_save($node) { ! if (is_array($node->images)) { ! foreach ($node->images as $iid => $image) { ! $image = (object)$image; ! ! if ($image->remove) { ! db_query("DELETE FROM {image_attach} WHERE vid = %d AND iid = %d", $node->vid, $image->nid); ! // Check if image is uses in other releases, before deleting it ! if (!db_num_rows(db_query('SELECT * FROM {image_attach} WHERE iid = %d', $image->nid))) { ! node_delete($image->nid); ! } ! } ! else { ! if (!db_num_rows(db_query('SELECT * FROM {image_attach} WHERE vid = %d AND iid = %d', $node->vid, $image->nid))) { ! db_query("INSERT INTO {image_attach} (nid, vid, iid) VALUES (%d, %d, %d)", $node->nid, $node->vid, $image->nid); ! } ! else { ! db_query("UPDATE {node} SET title = '%s' WHERE nid = %d", $image->title, $image->nid); ! } ! } ! ! // remove it from previews, as it is processed. ! unset($_SESSION['image_attach_uploaded'][$image->nid]); ! unset($_SESSION['image_attach_existing'][$image->nid]); ! } ! } ! } ! ! function _image_attach_delete($node) { ! $images = array(); ! $result = db_query('SELECT DISTINCT iid FROM {image_attach} WHERE nid = %d', $node->nid); ! while ($row = db_fetch_object($result)) { ! $images[] = $row->iid; ! } ! ! foreach ($images as $iid) { ! db_query("DELETE FROM {image_attach} WHERE nid = %d AND iid = %d", $node->nid, $iid); ! node_delete($iid); ! } ! } ! ! ! function _image_attach_delete_revision($node) { ! $images = array(); ! $result = db_query('SELECT iid FROM {image_attach} WHERE vid = %d', $node->vid); ! while ($row = db_fetch_object($result)) { ! $images[] = $row->iid; ! } ! ! foreach ($images as $iid) { ! db_query("DELETE FROM {image_attach} WHERE vid = %d AND iid = %d", $node->vid, $iid); ! ! // Check if image is still uses in other releases, before deleting it ! $result = db_query('SELECT vid FROM {image_attach} WHERE nid = %d AND iid = %d', $node->nid, $iid); ! if (!db_num_rows($result)) { ! node_delete($iid); ! } } } *************** *** 205,210 **** --- 434,440 ---- return $rows; } + /** * Theme the teaser. * *************** *** 214,228 **** function theme_image_attach_teaser($node){ theme_add_style(drupal_get_path('module', 'image_attach') .'/image_attach.css'); ! $image = node_load($node->iid); ! ! $info = image_get_info(file_create_path($image->images['thumbnail'])); ! $output = ''; ! $output .= '
'; ! $output .= l(image_display($image, 'thumbnail'), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE); ! $output .= '
'."\n"; ! $output .= $node->teaser; ! return $output; } /** --- 444,465 ---- function theme_image_attach_teaser($node){ theme_add_style(drupal_get_path('module', 'image_attach') .'/image_attach.css'); ! if (count($node->images) > 0) { ! $image = array_shift($node->images); ! } ! else if ($noimage_iid = variable_get('image_attach_noimage_iid', 0)) { ! $image = node_load($noimage_iid); ! } ! ! if ($image) { ! $info = image_get_info(file_create_path($image->images['thumbnail'])); ! $output = ''; ! $output .= '
'; ! $output .= '
'; ! $output .= l(image_display($image, 'thumbnail'), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE); ! $output .= '
'."\n"; ! return $output; ! } } /** *************** *** 230,244 **** */ function theme_image_attach_body($node){ theme_add_style(drupal_get_path('module', 'image_attach') .'/image_attach.css'); ! $image = node_load($node->iid); ! ! $info = image_get_info(file_create_path($image->images['thumbnail'])); ! $output = ''; ! $output .= '
'; ! $output .= l(image_display($image, 'thumbnail'), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE); ! $output .= '
'."\n"; ! $output .= $node->body; return $output; } --- 467,615 ---- */ function theme_image_attach_body($node){ theme_add_style(drupal_get_path('module', 'image_attach') .'/image_attach.css'); + + $max_width = 0; + if (count($node->images) > 0) { + $attached_images = $node->images; + } + else if ($noimage_iid = variable_get('image_attach_noimage_iid', 0)) { + $attached_images[] = node_load($noimage_iid); + } ! if (count($attached_images) > 0) { ! $images = array(); ! foreach ($attached_images as $image) { ! $info = image_get_info(file_create_path($image->images['thumbnail'])); ! $max_width = max($max_width, $info['width']); ! $images[] = '
'.l(image_display($image, 'thumbnail'), "node/$image->nid", array('title' => t('Click to see larger image')), NULL, NULL, FALSE, TRUE).'
'; ! } ! $output = '
' . implode("\n", $images) . "
\n"; ! return $output; ! } ! } ! ! function theme_image_attach_form_current(&$form) { ! theme_add_style(drupal_get_path('module', 'image_attach') .'/image_attach.css'); ! $output = ''; ! foreach (element_children($form) as $key) { ! $form[$key]['remove']['#printed'] = $form[$key]['title']['#printed'] = TRUE; ! ! $output .= '
'; ! ! if (strpos($form[$key]['remove']['#attributes']['class'], 'form-radio') === FALSE) ! $form[$key]['remove']['#attributes']['class'] .= ' form-radio'; ! $output .= ''; ! ! $output .= '
'. form_render($form[$key]['thumbnail']) ."
\n"; ! ! if (strpos($form[$key]['title']['#attributes']['class'], 'form-textfield') === FALSE) ! $form[$key]['title']['#attributes']['class'] .= ' form-textfield'; ! $output .= ''; ! $output .= "
\n"; ! } ! return $output; } + function theme_image_attach_form_new($form) { + theme_add_style(drupal_get_path('module', 'image_attach') .'/image_attach.css'); + $output = form_render($form); + return $output; + } + + function image_attach_js() { + // We only do the upload.module part of the node validation process. + $node = (object)$_POST['edit']; + $node->type = $node->image_attach_node_type; + + $upload = variable_get('image_attach_'. $node->type .'_upload', 0); + $existing = variable_get('image_attach_'. $node->type .'_existing', 0); + $enabled = $existing || $upload; + + if ($enabled) { + // Load existing node files. + $node->images = _image_attach_load($node); + + // Handle new uploads, and merge tmp files into node-files. + _image_attach_prepare($node, $upload && user_access('create images'), $existing && user_access('access content')); + _image_attach_validate($node); + + // Preserve modifications + if (is_array($_POST['edit']['images'])) { + foreach ($_POST['edit']['images'] as $iid => $image) { + if (array_key_exists($iid, $node->images)) { + $node->images[$iid]->remove = $image['remove']; + $node->images[$iid]->title = $image['title']; + } + } + } + + $form = _image_attach_form($node, $upload, $existing); + } + + foreach (module_implements('form_alter') as $module) { + $function = $module .'_form_alter'; + $function('image_attach_js', $form); + } + + $form = form_builder('image_attach_js', $form); + $output = theme('status_messages') . form_render($form); + + // We send the updated file attachments form. + print drupal_to_js(array('status' => TRUE, 'data' => $output)); + exit; + } + + + /** + * Implementation of hook_views_tables() + */ + function image_attach_views_tables() { + + $tables['image_attach'] = array( + 'name' => 'node', + 'fields' => array( + 'iid' => array( + 'name' => t('Attached Image: Display Image'), + 'handler' => array( + 'image_attach_views_handler_image_img' => t('Image'), + 'image_attach_views_handler_image_img_link' => t('Image with link'), + ), + 'option' => array( + '#type' => 'select', + '#options' => 'image_views_handler_filter_image_size', + ), + 'notafield' => true, + 'sortable' => false, + ), + ), + ); + return $tables; + } + + /** + * Views handler for displaying the image. + */ + function image_attach_views_handler_image_img($fieldinfo, $fielddata, $value, $data) { + $iid = db_result(db_query('SELECT iid FROM {image_attach} i, {node} n WHERE n.nid=%d AND n.vid=i.vid LIMIT 1', $data->nid)); + if (!$iid) { + $iid = variable_get('image_attach_noimage_iid', 0); + } + if ($iid && $node = node_load($iid)) { + return image_display($node, $fielddata['options']); + } + } + + /** + * Views handler for displaying the image in a link to the the image node + */ + function image_attach_views_handler_image_img_link($fieldinfo, $fielddata, $value, $data) { + $iid = db_result(db_query('SELECT iid FROM {image_attach} i, {node} n WHERE n.nid=%d AND n.vid=i.vid LIMIT 1', $data->nid)); + if (!$iid) { + $iid = variable_get('image_attach_noimage_iid', 0); + } + if ($iid && $node = node_load($iid)) { + return l(image_display($node, $fielddata['options']), "node/$data->nid", array(), NULL, NULL, FALSE, TRUE); + } + } +