/[drupal]/contributions/modules/semantic_search/semantic_search.install
ViewVC logotype

Contents of /contributions/modules/semantic_search/semantic_search.install

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


Revision 1.1 - (show annotations) (download) (as text)
Tue Jun 5 06:37:06 2007 UTC (2 years, 5 months ago) by hendler
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
adding files from our SVN
1 <?php
2
3 /**
4 * This script provides an interactive Drupal module for the building of
5 * a SEMANTIC_SEARCH install.
6 *
7 * installs SONIA
8 * installs ARC
9 *
10 * http://drupal.org/node/51220
11 * http://drupal.org/node/22218#utf8_sql
12 *
13 * @package SEMANTIC_SEARCH
14 * @author Jonathan Hendler <jonathan@civicactions.com>
15 *
16 * */
17
18 if (!defined('SEMANTIC_SEARCH_LOCATION')){
19 define('SEMANTIC_SEARCH_LOCATION',dirname(__FILE__).'/');
20 }
21
22 require_once SEMANTIC_SEARCH_LOCATION.'semantic_search.module';
23
24 /**
25 * Implementation of hook_uninstall().
26 */
27 function semantic_search_uninstall() {
28 $store = new SONIAARCStore(null);
29 $store->removeTables('drupal_set_message');
30 db_query('TRUNCATE TABLE {sonia_cache}');
31
32 $variables[] = 'Search Title';
33 $variables[] = 'Search Form Title';
34 $variables[] = 'Semantic Search Help Title';
35 $variables[] = 'Semantic Search Search Help Text';
36
37 $type_options = _content_type_info();
38
39 //removes all the individual settings for CCK types and fields
40 foreach ($type_options['content types'] as $id => $data) {
41 $variables[] = 'display_' . $id;
42 $fields = $data['fields'];
43 foreach ($fields as $fid => $field_data) {
44 $variables[] = 'display_result_' . $fid;
45 }
46 }
47
48 //do the removal
49 foreach($variables as $var){
50 variable_del($var);
51 }
52 }
53
54 /***
55 * Basially installs the schemas needed by SONIAs RDF store
56
57 * @todo needs better checking. If configs are wrong before hitting admin/modules
58 * a check config script?
59 *
60 * @todo check that cache works properly
61 * @todo validate confgiuration options
62 * @todo run other tests
63 * */
64 function semantic_search_install() {
65 global $_semantic_search_search;
66 if (empty ($_semantic_search_search))
67 _SEMANTIC_SEARCH_INIT();
68
69 switch ($GLOBALS['db_type']) {
70 case 'mysql' :
71 case 'mysqli' :
72 if (!db_table_exists('semantic_search_searches')){
73 db_query('CREATE TABLE {semantic_search_searches} (
74 id INT( 4 ) UNSIGNED NOT NULL AUTO_INCREMENT,
75 name VARCHAR( 32 ) NOT NULL ,
76 type VARCHAR( 32 ) NOT NULL ,
77 path VARCHAR( 32 ) NOT NULL ,
78 store_type VARCHAR( 32 ) NOT NULL ,
79 node_settings TEXT NOT NULL ,
80 title VARCHAR( 64 ) NOT NULL ,
81 description TEXT NOT NULL ,
82 UNIQUE (name),
83 PRIMARY KEY (id)
84 ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
85 }
86
87 if (!db_table_exists('semantic_search_searches_fields')){
88 db_query('CREATE TABLE {semantic_search_searches_fields} (
89 sid INT( 4 ) UNSIGNED NOT NULL ,
90 id INT( 6 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
91 uris TEXT NOT NULL ,
92 form_type VARCHAR( 32 ) NOT NULL ,
93 search_field_type VARCHAR( 32 ) NOT NULL ,
94 title VARCHAR( 32 ) NOT NULL ,
95 description VARCHAR( 512 ) NOT NULL ,
96 grand_total INT( 1 ) UNSIGNED NOT NULL ,
97 top_option INT( 1 ) UNSIGNED NOT NULL ,
98 title_as_option INT( 1 ) UNSIGNED NOT NULL ,
99 multiple INT( 1 ) UNSIGNED NOT NULL ,
100 INDEX ( sid )
101 ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
102 }
103
104
105
106 switch (SONIA_BACKEND_TYPE) {
107 case 'sonia_arc_local' :
108 if (!class_exists('SONIAARCStore')) {
109 set_sonia_configs('sonia_arc_local', 'drupal');
110 }
111 //once configured properly the store knows what to setup
112 drupal_set_message('Installing SEMANTIC_SEARCH ARC datastore.');
113 $store = new SONIAARCStore(null);
114 //basic check
115 if (!($store instanceof SONIAStoreAPI)) {
116 drupal_set_message(t('SONIA store is wrong kind of object'));
117 }
118
119 //TODO tablenames should be retrieved automatically
120 //since the tables are created externally, this must be done via a function
121 $table_names = $store->installBackend('drupal_set_message');
122
123 //TODO set the semantic_search_js.module bootstrap order to be very early??
124
125 $success = (!empty ($table_names)) ? true : false;
126
127 if ($success) {
128 $message = t('SemanticSearch ARC datastore installed tables successfully.');
129 drupal_set_message($message);
130 watchdog('Semantic Search',$message);
131 } else {
132 drupal_set_message(t('The installation of SEMANTIC_SEARCH ARC datastore was unsuccessful.'), 'error');
133 }
134 break;
135 default :
136 die("$install_type is not a recognized backend for this install script.");
137 }
138
139 break;
140 default :
141 die("SEMANTIC_SEARCH only supports MySQL at the moment.");
142 }
143 }
144
145 function semantic_search_update_1() {
146 //testing only
147 drupal_set_message('TEST ONLY: Updating Tables to UTF 8');
148 $table_names = array ();
149 return _system_update_utf8($table_names);
150 }

  ViewVC Help
Powered by ViewVC 1.1.2