You are here

bueditor.install in BUEditor 5

Same filename and directory in other branches
  1. 6.2 bueditor.install
  2. 6 bueditor.install
  3. 7 bueditor.install

File

bueditor.install
View source
<?php

/**
 * Implementation of hook_install()
 */
function bueditor_install() {
  $created = FALSE;
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {bueditor_editors} (\n        eid int(10) unsigned NOT NULL auto_increment,\n        name varchar(255) NOT NULL default '',\n        pages text NOT NULL,\n        excludes text NOT NULL,\n        PRIMARY KEY (eid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {bueditor_buttons} (\n        bid int(10) unsigned NOT NULL auto_increment,\n        eid int(10) unsigned NOT NULL default '0',\n        title varchar(255) NOT NULL default '',\n        content text NOT NULL,\n        icon varchar(255) NOT NULL default '',\n        accesskey char(1) NOT NULL default '',\n        weight tinyint(1) NOT NULL default '0',\n        PRIMARY KEY (bid),\n        KEY eid (eid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("INSERT INTO {sequences} (name, id) VALUES ('bueditor_editors_eid', 1);");
      $created = TRUE;
      break;
    case 'pgsql':
      db_query("CREATE TABLE {bueditor_editors} (\n        eid SERIAL,\n        name varchar(255) NOT NULL default '',\n        pages text NOT NULL,\n        excludes text NOT NULL,\n        PRIMARY KEY (eid)\n      )");
      db_query("CREATE TABLE {bueditor_buttons} (\n        bid SERIAL,\n        eid integer NOT NULL default '0',\n        title varchar(255) NOT NULL default '',\n        content text NOT NULL,\n        icon varchar(255) NOT NULL default '',\n        accesskey char(1) NOT NULL default '',\n        weight smallint NOT NULL default '0',\n        PRIMARY KEY (bid)\n      )");
      db_query("CREATE INDEX {bueditor_buttons}_eid_idx ON bueditor_buttons(eid);");
      db_query("ALTER SEQUENCE {bueditor_editors}_eid_seq MINVALUE 2 RESTART 2");
      db_query("ALTER SEQUENCE {bueditor_buttons}_bid_seq MINVALUE 10 RESTART 10");
      $created = TRUE;
      break;
  }
  if ($created) {
    db_query("INSERT INTO {bueditor_editors} (eid, name, pages, excludes) VALUES (1, 'default', 'node/add/*\nnode/*/edit\ncomment/reply/*', 'edit-log');");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (1, 1, 'Insert/edit image', '%s', 'image.png', 'M', '-10');", "php:\n\$imce_url = function_exists('imce_menu') && user_access('access imce') ? url('imce/browse') : '';\n\nreturn \"js:\nvar B = eDefBrowseButton('\$imce_url', 'attr_src', 'Browse', 'image');\nvar form = [\n {name: 'src', title: 'Image URL', suffix: B},\n {name: 'width', title: 'Width x Height', suffix: ' x ', getnext: true, attributes: {size: 3}},\n {name: 'height', attributes: {size: 3}},\n {name: 'alt', title: 'Alternative text'}\n];\neDefTagDialog('img', form, 'Insert/edit image', 'OK');\n\";");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (2, 1, 'Insert/edit link', '%s', 'link.png', 'L', '-10');", "php:\n\$imce_url = function_exists('imce_menu') && user_access('access imce') ? url('imce/browse') : '';\n\nreturn \"js:\nvar B = eDefBrowseButton('\$imce_url', 'attr_href', 'Browse', 'link');\nvar form = [\n {name: 'href', title: 'Link href', suffix: B},\n {name: 'title', title: 'Title text'}\n];\neDefTagDialog('a', form, 'Insert/edit link', 'OK');\n\";");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (3, 1, 'Bold', '<strong>%TEXT%</strong>', 'bold.png', 'B', '-9');");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (4, 1, 'Italic', '<em>%TEXT%</em>', 'italic.png', 'I', '-9');");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (5, 1, 'Ordered list. Converts selected lines to a numbered list.', 'js: eDefSelProcessLines(\\'<ol>\\\\n\\', \\' <li>\\', \\'</li>\\', \\'\\\\n</ol>\\');', 'ol.png', 'O', '-8');");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (6, 1, 'Unordered list. Converts selected lines to a bulleted list.', 'js: eDefSelProcessLines(\\'<ul>\\\\n\\', \\' <li>\\', \\'</li>\\', \\'\\\\n</ul>\\');', 'ul.png', 'U', '-8');");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (7, 1, 'Teaser break', '<!--break-->', 'teaserbr.png', 'T', '0');");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (8, 1, 'Preview textarea content.', 'js: eDefPreview();', 'preview.png', 'P', '9');");
    db_query("INSERT INTO {bueditor_buttons} (bid, eid, title, content, icon, accesskey, weight) VALUES (9, 1, 'Get help on button functionality.', 'js: eDefHelp();', 'help.png', 'H', '10');");
  }
}

/**
* Implementation of hook_uninstall().
*/
function bueditor_uninstall() {
  db_query('DROP TABLE {bueditor_buttons}');
  db_query('DROP TABLE {bueditor_editors}');
  if ($GLOBALS['db_type'] == 'mysql' || $GLOBALS['db_type'] == 'mysqli') {
    db_query("DELETE FROM {sequences} WHERE name='bueditor_editors_eid'");
  }
  variable_del('bueditor_user1');
  variable_del('bueditor_roles');
  variable_del('bueditor_cron_last');
}

Functions

Namesort descending Description
bueditor_install Implementation of hook_install()
bueditor_uninstall Implementation of hook_uninstall().