jw_player.install in JW Player 7
Same filename and directory in other branches
Install, update and uninstall functions for the JW Player module.
File
jw_player.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the JW Player module.
*/
/**
* Implements hook_schema().
*/
function jw_player_schema() {
$schema['jwplayer_preset'] = array(
'description' => 'Stores information of JW Player presets',
'export' => array(
'key' => 'machine_name',
'identifier' => 'jw_player_preset',
'default hook' => 'default_jw_player_presets',
// Function hook name
'api' => array(
'owner' => 'jw_player',
'api' => 'jw_player_presets',
// Base name for api include files.
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'preset_name' => array(
'type' => 'varchar',
'length' => 255,
'description' => 'Name for the preset.',
),
'machine_name' => array(
'type' => 'varchar',
'length' => 255,
'description' => 'Unique machine name for every configuration preset.',
),
'description' => array(
'description' => "Provide text summary for the preset",
'type' => 'text',
),
'settings' => array(
'description' => 'Serialized settings array of a given preset.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
),
),
'unique keys' => array(
'machine_name' => array(
'machine_name',
),
),
'primary key' => array(
'machine_name',
),
);
return $schema;
}
/**
* Implements hook_requirements().
*/
function jw_player_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time
$t = get_t();
drupal_load('module', 'libraries');
$directory = libraries_get_path('jwplayer');
// Check the exisence of the JW Player Library
if ($phase == 'runtime') {
$errors = array();
foreach (array(
'player.swf',
'jwplayer.js',
) as $file) {
if (!file_exists($directory . '/' . $file)) {
$errors[] = $t('The file %file is not present in the directory %directory', array(
'%file' => $file,
'%directory' => $directory,
));
}
}
$requirements['jw_player'] = array(
'title' => $t('JW Player'),
'value' => !empty($errors) ? theme('item_list', array(
'items' => $errors,
)) . $t('Please consult INSTALL.txt for installation instructions.') : $t('Installed correctly'),
'severity' => !empty($errors) ? REQUIREMENT_ERROR : REQUIREMENT_OK,
);
}
return $requirements;
}
Functions
Name | Description |
---|---|
jw_player_requirements | Implements hook_requirements(). |
jw_player_schema | Implements hook_schema(). |