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

Contents of /contributions/modules/search_files/search_files.install

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


Revision 1.11 - (show annotations) (download) (as text)
Tue Jan 6 18:13:12 2009 UTC (10 months, 2 weeks ago) by jrglasgow
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +2 -2 lines
File MIME type: text/x-php
#355072 by artur.ejsmont - misspelled function name
1 <?php
2 // $Id: search_files.install,v 1.10 2008/06/20 15:37:28 jrglasgow Exp $
3
4 /**
5 * @file
6 * Auto installation for database table(s)
7 */
8
9 function search_files_schema() {
10 $schema['search_files_helpers'] = array(
11 'description' => t('list of programs that translate the file to test to be indexed'),
12 'fields' => array(
13 'id' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
14 'name' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
15 'extension' => array('type' => 'varchar', 'length' => '10', 'not null' => FALSE),
16 'helper_path' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
17 ),
18 'indexes' => array(
19 'id' => array('id')
20 ),
21 );
22
23 $schema['search_files_files'] = array(
24 'description' => t('list of files in the directories, this is here because the the search_dataset table needs some sort of integer id to reference the file by'),
25 'fields' => array(
26 'id' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
27 'full_path' => array('type' => 'varchar', 'length' => '300', 'not null' => TRUE),
28 'directory_id' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
29 'index_attempts' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'disp-width' => '4'),
30 ),
31 'primary key' => array('id'),
32 'unique keys' => array(
33 'full_path' => array('full_path'),
34 ),
35 );
36
37 $schema['search_files_directories'] = array(
38 'description' => t('list of directories that we will index'),
39 'fields' => array(
40 'id' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
41 'directory' => array('type' => 'varchar', 'length' => '150', 'not null' => TRUE),
42 ),
43 'primary key' => array('id'),
44 'unique keys' => array(
45 'directory' => array('directory')),
46 );
47 return $schema;
48 }
49
50 function search_files_install() {
51 $result = drupal_install_schema('search_files');
52 //drupal_set_message('result = <pre>'.print_r($result, true).'</pre>');
53 $successess = 0;
54 $failures= 0;
55 $failed = array();
56 foreach ($result as $key => $value) {
57 #drupal_set_message($key .' => <pre>'.print_r($value, true).'</pre>');
58 if ($value['success']) {
59 $successes++;
60 }
61 else {
62 $failures++;
63 $failed[] = $value['query'];
64 }
65 }
66 $failed_querys = '';
67 if($failures) {
68 $failed_querys .= '<ul>';
69 foreach ($failed as $key => $value) {
70 $failed_querys .= '<li>'.$value.'</li>';
71 }
72 $failed_querys = '</ul>';
73 watchdog('Search Files', $failures . t('unsuccessful querys while installing: ') . $failed_querys, array(), WATCHDOG_ERROR);
74 }
75
76 drupal_set_message(t('Search Files Install <ul><li>Tables successfully created: %successes</li><li>Tables unsuccessfuly created: %failures %failed_querys</li></ul>', array('%successes' => $successes, '%failures' => $failures, '%failed_querys' => ($failures ? $failed_querys : ""))));
77
78 // load sample helper apps into database
79 db_query('INSERT INTO {search_files_helpers} VALUES(NULL, "%s", "%s", "%s")', "PDF", "pdf", "/usr/bin/env pdftotext %file% -");
80 db_query('INSERT INTO {search_files_helpers} VALUES(NULL, "%s", "%s", "%s")', "Text", "txt", "/usr/bin/env cat %file%");
81 //change variable search_cron_limit to 10 so cron doesn't keep timing out
82 variable_set('search_cron_limit', 10);
83 drupal_set_message(t('Your search cron limit, which limits the number of items searched per cron run, has been set to 10. If it had been left at the default 100 your cron jobs could potentially continuously timeout. If you want to change this back you can do so <a href="!link">here</a>', array('!link' => url('admin/settings/search'))));
84 }
85
86 function search_files_uninstall() {
87 drupal_uninstall_schema('search_files');
88 db_query('DELETE FROM {search_dataset} WHERE TYPE LIKE "search_files"');
89 db_query('DELETE FROM {search_index} WHERE TYPE LIKE "search_files"');
90 variable_del('search_files_label');
91 drupal_set_message(t('Search Files successfully uninstalled.'));
92 }

  ViewVC Help
Powered by ViewVC 1.1.2