quail_api.install in Quail API 7
Same filename and directory in other branches
Install file for the quail api.
File
quail_api.installView source
<?php
/**
* @file
* Install file for the quail api.
*/
/**
* Implements hook_requirements().
*/
function quail_api_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$t = get_t();
$requirements['quail_library_available'] = array();
$requirements['quail_library_available']['title'] = $t("Quail Library");
$requirements['quail_library_available']['value'] = $t("Failed");
$requirements['quail_library_available']['severity'] = REQUIREMENT_ERROR;
if (function_exists('libraries_detect')) {
$library = libraries_detect('quail');
}
else {
$library = FALSE;
}
if ($library) {
$library = libraries_load('quail');
if (empty($library['loaded'])) {
if (empty($library['error'])) {
$requirements['quail_library_available']['value'] = $t('Found but Failed to Load');
$requirements['quail_library_available']['description'] = $t("Unable to load Quail-Lib.");
}
else {
$requirements['quail_library_available']['value'] = $library['error'];
$requirements['quail_library_available']['description'] = $library['error message'];
}
}
else {
$requirements['quail_library_available']['value'] = $library['version'];
$requirements['quail_library_available']['severity'] = REQUIREMENT_OK;
}
}
else {
if (empty($library['error'])) {
$log_message = "Unable to find the Quail php library. ";
$log_message .= "You can download the Quail library from <a href='@quail_url'>@quail_url</a>. ";
$log_message .= "Make sure to place the extracted quail library at the appropriate library path, (which is usually in /sites/all/libraries/)";
$requirements['quail_library_available']['description'] = $t($log_message, array(
'@quail_url' => "http://code.google.com/p/quail-lib/",
));
}
else {
$requirements['quail_library_available']['value'] = $library['error'];
$requirements['quail_library_available']['description'] = $library['error message'];
}
}
}
return $requirements;
}
/**
* Implementation of hook_schema().
*/
function quail_api_schema() {
$schema = array();
$schema['quail_api_tests'] = array(
'fields' => array(
'id' => array(
'description' => st("A numerical primary key that uniquely represents this node type. Any foreign keys should point to this."),
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
'size' => 'big',
),
'severity' => array(
'description' => st("This is the numeric representation of the quail test display levels."),
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'machine_name' => array(
'description' => st("This is the machine-friendly name used by the quail library that represents the test."),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'human_name' => array(
'description' => st("This is the human-friendly name used by the quail library that represents the test."),
'type' => 'text',
'size' => 'normal',
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => st("This is the description the test that this row represents."),
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'id',
),
'unique keys' => array(
'machine_name' => array(
'machine_name',
),
),
);
// workaround mysql's violation of the SQL standard in a way that does not break standards-compliant databases.
// @see https://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html
// @see https://bugs.mysql.com/bug.php?id=25520
// @see https://drupal.org/node/1401782
// @see https://drupal.org/node/143881
if (db_driver() == 'mysql') {
unset($schema['quail_api_tests']['fields']['human_name']['default']);
unset($schema['quail_api_tests']['fields']['description']['default']);
}
return $schema;
}
/**
* Implementation of hook_disable().
*/
function quail_api_disable() {
if (function_exists('quail_api_reset_cache')) {
quail_api_reset_cache();
}
}
Functions
Name | Description |
---|---|
quail_api_disable | Implementation of hook_disable(). |
quail_api_requirements | Implements hook_requirements(). |
quail_api_schema | Implementation of hook_schema(). |