Index: link_node.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/link_node/link_node.info,v
retrieving revision 1.1
diff -u -p -r1.1 link_node.info
--- link_node.info	11 Oct 2007 22:42:16 -0000	1.1
+++ link_node.info	6 Sep 2008 07:12:49 -0000
@@ -1,3 +1,5 @@
 ; $Id $
 name = "Link node"
 description = "Provides an input filter that allows a node to link to other nodes."
+
+core = 6.x
\ No newline at end of file
Index: link_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/link_node/link_node.module,v
retrieving revision 1.1
diff -u -p -r1.1 link_node.module
--- link_node.module	11 Oct 2007 22:42:16 -0000	1.1
+++ link_node.module	6 Sep 2008 07:12:50 -0000
@@ -1,7 +1,8 @@
 <?php
+// $Id$
+
 /*
-This file is link_node module - It allows users to
-link a node to another node.
+@file Allows users to link a node to another node.
 
 Copyright (c) 2004 Mark Howell
 Copyright (c) 2007 Tom Chiverton
@@ -22,18 +23,6 @@ Foundation, Inc., 59 Temple Place - Suit
 
 */
 
-
-/**
- * Adds attached_node stylesheet to html head section of pages
- */
-function link_node_init() {
-  global $base_url;
-  /*if (function_exists('drupal_set_html_head')){
-  drupal_set_html_head("<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"$base_url/modules/attached_node/attached_node.css\" />");
-  }*/
-}
-
-
 /**
  * Hook which handles filtering.
  */
@@ -73,14 +62,14 @@ function link_node_filter_settings() {
       Each list below should be a comma separated list (no spaces) of what node properties users are
       allowed to override for the purposes of displaying a node.  E.g. <em>title,border</em>')
   );
-  foreach(node_get_types() as $type => $name) {
-  $form['filter_link_node']["link_node_allowed_vars_$type"] = array(
-    '#type' => 'textfield',
-    '#title' => t("Allowed parameters for %type nodes", array('%type'=>$type)),
-    '#default_value' => variable_get("link_node_allowed_vars_$type", ""),
-    '#size' => 40,
-    '#maxlength' => 256
-  );
+  foreach (node_get_types() as $type => $name) {
+    $form['filter_link_node']["link_node_allowed_vars_$type"] = array(
+      '#type' => 'textfield',
+      '#title' => t("Allowed parameters for %type nodes", array('%type' => $type)),
+      '#default_value' => variable_get("link_node_allowed_vars_$type", ""),
+      '#size' => 40,
+      '#maxlength' => 256
+    );
   }
   return $form;
 }
