| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: author_taxonomy.module,v 1.1 2008/04/11 23:12:27 toddnienkerk Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 112 |
case 'view' : |
case 'view' : |
| 113 |
$display = variable_get('author_taxonomy_prepend_node', TRUE); |
$display = variable_get('author_taxonomy_prepend_node', TRUE); |
| 114 |
if ($display && ($page || $teaser)) { |
if ($display && ($page || $teaser)) { |
| 115 |
$node->content['body']['#value'] = author_taxonomy_output($node) . "\n" . $node->content['body']['#value']; |
$node->content['body']['#value'] = author_taxonomy_output($node) ."\n". $node->content['body']['#value']; |
| 116 |
} |
} |
| 117 |
break; |
break; |
| 118 |
} |
} |
| 123 |
* Creates array of authors' names and prepares output for the theme functions |
* Creates array of authors' names and prepares output for the theme functions |
| 124 |
*/ |
*/ |
| 125 |
function author_taxonomy_output($node) { |
function author_taxonomy_output($node) { |
| 126 |
$author_tids = taxonomy_node_get_terms_by_vocabulary($node->nid, variable_get('author_taxonomy_vocab', 1)); |
$author_tids = taxonomy_node_get_terms_by_vocabulary($node->nid, variable_get('author_taxonomy_vocab', 1)); |
| 127 |
$author_names = array(); |
$author_names = array(); |
| 128 |
$author_links = variable_get('author_taxonomy_link_authors', TRUE); |
$author_links = variable_get('author_taxonomy_link_authors', TRUE); |
| 129 |
|
|
| 130 |
if (!empty($author_tids)) { |
if (!empty($author_tids)) { |
| 131 |
foreach ($author_tids as $tid => $term) { |
foreach ($author_tids as $tid => $term) { |
| 132 |
if ($author_links) { |
if ($author_links) { |
| 133 |
$author_names[] = l($term->name, taxonomy_term_path($term), array('title' => t('See all stories by @author', array('@author' => $term->name)))); |
$author_names[] = l($term->name, taxonomy_term_path($term), array('title' => t('See all stories by @author', array('@author' => $term->name)))); |
| 136 |
$author_names[] = $term->name; |
$author_names[] = $term->name; |
| 137 |
} |
} |
| 138 |
} |
} |
| 139 |
} |
} |
| 140 |
|
|
| 141 |
$show_timestamp = variable_get('author_taxonomy_timestamp_display', TRUE); |
$show_timestamp = variable_get('author_taxonomy_timestamp_display', TRUE); |
| 142 |
|
|
| 143 |
return theme('author_taxonomy_output', $node, $author_names, $show_timestamp); |
return theme('author_taxonomy_output', $node, $author_names, $show_timestamp); |
| 144 |
} |
} |
| 145 |
|
|
| 146 |
|
|
| 152 |
|
|
| 153 |
if ($show_timestamp) { |
if ($show_timestamp) { |
| 154 |
// Print timestamp |
// Print timestamp |
| 155 |
$output .= '<span class="timestamp">' . theme('author_taxonomy_timestamp', $node->created) . '</span>'; |
$output .= '<span class="timestamp">'. theme('author_taxonomy_timestamp', $node->created) .'</span>'; |
| 156 |
} |
} |
| 157 |
|
|
| 158 |
if ($show_timestamp && !empty($author_names)) { |
if ($show_timestamp && !empty($author_names)) { |
| 162 |
|
|
| 163 |
if (!empty($author_names)) { |
if (!empty($author_names)) { |
| 164 |
// Print authors |
// Print authors |
| 165 |
$output .= '<span class="authors">' . theme('author_taxonomy_authors', $author_names) . '</span>'; |
$output .= '<span class="authors">'. theme('author_taxonomy_authors', $author_names) .'</span>'; |
| 166 |
} |
} |
| 167 |
|
|
| 168 |
// Wrap everything in div.submitted and return it |
// Wrap everything in div.submitted and return it |
| 169 |
return '<div class="submitted">' . $output . '</div>'; |
return '<div class="submitted">'. $output .'</div>'; |
| 170 |
} |
} |
| 171 |
|
|
| 172 |
|
|
| 194 |
foreach ($author_names as $author_name) { |
foreach ($author_names as $author_name) { |
| 195 |
// If this is the last author |
// If this is the last author |
| 196 |
if ($i == $author_count) { |
if ($i == $author_count) { |
| 197 |
$output .= 'and ' . $author_name; |
$output .= 'and '. $author_name; |
| 198 |
} |
} |
| 199 |
else { |
else { |
| 200 |
$output .= $author_name . ', '; |
$output .= $author_name .', '; |
| 201 |
} |
} |
| 202 |
$i++; |
$i++; |
| 203 |
} |
} |