You are here

smiley.install in Smiley 6

Same filename and directory in other branches
  1. 7 smiley.install

File

smiley.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function smiley_schema() {
  $schema['smiley'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'acronyms' => array(
        'type' => 'varchar',
        'not null' => TRUE,
        'default' => '',
        'length' => 255,
      ),
      'image' => array(
        'type' => 'varchar',
        'not null' => TRUE,
        'default' => '',
        'length' => 255,
      ),
      'description' => array(
        'type' => 'varchar',
        'not null' => TRUE,
        'default' => '',
        'length' => 64,
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'standalone' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'promote_to_box' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'size' => 'tiny',
      ),
      'package' => array(
        'type' => 'varchar',
        'not null' => TRUE,
        'default' => 'Miscellaneous',
        'length' => 64,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function smiley_install() {

  // Create tables.
  $result = drupal_install_schema('smiley');

  // Feed sample data.
  if ($result) {
    $path = drupal_get_path('module', 'smiley') . '/packs/Roving/';
    $examples = array(
      array(
        ':) :-) :smile:',
        'smile.png',
        'Smile',
        1,
      ),
      array(
        ':D :-D :lol:',
        'lol.png',
        'Laughing out loud',
        1,
      ),
      array(
        ':bigsmile:',
        'bigsmile.png',
        'Big smile',
        1,
      ),
      array(
        ';) ;-) :wink:',
        'wink.png',
        'Wink',
        1,
      ),
      array(
        ':p :-p :tongue:',
        'tongue.png',
        'Tongue',
        1,
      ),
      array(
        ':O :-O :shock:',
        'shock.png',
        'Shock',
        1,
      ),
      array(
        ':| :-| :stare:',
        'flat.png',
        'Stare',
        1,
      ),
      array(
        ':( :-( :sad:',
        'aw.png',
        'Sad',
        1,
      ),
      array(
        ':~ :-~ :puzzled:',
        'puzzled.png',
        'Puzzled',
        1,
      ),
      array(
        ':(( :-(( :cry:',
        'sad.png',
        'Crying',
        1,
      ),
      array(
        '8) 8-) :cool:',
        'cool.png',
        'Cool',
        1,
      ),
      array(
        ':steve:',
        'steve.png',
        'Steve',
        1,
      ),
      array(
        'J) J-) :crazy:',
        'crazy.png',
        'Crazy',
        1,
      ),
      array(
        ':glasses:',
        'glasses.png',
        'Glasses',
        1,
      ),
      array(
        ':party:',
        'party.png',
        'Party',
        1,
      ),
      array(
        ':love:',
        'love.png',
        'Love',
        1,
      ),
      array(
        ':X :-X :oups:',
        'oups.png',
        'Oups',
        0,
      ),
      array(
        ':8) :8-) :shy:',
        'shy.png',
        'Shy',
        0,
      ),
      array(
        '0:) 0) 0:-) :innocent:',
        'innocent.png',
        'Innocent',
        0,
      ),
      array(
        ':* :-* :sexy:',
        'sexy.png',
        'Sexy',
        0,
      ),
      array(
        '|( \\( :angry:',
        'angry.png',
        'Angry',
        0,
      ),
      array(
        ':Sp :-S) :sick:',
        'sick.png',
        'Sick',
        0,
      ),
      array(
        ':tired:',
        'tired.png',
        'Tired',
        0,
      ),
      array(
        ':santa:',
        'santa.png',
        'Santa',
        0,
      ),
      array(
        ':mail:',
        'mail.png',
        'Mail',
        0,
      ),
      array(
        ':sushi:',
        'sushi.png',
        'Sushi',
        0,
      ),
      array(
        ':hat:',
        'hat.png',
        'Hat',
        0,
      ),
      array(
        'H) H:) H:-) :grade:',
        'grade.png',
        'Grade',
        0,
      ),
      array(
        ':ghost:',
        'ghost.png',
        'Ghost',
        0,
      ),
      array(
        '$) $-) :cash:',
        'cash.png',
        'Cash',
        0,
      ),
      array(
        ':crown:',
        'crown.png',
        'Crown',
        0,
      ),
      array(
        ':davie:',
        'davie.png',
        'Davie',
        0,
      ),
      array(
        'S) S) :drunk:',
        'drunk.png',
        'Drunk',
        0,
      ),
      array(
        '>) >-) :evil:',
        'evil.png',
        'Evil',
        0,
      ),
      array(
        ':beer:',
        'beer.png',
        'Beer',
        0,
      ),
      array(
        ':star:',
        'star.png',
        'Star',
        0,
      ),
      array(
        ':arrow:',
        'arrow.png',
        'Arrow',
        0,
      ),
      array(
        ':quest:',
        'quest.png',
        'Quest',
        0,
      ),
      array(
        ':exmark:',
        'mark.png',
        'Exclamation Mark',
        0,
      ),
    );
    foreach ($examples as $example) {
      db_query("INSERT INTO {smiley} (acronyms, image, description, standalone, promote_to_box, package) VALUES ('%s', '%s', '%s', 1, '%d', '%s');", $example[0], $path . $example[1], $example[2], $example[3], 'Roving');
    }
  }
}

/**
* Implementation of hook_uninstall().
*/
function smiley_uninstall() {

  // Remove variables.
  variable_del('smiley_enable_for_comments');
  variable_del('smiley_enable_for_nodes');
  variable_del('smiley_node_types_content');
  variable_del('smiley_select_box_expanded');
  variable_del('smiley_enable_dialog');
  variable_del('smiley_dialog_titles');
  variable_del('smiley_dialog_draggable');
  variable_del('smiley_dialog_resizable');
  variable_del('smiley_dialog_height');
  variable_del('smiley_dialog_width');

  // Remove tables.
  drupal_uninstall_schema('smiley');
}

Functions

Namesort descending Description
smiley_install Implementation of hook_install().
smiley_schema Implementation of hook_schema().
smiley_uninstall Implementation of hook_uninstall().