views_isotope.install in Brainstorm profile 7
Installation functions.
File
modules/custom/views_isotope/views_isotope.installView source
<?php
/**
* @file
* Installation functions.
*/
/**
* Implements hook_schema().
*/
function views_isotope_schema() {
$schema['isotope_configurations'] = [
'description' => 'Table storing Isotope configurations.',
'export' => [
'key' => 'name',
'key name' => 'Name',
'primary key' => 'pid',
// Exports will be defined as $config.
'identifier' => 'config',
// Function hook name.
'default hook' => 'default_isotope_configuration',
'api' => [
'owner' => 'views_isotope',
// Base name for api include files.
'api' => 'default_isotope_configurations',
'minimum_version' => 1,
'current_version' => 1,
],
],
'fields' => [
'pid' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
// Do not export database-only keys.
'no export' => TRUE,
],
'name' => [
'type' => 'varchar',
'length' => '255',
'description' => 'Unique ID for configs. Used to identify them programmatically.',
],
'admin_title' => [
'type' => 'varchar',
'length' => '255',
'description' => 'Human readable name.',
],
'layoutMode' => [
'type' => 'varchar',
'length' => '255',
'description' => 'One of a list of Isotope Layout Modes.',
],
'plugins' => [
'type' => 'text',
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of plugin names.',
],
'transitionDuration' => [
'type' => 'varchar',
'length' => '10',
'description' => 'In CSS Time format.',
],
'urlFilters' => [
'type' => 'int',
'size' => 'tiny',
'description' => 'Should filters be represented in URL?',
],
'isFitWidth' => [
'type' => 'int',
'size' => 'tiny',
'description' => 'isFitWidth',
],
'isHorizontal' => [
'type' => 'int',
'size' => 'tiny',
'description' => 'isHorizontal',
],
'stamp' => [
'type' => 'varchar',
'length' => '255',
'description' => 'Selector of element to be stamped',
],
'horizontalAlignment' => [
'type' => 'varchar',
'length' => '3',
'description' => 'Decimal between 0 and 1',
],
'verticalAlignment' => [
'type' => 'varchar',
'length' => '3',
'description' => 'Decimal between 0 and 1',
],
'isOriginLeft' => [
'type' => 'int',
'size' => 'tiny',
'description' => 'isOriginLeft',
],
],
'primary key' => [
'pid',
],
'unique keys' => [
'name' => [
'name',
],
],
];
return $schema;
}
/**
* Implements hook_requirements().
*/
function views_isotope_requirements($phase) {
$requirements = [];
if ($phase == "runtime") {
$requirements['isotope'] = [
'title' => t('Isotope library'),
'value' => t('Enabled'),
];
$isotope_scope = views_isotope_check_library();
// If Libraries API is enabled but the .js is not found within the
// sites/all/libraries folder report a warning. The module will fall back to
// its included copy so this isn't a showstopper.
if (function_exists('libraries_get_path') && $isotope_scope == 'cdn') {
$path = libraries_get_path('isotope');
$path = !empty($path) ? $path : 'libraries/isotope';
$requirements['isotope']['value'] = t('Isotope is not correctly using Libraries API');
$requirements['isotope']['severity'] = REQUIREMENT_WARNING;
$requirements['isotope']['description'] = t('Please install <a href="http://isotope.metafizzy.co/">Isotope</a> in <strong>%path</strong>. The module is using an external copy from %cdn', [
'%path' => $path . '/' . VIEWS_ISOTOPE_FILENAME,
'%cdn' => VIEWS_ISOTOPE_CDN_PATH,
]);
}
// If the external copy has been removed or renamed report an error. At this
// point the module cannot function properly.
if ($isotope_scope == FALSE) {
$requirements['isotope']['value'] = t('Isotope is not correctly installed');
$requirements['isotope']['severity'] = REQUIREMENT_ERROR;
$requirements['isotope']['description'] = t('The external script is not available. Please enable the Libraries API module AND install <a href="http://isotope.metafizzy.co/">Isotope</a> in the isotope directory in libraries (sites/all/libraries/isotope/%file).', [
'%file' => VIEWS_ISOTOPE_FILENAME,
]);
}
}
return $requirements;
}
/**
* Add urlFilters field to isotope_configurations table.
*/
function views_isotope_update_7100() {
$spec = [
'type' => 'int',
'size' => 'tiny',
'description' => 'Should filters be represented in URL?',
];
db_add_field('isotope_configurations', 'urlFilters', $spec);
}
/**
* Add isOriginLeft field to isotope_configurations table.
*/
function views_isotope_update_7101() {
$spec = [
'type' => 'int',
'size' => 'tiny',
'description' => 'isOriginLeft',
];
db_add_field('isotope_configurations', 'isOriginLeft', $spec);
}
Functions
Name | Description |
---|---|
views_isotope_requirements | Implements hook_requirements(). |
views_isotope_schema | Implements hook_schema(). |
views_isotope_update_7100 | Add urlFilters field to isotope_configurations table. |
views_isotope_update_7101 | Add isOriginLeft field to isotope_configurations table. |