I've done some minor changes here to additionally support the attachment module. Inline module now works for both, upload module and attachment module at the same time. Although attachment module is disabled automatically if upload module is active, concurrent use of both modules works, too.

I've also moved some code away from the theming functions in favor of theme overriding functions. Please keep it always as simple as possible for designers to override these.

Plus, I've added the possibility for mime type based file icons if the theme is providing some. These have to be stored in a subfolder /mime below your current theme directory.

Also added some remarks to functions.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Title: Compatility with attachment module / theming / file type icons » Compatibility w/ attachment module / theming / file type icons

typo

Bèr Kessels’s picture

Status: Needs review » Needs work

Your forgot to provide a new patch that fixes the typo.

sun’s picture

Status: Needs work » Needs review

just a typo in the issue title...
I assume for that no patch update is required...? ;)

sun’s picture

Did anyone test this patch?

sun’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
5.08 KB

Inlcuded patch now additionally takes into account:

  • Inline filter tag title (passed after '=') was not used if given - btw did this ever work? Looked hard at the code but couldn't find re-usage of $titl ... If a title is passed to inline now, this title always has precedence.
  • $node->files seems to be an array now. Already reported here. So the resulting $file should always be returned as object. This was already done for attachments, but not for uploads.
  • Optimized code for attachment module compatibility.

This patch has been tested with MySQL and PostGreSQL.

sun’s picture

Title: Compatibility w/ attachment module / theming / file type icons » attachment module/theming/mime type icons/title
FileSize
8 KB
sun’s picture

FileSize
8.3 KB

Inline module produced errors if there are no files attached to a node.
Attached patch takes this into account.

Now tested with Windows and Linux, MySQL and PostGreSQL and any combination of installed modules and files/attachments (upload module and attachment module).

sun’s picture

FileSize
8.3 KB

According to Drupal style rules, inline module has to use CSS class inline in its output.

sun’s picture

Richard, are there any problems with this patch?

Richard Archer’s picture

No, the problem is that I'm flat out like a lizard drinking.

I want to spend a good solid day on inline really soon. I want to get some of Bert's new syntax into the 4.7 branch of inline before too many people install it for 4.7. And there are several other patches that look good but need further analysis. And of course there's work to merge all these patches together.

I'll try to stay up late tonight or tomorrow and get the "ready" patches all committed.

sun’s picture

FileSize
8.72 KB

Reworked the display of file type icons. In short,

<a>(icon) Linktext</a>

is now

<a>(icon)</a> <a>Linktext</a> [if a file type icon exists]

or

<a>&raquo; Linktext</a> [if no file type icon exists]

sun’s picture

FileSize
14.37 KB

As requested by eric in http://drupal.org/node/64445 here is the comlete inline module with the patch already applied.

ec’s picture

Sun, thank you for your file but there is still something wrong for me. I always got NOT FOUND: when I use [inline:my_file.xx], thought I know it works with the current inline cvs ! I may miss something ? Any idea ? regards, eric.

PS : did I say I'm using it with a 471

sun’s picture

FileSize
9.26 KB
  • Fixed inlining of file uploads ($node->files is an object on view, an array on preview).
  • Fixed replacement of numeric inline tags for file uploads (files are stored with database file ID).
  • Cleaned code.
boriso’s picture

thanks for all the good work Sun. However, things are getting a bit messy. I tried to patch the file, but got some problems. When I try to use the file ID, I get database errors, when I use the file name, the file name still shows up on the page (in addition to the given name). Maybe I did the patching wrongly? Perhaps you could provid with the latest version, everything already patched?

thanks in advance,
boris

sun’s picture

FileSize
14.89 KB

@boriso: Patched version of working inline module attached.

Bèr Kessels’s picture

Status: Reviewed & tested by the community » Needs work

Patch fails.

Also: This patch tries to do too many things in one (which makes it very hard to maintain and review).

Lets try to solve the issues one at a time. Leave this issue for integration with attachement.module, move the preview issues etc to to other threads.

lisa’s picture

Posts seem to indicate people are having problems with patch #5, 6 and 7. I just want to fix the problem that titles are not displaying as they should with Drupal 4.7.2. Instead of seeing title, file name is displayed.

When I specify a title like [file:myfile.pdf=mytitle], inline.module ignores title and provides a link like

<a href="myfile.pdf">myfile.pdf</a>

it should be

<a href="myfile.pdf">mytitle</a>

Which patch should I apply to fix this? Patch 0?

Also, what is the difference between [file:myfile.pdf=mytitle] and [attachment:myfile.pdf=mytitle]? They seem to function the same?

Thanks.

sun’s picture

Thanks Bèr. I will update the patch and divide it into more than one issue shortly.
I'll try to find some time at the weekend.

ymcp’s picture

I just tried the "inline_7.module" patched module, and it does seem to fix the "title not shown" bug.

Spotted a little typo in the inline_filter_tips() text: "will be replaced by... file1.pdf.png" should be "file1.pdf".

I like the idea of the "{current_theme}/mime" folder containing little icons showing the file tye... must give it a try!

