Index: project_issue.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.css,v retrieving revision 1.12 diff -u -p -r1.12 project_issue.css --- project_issue.css 16 Aug 2007 00:10:02 -0000 1.12 +++ project_issue.css 3 Dec 2007 23:11:24 -0000 @@ -132,3 +132,12 @@ table.projects .project-project-links { text-align: right; color: #999; } + +/* Automatic issue links */ +.project-issue-status-2, +.project-issue-status-3, +.project-issue-status-5, +.project-issue-status-6, +.project-issue-status-7 { + text-decoration: line-through; +} Index: project_issue.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.module,v retrieving revision 1.38.2.5 diff -u -p -r1.38.2.5 project_issue.module --- project_issue.module 13 Nov 2007 01:28:24 -0000 1.38.2.5 +++ project_issue.module 3 Dec 2007 23:11:26 -0000 @@ -874,3 +874,79 @@ function _project_issue_roles($permissio } return $roles; } + + +/** + * @defgroup project_issue_filter Project Issue number to link filter + */ + +/** + * Theme automatic Project Issue links + * @ingroup project_issue_filter + */ +function theme_project_issue_issue_link($node, $comment_id=0) { + if ($node->type == 'project_issue') { + $title = check_plain("#$node->nid: $node->title"); + $path = "node/$node->nid"; + $attributes = array('title' => project_issue_state($node->sid)); + $fragment = null; + if($comment_id > 0) { + $title = check_plain("#$node->nid#comment-$comment_id: $node->title"); + $fragment = "comment-$comment_id"; + } + $output = "sid>"; + $output .= l($title, $path, $attributes, null, $fragment); + $output .= ''; + } + else { + $output = "[#$node->nid]"; + } + return $output; +} + +/** + * Implementation of hook_form_filter_tips() + * @ingroup project_issue_filter + */ +function project_issue_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_issue_filter + */ +function project_issue_filter($op, $delta = 0, $format = -1, $text = '') { + switch ($op) { + case 'list': + return array(0 => t('Project 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': + $regex = '(?|([^<]|(<(?!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) && project_issue_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; + } +}