201 lines
5.8 KiB
Plaintext
201 lines
5.8 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Install, update and uninstall functions for the aggregator module.
|
|
*/
|
|
use Drupal\Core\Language\Language;
|
|
|
|
/**
|
|
* Implements hook_requirements().
|
|
*/
|
|
function aggregator_requirements($phase) {
|
|
$has_curl = function_exists('curl_init');
|
|
$requirements = array();
|
|
$requirements['curl'] = array(
|
|
'title' => t('cURL'),
|
|
'value' => $has_curl ? t('Enabled') : t('Not found'),
|
|
);
|
|
if (!$has_curl) {
|
|
$requirements['curl']['severity'] = REQUIREMENT_ERROR;
|
|
$requirements['curl']['description'] = t('The Aggregator module could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/curl.setup.php'));
|
|
}
|
|
return $requirements;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_schema().
|
|
*/
|
|
function aggregator_schema() {
|
|
$schema['aggregator_feed'] = array(
|
|
'description' => 'Stores feeds to be parsed by the aggregator.',
|
|
'fields' => array(
|
|
'fid' => array(
|
|
'type' => 'serial',
|
|
'not null' => TRUE,
|
|
'description' => 'Primary Key: Unique feed ID.',
|
|
),
|
|
'uuid' => array(
|
|
'description' => 'Unique Key: Universally unique identifier for this entity.',
|
|
'type' => 'varchar',
|
|
'length' => 128,
|
|
'not null' => FALSE,
|
|
),
|
|
'title' => array(
|
|
'type' => 'varchar',
|
|
'length' => 255,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => 'Title of the feed.',
|
|
),
|
|
'langcode' => array(
|
|
'description' => 'The {language}.langcode of this feed.',
|
|
'type' => 'varchar',
|
|
'length' => 12,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
),
|
|
'url' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'description' => 'URL to the feed.',
|
|
),
|
|
'refresh' => array(
|
|
'type' => 'int',
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'description' => 'How often to check for new feed items, in seconds.',
|
|
),
|
|
'checked' => array(
|
|
'type' => 'int',
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'description' => 'Last time feed was checked for new items, as Unix timestamp.',
|
|
),
|
|
'queued' => array(
|
|
'type' => 'int',
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
|
|
),
|
|
'link' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'description' => 'The parent website of the feed; comes from the <link> element in the feed.',
|
|
),
|
|
'description' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'size' => 'big',
|
|
'description' => "The parent website's description; comes from the <description> element in the feed.",
|
|
),
|
|
'image' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'size' => 'big',
|
|
'description' => 'An image representing the feed.',
|
|
),
|
|
'hash' => array(
|
|
'type' => 'varchar',
|
|
'length' => 64,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => 'Calculated hash of the feed data, used for validating cache.',
|
|
),
|
|
'etag' => array(
|
|
'type' => 'varchar',
|
|
'length' => 255,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => 'Entity tag HTTP response header, used for validating cache.',
|
|
),
|
|
'modified' => array(
|
|
'type' => 'int',
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'description' => 'When the feed was last modified, as a Unix timestamp.',
|
|
),
|
|
),
|
|
'primary key' => array('fid'),
|
|
'indexes' => array(
|
|
'url' => array(array('url', 255)),
|
|
'queued' => array('queued'),
|
|
),
|
|
'unique keys' => array(
|
|
'title' => array('title'),
|
|
),
|
|
);
|
|
|
|
$schema['aggregator_item'] = array(
|
|
'description' => 'Stores the individual items imported from feeds.',
|
|
'fields' => array(
|
|
'iid' => array(
|
|
'type' => 'serial',
|
|
'not null' => TRUE,
|
|
'description' => 'Primary Key: Unique ID for feed item.',
|
|
),
|
|
'fid' => array(
|
|
'type' => 'int',
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'description' => 'The {aggregator_feed}.fid to which this item belongs.',
|
|
),
|
|
'title' => array(
|
|
'type' => 'varchar',
|
|
'length' => 255,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => 'Title of the feed item.',
|
|
),
|
|
'langcode' => array(
|
|
'description' => 'The {language}.langcode of this feed item.',
|
|
'type' => 'varchar',
|
|
'length' => 12,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
),
|
|
'link' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'description' => 'Link to the feed item.',
|
|
),
|
|
'author' => array(
|
|
'type' => 'varchar',
|
|
'length' => 255,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => 'Author of the feed item.',
|
|
),
|
|
'description' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'size' => 'big',
|
|
'description' => 'Body of the feed item.',
|
|
),
|
|
'timestamp' => array(
|
|
'type' => 'int',
|
|
'not null' => FALSE,
|
|
'description' => 'Posted date of the feed item, as a Unix timestamp.',
|
|
),
|
|
'guid' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'description' => 'Unique identifier for the feed item.',
|
|
)
|
|
),
|
|
'primary key' => array('iid'),
|
|
'indexes' => array(
|
|
'fid' => array('fid'),
|
|
'timestamp' => array('timestamp'),
|
|
),
|
|
'foreign keys' => array(
|
|
'aggregator_feed' => array(
|
|
'table' => 'aggregator_feed',
|
|
'columns' => array('fid' => 'fid'),
|
|
),
|
|
),
|
|
);
|
|
|
|
return $schema;
|
|
}
|