Index: technorati.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/technorati/technorati.info,v
retrieving revision 1.5
diff -u -r1.5 technorati.info
--- technorati.info 18 Jun 2007 23:50:58 -0000 1.5
+++ technorati.info 27 Jul 2008 15:40:14 -0000
@@ -1,5 +1,6 @@
name = Technorati
description = "Enables Technorati tags for selected content types, and pings Technorati when new content is created."
-dependencies =ping
-package =
+dependencies[] = ping
+core = 6.x
+php = 5.1
Index: technorati.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/technorati/technorati.install,v
retrieving revision 1.1
diff -u -r1.1 technorati.install
--- technorati.install 28 Oct 2006 02:17:35 -0000 1.1
+++ technorati.install 27 Jul 2008 15:40:14 -0000
@@ -1,18 +1,59 @@
+ */
+/**
+ * Implementation of hook_install().
+ */
function technorati_install() {
- switch ($GLOBALS['db_type']) {
- case 'mysqli':
- case 'mysql':
- $result = db_query("
- CREATE TABLE {technorati} (
- nid INT NOT NULL default '0',
- tags TEXT NOT NULL default '',
- PRIMARY KEY nid (nid)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
- break;
+ $result = drupal_install_schema('technorati');
+
+ if (count($result) > 0) {
+ drupal_set_message(t('technorati module installed.'));
+ }
+ else {
+ drupal_set_message(t('technorati table creation failed. Please "uninstall" the module and retry.'));
+ }
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function technorati_uninstall() {
+ drupal_uninstall_schema('technorati');
+
+ // delete variables
+ variable_del('technorati_display_type');
+ foreach (node_get_types() as $node_type => $node_name) {
+ variable_del('technorati_node_type_'. $node_type);
}
+
+ drupal_set_message(t('technorati module uninstalled.'));
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function technorati_schema() {
+ $schema['technorati'] = array(
+ 'fields' => array(
+ 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
+ 'default' => 0),
+ 'tags' => array('type' => 'text', 'size' => 'normal',
+ 'not null' => TRUE, 'default' => '')
+ ),
+ 'indexes' => array(
+ 'nid' => array('nid')
+ ),
+ 'primary key' => array('nid'),
+ );
+
+ return $schema;
}
Index: technorati.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/technorati/technorati.module,v
retrieving revision 1.10
diff -u -r1.10 technorati.module
--- technorati.module 1 May 2007 19:56:19 -0000 1.10
+++ technorati.module 27 Jul 2008 15:40:14 -0000
@@ -1,7 +1,17 @@
+ */
define('TECHNORATI_NODE_TYPE', 'technorati_node_type_');
@@ -17,29 +27,36 @@
define('TECHNORATI_DISPLAY_FULL', 2);
define('TECHNORATI_DISPLAY_BOTH', 3);
-function technorati_help($section) {
- switch ($section) {
- case 'admin/modules#description':
- return t('Enables Technorati tags for selected content types, and pings Technorati when new content is created.');
+/**
+ * Implementation of hook_help().
+ */
+function technorati_help($path, $arg) {
+ switch ($path) {
+ case 'admin/help#technorati' :
+ return '
'. t('Enables Technorati tags for selected content types, and pings Technorati when new content is created.') .'
';
}
}
-function technorati_menu($may_cache) {
+/**
+ * Implementation of hook_menu().
+ */
+function technorati_menu() {
$items = array();
- $items[] = array(
- 'path' => 'admin/settings/technorati',
- 'title' => t('Technorati'),
- 'description' => t('technorati settings.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('technorati_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM, // optional
- );
+ $items['admin/settings/technorati'] = array(
+ 'title' => 'Technorati',
+ 'description' => 'technorati settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('technorati_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_NORMAL_ITEM
+ );
return $items;
}
-
+/**
+ * Form definition for technorati module settings.
+ */
function technorati_admin_settings() {
if (!module_exists('ping')) {
drupal_set_message(t('This module requires that the %pingmodule be enabled',
@@ -76,7 +93,7 @@
'#description' => t('Select the type of tags to use for each content type.- None: means do not do any Technorati tags for this content type.
- Manual entry: means that the tags have to be entered manually for each node.
- Drupal categories: means that the terms the node belong to will be used as Technorati tags.
- Both: means a combination of manual entries and categories.
'),
);
- foreach(node_get_types() as $node_type => $node_name) {
+ foreach (node_get_types() as $node_type => $node_name) {
$type = TECHNORATI_NODE_TYPE . $node_type;
$form['types'][$type] = array(
'#type' => 'select',
@@ -86,17 +103,20 @@
);
}
- return system_settings_form($form);
+ return system_settings_form($form);
}
-function technorati_form_alter($form_id, &$form) {
+/**
+ * Implementation of hook_form_alter().
+ */
+function technorati_form_alter(&$form, &$form_state, $form_id) {
if (preg_match('/^(.*)_node_form$/', $form_id, $matches)) {
// Get the node type we are processing
$node_type = $matches[1];
// Check what the technorati mode for that node type
$mode = variable_get(TECHNORATI_NODE_TYPE . $node_type, TECHNORATI_MODE_NONE);
- switch($mode) {
+ switch ($mode) {
case TECHNORATI_MODE_NONE:
case TECHNORATI_MODE_TAXONOMY:
// No need to do anything in the node form
@@ -133,9 +153,23 @@
}
}
-function technorati_nodeapi(&$node, $op, $teaser, $page) {
+/**
+ * Implementation of hook_theme().
+ */
+function technorati_theme() {
+ return array(
+ 'technorati_tags' => array(
+ 'arguments' => array('tags' => NULL),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_nodeapi().
+ */
+function technorati_nodeapi(&$node, $op, $a3, $a4) {
$mode = variable_get(TECHNORATI_NODE_TYPE . $node->type, TECHNORATI_MODE_NONE);
- switch($mode) {
+ switch ($mode) {
case TECHNORATI_MODE_NONE:
case TECHNORATI_MODE_TAXONOMY:
// No need to do anything in the node form
@@ -167,50 +201,57 @@
break;
case 'view':
- $technorati = array (
+ $technorati = array(
'#value' => theme('technorati_tags', _technorati_process_tags($node)),
'#weight' => 10,
- );
+ );
$mode = variable_get(TECHNORATI_DISPLAY_TYPE, TECHNORATI_DISPLAY_FULL);
- switch($mode) {
+ switch ($mode) {
case TECHNORATI_DISPLAY_NONE:
// No inline display. Theme will handle it all.
break;
case TECHNORATI_DISPLAY_TEASER:
// Teaser view only
- if ($teaser) {
+ if ($a3) {
$node->content['technorati'] = $technorati;
}
break;
case TECHNORATI_DISPLAY_FULL:
// Full page view only
- if (!$teaser) {
- $node->content['technorati'] = $technorati;
+ if (!$a3) {
+ $node->content['technorati'] = $technorati;
}
break;
case TECHNORATI_DISPLAY_BOTH:
- // Teaser and full page view
- $node->content['technorati'] = $technorati;
+ // Teaser and full page view
+ $node->content['technorati'] = $technorati;
break;
}
break;
}
}
+/**
+ * Theme function for registered theme 'technorati_tags'.
+ */
function theme_technorati_tags($tags) {
- $path = base_path() . drupal_get_path('module', 'technorati') . '/technobubble.gif';
+ $path = base_path() . drupal_get_path('module', 'technorati') .'/technobubble.gif';
$output = '';
//$output .= '';
- return $output;
+ return $output;
}
+/**
+ * This function is called by technorati_nodeapi() with $op 'view' and
+ * processes the tags in a node type and technorati mode specific way.
+ */
function _technorati_process_tags($node) {
$mode = variable_get(TECHNORATI_NODE_TYPE . $node->type, TECHNORATI_MODE_NONE);
- switch($mode) {
+ switch ($mode) {
case TECHNORATI_MODE_MANUAL:
return _technorati_manual($node);
@@ -222,32 +263,46 @@
}
}
+/**
+ * This function handles the manually assigned technorati tags of a node. It
+ * is called by _technorati_process_tags() for the technorati modes 'manual'
+ * and 'both'.
+ */
function _technorati_manual($node) {
$links = array();
if (is_array($node->technorati_tags)) {
- foreach($node->technorati_tags as $tag) {
+ foreach ($node->technorati_tags as $tag) {
$links[] = _technorati_link($tag);
}
}
return $links;
}
+/**
+ * This function handles the taxonomy tags of a node and creates technorati
+ * links from them. It is called by _technorati_process_tags() for the
+ * technorati modes 'taxonomy' and 'both'.
+ */
function _technorati_taxonomy($node) {
$links = array();
- $terms = taxonomy_node_get_terms($node->nid);
+ $terms = taxonomy_node_get_terms($node);
foreach ($terms as $term) {
$links[] = _technorati_link($term->name);
}
return $links;
}
+/**
+ * Calls the Technorati ping service at http://rpc.technorati.com/rpc/ping and
+ * notifies changes to the given URL.
+ */
function technorati_ping($name = '', $url = '') {
$result = xmlrpc('http://rpc.technorati.com/rpc/ping', 'weblogUpdates.ping', $name, $url);
if ($result) {
- watchdog("directory ping", t('Successfully notified technorati.com site.'), WATCHDOG_NOTICE);
+ watchdog("directory ping", 'Successfully notified technorati.com site.', WATCHDOG_NOTICE);
}
else {
- watchdog('directory ping', t('Failed to notify technorati.com site.'), WATCHDOG_WARNING);
+ watchdog('directory ping', 'Failed to notify technorati.com site.', WATCHDOG_WARNING);
}
}
@@ -268,7 +323,7 @@
/**
* Strip whitespace from left and/or right of tags, and reduce multiples
- * to just one
+ * to just one.
*
* Reference: daggillies's comment on http://www.php.net/trim
*/