diff -ur inline/inline.module inline-hacked/inline.module
--- inline/inline.module 2004-11-22 12:04:33.000000000 +0100
+++ inline-hacked/inline.module 2005-01-04 22:50:49.000000000 +0100
@@ -56,15 +56,18 @@
function inline_nodeapi(&$node, $op, $arg) {
if(is_array($node->files) && $op == 'view') {
-
- if (preg_match_all("/\[(inline|file|attachment):(\d+)=?(.*)?\]/i", $node->body, $match)) {
+ if (preg_match_all("/\[(inline|file|attachment):([^=\\]]+)=?([^\\]]*)?\]/i", $node->body, $match)) {
foreach ($match[2] as $key => $value) {
$map[$value] = $key;
$titl = $match[3][$key];
+ $mytype = $match[1][$key];
$inline_file = _inline_filename($node, $value);
$replace = "";
- if ($inline_file != "") {
- $replace = theme('inline_html', $inline_file[0], $inline_file[1], $titl);
+ if ($inline_file != NULL) {
+ $replace = theme('inline_html', $inline_file[0], $inline_file[1], $titl, $mytype == "inline");
+ }
+ else {
+ $replace = "NOT FOUND: $value";
}
$mtch[] = $match[0][$key];
$repl[] = $replace;
@@ -77,38 +80,48 @@
}
}
-function _inline_filename(&$node, $num) {
-
+function _inline_filename(&$node, $id) {
+ if (is_numeric($id)) {
$n=1;
foreach ($node->files as $file) {
- if ($n==$num) {
+ if ($n == $id) {
return array($file->filename, file_create_url($file->filepath));
}
++$n;
}
- return '';
+ return NULL;
+ }
+ else
+ {
+ foreach ($node->files as $file) {
+ if ($file->filename == $id) {
+ return array($file->filename, file_create_url($file->filepath));
+ }
+ }
+ return NULL;
+ }
}
-function theme_inline_html($filename, $filepath, $title) {
+function theme_inline_html($filename, $filepath, $title, $allow_inline_image) {
//make a list with allowed image-tags
$extensions = 'jpg jpeg gif png';
$regex = '/\.('. ereg_replace(' +', '|', preg_quote($extensions)) .')$/i';
- if (preg_match($regex, $filepath)) {
+ if (preg_match($regex, $filepath) && $allow_inline_image) {
if ($title != "") {
- $html = ' ';
+ $html = '';
}
else {
- $html = ' ';
+ $html = '';
}
}
else {
if ($title != "") {
- $html = ' '. $title .' ';
+ $html = ''. $title .'';
}
else {
//If you comment out the first line below, and uncomment the second, the actual filename will be used for files without title attributes. (Instead of the icon 'file.gif')
- //$html = ' ';
- $html = ' '. $filename .' ';
+ //$html = '';
+ $html = ''. $filename .'';
}
}
return $html;