@@ -94,78 +83,66 @@ function link_node_filter_settings() {
  */
 function link_node_filter_process($text, $show_error_msgs=1) {
   if (variable_get("attached_node_enabled", 1)) {
+
     // *** [node:NID,a="b",c="d",width="40",etc="foo"] ***
     // first we find every tag
+
     $meta_tag_regexp = '/\[node:(\d+)(.*)\]/i';
-    $meta_tag_params_regexp = '/,\s*([\w_-]+)\s*=\s*"([^"]+)"\s*/';
-    $meta_tag_params_regexp2 = '/,\s*([\w_-]+)\s*=\s*&quot;([^,]+)&quot;\s*/';
+
     if (preg_match_all($meta_tag_regexp, $text, $match)) {
       //print("matches:<br><pre>".var_dump($match, 1)."</pre>");
       // then we make the html
       foreach ($match[1] as $key => $nid) {
         $map[$nid] = $key;
-        $node = node_load(array("nid"=>$nid));
-        if($node) {
+        $node = node_load(array("nid" => $nid));
+        if ($node) {
           // check here to see if user has permissions to access this node
-          if(!node_access("view", $node)) {
+          if (!node_access("view", $node)) {
             $matches_html[$key] = t('You do not have access to view this node');
             continue;
           }
-          
-          //drupal_set_message("found node $nid and it's of type $node->type");
 
-          // iterate over all name=value pairs and override $node values with them
-	  if ( preg_match_all($meta_tag_params_regexp, $match[2][$key], $parm_match) == 0 ){
-	    $meta_tag_params_regexp=$meta_tag_params_regexp2 ;
-	  }
+          $meta_tag_params_regexp = '/,\s*([\w_-]+)\s*=\s*"([^"]+)"\s*/';
+          $meta_tag_params_regexp2 = '/,\s*([\w_-]+)\s*=\s*&quot;([^,]+)&quot;\s*/';
+
+          if ( preg_match_all($meta_tag_params_regexp, $match[2][$key], $parm_match) == 0 ) {
+            $meta_tag_params_regexp=$meta_tag_params_regexp2 ;
+          }
+
           if (preg_match_all($meta_tag_params_regexp, $match[2][$key], $parm_match)) {
-            //print("\nparm_match = <pre>\n"); var_dump($parm_match); print("\n</pre>\n");
-            $allowed_vars = explode(',', variable_get("attached_node_allowed_vars_$node->type", ""));
-            for($i=0; $i<count($parm_match[1]); $i++) {  
+            $allowed_vars = explode(',', variable_get("link_node_allowed_vars_$node->type", ""));
+            for ($i=0; $i<count($parm_match[1]); $i++) {  
               //$parm_match[1] contains the param names, $parm_match[2] contains values
               $parm = $parm_match[1][$i];
               $val = $parm_match[2][$i];
               
               // check the name ($parm) to make sure it's an allowable value (like "align" or "border" or something)
-              if(in_array($parm, $allowed_vars)) {
+              if (in_array($parm, $allowed_vars)) {
                 //if($show_error_msgs) {
                 //  drupal_set_message("setting node param '$parm' to value '$val' for ".$node->type);
                 //}
                 $node->$parm = $val;
               }
               else {
-                if($show_error_msgs) {
-                  drupal_set_message("ignoring param '$parm' for ".$node->type." as it is not valid.  Possible values are '<code>". variable_get("attached_node_allowed_vars_$node->type", "") ."</code>'.");
+                if ($show_error_msgs) {
+                  drupal_set_message("ignoring param '$parm' for ". $node->type ." as it is not valid.  Possible values are '<code>". variable_get("attached_node_allowed_vars_$node->type", "") ."</code>'.");
                 }
               }
             }      
           }
-		else {
-//	var_dump("ignori ".$match[2][$key]."-".$node->type."-".$node->title);
-  //      var_dump( explode(',', variable_get("attached_node_allowed_vars_$node->type", "")) );
-//	var_dump( "matches:");
-//	var_dump( $match[2][$key] );
-//	$meta_tag_params_regexp = '/,\s*([\w_-]+)\s*=\s*&quot;([^,]+)&quot;\s*/';
-//	var_dump( "==");
-//	var_dump( preg_match_all($meta_tag_params_regexp, $match[2][$key], $parm_match) );
-//	var_dump( $parm_match );
-	
-}
 
-          //$matches_html[$key] = "thumbnail of node $node->nid goes here";
-          //$matches_html[$key] = theme("attached_node_thumbnail", $node);
           $matches_html[$key] = theme_link_node_thumbnail($node);//."k:".$key."v:".var_dump($match);
         }
         else {
-          if($show_error_msgs) {
-            $matches_html[$key] = theme("link_node_format", t("Nonexistent node nid: ") . "$nid.");
+          if ($show_error_msgs) {
+            $matches_html[$key] = theme("link_node_format", t("Nonexistent node nid: ") ."$nid.");
           }
           else {
             $matches_html[$key] = "";
           }
         }
       }
-      
+
       // PHP (4.3.2) str_replace appears to use some internal order
       // rather than array index when finding replace elements
       // corresponding to search elements.  To make sure that the
@@ -185,17 +162,17 @@ function link_node_filter_process($text,
  */
 function theme_link_node_thumbnail(&$node) {
 
-  $main = true;
+  $main = TRUE;
   
-  if($node->type == "image") {
+  if ($node->type == "image") {
     
     // offer theme developers and module developers to override this
-    if(function_exists("image_link_node_thumbnail")) {
+    if (function_exists("image_link_node_thumbnail")) {
       return image_link_node_thumbnail($node);
     }
   }
-  
-  $output = "<a href=\"/node/".$node->nid."\">".$node->title."</a>";
+
+  $output = l($node->title, drupal_get_path_alias('node/'. $node->nid));
 
   return $output;
 }
@@ -204,14 +181,14 @@ function theme_link_node_thumbnail(&$nod
  * Puts a box around the attached_node's content
  */
 function theme_link_node_format($content) {
-  return '<div class="attached_node">' . $content . "</div>\n";
+  return '<div class="attached_node">'. $content ."</div>\n";
 }
 
 /**
  * Clears the filter cache when any node is updated
  */
 function link_node_nodeapi(&$node, $op) {
-  if($op == "update") {
+  if ($op == "update") {
     // since this is a node-specific filter, clear the cache when nodes are updated
     cache_clear_all(null, 'cache_filter');
   }
@@ -235,8 +212,8 @@ function link_node_help($section = "admi
       [node:123]<br>
       [node:123,title="original"]<br>
       </p><p>Currently available parameters:<table border="1">');
-      foreach(node_get_types() as $type => $name) {
-        $output .= "<tr><td>" . t("Allowed parameters for <strong>$type</strong> nodes: ") . "</td><td>" . variable_get("link_node_allowed_vars_$type", "") . "</td></tr>\n";
+      foreach (node_get_types() as $type => $name) {
+        $output .= "<tr><td>". t("Allowed parameters for <strong>$type</strong> nodes: ") ."</td><td>". variable_get("link_node_allowed_vars_$type", "") ."</td></tr>\n";
       }
       $output .= t('</table></p><p>
       Site admin: If there are properties of a node that you want to allow your users to modify when referring to them,
@@ -250,8 +227,8 @@ function link_node_help($section = "admi
 /**
  * Implementation of hook_filter_tips().
  */
-function link_node_filter_tips($delta, $format, $long = false) {
-  if($long) {
+function link_node_filter_tips($delta, $format, $long = FALSE) {
+  if ($long) {
     $txt = t('<strong>Linking Nodes To Other Nodes</strong>
       <p>
       You can link nodes to other nodes using the following syntax:<br>
@@ -262,8 +239,8 @@ function link_node_filter_tips($delta, $
       [node:123]<br>
       [node:123,title="original"]<br>
       </p><p>Currently available parameters:<table border="1">');
-    foreach(node_get_types() as $type => $name) {
-      $txt .= "<tr><td>" . t("Allowed parameters for <strong>$type</strong> nodes: ") . "</td><td>" . variable_get("link_node_allowed_vars_$type", "") . "</td></tr>\n";
+    foreach (node_get_types() as $type => $name) {
+      $txt .= "<tr><td>". t("Allowed parameters for <strong>$type</strong> nodes: ") ."</td><td>". variable_get("link_node_allowed_vars_$type", "") ."</td></tr>\n";
     }
 
     $txt .= t('</table></p><p>
