<?php

function project_issue_filter($op, $delta = 0, $format = -1, $text = '') {
  switch (
$op) {

    case
'description':
      switch (
$delta) {
        case
0:
          return
t('Converts references to project issues (in the form of [#12345]) into links. Use this filter when using node access control modules or if access to project issues is not given to all users (both anonymous and authenticated).');
        case
1:
          return
t('Converts references to project issues (in the form of [#12345]) into links. Use this filter if no node access control modules are used on your site and if all users can access all project issues.');
      }

    case
'process':
     
$regex = '(?<!\w)(\[#(\d+)(#comment-(\d+))?\])(?![^<]*<\/a>|([^<]|(<(?!code>)))*<\/code>|([^<]|(<(?!pre>)))*<\/pre>|\w)';
     
$offset = 0;
      while(
preg_match('/'.$regex.'/', $text, $preg_matches, PREG_OFFSET_CAPTURE, $offset)) {
       
$offset++;
       
$match = $preg_matches[1];
       
$nid = $preg_matches[2][0];
       
$comment_id=$preg_matches[4][0];
       
$node = node_load($nid);
        if (
is_object($node) && node_access('view', $node)) {
         
$link = theme_project_issue_issue_link($node, $comment_id);
         
$text = substr_replace($text, $link, $match[1], strlen($match[0]));
         
$offset = max($offset, $match[1]+strlen($link));
        }
        else {
         
$offset = max($offset, $match[1]+strlen($match[0]));
        }
      }
      return
$text;
  }
}


?>

EOT; $regex = '(?|([^<]|(<(?!code)))*<\/code>|([^<]|(<(?!pre)))*<\/pre>|\w)'; $offset = 0; $stuff = preg_match("/$regex/", $text, $preg_matches, PREG_OFFSET_CAPTURE, $offset);