| 1 |
<?php |
<?php |
| 2 |
// $Id: autotagging.module,v 1.8 2009/07/27 17:52:01 acstewart Exp $ |
// $Id: autotagging.module,v 1.9 2009/07/27 17:58:39 acstewart Exp $ |
| 3 |
/* |
/* |
| 4 |
* @file autotagging.module |
* @file |
| 5 |
* Module for base Autotagging API. |
* Module for base Autotagging API. |
| 6 |
*/ |
*/ |
| 7 |
|
|
| 8 |
|
/** |
| 9 |
|
* Implementation of hook_menu() |
| 10 |
|
*/ |
| 11 |
function autotagging_menu() { |
function autotagging_menu() { |
| 12 |
$items = array(); |
$items = array(); |
| 13 |
$items['admin/settings/autotagging'] = array( |
$items['admin/settings/autotagging'] = array( |
| 21 |
return $items; |
return $items; |
| 22 |
} |
} |
| 23 |
|
|
| 24 |
|
/** |
| 25 |
|
* Implementation of hook_help() |
| 26 |
|
*/ |
| 27 |
function autotagging_help($section) { |
function autotagging_help($section) { |
| 28 |
|
// TODO: implement |
| 29 |
} |
} |
| 30 |
|
|
| 31 |
|
/** |
| 32 |
|
* Implementation of hook_perm() |
| 33 |
|
*/ |
| 34 |
function autotagging_perm() { |
function autotagging_perm() { |
| 35 |
return array( |
return array( |
| 36 |
'administer autotagging', |
'administer autotagging', |
| 38 |
); |
); |
| 39 |
} |
} |
| 40 |
|
|
| 41 |
|
/** |
| 42 |
|
* Implementation of hook_nodeapi() |
| 43 |
|
*/ |
| 44 |
function autotagging_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
function autotagging_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
| 45 |
// act on the node |
// act on the node and set up for processing by other autotagging api modules |
|
// |
|
| 46 |
switch ($op) { |
switch ($op) { |
| 47 |
case 'update': |
case 'update': |
| 48 |
case 'insert': |
case 'insert': |
| 49 |
$terms = array(); |
$terms = array(); |
| 50 |
// check that this node type is allowed for autotagging |
// check that this node type is allowed for autotagging |
|
// |
|
| 51 |
$allowed_types = variable_get('autotagging_allowed_types', array()); |
$allowed_types = variable_get('autotagging_allowed_types', array()); |
| 52 |
|
|
| 53 |
if (!in_array($node->type, $allowed_types)) { |
if (!in_array($node->type, $allowed_types)) { |
| 55 |
} |
} |
| 56 |
|
|
| 57 |
// invoke autotagging api |
// invoke autotagging api |
|
// |
|
| 58 |
$text = array(); |
$text = array(); |
| 59 |
$text[] = $node->title; |
$text[] = $node->title; |
| 60 |
$text[] = str_replace("\n", ' ', $node->body); |
$text[] = str_replace("\n", ' ', $node->body); |
| 91 |
} |
} |
| 92 |
} |
} |
| 93 |
|
|
| 94 |
|
/** |
| 95 |
|
* Implementation of hook_requirements() |
| 96 |
|
*/ |
| 97 |
function autotagging_requirements($phase) { |
function autotagging_requirements($phase) { |
| 98 |
switch ($phase) { |
switch ($phase) { |
| 99 |
case 'install': |
case 'install': |