| 1 |
<?php
|
| 2 |
// $Id: contextlinks.install,v 1.2 2006/05/10 16:14:45 jhriggs Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Handles installation and updates for the contextlinks module.
|
| 6 |
*
|
| 7 |
* @version $Id: contextlinks.install,v 1.2 2006/05/10 16:14:45 jhriggs Exp $
|
| 8 |
* @copyright Copyright (c) 2006-2007 Jim Riggs. All rights reserved.
|
| 9 |
* @author Jim Riggs <drupal at jim and lissa dot com>
|
| 10 |
*/
|
| 11 |
|
| 12 |
/********************************************************************
|
| 13 |
* Drupal Hooks
|
| 14 |
********************************************************************/
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Installs the contextlinks module by creating the table and setting the
|
| 18 |
* version variable.
|
| 19 |
*/
|
| 20 |
function contextlinks_install() {
|
| 21 |
global $db_type;
|
| 22 |
|
| 23 |
db_query('
|
| 24 |
CREATE TABLE {contextlinks_class} (
|
| 25 |
cid INTEGER NOT NULL PRIMARY KEY,
|
| 26 |
name VARCHAR(16) NOT NULL UNIQUE,
|
| 27 |
position INTEGER(1) NOT NULL,
|
| 28 |
new_window INTEGER(1) NOT NULL,
|
| 29 |
image VARCHAR(255) NOT NULL,
|
| 30 |
string VARCHAR(255) NOT NULL,
|
| 31 |
link_text INTEGER(1) NOT NULL,
|
| 32 |
url_template VARCHAR(255) NOT NULL
|
| 33 |
) /*!40100 DEFAULT CHARACTER SET utf8 */
|
| 34 |
');
|
| 35 |
|
| 36 |
if ($db_type == 'pgsql') {
|
| 37 |
db_query('CREATE SEQUENCE {contextlinks}_cid_seq');
|
| 38 |
}
|
| 39 |
|
| 40 |
$query = "INSERT INTO {contextlinks_class} (cid, name, position, new_window, image, string, link_text, url_template) VALUES (%d, '%s', %d, %d, '%s', '%s', %d, '%s')";
|
| 41 |
$path = drupal_get_path('module', 'contextlinks');
|
| 42 |
$default = db_next_id('{contextlinks}_cid');
|
| 43 |
|
| 44 |
db_query($query, $default, 'link', 1, 0, '', '', 1, '');
|
| 45 |
db_query($query, db_next_id('{contextlinks}_cid'), 'external', 1, 1, "$path/images/external.gif", '', 1, '');
|
| 46 |
db_query($query, db_next_id('{contextlinks}_cid'), 'info', 1, 0, "$path/images/info.gif", '', 0, '');
|
| 47 |
db_query($query, db_next_id('{contextlinks}_cid'), 'info-text', 1, 0, '', '[info]', 0, '');
|
| 48 |
db_query($query, db_next_id('{contextlinks}_cid'), 'note', 1, 0, "$path/images/note.gif", '', 0, '');
|
| 49 |
db_query($query, db_next_id('{contextlinks}_cid'), 'note-text', 1, 0, '', '[note]', 0, '');
|
| 50 |
db_query($query, db_next_id('{contextlinks}_cid'), 'person', 1, 0, "$path/images/person.gif", '', 0, '');
|
| 51 |
db_query($query, db_next_id('{contextlinks}_cid'), 'person-text', 1, 0, '', '[person]', 0, '');
|
| 52 |
db_query($query, db_next_id('{contextlinks}_cid'), 'question', 1, 0, "$path/images/question.gif", '', 0, '');
|
| 53 |
db_query($query, db_next_id('{contextlinks}_cid'), 'question-text', 1, 0, '', '[?]', 0, '');
|
| 54 |
db_query($query, db_next_id('{contextlinks}_cid'), 'warning', 1, 0, "$path/images/warning.gif", '', 0, '');
|
| 55 |
db_query($query, db_next_id('{contextlinks}_cid'), 'warning-text', 1, 0, '', '[warning]', 0, '');
|
| 56 |
db_query($query, db_next_id('{contextlinks}_cid'), 'google', 1, 0, '', '[Google]', 0, 'http://google.com/search?q=');
|
| 57 |
db_query($query, db_next_id('{contextlinks}_cid'), 'amazon', 1, 0, '', '[Amazon]', 0, 'http://www.amazon.com/exec/obidos/external-search/?field-keywords={}&mode=blended');
|
| 58 |
|
| 59 |
variable_set('contextlinks_default', $default);
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
| 63 |
* Implementation of hook_uninstall().
|
| 64 |
*/
|
| 65 |
function contextlinks_uninstall() {
|
| 66 |
global $db_type;
|
| 67 |
|
| 68 |
db_query('DROP TABLE {contextlinks_class}');
|
| 69 |
|
| 70 |
if ($db_type == 'pgsql') {
|
| 71 |
db_query('DROP SEQUENCE {contextlinks}_cid_seq');
|
| 72 |
}
|
| 73 |
|
| 74 |
variable_del('contextlinks_default');
|
| 75 |
}
|
| 76 |
|
| 77 |
/**
|
| 78 |
* Updates existing tables to UTF-8.
|
| 79 |
*/
|
| 80 |
function contextlinks_update_1() {
|
| 81 |
return _system_update_utf8(array('contextlinks_class'));
|
| 82 |
}
|
| 83 |
|
| 84 |
/**
|
| 85 |
* Deletes the old version variable and displays installation
|
| 86 |
* message.
|
| 87 |
*/
|
| 88 |
function contextlinks_update_2() {
|
| 89 |
variable_del('contextlinks_version');
|
| 90 |
}
|
| 91 |
|
| 92 |
/**
|
| 93 |
* Drops ctime, mtime, and uid columns and adds the url_template column.
|
| 94 |
*/
|
| 95 |
function contextlinks_update_3() {
|
| 96 |
$items = array();
|
| 97 |
|
| 98 |
$items[] = update_sql('ALTER TABLE {contextlinks_class} DROP COLUMN ctime');
|
| 99 |
$items[] = update_sql('ALTER TABLE {contextlinks_class} DROP COLUMN mtime');
|
| 100 |
$items[] = update_sql('ALTER TABLE {contextlinks_class} DROP COLUMN uid');
|
| 101 |
$items[] = update_sql('ALTER TABLE {contextlinks_class} ADD url_template VARCHAR(255) NOT NULL');
|
| 102 |
|
| 103 |
return $items;
|
| 104 |
}
|
| 105 |
|
| 106 |
?>
|