Index: inline.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/inline/inline.info,v retrieving revision 1.3 diff -u -p -r1.3 inline.info --- inline.info 15 Jun 2008 02:39:45 -0000 1.3 +++ inline.info 8 Aug 2008 21:39:21 -0000 @@ -2,4 +2,5 @@ name = Inline description = Allows attached files to be placed into the body of a node either automatically or by using simple tags. package = Input filters -dependencies = upload +dependencies[] = upload +core = 6.x Index: inline.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/inline/inline.module,v retrieving revision 1.32 diff -u -p -r1.32 inline.module --- inline.module 5 Jul 2008 00:20:18 -0000 1.32 +++ inline.module 8 Aug 2008 21:50:23 -0000 @@ -5,18 +5,15 @@ /** * Implementation of hook_menu(). */ -function inline_menu($may_cache) { +function inline_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/inline', - 'title' => t('Inline'), - 'description' => t('Manage automatic and manual inclusion of attachments in the content of your posts.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('inline_settings'), - 'access' => user_access('administer inline settings'), - ); - } + $items['admin/settings/inline'] = array( + 'title' => 'Inline', + 'description' => 'Manage automatic and manual inclusion of attachments in the content of your posts.', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('inline_settings'), + 'access arguments' => array('administer inline settings'), + ); return $items; } @@ -30,13 +27,13 @@ function inline_perm() { /** * Implementation of hook_help(). */ -function inline_help($section = 'admin/help#inline') { - switch ($section) { +function inline_help($path, $arg) { + switch ($path) { case 'admin/help#inline': return t('

Sometimes a user may want to add an image or a file inside the body of a node. This can be done with special tags that are replaced by links to the corresponding uploaded file. If the file is an image, it will be displayed inline, otherwise a link to the file will be inserted. To enable this feature and learn the proper syntax, visit the filters configuration screen.

', array('!filters' => url('admin/filters'))); case 'filter#short-tip': - return t('You may add links to files uploaded with this node using special tags', array('!explanation-url' => url('filter/tips', NULL, 'image'))); + return t('You may add links to files uploaded with this node using special tags', array('!explanation-url' => url('filter/tips', array('fragment' => 'image')))); case 'filter#long-tip': return t('

You may link to files uploaded with the current node using special tags. The tags will be replaced by the corresponding files. Syntax: [inline:file_id]. Parameter: file_id represents the file uploaded with the node in which to link, assuming that the first uploaded file is labeled as 1 and so on.

@@ -147,7 +144,7 @@ function inline_settings() { * * Allows to enable/disable auto-inline support for each content type. */ -function inline_form_alter($form_id, &$form) { +function inline_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'node_type_form') { $node_type = $form['orig_type']['#value']; $form['workflow']['upload_inline'] = array( @@ -176,7 +173,7 @@ function inline_filter($op, $delta = 0, switch ($op) { case 'list': return array(0 => t('Inline file filter')); - + case 'description': return t('Substitutes [inline:xx] tags with the xxth file uploaded with the node.'); @@ -213,7 +210,7 @@ function inline_filter_tips($delta, $for will be replaced by <a href=file1.pdf.png>test</a>') .'

'; } else { - return t('You may use [inline:xx] tags to display uploaded files or images inline.', array('!inline_help' => url("filter/tips/$format", NULL, 'filter-inline'))); + return t('You may use [inline:xx] tags to display uploaded files or images inline.', array('!inline_help' => url("filter/tips/$format", array('fragment' => 'filter-inline')))); } } @@ -249,7 +246,7 @@ function inline_nodeapi(&$node, $op, $ar return; case 'prepare': - case 'submit': + case 'presave': $node->teaser = _inline_replace_numbers($node, 'teaser'); $node->body = _inline_replace_numbers($node, 'body'); return; @@ -304,81 +301,27 @@ function inline_prepare_file_object($fil } /** - * Return HTML for a link to a file. - */ -function theme_inline_as_link($file) { - // Prepare link text with title or filename. - $linktext = ($file->title ? $file->title : $file->filename); - - return l($linktext, file_create_url($file->filepath), array('title' => t('Download: @name (@size)', array('@name' => $file->filename, '@size' => format_size($file->filesize))))); -} - -/** - * Return HTML for an image. - */ -function theme_inline_img($file, $field) { - // Prepare link text with inline title, file description or filename. - $title = (!empty($file->title) ? $file->title : (!empty($file->description) ? $file->description : $file->filename)); - $inline_preset = $field == 'teaser' ? 'inline_teaser_preset' : 'inline_full_preset'; - - if (module_exists('imagecache') && variable_get($inline_preset, '') != '') { - $image = theme('imagecache', - variable_get($inline_preset, ''), - $file->filepath, - $title, - $title, - array('class' => 'inline') - ); - } - else { - $image = theme('image', - $file->filepath, - $title, - $title, - array('class' => 'inline') - ); - } - - if (variable_get('inline_link_img', '1')) { - $attributes = array( - 'class' => 'inline-image-link', - 'title' => t("View") .': '. $title, - ); - $html = l($image, $file->filepath, $attributes, NULL, NULL, FALSE, TRUE); - } - else { - $html = $image; - } - - return $html; -} - -/** - * Insert an image in front of node teaser. - * - * @param object $node - * The node object to process. - * @param object $file - * A file object of an image to insert. - * @param string $field - * The field name to prepend with the image. + * Implementation of hook_theme(). */ -function theme_inline_add_to_teaser($node, $file, $field) { - return theme('inline_img', $file, $field) . $node->teaser; -} - -/** - * Insert an image in front of node body. - * - * @param object $node - * The node object to process. - * @param object $file - * A file object of an image to insert. - * @param string $field - * The field name to prepend with the image. - */ -function theme_inline_add_to_body($node, $file, $field) { - return theme('inline_img', $file, $field) . $node->body; +function inline_theme() { + return array( + 'inline_as_link' => array( + 'arguments' => array('link' => NULL), + 'file' => 'inline.theme.inc', + ), + 'inline_img' => array( + 'arguments' => array('file' => NULL, 'field' => NULL), + 'file' => 'inline.theme.inc', + ), + 'inline_add_to_teaser' => array( + 'arguments' => array('node' => NULL, 'file' => NULL, 'field' => NULL), + 'file' => 'inline.theme.inc', + ), + 'inline_add_to_body' => array( + 'arguments' => array('node' => NULL, 'file' => NULL, 'field' => NULL), + 'file' => 'inline.theme.inc', + ) + ); } /** Index: inline.theme.inc =================================================================== RCS file: inline.theme.inc diff -N inline.theme.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ inline.theme.inc 8 Aug 2008 21:49:05 -0000 @@ -0,0 +1,83 @@ +title ? $file->title : $file->filename); + + return l($linktext, file_create_url($file->filepath), array('attributes' => array('title' => t('Download: @name (@size)', array('@name' => $file->filename, '@size' => format_size($file->filesize)))))); +} + +/** + * Return HTML for an image. + */ +function theme_inline_img($file, $field) { + // Prepare link text with inline title, file description or filename. + $title = (!empty($file->title) ? $file->title : (!empty($file->description) ? $file->description : $file->filename)); + $inline_preset = $field == 'teaser' ? 'inline_teaser_preset' : 'inline_full_preset'; + + if (module_exists('imagecache') && variable_get($inline_preset, '') != '') { + $image = theme('imagecache', + variable_get($inline_preset, ''), + $file->filepath, + $title, + $title, + array('class' => 'inline') + ); + } + else { + $image = theme('image', + $file->filepath, + $title, + $title, + array('class' => 'inline') + ); + } + + if (variable_get('inline_link_img', '1')) { + $attributes = array( + 'class' => 'inline-image-link', + 'title' => t("View") .': '. $title, + ); + $html = l($image, $file->filepath, array('attributes' => $attributes, 'html' => true)); + } + else { + $html = $image; + } + + return $html; +} + +/** + * Insert an image in front of node teaser. + * + * @param object $node + * The node object to process. + * @param object $file + * A file object of an image to insert. + * @param string $field + * The field name to prepend with the image. + */ +function theme_inline_add_to_teaser($node, $file, $field) { + return theme('inline_img', $file, $field) . $node->teaser; +} + +/** + * Insert an image in front of node body. + * + * @param object $node + * The node object to process. + * @param object $file + * A file object of an image to insert. + * @param string $field + * The field name to prepend with the image. + */ +function theme_inline_add_to_body($node, $file, $field) { + return theme('inline_img', $file, $field) . $node->body; +} + +