Index: includes/linodef-filter.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/linodef/includes/linodef-filter.inc,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 linodef-filter.inc
--- includes/linodef-filter.inc	22 Jan 2009 11:18:40 -0000	1.1.2.6
+++ includes/linodef-filter.inc	19 Apr 2009 21:24:32 -0000
@@ -22,34 +22,29 @@
   // Define Linodef tags
   $preg = array(
 
-    // Link Node ID with user defined text.
-    "@\xf4\x80\x81\x8c#([0-9]+)\xf4\x80\x8f\x8d(.*?)\xf4\x80\x81\x8c/#\xf4\x80\x8f\x8d@se"                => "_linodef_find_node($1,'$2');",
-
+    // No options therefore comment has to be treated separately.
     // Link Node ID and embed title or field values.
     "@\[#([0-9]+)\]@e"                                      => "_linodef_find_nodesnfields($1);",
     "@\[#([0-9]+):([0-9a-z_]+)\]@e"                         => "_linodef_find_nodesnfields($1,$2);",
     "@\[#([0-9]+):([0-9a-z_]+):([0-9]+)\]@e"                => "_linodef_find_nodesnfields($1,$2,$3);",
 
-    // Link Node ID and embed title or field values, comment has to be substituted too.
-    "@\[#([0-9]+?) (.+?)\]@e"                                => "_linodef_find_nodesnfields($1);",
-    "@\[#([0-9]+?):([0-9a-z_]+?) (.+?)\]@e"                  => "_linodef_find_nodesnfields($1,$2);",
-    "@\[#([0-9]+?):([0-9a-z_]+?):([0-9]+?) (.+?)\]@e"        => "_linodef_find_nodesnfields($1,$2,$3);",
+    // Link Node ID and embed title or field values, comment will be substituted.
+    "@\[#([0-9]+?) [^\]\r\n]+\]@e"                          => "_linodef_find_nodesnfields($1);",
+    "@\[#([0-9]+?):([0-9a-z_]+?) [^\]\r\n]+\]@e"            => "_linodef_find_nodesnfields($1,$2);",
+    "@\[#([0-9]+?):([0-9a-z_]+?):([0-9]+?) [^\]\r\n]+\]@e"  => "_linodef_find_nodesnfields($1,$2,$3);",
     
-    // Embed view without options.
+    // Embed view.
     "@\[#([0-9a-zA-Z_]+?)\]@e"                              => "_linodef_find_view($1);",
-    "@\[#([0-9a-zA-Z_]+?) (.+?)\]@e"                        => "_linodef_find_view($1);",
+    "@\[#([0-9a-zA-Z_]+?) [^\]\r\n]+\]@e"                   => "_linodef_find_view($1);",
 
-    // ID with options, alphanumeric for viewname.
-    "@\[#([0-9a-zA-Z_]+?),([0-9a-zA-Z,=_]*)\]@e"                           => "_linodef_filter_processoptions($1,False,0,'$2');",
-    "@\[#([0-9]+?):([0-9a-z_]+?),([0-9a-zA-Z,=_]*)\]@e"                    => "_linodef_filter_processoptions($1,$2,0,'$3');",
-    "@\[#([0-9]+?):([0-9a-z_]+?):([0-9]+?),([0-9a-zA-Z,=_]*)\]@e"          => "_linodef_filter_processoptions($1,$2,$3,'$4');",
-
-    // ID with options, alphanumeric for viewname, comment has to be substituted too.
-    "@\[#([0-9a-zA-Z_]+?),([0-9a-zA-Z,=_]*) (.+?)\]@e"                     => "_linodef_filter_processoptions($1,False,0,'$2');",
-    "@\[#([0-9]+?):([0-9a-z_]+?),([0-9a-zA-Z,=_]*) (.+?)\]@e"              => "_linodef_filter_processoptions($1,$2,0,'$3');",
-    "@\[#([0-9]+?):([0-9a-z_]+?):([0-9]+?),([0-9a-zA-Z,=_]*) (.+?)\]@e"    => "_linodef_filter_processoptions($1,$2,$3,'$4');",
+    // ID with options, alphanumeric for viewname, possible comment will be substituted.
+    '@\[#([0-9a-zA-Z_]+),((?:[,0-9a-zA-Z]*(?:="[^"\]\r\n]*")*)*)[^\]\r\n]*\]@e'                 => '_linodef_filter_processoptions($1,False,0,"$2");',
+    '@\[#([0-9]+):([0-9a-z_]+),((?:[,0-9a-zA-Z]*(?:="[^"\]\r\n]*")*)*)[^\]\r\n]*\]@e'           => '_linodef_filter_processoptions($1,$2,0,"$3");',
+    '@\[#([0-9]+):([0-9a-z_]+):([0-9]+),((?:[,0-9a-zA-Z]*(?:="[^"\]\r\n]*")*)*)[^\]\r\n]*\]@e'  => '_linodef_filter_processoptions($1,$2,$3,"$4");',
 
-    // Backwards compatibility for RC1 syntax.
+    // Backwards compatibility for RC1/2 syntax.
+    // Link Node ID with user defined text.
+    "@\xf4\x80\x81\x8c#([0-9]+)\xf4\x80\x8f\x8d(.*?)\xf4\x80\x81\x8c/#\xf4\x80\x8f\x8d@se"                => "_linodef_find_node($1,'$2');",
     // Embed title or field values, add no link.
     "@\[#nl([0-9]+)\]@e"                                    => "_linodef_filter_processoptions($1,False,0,'nolink');",
     "@\[#nl([0-9]+):([0-9a-z_]+)\]@e"                       => "_linodef_filter_processoptions($1,$2,0,'nolink');",
@@ -66,53 +61,74 @@
 function _linodef_filter_processoptions($id, $fieldname = False, $valuenumber = 0, $option_string = '') {
     $type = '';
     $message = '';
-    if (!empty($option_string) && $options = explode(',', $option_string)) {
-        // Get and validate ID type: Last occurence determines ID type (if user does the fault including both).
-        foreach ($options as $value) {
-            switch ($value) {
-            case 'nid':
-                $type = 'nid';
-                break;
-            case 'tid':
-                $message .= _linodef_filter_validate_idtype($id, $value, $fieldname, $type);
-                break;
-            case 'viewid':
-                $message .= _linodef_filter_validate_idtype($id, $value, $fieldname, $type);
-                break;
-            case 'cid':
-                $message .= _linodef_filter_validate_idtype($id, $value, $fieldname, $type);
-                break;
-            }
-        }
-        // Get and validate options.
-        foreach ($options as $value) {
-            if ($value != 'nid' && $value != 'tid' && $value != 'viewid' && $value != 'cid') {
-                if ($value == '') {
-                    $message .= linodef_message(array('custom' => t('Enter a further option for Linodef tag with id %id or remove the last comma inside the tag', array('%id' => $id))), TRUE, 'warning');
+    if (!empty($option_string)) {
+    
+        // Replace , inside "" before exploding. Replace it back at option.
+        $option_string = preg_replace('@(="[^"]*")@e', 'str_replace(",", "\xf4\x80\x81\x8c", "$1")', $option_string);
+        // Replace " for backwards compatibility. However in messages those " won't appear even if entered.
+        $option_string = str_replace('"', "", $option_string);
+        
+        if ($options = explode(',', $option_string)) {
+            // Get and validate ID type: Last occurence determines ID type (if user does the fault including both).
+            foreach ($options as $value) {
+                switch ($value) {
+                case 'nid':
+                    $type = 'nid';
+                    break;
+                case 'tid':
+                    $message .= _linodef_filter_validate_idtype($id, $value, $fieldname, $type);
+                    break;
+                case 'viewid':
+                    $message .= _linodef_filter_validate_idtype($id, $value, $fieldname, $type);
+                    break;
+                case 'cid':
+                    $message .= _linodef_filter_validate_idtype($id, $value, $fieldname, $type);
+                    break;
                 }
-                // Common values, need no ID type validation, but if no ID type set, use nid (in case no other option is provided which sets ID type automatically)
-                elseif ($value == 'nolink') {
-                    $options[$value] = TRUE;
-                    if (!$type) {
-                        $type = 'nid';
+            }
+            // Get and validate options.
+            foreach ($options as $value) {
+                if ($value != 'nid' && $value != 'tid' && $value != 'viewid' && $value != 'cid') {
+                    if ($value == '') {
+                        $message .= linodef_message(array('custom' => t('Enter a further option for Linodef tag with id %id or remove the last comma inside the tag', array('%id' => $id))), TRUE, 'warning');
+                    }
+                    // Common values, need no ID type validation, but if no ID type set, use nid (in case no other option is provided which sets ID type automatically)
+                    elseif ($value == 'nolink') {
+                        $options[$value] = TRUE;
+                        if (!$type) {
+                            $type = 'nid';
+                        }
+                    }
+                    elseif (substr($value, 0, 8) == 'linktext') {
+                        $linktext = substr($value, 9);
+                        if (strlen($linktext) > 0) {
+                            // Replace , back.
+                            $options[substr($value, 0, 8)] = str_replace("\xf4\x80\x81\x8c", ",", $linktext);
+                        }
+                        else {
+                            $message .= linodef_message(array('warning' => array('option ignored' => array('%id' => $id, '%option' => substr($value, 0, 8))), 'explanation' => array('empty value' => TRUE)), TRUE);
+                        }
+                        if (!$type) {
+                            $type = 'nid';
+                        }
+                    }
+                    // ID type: nid
+                    elseif (substr($value, 0, 11) == 'translation') {
+                        $message .= _linodef_filter_validate_option($id, $value, 'nid', substr($value, 0, 11), substr($value, 12, 2), $options, $type);
+                    }
+                    // ID type: viewid
+                    elseif (substr($value, 0, 11) == 'viewdisplay') {
+                        $message .= _linodef_filter_validate_option($id, $value, 'viewid', substr($value, 0, 11), substr($value, 12), $options, $type);
+                    }
+                    elseif (substr($value, 0, 8) == 'viewargs') {
+                        $message .= _linodef_filter_validate_option($id, $value, 'viewid', substr($value, 0, 8), substr($value, 9), $options, $type);
+                    }
+                    elseif ($value == 'viewtitle') {
+                        $message .= _linodef_filter_validate_option($id, $value, 'viewid', $value, TRUE, $options, $type);
+                    }
+                    else {
+                        $message .= linodef_message(array('warning' => array('option unknown' => array('%id' => $id, '%option' => $value))), TRUE);
                     }
-                }
-                // ID type: nid
-                elseif (substr($value, 0, 11) == 'translation') {
-                    $message .= _linodef_filter_validate_option($id, $value, 'nid', substr($value, 0, 11), substr($value, 12, 2), $options, $type);
-                }
-                // ID type: viewid
-                elseif (substr($value, 0, 11) == 'viewdisplay') {
-                    $message .= _linodef_filter_validate_option($id, $value, 'viewid', substr($value, 0, 11), substr($value, 12), $options, $type);
-                }
-                elseif (substr($value, 0, 8) == 'viewargs') {
-                    $message .= _linodef_filter_validate_option($id, $value, 'viewid', substr($value, 0, 8), substr($value, 9), $options, $type);
-                }
-                elseif ($value == 'viewtitle') {
-                    $message .= _linodef_filter_validate_option($id, $value, 'viewid', $value, TRUE, &$options, &$type);
-                }
-                else {
-                    $message .= linodef_message(array('warning' => array('option unknown' => array('%id' => $id, '%option' => $value))), TRUE);
                 }
             }
         }
@@ -189,7 +205,12 @@
         $type = $idtype;
     }
     if ($type == $idtype) {
-        $options[$optionkey] = $optionvalue;
+        if (strlen($optionvalue) > 0 || $optionvalue == TRUE) {
+            $options[$optionkey] = $optionvalue;
+        }
+        else {
+            return linodef_message(array('warning' => array('option ignored' => array('%id' => $id, '%option' => $option)), 'explanation' => array('empty value' => TRUE)), TRUE);
+        }
     }
     else {
         return linodef_message(array('warning' => array('option ignored' => array('%id' => $id, '%option' => $option)), 'explanation' => array('option not compatible with idtype' => array('%idtype' => $type, '%option' => $option))), TRUE);
@@ -303,6 +324,9 @@
             return $output;
         }
         else {
+            if (isset($options['linktext'])) {
+                $output = $options['linktext'];
+            }
             // l() does check_plain on $text and does any path aliases if required (thx @AjK). html => true let l() doesn't do check_plain.
             return l($output, 'node/'. $node->nid, array('html' => true, 'attributes' => array('title' => t('Node') .' '. $node->nid .': '. $node->title)));
         }
@@ -334,7 +358,13 @@
             return check_plain($term->name);
         }
         $termlink = taxonomy_term_path($term);
-        return l($term->name, $termlink, array('attributes' => array('title' => t('Shows a teaser list of nodes using term !term', array('!term' => $term->name)))));
+        if (isset($options['linktext'])) {
+            $output = $options['linktext'];
+        }
+        else {
+            $output = $term->name;
+        }
+        return l($output, $termlink, array('attributes' => array('title' => t('Shows a teaser list of nodes using term !term', array('!term' => $term->name)))));
     }
     else {
         return linodef_message(array('error' => array('term' => $tid, 'type' => 'not found')), TRUE);
@@ -372,6 +402,9 @@
             if ($url_args) {
                 $path .= '/'. $url_args;
             }
+            if (isset($options['linktext'])) {
+                $output = $options['linktext'];
+            }
             return l($output, $view->get_url($args, $path), array('html' => true, 'attributes' => array('title' => t('Show !view', array('!view' => $output)))));
         }
         else {
Index: linodef.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/linodef/linodef.module,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 linodef.module
--- linodef.module	21 Jan 2009 17:19:39 -0000	1.1.2.4
+++ linodef.module	19 Apr 2009 12:47:28 -0000
@@ -245,6 +245,9 @@
                     case 'option fieldname set':
                         $explanation[$key] = t('since a fieldname is set and therefore the ID type is always %nid (node ID)', array('%nid' => 'nid'));
                         break;
+                    case 'empty value':
+                        $explanation[$key] = t('since it has no value');
+                        break;
                     case 'option not compatible with idtype':
                         if ($value['%idtype'] && $value['%option']) {
                             $explanation[$key] = t('since the ID type %idtype does not use the option %option', $value);

