Index: modules/img_assist/img_assist.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/img_assist.module,v retrieving revision 1.54 diff -u -p -r1.54 img_assist.module --- modules/img_assist/img_assist.module 30 Nov 2005 02:48:56 -0000 1.54 +++ modules/img_assist/img_assist.module 8 Jan 2006 06:09:29 -0000 @@ -135,17 +135,61 @@ function img_assist_settings() { if (!$upload_enabled && !$image_enabled) { drupal_set_message(t('Neither Upload module or Image module are enabled. Img_assist needs one of these modules enabled in order to work. Please do that now.'), 'error'); } + + $form['array_filter'] = array('#type' => 'value', '#value' => TRUE); - $group = form_radios(t('Display img_assist on'), 'img_assist_all', variable_get('img_assist_all', 1), array(t('on specific pages'), t('on all textareas'))); + $form['img_assist_access'] = array( + '#title' => t('Access settings'), + '#type' => 'fieldset', + '#collapsible' => true, + '#collapsed' => true, + ); + $form['img_assist_access']['img_assist_all'] = array( + '#type' => 'radios', + '#title' => t('Display img_assist on'), + '#default_value' => variable_get('img_assist_all', 1), + '#options' => array(t('on specific pages'), t('on all textareas')), + ); + if (!variable_get('img_assist_all', 1)) { - $group .= form_textarea(t('Pages'), 'img_assist_pages', variable_get('img_assist_pages', img_assist_help('admin/settings/img_assist#pages')), 40, 5, t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are 'blog' for the blog page and 'blog/*' for every personal blog. '<front>' is the front page.")); - } - $output = form_group_collapsible(t('Access settings'), $group, TRUE); - - $group = form_checkboxes(t('Hide \'inline image link\' for the following node types'), 'img_assist_no_nodes', variable_get('img_assist_no_nodes', array()), $nodetypes, t('Check the node types you do not want the ability to add images to.'), NULL, TRUE); - $group .= form_textarea(t('Image HTML template'), 'img_assist_img_html', variable_get('img_assist_img_html', img_assist_help('img_assist/template')), 50, 10, t('Enter the HTML wrap around your image tag. You can use the following variables: %image-class - CSS class name of the image. The default is "image", %img-link - a link to the original image, %node-link - a link to the original node containing the image, %nid - a nid of the original node containing the image, and %caption - a user-defined caption.')); - $group .= form_radios(t('Preload image captions'), 'img_assist_load_caption', variable_get('img_assist_load_caption', 1), array(t('Disabled'), t('Enabled')), t('If enabled, The body text from the image will be loaded as the caption by default.')); - $output .= form_group_collapsible(t('Image output settings'), $group, TRUE); + $form['img_assist_access']['img_assist_pages'] = array( + '#type' => 'textarea', + '#title' => t('Pages'), + '#default_value' => variable_get('img_assist_pages', img_assist_help('admin/settings/img_assist#pages')), + '#cols' => 40, + '#rows' => 5, + '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are 'blog' for the blog page and 'blog/*' for every personal blog. '<front>' is the front page."), + ); + } + $form['img_assist_output'] = array( + '#title' => t('Image output settings'), + '#type' => 'fieldset', + '#collapsible' => true, + '#collapsed' => true, + ); + $form['img_assist_output']['img_assist_no_nodes'] = array( + '#type' => 'checkboxes', + '#title' => t('Hide \'inline image link\' for the following node types'), + '#default_value' => variable_get('img_assist_no_nodes', array('image')), + '#options' => node_get_types(), + '#description' => t('Check the node types you do not want the ability to add images to.'), + ); + $form['img_assist_output']['img_assist_img_html'] = array( + '#type' => 'textarea', + '#title' => t('Image HTML template'), + '#default_value' => variable_get('img_assist_img_html', img_assist_help('img_assist/template')), + '#cols' => 50, + '#rows' => 10, + '#description' => t('Enter the HTML wrap around your image tag. You can use the following variables: %image-class - CSS class name of the image. The default is "image", %img-link - a link to the original image, %node-link - a link to the original node containing the image, %nid - a nid of the original node containing the image, and %caption - a user-defined caption.'), + ); + $form['img_assist_output']['img_assist_load_caption'] = array( + '#type' => 'radios', + '#title' => t('Preload image captions'), + '#default_value' => variable_get('img_assist_load_caption', 1), + '#options' => array(t('Disabled'), t('Enabled')), + '#description' => t('If enabled, The body text from the image will be loaded as the caption by default.'), + ); + if (module_exist('taxonomy')) { $vocs[0] = '<'. t('none') .'>'; @@ -153,12 +197,23 @@ function img_assist_settings() { $vocs[$vid] = $voc->name; } - if ($voc) { - $preview = form_select(t('Image preview filter'), 'img_assist_preview_filter', variable_get('img_assist_preview_filter', array()), $vocs, t('Select the vocabularies you want to be able to filter thumbnails by. This setting changes the behavior of img_assist at startup from loading all image thumbnails to displaying a list of image names until a filter is chosen.'), '', 1); - } + } + $form['img_assist_preview_settings'] = array( + '#title' => t('Preview settings'), + '#type' => 'fieldset', + '#collapsible' => true, + '#collapsed' => true, + ); + if ($voc) { + $form['img_assist_preview_settings']['img_assist_preview_filter'] = array( + '#type' => 'select', + '#title' => t('Image preview filter'), + '#default_value' => variable_get('img_assist_preview_filter', array()), + '#options' => $vocs, + '#description' => t('Select the vocabularies you want to be able to filter thumbnails by. This setting changes the behavior of img_assist at startup from loading all image thumbnails to displaying a list of image names until a filter is chosen.'), + '#multiple' => 1, + ); } - - $group = $preview; if (function_exists('_image_get_sizes')) { foreach (_image_get_sizes() as $size) { if ($size['label']) { @@ -167,13 +222,40 @@ function img_assist_settings() { } } if ($derivatives) { - $group .= form_select(t('Default derivative selection'), 'default_label', variable_get('default_label', '_original'), $derivatives, t('Select a derivative to be highlighted by default when an image is selected in the img_assist preview pane.')); - } - $group .= form_textfield(t('Default width of image thumbnail previews'), 'img_assist_default_preview_width', variable_get('img_assist_default_preview_width', 75), 6, 6, t('Enter, in pixels, the default width of an image to display in the preview pane. The smaller this number, the more images you will be able to see without scrolling.')); - $group .= form_textfield(t('Max number of images to preview'), 'img_assist_preview_count', variable_get('img_assist_preview_count', 25), 6, 6, t('Enter the threshold of the number of images to display in the directory preview pane. If there are more images for a given view, they will be displayed as hyperlinks.')); - $output .= form_group_collapsible(t('Preview settings'), $group, TRUE); + $form['img_assist_preview_settings']['default_label'] = array( + '#type' => 'select', + '#title' => t('Default derivative selection'), + '#default_value' => variable_get('default_label', '_original'), + '#options' => $derivatives, + '#description' => t('Select a derivative to be highlighted by default when an image is selected in the img_assist preview pane.'), + ); + } + $form['img_assist_preview_settings']['img_assist_default_preview_width'] = array( + '#type' => 'textfield', + '#title' => t('Default width of image thumbnail previews'), + '#default_value' => variable_get('img_assist_default_preview_width', 75), + '#size' => 6, + '#maxlength' => 6, + '#description' => t('Enter, in pixels, the default width of an image to display in the preview pane. The smaller this number, the more images you will be able to see without scrolling.'), + ); + $form['img_assist_preview_settings']['img_assist_preview_count'] = array( + '#type' => 'textfield', + '#title' => t('Max number of images to preview'), + '#default_value' => variable_get('img_assist_preview_count', 25), + '#size' => 6, + '#maxlength' => 6, + '#description' => t('Enter the threshold of the number of images to display in the directory preview pane. If there are more images for a given view, they will be displayed as hyperlinks.'), + ); + + return $form; +} - return $output; +/** + * Implementation of hook_elements(). + */ +function img_assist_elements() { + $type['textarea'] = array('#process' => array('img_assist_textarea' => array())); + return $type; } /** @@ -181,12 +263,13 @@ function img_assist_settings() { * * Add image links underneath textareas. */ -function img_assist_textarea($op, $name) { - if ($op == 'post' && _img_assist_page_match() && !strstr($_GET['q'], 'img_assist/add/image')) { - $anchor = '
'; +function img_assist_textarea($element) { + if (_img_assist_page_match($node) && !strstr($_GET['q'], 'img_assist/add/image')) { + $anchor = '
'; $image = ''; - return $anchor. $image . '
'; + $element['#suffix'] .= $anchor. $image . '
'; } + return $element; } /******************************************************************** @@ -201,7 +284,6 @@ function img_assist_create() { $textarea = $_GET['textarea'] ? $_GET['textarea'] : variable_get('img_assist_textarea', $textarea); variable_set('img_assist_textarea', $textarea); - $head = ''; $editor = ''; if ($_GET['editor']) { @@ -336,23 +418,10 @@ function img_assist_image_add() { $img_assist_dir = drupal_get_path('module', 'img_assist'); switch ($op) { - case t('Preview'): - $edit = node_validate($edit); - drupal_set_title(t('Preview')); - $output .= node_preview($edit); - break; - case t('Submit'): - if ($nid = node_submit($edit)) { - // Pass along the editor instance if there is one. - drupal_goto('img_assist/add', 'editor='. $_GET['editor']. '&textarea='. variable_get('img_assist_textarea', '')); - } - else { - drupal_set_title(t('Submit')); - $output .= node_preview($edit); - } + $output .= img_assist_node_add('image',$op); + drupal_goto('img_assist/add', 'editor='. $_GET['editor']. '&textarea='. variable_get('img_assist_textarea', '')); break; - default: $output .= node_add('image'); } @@ -485,7 +554,7 @@ function img_assist_load_images($tid = n } if (!$image) { - $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, f.* FROM {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.nid INNER JOIN {files} f ON n.nid = f.nid AND n.type = 'image' ". $where ." ORDER BY n.changed DESC")); + $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, f.* FROM {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.vid INNER JOIN {files} f ON n.nid = f.nid AND n.type = 'image' ". $where ." ORDER BY n.changed DESC")); while ($node = db_fetch_object($result)) { $node->filepath = file_create_path($node->filepath); $dim = getimagesize($node->filepath, $info); @@ -508,7 +577,7 @@ function img_assist_load_images($tid = n // NOTE: If we didn't use "LIKE 'image/%%'" here we could load other files. // Might be interesting to expand on this someday. if ($image) { - $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, f.* FROM {files} f, {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.nid WHERE f.nid = n.nid AND f.filemime LIKE 'image/%%' AND n.nid NOT IN (". implode(array_keys($image), ', ') .") ". $where ." ORDER BY n.changed DESC")); + $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, f.* FROM {files} f, {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.vid WHERE f.nid = n.nid AND f.filemime LIKE 'image/%%' AND n.nid NOT IN (". implode(array_keys($image), ', ') .") ". $where ." ORDER BY n.changed DESC")); while ($node = db_fetch_object($result)) { $node->filepath = file_create_path($node->filepath); $dim = getimagesize($node->filepath, $info); @@ -539,7 +608,7 @@ function img_assist_load_images($tid = n * Load an image from the database */ function img_assist_load_image($id, $derivatives = TRUE) { - $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, r.teaser, f.* FROM {files} f, {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.nid WHERE f.nid = n.nid AND f.fid = %d'), $id)); + $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, r.teaser, f.* FROM {files} f, {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.vid WHERE f.nid = n.nid AND f.fid = %d'), $id)); $node->filepath = file_create_path($node->filepath); if (!$derivatives) { @@ -554,7 +623,7 @@ function img_assist_load_image($id, $der foreach (_image_get_sizes() as $size) { if ($size['label'] == $node->filename) { $image_module_image = TRUE; - $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, r.teaser, f.* FROM {files} f, {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.nid WHERE f.nid = n.nid AND n.nid = %d'), $node->nid); + $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, r.teaser, f.* FROM {files} f, {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.vid WHERE f.nid = n.nid AND n.nid = %d'), $node->nid); while ($node = db_fetch_object($result)) { $node->filepath = file_create_path($node->filepath); $dim = getimagesize($node->filepath, $info); @@ -586,11 +655,8 @@ function img_assist_load_image($id, $der */ function img_assist_load_directory() { global $user; - - if ($_POST['edit']) { - $tid = $_POST['edit']['taxonomy']; - } - + + $tid = NULL; if ($_GET['user']) { $user_images = true; } @@ -606,11 +672,17 @@ function img_assist_load_directory() { $has_tid = true; } $voc = taxonomy_get_vocabulary($vid); - $filterbar .= _taxonomy_term_select($voc->name, 'taxonomy', $tid[$i], $vid, '', 0, '<'. t('none') .'>'); + $form['taxonomy']['taxonomy_'. $voc->vid] = _taxonomy_term_select($voc->name, 'taxonomy', NULL, $vid, '', 0, '<'. t('none') .'>'); $i++; } - $filterbar .= ''. form_submit(t('Go')); - $filterbar = form($filterbar). ''; + $form['submit'] = array( + '#type' => 'submit', + '#prefix' => '', + '#suffix' => '', + '#value' => t('Go') + ); + $filterbar .= drupal_get_form('img_assist_filters', $form). ''; + $tid = _img_assist_filters_get_tids(); } $resize = '[-] [+]'; @@ -676,6 +748,38 @@ function img_assist_load_directory() { } /** + * Grabs all filter values that have been submitted, and store them in a + * temporary cache. + */ +function img_assist_filters_submit($form_id, $form_values) { + $tids = array(); + foreach ($form_values as $key => $value) { + if (substr($key, 0, 9) == 'taxonomy_') { + $tids[] = $value; + } + } + _img_assist_filters_get_tids($tids); +} + +/** + * Stores filter values in a temporary cache, and returns the contents of the + * cache. + */ +function _img_assist_filters_get_tids($tids = array()) { + static $tid_cache; + + if (!isset($tid_cache)) { + $tid_cache = array(); + } + + if (!empty($tids) && is_array($tids)) { + $tid_cache = $tids; + } + + return $tid_cache; +} + +/** * Load the preview pane. */ function img_assist_load_preview($id = null) { @@ -707,7 +811,15 @@ function img_assist_load_preview($id = n $output .= l("filepath)."\" $dim border=\"1\" />", "img_assist/load/properties/$dsp_img->fid", array('target' => 'img_assist_properties'), NULL, NULL, FALSE, TRUE); $output .= "
". l($img->title, "node/$dsp_img->nid", array('target' => '_blank')). " ($dsp_img->width x $dsp_img->height)\n"; if ($image_module_image) { - $output .= form(form_select(t('Select a derivative'), 'label', $selected, $options, NULL, 'onchange=parent.img_assist_properties.location.href=this.options[selectedIndex].value')); + $form['label'] = array( + '#type' => 'select', + '#title' => t('Select a derivative'), + '#default_value' => $selected, + '#options' => $options, + '#description' => NULL, + '#attributes' => array('onchange' => 'parent.img_assist_properties.location.href=this.options[selectedIndex].value'), + ); + $output .= drupal_get_form('img_assist_load_preview', $form); } /* If the directory view is the one invoking this function */ @@ -731,7 +843,7 @@ function img_assist_load_properties($id $img_assist_editor = variable_get('img_assist_editor', ''); $on_submit_hook = $img_assist_editor. '_img_assist_on_submit'; - $on_click = function_exists($on_submit_hook) ? $on_submit_hook() : 'create_image(this.form);'; + $on_click = function_exists($on_submit_hook) ? $on_submit_hook() : 'create_image(document.forms[0]);'; if (!$id) { $id = arg(3); @@ -752,69 +864,113 @@ function img_assist_load_properties($id } } - // This isn't too much of a hack in my opinion as there aren't any security - // breeches with this user permission, it's just an advanced option that's - // confusing for beginners. - $ft_hide = ''; - if (!user_access('choose format type')) { - $ft_hide = 'style="display:none;"'; - } - - $preview = form_button(t('Show code'), 'preview', 'button', array('onClick' => 'img_preview(this.form)')). ' '; - $alt = form_textfield(t('Image description for the visually impaired'), 'alt', $img->title, 55, 255); - $dim_txt = t('Image size in pixels'); - $width_txt = t('Width'); - $width = form_textfield(null, 'width', $img->width, 3, 5, null, array('onKeyUp' => "resizew(this.form, $img->width, $img->height)")); - $height_txt = t('Height'); - $height = form_textfield(null, 'height', $img->height, 3, 5, null, array('onKeyUp' => "resizeh(this.form, $img->width, $img->height)")); - $aspect = form_checkbox(t('Maintain aspect ratio'), 'aspect', 1, 1, null); - $caption = form_textarea(t('Image caption (optional)'), 'caption', $img->caption, 70, 2); - $id_field = form_hidden('fid', $img->fid); - $id_field .= form_hidden('nid', $img->nid); - $id_field .= form_hidden('filepath', file_create_url($img->filepath)); - $id_field .= form_hidden('nodePath', url("node/$img->nid")); - $id_field .= form_hidden('origWidth', $img->width); - $id_field .= form_hidden('origHeight', $img->height); - $format_type = ' '. t('filter'); - $format_type .= '  '. t('html'). ''; - $submit = $preview . form_button(t('Insert image'), 'op', 'button', array('onClick' => $on_click. 'javascript:top.window.close();')). ' '; - $thumb = form_group(t('Image to use'), $label); + $form['imgtouse'] = array( + '#type' => 'fieldset', + '#title' => t('Image to use'), + '#prefix' => '' + ); + $form['imgtouse']['alt'] = array( + '#type' => 'textfield', + '#title' => t('Image description for the visually impaired'), + '#default_value' => $img->title, + '#size' => 55, + '#maxlength' => 255, + ); + $form['imgtouse']['caption'] = array( + '#type' => 'textarea', + '#title' => t('Image caption (optional)'), + '#default_value' => $img->caption, + '#cols' => 70, + '#rows' => 2, + ); + $form['imgsize'] = array( + '#type' => 'fieldset', + '#title' => t('Image size in pixels'), + '#prefix' => '
', + '#suffix' => '', + '#suffix' => '
' + ); + $form['imgsize']['width'] = array( + '#type' => 'textfield', + '#title' => t('Width'), + '#default_value' => $img->width, + '#size' => 3, + '#maxlength' => 5, + '#description' => null, + '#attributes' => array('onKeyUp' => "resizew(this.form, $img->width, $img->height)"), + ); + $form['imgsize']['height'] = array( + '#type' => 'textfield', + '#title' => t('Height'), + '#default_value' => $img->height, + '#size' => 3, + '#maxlength' => 5, + '#description' => null, + '#attributes' => array('onKeyUp' => "resizeh(this.form, $img->width, $img->height)"), + ); + $form['imgsize']['aspect'] = array( + '#type' => 'checkbox', + '#title' => t('Maintain aspect ratio'), + '#return_value' => 1, + '#default_value' => 1, + '#description' => null, + ); + $form['id_field']['fid'] = array( + '#type' => 'hidden', + '#value' => $img->fid, + ); + $form['id_field']['nid'] = array( + '#type' => 'hidden', + '#value' => $img->nid, + ); + $form['id_field']['filepath'] = array( + '#type' => 'hidden', + '#value' => file_create_url($img->filepath), + ); + $form['id_field']['nodePath'] = array( + '#type' => 'hidden', + '#value' => url("node/$img->nid",NULL,NULL,TRUE), + ); + $form['id_field']['origWidth'] = array( + '#type' => 'hidden', + '#value' => $img->width, + ); + $form['id_field']['origHeight'] = array( + '#type' => 'hidden', + '#value' => $img->height, + ); + if (user_access('choose format type')) { + $form['formatType'] = array( + '#type' => 'radios', + '#title' => t('format type'), + '#options' => array('filter' => t('filter'), 'html' => t('html')), + ); + } + $form['preview'] = array( + '#type' => 'button', + '#value' => t('Show code'), + '#button_type' => 'button', + '#attributes' => array('onClick' => "img_preview(document.forms[0]);") + ); + $form['insert'] = array( + '#type' => 'button', + '#value' => t('Insert image'), + '#weight' => 19, + '#attributes' => array('onClick' => $on_click . "javascript:top.window.close();"), + ); -$output = << - $alt +$output = drupal_get_form('img_assist_load_properties', $form); +$output .= << - - $thumb - - -
- $dim_txt - - - - -
$width_txt$width
$height_txt$height
 $aspect
-
- - - - $caption - -

$format_type $id_field $submit

- - EOD; - - return ($id > 0 ? form($output) : t('

Once you\'ve clicked on an above image, you can modify its properties in this pane.

')); +return ($id > 0 ? $output : t('

Once you\'ve clicked on an above image, you can modify its properties in this pane.

')); } /******************************************************************** @@ -1044,4 +1200,147 @@ function _img_assist_page_match() { return $page_match; } } + + +/** + * + */ + +function img_assist_node_add($type) { + global $user; + + $edit = isset($_POST['edit']) ? $_POST['edit'] : ''; + + // If a node type has been specified, validate its existence. + if (node_access('create', $type)) { + // Initialize settings: + $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type); + + $output = img_assist_node_form($node); + drupal_set_title(t('Submit %name', array('%name' => node_get_name($node)))); + } + else { + $output = t('You are not allowed to create content.'); + } + return $output; +} + +function img_assist_node_form($node) { + $op = isset($_POST['op']) ? $_POST['op'] : ''; + + $node = array2object($node); + node_object_prepare($node); + + // Set the id of the top-level form tag + $form['#attributes']['id'] = 'node-form'; + + /** + * Basic node information. + * These elements are just values so they are not even sent to the client. + */ + $form['nid'] = array('#type' => 'value', '#value' => $node->nid); + $form['vid'] = array('#type' => 'value', '#value' => $node->vid); + $form['uid'] = array('#type' => 'value', '#value' => $node->uid); + $form['created'] = array('#type' => 'value', '#value' => $node->created); + $form['changed'] = array('#type' => 'value', '#value' => $node->changed); + $form['type'] = array('#type' => 'value', '#value' => $node->type); + $form['#node'] = $node; + + // Get the node-specific bits. + $form = array_merge($form, node_invoke($node, 'form')); + if (!isset($form['title']['#weight'])) { + $form['title']['#weight'] = -18; + } + if (!isset($form['body']['#weight'])) { + $form['body']['#weight'] = -17; + } + + // If this is a new node, fill in the default values. + $node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); + if (!isset($node->status)) { + $node->status = in_array('status', $node_options); + } + if (!isset($node->moderate)) { + $node->moderate = in_array('moderate', $node_options); + } + if (!isset($node->promote)) { + $node->promote = in_array('promote', $node_options); + } + if (!isset($node->sticky)) { + $node->sticky = in_array('sticky', $node_options); + } + if (!isset($node->revision)) { + $node->revision = in_array('revision', $node_options); + } + + if (user_access('administer nodes')) { + // Node author information + $form['author'] = array('#type' => 'fieldset', '#title' => t('Authoring information'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -5); + $form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#required' => TRUE, '#default_value' => $node->name, '#weight' => -1); + $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#required' => TRUE, '#default_value' => $node->date); + + + // Node options for administrators + $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -5); + $form['options']['status'] = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status); + $form['options']['moderate'] = array('#type' => 'checkbox', '#title' => t('In moderation queue'), '#default_value' => $node->moderate); + $form['options']['promote'] = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote); + $form['options']['sticky'] = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky); + $form['options']['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision); + } + else { + // Don't show node options because the user doesn't have admin access. + $form['status'] = array('#type' => 'value', '#value' => $node->status); + $form['moderate'] = array('#type' => 'value', '#value' => $node->moderate); + $form['promote'] = array('#type' => 'value', '#value' => $node->promote); + $form['sticky'] = array('#type' => 'value', '#value' => $node->sticky); + $form['revision'] = array('#type' => 'value', '#value' => $node->revision); + } + + // Add the buttons. + $form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 19); + + $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 20); + if ($node->nid && node_access('delete', $node)) { + $form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 21); + } + + if ($op == t('Preview')) { + $form['#after_build'] = 'node_form_add_preview'; + } + + return drupal_get_form($node->type . '_node_form', $form, 'img_assist_node_form'); +} + +function img_assist_node_form_validate($form_id, $edit) { + node_validate($edit); +} + +function img_assist_node_form_submit($form_id, $edit) { + global $user; + + // Fix up the node when required: + $node = node_submit($edit); + + // Prepare the node's body: + if ($node->nid) { + // Check whether the current user has the proper access rights to + // perform this operation: + if (node_access('update', $node)) { + node_save($node); + watchdog('content', t('%type: updated %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); + $msg = t('The %post was updated.', array ('%post' => node_get_name($node))); + } + } + else { + // Check whether the current user has the proper access rights to + // perform this operation: + if (node_access('create', $node)) { + node_save($node); + watchdog('content', t('%type: added %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid")); + $msg = t('Your %post was created.', array ('%post' => node_get_name($node))); + } + } +} + ?> Index: modules/img_assist/properties.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/properties.js,v retrieving revision 1.13 diff -u -p -r1.13 properties.js --- modules/img_assist/properties.js 12 Jul 2005 20:07:50 -0000 1.13 +++ modules/img_assist/properties.js 8 Jan 2006 06:09:29 -0000 @@ -29,10 +29,10 @@ function resizeh(form, orig_width, orig_ * Build the HTML image tag. */ function generate_image_tag(form) { - for (i=0, n=form['formatType'].length; i