| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: issue_node_view.inc,v 1.1 2009/06/18 03:28:55 dww Exp $ 3 4 /** 5 * @file 6 * Code required when viewing an issue node. 7 */ 8 9 /** 10 * Private helper to implement hook_view(). 11 */ 12 function _project_issue_view($node, $teaser = FALSE, $page = FALSE) { 13 $node = node_prepare($node, $teaser); 14 15 if (!$teaser && ($page || project_issue_is_comment_reply())) { 16 17 $node->content['#prefix'] = '<div class="project-issue">'; 18 $node->content['#suffix'] = '</div>'; 19 20 $project = node_load(array('nid' => $node->project_issue['pid'], 'type' => 'project_project')); 21 $release->nid = $node->project_issue['rid']; 22 if (module_exists('project_release')) { 23 $release = project_release_load($release); 24 } 25 $assigned = ($node->project_issue['assigned'] && ($account = user_load(array('uid' => $node->project_issue['assigned']))) ? $account->name : t('Unassigned')); 26 27 $current_data = array(); 28 $current_data['pid'] = array( 29 'label' => t('Project'), 30 'current' => $project->title, 31 ); 32 if (!empty($release->project_release['version'])) { 33 $current_data['rid'] = array( 34 'label' => t('Version'), 35 'current' => $release->project_release['version'], 36 ); 37 } 38 $current_data['component'] = array( 39 'label' => t('Component'), 40 'current' => $node->project_issue['component'], 41 ); 42 $current_data['category'] = array( 43 'label' => t('Category'), 44 'current' => project_issue_category($node->project_issue['category'], 0), 45 ); 46 $current_data['priority'] = array( 47 'label' => t('Priority'), 48 'current' => project_issue_priority($node->project_issue['priority']), 49 ); 50 $current_data['assigned'] = array( 51 'label' => t('Assigned'), 52 'current' => $assigned, 53 ); 54 $current_data['sid'] = array( 55 'label' => t('Status'), 56 'current' => project_issue_state($node->project_issue['sid']), 57 ); 58 59 // Allow modules to alter the metadata displayed in the table on the actual 60 // issue node itself (at the very top of the issue). Modules should accept 61 // the $current_data parameter by reference and add additional 62 // elements for additional lines in the table. 63 // 64 // Modules implementing this hook should take the following parameters: 65 // @param $view 66 // A string representing the metadata view being generated. For the issue 67 // node main table, this will be 'current'. 68 // @param $node 69 // The project_issue node object. 70 // @param $current_data 71 // An associative array of rows in the project issue metadata table that 72 // will be displayed, with the following key/value pairs: 73 // 'label' => The metadata label. 74 // 'current' => The current metadata value. 75 // This parameter should be accepted by reference. 76 foreach (module_implements('project_issue_metadata') as $module) { 77 $function = $module .'_project_issue_metadata'; 78 $function('current', $node, $current_data); 79 } 80 81 $node->content['project_issue_summary'] = array( 82 '#value' => theme('project_issue_summary', $current_data, project_issue_internal_links($node)), 83 '#weight' => -5, 84 ); 85 86 $node->content['project_issue_header'] = array( 87 '#value' => '<div class="header">'. t('Description') .'</div>', 88 '#weight' => -3, 89 ); 90 91 project_issue_set_breadcrumb($node, $project); 92 } 93 return $node; 94 } 95 96 /** 97 * Themes the metadata table and internal page links for issue nodes. 98 * 99 * @param $current_data 100 * An array of current issue data for the metadata table. 101 * @param $summary_links 102 * An array of internal page links. 103 * @return 104 * An HTML string of the summary section. 105 */ 106 function theme_project_issue_summary($current_data, $summary_links) { 107 $allowed_tags = array('a', 'em', 'strong', 'div', 'span'); 108 // Fields that should be rendered as plain text, not filtered HTML. 109 $plain_fields = array('title', 'pid', 'rid'); 110 111 $rows = array(); 112 foreach ($current_data as $name => $values) { 113 $row = array(); 114 $row[] = filter_xss($values['label'], $allowed_tags) .':'; 115 if (in_array($name, $plain_fields)) { 116 $row[] = check_plain($values['current']); 117 } 118 else { 119 $row[] = filter_xss($values['current'], $allowed_tags); 120 } 121 $rows[] = $row; 122 } 123 124 $output = '<div id="project-summary-container" class="clear-block">'; 125 $output .= '<div id="project-issue-summary-table" class="summary">'. theme('table', array(), $rows) .'</div>'; 126 if (!empty($summary_links)) { 127 $output .= '<div id="project-issue-summary-links">'. theme('item_list', $summary_links, t('Jump to:'), 'ul', array('class' => 'internal-links')) .'</div>'; 128 } 129 $output .= '</div>'; 130 131 return $output; 132 } 133 134 /** 135 * Generates internal page links for issue pages. 136 * 137 * @param $node 138 * The issue node. 139 * @return 140 * An array of internal page links. 141 */ 142 function project_issue_internal_links($node) { 143 $links = array(); 144 145 if ($node->comment != COMMENT_NODE_DISABLED) { 146 // Link to the first unread, or most recent comment. 147 if (comment_num_new($node->nid)) { 148 // There are unread replies; link to first unread comment. 149 $links[] = l(t('First unread comment'), "node/$node->nid", array('fragment' => 'new')); 150 } 151 else { 152 // No unread replies; link to most recent comment. 153 $comment_cid = db_result(db_query_range("SELECT pic.cid FROM {project_issue_comments} pic INNER JOIN {node} n on pic.nid = n.nid WHERE n.status = 1 AND n.nid = %d ORDER BY pic.cid DESC", $node->nid, 0, 1)); 154 if ($comment_cid) { 155 $links[] = l(t('Most recent comment'), "node/$node->nid", array('fragment' => "comment-$comment_cid")); 156 } 157 } 158 // Link for most recent patch. 159 $file_cid = db_result(db_query_range("SELECT cu.cid FROM {comment_upload} cu INNER JOIN {node} n on cu.nid = n.nid WHERE n.status = 1 AND n.nid = %d ORDER BY cu.fid DESC", $node->nid, 0, 1)); 160 if ($file_cid) { 161 $links[] = l(t('Most recent attachment'), "node/$node->nid", array('fragment' => "comment-$file_cid")); 162 } 163 } 164 165 // Link straight to comment form. 166 if ($node->comment == COMMENT_NODE_READ_WRITE && (user_access('post comments') || user_access('post comments without approval'))) { 167 // TODO: This conditional needs to be ripped out in D6. 168 $comment_form_location = isset($node->project_issue['comment_form_location']) ? $node->project_issue['comment_form_location'] : variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE); 169 170 // Comment form isn't on the page, link to the comment reply page. 171 if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) { 172 $links[] = l(t('Add new comment'), "comment/reply/$node->nid"); 173 } 174 // Comment form is on the page, generate an internal page link for it. 175 else { 176 $links[] = l(t('Add new comment'), "node/$node->nid", array('fragment' => "comment-form")); 177 } 178 } 179 180 return $links; 181 } 182
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |