brilliant_gallery.install in Brilliant Gallery 7.2
Install, update and uninstall functions for the brilliant_gallery module.
File
brilliant_gallery.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the brilliant_gallery module.
*
*/
/**
* Implements hook_uninstall().
*/
function brilliant_gallery_uninstall() {
$query = db_select('variable', 'v')
->fields('v', array(
'name',
))
->condition('name', db_like('brilliant_gallery') . '%', 'LIKE')
->execute();
while ($variable = $query
->fetchAssoc()) {
variable_del($variable['name']);
}
}
/**
* Implements hook_schema().
*/
function brilliant_gallery_schema() {
$schema = array();
$schema['brilliant_gallery_sources'] = array(
'description' => 'Caches some information about all images under the main Brilliant Gallery album folder.',
'fields' => array(
'pathname_hash' => array(
'type' => 'varchar',
'length' => 32,
'description' => 'Hash based on path and filename.',
'not null' => TRUE,
),
'path' => array(
'description' => 'Path to the image relative to the main album folder, without starting or ending slashes.',
'type' => 'varchar',
'length' => '2048',
'not null' => TRUE,
),
'filename' => array(
'description' => 'File name of the image.',
'type' => 'text',
'size' => 'tiny',
'not null' => TRUE,
),
'mtime' => array(
'description' => 'Date and time of last change of this file.',
'type' => 'datetime',
'mysql_type' => 'DATETIME',
'pgsql_type' => 'timestamp without time zone',
'sqlite_type' => 'VARCHAR',
'sqlsrv_type' => 'smalldatetime',
'not null' => TRUE,
),
'datime' => array(
'description' => 'Date and time of this file row insert or update.',
'type' => 'datetime',
'mysql_type' => 'DATETIME',
'pgsql_type' => 'timestamp without time zone',
'sqlite_type' => 'VARCHAR',
'sqlsrv_type' => 'smalldatetime',
'not null' => TRUE,
),
'hidden' => array(
'description' => 'A flag indicating the given image was marked to remain hidden.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
),
'caption' => array(
'description' => 'Caption for the image.',
'type' => 'text',
'size' => 'tiny',
'not null' => TRUE,
),
),
'primary key' => array(
'pathname_hash',
),
/*
'unique keys' => array(
'path_filename_mtime' => array(
array('path', 255),
array('filename', 255),
'mtime',
),
),
*/
'indexes' => array(
'path' => array(
array(
'path',
255,
),
),
'filename' => array(
array(
'filename',
255,
),
),
'mtime' => array(
'mtime',
),
'datime' => array(
'datime',
),
'hidden' => array(
'hidden',
),
'caption' => array(
array(
'caption',
20,
),
),
),
);
return $schema;
}
/**
*
*/
/*
function brilliant_gallery_update_7204() {
// Precaution (the table might have been made before without deletion).
if (db_table_exists('brilliant_gallery_image_arrays_old')) {
db_drop_table('brilliant_gallery_image_arrays_old');
}
db_query('ALTER TABLE {brilliant_gallery_image_arrays} RENAME {brilliant_gallery_image_arrays_old};');
$schema = array();
$schema['brilliant_gallery_image_arrays'] = array(
'description' => t('Binds image property array with its hash that is present in the cached file name and in the URL.'),
'fields' => array(
'hash' => array(
'description' => t('Hash of the serialized array.'),
'type' => 'varchar',
'length' => '32',
'not null' => TRUE,
),
'array' => array(
'description' => t('Array of image parametres.'),
'type' => 'text',
'not null' => TRUE,
),
'datetime' => array(
'description' => t('Date and time of last value refresh.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('hash'),
'indexes' => array(
'datetime' => array('datetime'),
),
);
if (!db_table_exists('brilliant_gallery_image_arrays')) {
db_create_table('brilliant_gallery_image_arrays', $schema['brilliant_gallery_image_arrays']);
}
$result = db_select('brilliant_gallery_image_arrays_old', 'b')
->fields('b', array('hash', 'array', 'datetime'))
->execute();
foreach ($result as $row) {
$nid = db_insert('brilliant_gallery_image_arrays')
->fields(array(
'hash' => $row->hash,
'array' => $row->array,
'datetime' => strtotime($row->datetime),
))
->execute();
}
db_drop_table('brilliant_gallery_image_arrays_old');
}
*/
/**
* Implements hook_requirements().
*/
function brilliant_gallery_requirements($phase) {
$requirements = array();
$t = get_t();
// Verify that the user has defined the root albums folder.
// If not, display a warning on the status page.
if ($phase == 'runtime') {
$rootalbumsdefined = FALSE;
// It's a weak test but better than none.
if (variable_get('brilliant_gallery_folder') != '') {
$rootalbumsdefined = TRUE;
}
if (!$rootalbumsdefined) {
$requirements['brilliant_gallery_authentication']['title'] = $t('Brilliant Gallery requirements');
$requirements['brilliant_gallery_authentication']['description'] = $t('You can set Brilliant Gallery root gallery folder <a href="/admin/config/brilliant_gallery">here</a>.');
$requirements['brilliant_gallery_authentication']['severity'] = REQUIREMENT_ERROR;
$requirements['brilliant_gallery_authentication']['value'] = $t('Brilliant Gallery root gallery folder has NOT been defined yet');
}
else {
$params = array(
'%brilliant_gallery_folder' => variable_get('brilliant_gallery_folder', 0),
);
$requirements['brilliant_gallery_folder'] = array(
'title' => $t('Brilliant Gallery'),
'description' => $t('The root gallery folder under files/ has been defined as: %brilliant_gallery_folder. If ever needed, you can change it <a href="/admin/config/brilliant_gallery">here</a>.', $params),
'severity' => REQUIREMENT_OK,
'value' => $t('Brilliant Gallery root gallery folder has been defined'),
);
}
}
return $requirements;
}
Functions
Name![]() |
Description |
---|---|
brilliant_gallery_requirements | Implements hook_requirements(). |
brilliant_gallery_schema | Implements hook_schema(). |
brilliant_gallery_uninstall | Implements hook_uninstall(). |