You are here

function smileys_install in Smileys 5

Same name and namespace in other branches
  1. 6 smileys.install \smileys_install()

Implementation of hook_install().

File

./smileys.install, line 6

Code

function smileys_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $result = db_query("CREATE TABLE IF NOT EXISTS {smileys} (\n        id int(11) auto_increment,\n        acronyms varchar(255) DEFAULT '' NOT NULL,\n        image varchar(255) DEFAULT '' NOT NULL,\n        description varchar(64) DEFAULT '' NOT NULL,\n        standalone tinyint(1) DEFAULT '0' NOT NULL,\n        promote_to_box tinyint(1) DEFAULT '1' NOT NULL,\n        package varchar(64) DEFAULT 'Uncategorized' NOT NULL,\n        PRIMARY KEY (id)\n      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $result = db_query("CREATE TABLE {smileys} (\n        id SERIAL,\n        acronyms varchar(255) DEFAULT '' NOT NULL,\n        image varchar(255) DEFAULT '' NOT NULL,\n        description varchar(64) DEFAULT '' NOT NULL,\n        standalone INT2 NOT NULL DEFAULT '0',\n        promote_to_box INT2 NOT NULL DEFAULT '1',\n        package varchar(64) DEFAULT 'Uncategorized' NOT NULL,\n        PRIMARY KEY (id)\n      )");
      break;
  }
  if ($result) {
    $dir = drupal_get_path('module', 'smileys') . '/packs/example/';
    $examples = array(
      array(
        ':) :-) :smile:',
        'smile.png',
        'Smiling',
      ),
      array(
        ';) ;-) :wink:',
        'wink.png',
        'Eye-wink',
      ),
      array(
        ':( :-( :sad:',
        'sad.png',
        'Sad',
      ),
      array(
        ':D :-D :lol:',
        'lol.png',
        'Laughing out loud',
      ),
      array(
        '}:) }:-) :evil:',
        'evil.png',
        'Evil',
      ),
      array(
        ':P :-P :tongue:',
        'tongue.png',
        'Sticking out tongue',
      ),
      array(
        ':O :-O :shocked:',
        'shock.png',
        'Shocked',
      ),
      array(
        ':? :-? :puzzled:',
        'puzzled.png',
        'Puzzled',
      ),
      array(
        '8) 8-) :cool:',
        'cool.png',
        'Cool',
      ),
      array(
        ':jawdrop:',
        'jawdrop.gif',
        'Jawdropping!',
      ),
      array(
        ':sick: :barf:',
        'barf.gif',
        'Barf!',
      ),
    );
    foreach ($examples as $data) {
      db_query("INSERT INTO {smileys} (acronyms, image, description, standalone, package) VALUES ('%s', '%s', '%s', 1, '%s');", $data[0], $dir . $data[1], $data[2], 'example');
    }
  }
}