Index: release/project_release.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/release/project_release.module,v
retrieving revision 1.42
diff -u -p -r1.42 project_release.module
--- release/project_release.module	19 Aug 2007 08:07:18 -0000	1.42
+++ release/project_release.module	2 Dec 2007 09:59:15 -0000
@@ -911,6 +911,56 @@ function theme_project_release_version_f
 
 
 /**
+ * @defgroup project_release_filter Issue number to link filter
+ */
+
+/**
+ * Implementation of hook_form_filter_tips()
+ * @ingroup project_release_filter
+ */
+function project_release_filter_tips($delta, $format, $long = FALSE) {
+  if ($long) {
+    return t('References to project issues (in the form of #12345) turn into links automatically, with the title of the issue appended. Issues with certain statuses are crossed out');
+  }
+  else {
+    return t('Project issue numbers (ex. #12345) turn into links automatically.');
+  }
+}
+
+/**
+ * Implementation of hook_form_filter()
+ * @ingroup project_release_filter
+ */
+function project_release_filter($op, $delta = 0, $format = -1, $text = '') {
+  switch ($op) {
+    case 'list':
+      return array(0 => t('Issue to link filter'));
+    case 'description':
+      return t('Converts references to project issues (in the form of #12345) into links');
+    case 'prepare':
+      return $text;
+    case 'process':
+//TODO: form (customize array of striked issue state ids)
+      $striked = array('2','3','4','5','6','7','8');
+      $regex = '(#\d+)';
+      $regex = '(?<!\w)'.$regex.'(?![^<]*<\/a>|\w)';
+      $offset = 0;
+      while(preg_match('/'.$regex.'/', $text, $preg_matches, PREG_OFFSET_CAPTURE, $offset)) {
+        $match = $preg_matches[1];
+        $offset = max($offset+1, $match[1]+strlen($link));
+        $nid = substr($match[0],1);
+        $node = node_load($nid);
+        if (!is_object($node) || !isset($node->sid)) continue;
+        $link = l('#'.$nid,'node/'.$nid,array('title'=>$node->title)).': '.$node->title;
+        if(in_array($node->sid, $striked)) $link = '<strike>'.$link.'</strike>';
+        $text = substr_replace($text, $link, $match[1], strlen($match[0]));
+      }
+      return $text;
+  }
+}
+
+
+/**
  * @defgroup project_release_fapi Form API hooks
  */
 