ymcp’s picture

Tried it with a couple of icons. Looks great! Well done!

The only thing that I'm not so keen on is that when you use something like "[file:myfile.pdf=My File]", you get this:

[icon] My File (11.66 KB)
myfile.pdf

I would prefer just this:

[icon] My File (11.66 KB)

The file name is included in the pop-up "title" anyway, and the whole reason why I would want to use my own "title" is to hide what might be a nasty long filename.

Anyway, a quick bit off CSS soon fixed that:

.inline dd { display: none; }

It might be worth including a tip about this in the README.txt (and supplying a few demo icons) when this module is next released.

On the subject of icons - wouldn't it make more sense to have the "mime" folder as a sub-directory of this module rather than in the theme?

Not complaining though... I think this patch is a *great* improvement.

sun’s picture

Title: attachment module/theming/mime type icons/title » attachment module support
Status: Needs work » Needs review
FileSize
4.25 KB

Here we go - I've separated all those new features to individual issues:

@ymcp: Bad description seems to be a bug of this new feature. I will analyze this shortly. But it looks like upload.module already provides $file->description while I'm trying to set it as the case arises. Mime type icon files have to be stored for each theme to allow different icons for different sites on a Drupal multi-site installation. Don't know if it would be a good idea to include default mime type icons with inline.module - because of copyright issues on the one hand and different looks for Drupal sites on the other hand (I'm not a fan of full-featured out-of-the-box designs regarding CMSs). Please post further comments regarding mime type icons in http://drupal.org/node/74622.

@Bèr: All those offshoots are based on the current CVS now. But it won't be possible to patch inline.module with those patches step by step, since they are overlapping in some cases.

havran’s picture

Bit. off topic but i have little idea. For simpler use inline module with TinyMCE editor i have use in my template.php this function:

<?php
/**
* Theme the attachments list. (from upload.module -> themeupload_form_current())
*/
function phptemplate_upload_form_current(&$form) {
$counter = 1;

$mime_type_array['image'] = array('image/jpeg','image/pjpeg','image/gif','image/png');

$header = array(t('Delete'), t('List'), t('Description'), t('Size'), t('Insert inline picture'));

foreach (element_children($form) as $key) {
// check if is image
if (in_array($form[$key]['filemime']['#value'],$mime_type_array['image'])) {
$typ_image = true;
}
else {
$typ_image = false;
}
$row = array();
$row[] = form_render($form[$key]['remove']);
$row[] = form_render($form[$key]['list']);
$row[] = form_render($form[$key]['description']);
$row[] = form_render($form[$key]['size']);
// insert inline tag into textarea
if ($typ_image) {
$row[] = "insert image code";
}
else {
$row[] = '';
}
$rows[] = $row;

$counter++;
}
$output = theme('table', $header, $rows);
$output .= form_render($form);
return $output;
}

Maybe is there better way integrate this funcionality into inline.module?

havran’s picture

Ups, sorry for this... Maybe someone can delete previous post?

/**
 * Theme the attachments list.
 */
function phptemplate_upload_form_current(&$form) {
  $counter = 1;

  $mime_type_array['image'] = array('image/jpeg','image/pjpeg','image/gif','image/png');
  
  $header = array(t('Delete'), t('List'), t('Description'), t('Size'), t('Inline picture'));

  foreach (element_children($form) as $key) {
    // is image?
    if (in_array($form[$key]['filemime']['#value'],$mime_type_array['image'])) {
      $typ_image = true;
    }
    else {
      $typ_image = false;
    }
    $row = array();
    $row[] = form_render($form[$key]['remove']);
    $row[] = form_render($form[$key]['list']);
    $row[] = form_render($form[$key]['description']);
    $row[] = form_render($form[$key]['size']);
    // if is image create link for insertting inline code
    if ($typ_image) {
      $row[] = "<a href=\"javascript:tinyMCE.execInstanceCommand('mce_editor_0','mceInsertContent',true,'[inline:".$counter."]')\">".t('insert code for image')."</a>";
    }
    else {
      $row[] = '';
    }
    $rows[] = $row;
    
    $counter++;
  }
  $output = theme('table', $header, $rows);
  $output .= form_render($form);
  return $output;
}

This code simple add new column to attachements table with link for insert inline image code into textarea.

Bèr Kessels’s picture

This looks very good. Let us dive into these issues one a time and get them reviewed and patched. (one a time).

I realise this is very suboptimal, but unfortunately another route does not really work right now. I mean: nearly all of the issues in here are from your hand, just updating the issue with latest heads :)

I would love to see the issues solved.

@Richard: I would like to discuss CVS access so that I can get the issues solved. There are a load of issues solved but waiting commits, for example: I fixed the previews.

Bèr

sun’s picture

@havran: Please create a new issue for your feature request. Use this link: http://drupal.org/node/add/project_issue/inline/feature

sun’s picture

Status: Needs review » Postponed

Marking this issue as dependent on http://drupal.org/node/80170

sun’s picture

Status: Postponed » Closed (won't fix)

Attachment module is dead and will not be developed further.