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

Contents of /contributions/modules/spritemenu/spritemenu.install

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


Revision 1.1 - (show annotations) (download) (as text)
Thu Dec 25 21:18:38 2008 UTC (11 months ago) by hanoii
Branch: MAIN
CVS Tags: DRUPAL-5--1-1, DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
File MIME type: text/x-php
Initial commit. This module let you upload a sprite image for a menu item and, with the use of CSS, configure different sprites of the image for different states of the link (normal, visited, hover and active).
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * .install code for the spritemenu module.
7 *
8 */
9
10 function spritemenu_install() {
11 switch ($GLOBALS['db_type']) {
12 case 'mysql':
13 case 'mysqli':
14 db_query("CREATE TABLE {spritemenu} (
15 mid INTEGER NOT NULL DEFAULT 0,
16 path VARCHAR(255) NOT NULL DEFAULT '',
17 filepath VARCHAR(255) NOT NULL DEFAULT '',
18 link VARCHAR(100) NOT NULL DEFAULT '',
19 visited VARCHAR(100) NOT NULL DEFAULT '',
20 hover VARCHAR(100) NOT NULL DEFAULT '',
21 active VARCHAR(100) NOT NULL DEFAULT '',
22 PRIMARY KEY (mid)
23 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
24 break;
25 }
26 }
27
28 function spritemenu_requirements($phase) {
29 $requirements = array();
30 // Ensure translations don't break at install time
31 $t = get_t();
32
33 if ($phase == 'install') {
34 if (function_exists('phptemplate_menu_item_link')) {
35 $requirements['phptemplate_menu_item_link'] = array(
36 'title' => 'phptemplate_menu_item_link',
37 'description' => $t('Sprite Graphic Menu overrides <b><i>phptemplate_menu_item_link()</i></b>, a template function that\'s already defined in your current theme. To install this module, rename your <b><i>template phptemplate_menu_item_link()</i></b> function to <b><i>phptemplate_spritemenu_item_link()</i></b> and you will need to update your temlate function to add the proper identifiers to the menu links.'),
38 'severity' => REQUIREMENT_ERROR,
39 );
40 }
41 if (function_exists('phptemplate_links')) {
42 $requirements['phptemplate_links'] = array(
43 'title' => 'phptemplate_links',
44 'description' => $t('Sprite Graphic Menu overrides <b><i>phptemplate_links()</i></b>, a template function that\'s already defined in your current theme. To install this module, rename your template <b><i>phptemplate_links()</i></b> function to <b><i>phptemplate_spritemenu_links()</i></b> and you will need to update your temlate function to add the proper identifiers to the menu links.'),
45 'severity' => REQUIREMENT_ERROR,
46 );
47 }
48 }
49
50 return $requirements;
51 }
52
53 function spritemenu_uninstall() {
54 require_once('spritemenu.module');
55
56 // Delete all image files from disk
57 $result = db_query("SELECT * FROM {spritemenu}");
58 while ($row = db_fetch_object($result)) {
59 file_delete($row->filepath);
60 }
61
62 // remove css
63 $css = _spritemenu_css_filepath();
64 file_delete($css);
65
66 // remove table
67 db_query("DROP TABLE {spritemenu}");
68
69 // remove settings
70 variable_del('spritemenu_path');
71 }

  ViewVC Help
Powered by ViewVC 1.1.2