textimage.install in Textimage 7.2
Same filename and directory in other branches
Installation callback for Textimage.
File
textimage.installView source
<?php
/**
* @file
* Installation callback for Textimage.
*/
/**
* Implements hook_requirements().
*/
function textimage_requirements($phase) {
// Ensure translations don't break at install time.
$t = get_t();
$requirements['textimage_gd'] = array(
'title' => $t('GD library'),
);
if (function_exists('imagegd2')) {
// Put GD Info into an array.
$info = gd_info();
// Get GD Version.
$requirements['textimage_gd']['value'] = $info['GD Version'];
// Check for FreeType support.
if (function_exists('imagettftext') && $info["FreeType Support"]) {
if (!module_exists('color') && !module_exists('imageapi_gd')) {
$requirements['textimage_gd']['severity'] = REQUIREMENT_OK;
}
else {
$requirements = array();
}
}
else {
$requirements['textimage_gd']['severity'] = REQUIREMENT_ERROR;
$requirements['textimage_gd']['description'] = $t('The GD library for PHP is enabled, but was compiled without FreeType support. Please check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array(
'@url' => 'http://www.php.net/manual/en/ref.image.php',
));
}
}
else {
$requirements['textimage_gd'] = array(
'value' => $t('Not installed'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('The GD library for PHP is missing or outdated. Please check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array(
'@url' => 'http://www.php.net/manual/en/image.setup.php',
)),
);
}
return $requirements;
}
/**
* Implements hook_schema().
*/
function textimage_schema() {
$schema['textimage_preset'] = array(
'export' => array(
'key' => 'name',
'identifier' => 'preset',
'default hook' => 'textimage_preset',
'api' => array(
'owner' => 'textimage',
'api' => 'textimage',
'minimum_version' => 1,
'current_version' => 1,
),
'list callback' => 'textimage_ctools_export_list',
'load callback' => 'textimage_ctools_export_load',
),
'fields' => array(
'pid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'description' => array(
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
'settings' => array(
'type' => 'text',
'not null' => TRUE,
),
),
'primary key' => array(
'pid',
),
);
$schema['textimage_image'] = array(
'fields' => array(
'pid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'file' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'data' => array(
'type' => 'text',
'not null' => TRUE,
),
),
'primary key' => array(
'file',
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function textimage_uninstall() {
file_unmanaged_delete_recursive('public://textimage');
db_delete('variable')
->condition('name', '%' . db_like('textimage_') . '%', 'LIKE')
->execute();
cache_clear_all('variables', 'cache');
}
Functions
Name | Description |
---|---|
textimage_requirements | Implements hook_requirements(). |
textimage_schema | Implements hook_schema(). |
textimage_uninstall | Implements hook_uninstall(). |