You are here

linkimagefield.install in Link Image Field 5

Same filename and directory in other branches
  1. 6 linkimagefield.install
  2. 7 linkimagefield.install

linkimagefield install file

File

linkimagefield.install
View source
<?php

/**
 * @file
 * linkimagefield install file 
 */

/**
 * Implementation of hook_install().
 */
function linkimagefield_install() {
}

/**
 * Data is now stored in per-field tables.
 */
function linkimagefield_update_1() {
  $ret = array();
  include_once drupal_get_path('module', 'content') . '/content.module';
  include_once drupal_get_path('module', 'content') . '/content_admin.inc';
  $fields = content_fields();
  foreach ($fields as $field) {
    switch ($field['type']) {
      case 'file':
        $columns = array(
          'list' => array(
            'type' => 'int',
            'not null' => TRUE,
            'default' => '0',
          ),
        );
        content_alter_db_field(array(), array(), $field, $columns);
        break;
    }
  }
  db_query('DELETE FROM {cache}');
  return $ret;
}

/**
 * Schema change to enable alt and title tags.
 */
function linkimagefield_update_2() {
  $ret = array();
  include_once drupal_get_path('module', 'content') . '/content.module';
  include_once drupal_get_path('module', 'content') . '/content_admin.inc';
  $fields = content_fields();
  foreach ($fields as $field) {
    switch ($field['type']) {
      case 'linkimage':
        $oldcolumns = array(
          'fid' => array(
            'type' => 'int',
            'not null' => TRUE,
            'default' => '0',
          ),
        );
        $newcolumns = array(
          'fid' => array(
            'type' => 'int',
            'not null' => TRUE,
            'default' => '0',
          ),
          'title' => array(
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => "''",
            'sortable' => TRUE,
          ),
          'alt' => array(
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => "''",
            'sortable' => TRUE,
          ),
          'url' => array(
            'type' => 'varchar',
            'length' => 255,
            'not null' => TRUE,
            'default' => "''",
            'sortable' => TRUE,
          ),
        );
        content_alter_db_field($field, $oldcolumns, $field, $newcolumns);
        break;
    }
    drupal_set_message('altered: <br /><pre>' . print_r($field, TRUE) . '</pre>');
  }
  db_query('DELETE FROM {cache}');
  return $ret;
}

Functions

Namesort descending Description
linkimagefield_install Implementation of hook_install().
linkimagefield_update_1 Data is now stored in per-field tables.
linkimagefield_update_2 Schema change to enable alt and title tags.