| 1 |
<?php |
<?php |
| 2 |
// $Id: technorati.module,v 1.6.2.3 2007/05/01 19:55:38 kbahey Exp $ |
// $Id: technorati.module,v 1.11 2008/07/27 16:28:34 kbahey Exp $ |
| 3 |
|
|
| 4 |
/* |
/* |
| 5 |
* @file |
* @file |
| 27 |
define('TECHNORATI_DISPLAY_FULL', 2); |
define('TECHNORATI_DISPLAY_FULL', 2); |
| 28 |
define('TECHNORATI_DISPLAY_BOTH', 3); |
define('TECHNORATI_DISPLAY_BOTH', 3); |
| 29 |
|
|
| 30 |
|
define('TECHNORATI_UNIFY_TAGS', 'technorati_unify_tags'); |
| 31 |
|
define('TECHNORATI_SORT_TAGS', 'technorati_sort_tags'); |
| 32 |
|
define('TECHNORATI_HIDE_NOTAGS', 'technorati_hide_notags'); |
| 33 |
|
|
| 34 |
/** |
/** |
| 35 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 36 |
*/ |
*/ |
| 82 |
TECHNORATI_MODE_BOTH => t('Both'), |
TECHNORATI_MODE_BOTH => t('Both'), |
| 83 |
); |
); |
| 84 |
|
|
| 85 |
$form[TECHNORATI_DISPLAY_TYPE] = array( |
$form['display'] = array( |
| 86 |
|
'#type' => 'fieldset', |
| 87 |
|
'#title' => t('Technorati tag display settings'), |
| 88 |
|
); |
| 89 |
|
|
| 90 |
|
$form['display'][TECHNORATI_DISPLAY_TYPE] = array( |
| 91 |
'#type' => 'select', |
'#type' => 'select', |
| 92 |
'#title' => t('How to display the technorati tags'), |
'#title' => t('How to display the technorati tags'), |
| 93 |
'#default_value' => variable_get(TECHNORATI_DISPLAY_TYPE, TECHNORATI_DISPLAY_FULL), |
'#default_value' => variable_get(TECHNORATI_DISPLAY_TYPE, TECHNORATI_DISPLAY_FULL), |
| 95 |
'#description' => t('Select how to display the tags.<ul><li>None: means that the module will not display the tags. The theme can use the $node->technorati object to display the tags anywhere.</li><li>Teaser: means that the tags will only be displayed when the node is in teaser view.</li><li>Full page: means that the tags will only be displayed when the node is in full page view.</li><li>Both: means the tags will be displayed in both teaser and full view.</li></ul>'), |
'#description' => t('Select how to display the tags.<ul><li>None: means that the module will not display the tags. The theme can use the $node->technorati object to display the tags anywhere.</li><li>Teaser: means that the tags will only be displayed when the node is in teaser view.</li><li>Full page: means that the tags will only be displayed when the node is in full page view.</li><li>Both: means the tags will be displayed in both teaser and full view.</li></ul>'), |
| 96 |
); |
); |
| 97 |
|
|
| 98 |
|
$form['display'][TECHNORATI_UNIFY_TAGS] = array( |
| 99 |
|
'#type' => 'checkbox', |
| 100 |
|
'#title' => t('Unify technorati tags'), |
| 101 |
|
'#default_value' => variable_get(TECHNORATI_UNIFY_TAGS, 0), |
| 102 |
|
'#description' => t('Use this option if you want to have only one occurrence of each choosen tag.'), |
| 103 |
|
); |
| 104 |
|
|
| 105 |
|
$form['display'][TECHNORATI_SORT_TAGS] = array( |
| 106 |
|
'#type' => 'checkbox', |
| 107 |
|
'#title' => t('Sort technorati tags'), |
| 108 |
|
'#default_value' => variable_get(TECHNORATI_SORT_TAGS, 0), |
| 109 |
|
'#description' => t('Sort the tags when displaying Technorati links.'), |
| 110 |
|
); |
| 111 |
|
|
| 112 |
|
$form['display'][TECHNORATI_HIDE_NOTAGS] = array( |
| 113 |
|
'#type' => 'checkbox', |
| 114 |
|
'#title' => t('Hide technorati display if empty'), |
| 115 |
|
'#default_value' => variable_get(TECHNORATI_HIDE_NOTAGS, 0), |
| 116 |
|
'#description' => t('Hide the display of the Technorati icon and the Technorati Tags label, if there are no tags assigned to a node.'), |
| 117 |
|
); |
| 118 |
|
|
| 119 |
$form['types'] = array( |
$form['types'] = array( |
| 120 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 121 |
'#title' => t('Content types'), |
'#title' => t('Content types'), |
| 189 |
function technorati_theme() { |
function technorati_theme() { |
| 190 |
return array( |
return array( |
| 191 |
'technorati_tags' => array( |
'technorati_tags' => array( |
| 192 |
'arguments' => array('tags' => NULL), |
'arguments' => array('tags' => NULL), |
| 193 |
), |
), |
| 194 |
); |
); |
| 195 |
} |
} |
| 265 |
* Theme function for registered theme 'technorati_tags'. |
* Theme function for registered theme 'technorati_tags'. |
| 266 |
*/ |
*/ |
| 267 |
function theme_technorati_tags($tags) { |
function theme_technorati_tags($tags) { |
| 268 |
|
if (empty($tags) && variable_get(TECHNORATI_HIDE_NOTAGS, 0)) { |
| 269 |
|
return ''; |
| 270 |
|
} |
| 271 |
$path = base_path() . drupal_get_path('module', 'technorati') .'/technobubble.gif'; |
$path = base_path() . drupal_get_path('module', 'technorati') .'/technobubble.gif'; |
| 272 |
$output = '<div class="technorati_tags">'; |
$output = '<div class="technorati_tags">'; |
| 273 |
$output .= '<img src="'. $path .'"/>'; |
$output .= '<img src="'. $path .'"/>'; |
| 286 |
$mode = variable_get(TECHNORATI_NODE_TYPE . $node->type, TECHNORATI_MODE_NONE); |
$mode = variable_get(TECHNORATI_NODE_TYPE . $node->type, TECHNORATI_MODE_NONE); |
| 287 |
switch ($mode) { |
switch ($mode) { |
| 288 |
case TECHNORATI_MODE_MANUAL: |
case TECHNORATI_MODE_MANUAL: |
| 289 |
return _technorati_manual($node); |
$tags = _technorati_manual($node); |
| 290 |
|
break; |
| 291 |
case TECHNORATI_MODE_TAXONOMY: |
case TECHNORATI_MODE_TAXONOMY: |
| 292 |
return _technorati_taxonomy($node); |
$tags = _technorati_taxonomy($node); |
| 293 |
|
break; |
| 294 |
case TECHNORATI_MODE_BOTH: |
case TECHNORATI_MODE_BOTH: |
| 295 |
return array_merge(_technorati_taxonomy($node), _technorati_manual($node)); |
$tags = array_merge(_technorati_taxonomy($node), _technorati_manual($node)); |
| 296 |
|
break; |
| 297 |
|
default: |
| 298 |
|
return; |
| 299 |
|
} |
| 300 |
|
if (variable_get(TECHNORATI_UNIFY_TAGS, 0)) { |
| 301 |
|
$tags = array_unique($tags); |
| 302 |
} |
} |
| 303 |
|
if (variable_get(TECHNORATI_SORT_TAGS, 0)) { |
| 304 |
|
natcasesort($tags); |
| 305 |
|
} |
| 306 |
|
return $tags; |
| 307 |
} |
} |
| 308 |
|
|
| 309 |
/** |
/** |
| 315 |
$links = array(); |
$links = array(); |
| 316 |
if (is_array($node->technorati_tags)) { |
if (is_array($node->technorati_tags)) { |
| 317 |
foreach ($node->technorati_tags as $tag) { |
foreach ($node->technorati_tags as $tag) { |
| 318 |
$links[] = _technorati_link($tag); |
if (!empty($tag)) { |
| 319 |
|
$links[] = _technorati_link($tag); |
| 320 |
|
} |
| 321 |
} |
} |
| 322 |
} |
} |
| 323 |
return $links; |
return $links; |