/[drupal]/contributions/modules/opencalais/calais.install
ViewVC logotype

Contents of /contributions/modules/opencalais/calais.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Thu Apr 24 17:56:49 2008 UTC (19 months ago) by febbraro
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +11 -1 lines
File MIME type: text/x-php
added license
1 <?php
2 /*
3 Copyright (C) 2008 by Phase2 Technology.
4 Author(s): Frank Febbraro, Irakli Nadareishvili
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY. See the LICENSE.txt file for more details.
10
11 $Id$
12 */
13
14 module_load_include('module', 'calais');
15 module_load_include('module', 'calais_api');
16
17
18 /**
19 * Placeholder Implementation of hook_uninstall().
20 */
21 function calais_uninstall() {
22 drupal_uninstall_schema('calais');
23
24 db_query("DELETE FROM {variable} where name like 'calais_%'");
25 calais_remove_vocabularies();
26 }
27
28 /**
29 * hook_install implementation
30 *
31 * Create the vocabularies for all know Calais ENtities.
32 */
33 function calais_install() {
34 drupal_install_schema('calais');
35 calais_create_vocabularies();
36
37 // Module weights: put calais after taxonomy for form altering.
38 db_query("UPDATE {system} SET weight = 10 WHERE name = 'calais'");
39 }
40
41 /**
42 * Implementation of hook_schema()
43 */
44 function calais_schema() {
45
46 $schema['calais_term'] = array(
47 'fields' => array(
48 'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
49 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
50 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
51 ),
52 'indexes' => array(
53 'vid' => array('vid'),
54 ),
55 'primary key' => array('tid'),
56 );
57
58 $schema['calais_term_node'] = array(
59 'fields' => array(
60 'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
61 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
62 ),
63 'indexes' => array(
64 'tid' => array('tid'),
65 'nid' => array('nid'),
66 ),
67 'primary key' => array('tid', 'nid'),
68 );
69 return $schema;
70 }
71
72 function calais_update_2() {
73 // Module weights: put calais after taxonomy for form altering.
74 $ret = array();
75 $ret[] = update_sql('UPDATE {system} SET weight = 10 WHERE name = "calais"');
76 return $ret;
77 }
78
79
80 /**
81 * Create new vocabularies for all currently known Calais Entities
82 */
83 function calais_create_vocabularies() {
84 $entities = calais_api_get_all_entities();
85 $vocabularies = array();
86
87 foreach ($entities as $e) {
88 $vid = calais_create_entity_vocabulary($e);
89 $vocabularies[$e] = $vid;
90 }
91
92 variable_set('calais_vocabulary_names', $vocabularies);
93 cache_clear_all();
94 }
95
96 /**
97 * Remove vocabularies for all currently known Calais Entities
98 */
99 function calais_remove_vocabularies() {
100 $entities = calais_get_entity_vocabularies();
101 foreach ($entities as $key => $value) {
102 db_query("DELETE FROM {vocabulary} where vid =%d ", $value);
103 }
104
105 cache_clear_all();
106 }

  ViewVC Help
Powered by ViewVC 1.1.2