View source
<?php
module_load_include('inc', 'patterns', 'includes/variables');
module_load_include('inc', 'patterns', 'includes/config');
module_load_include('inc', 'patterns', 'includes/path');
module_load_include('inc', 'patterns', 'includes/io/io');
function patterns_install() {
}
function patterns_uninstall() {
$del = db_delete('variable')
->condition('name', 'patterns_%', 'LIKE')
->execute();
}
function patterns_schema() {
$schema['patterns'] = array(
'description' => 'Stores patterns information.',
'fields' => array(
'pid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique pattern ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 55,
'default' => '',
'description' => 'Machine readable name of this pattern.',
),
'format' => array(
'type' => 'varchar',
'length' => 10,
'default' => '',
'description' => 'Format of the patterns (XML, YAML, etc.).',
),
'status' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Boolean indicating whether the pattern has been executed (enabled).',
),
'public' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Boolean indicating whether the pattern is published (available for sharing via patterns server).',
),
'file' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Path of the pattern file relative to Drupal root.',
),
'updated' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '0',
'description' => 'The Unix timestamp indicating when the pattern file was last time updated (modified).',
),
'enabled' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '0',
'description' => 'The Unix timestamp indicating when the pattern was last time executed.',
),
'title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Title of the pattern.',
),
'description' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Description of the pattern.',
),
'pattern' => array(
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
'description' => 'A serialized array containing pattern code.',
),
),
'primary key' => array(
'pid',
),
'unique keys' => array(
'name' => array(
'name',
),
),
);
return $schema;
}
function patterns_update_7026() {
$spec = array(
'type' => 'varchar',
'length' => 10,
'default' => '',
'description' => 'Format of the patterns (XML, YAML, etc.).',
);
db_add_field('patterns', 'format', $spec);
}
function patterns_requirements($phase) {
$requirements = array();
if (!_patterns_io_is_patterns_dir_ready(NULL, FILE_CREATE_DIRECTORY)) {
$requirements['pdir'] = array(
'title' => t('Patterns files dir writable'),
'description' => t("Patterns folder doesn't exist or is not writable: !path", array(
'!path' => patterns_path_get_files_dir(),
)),
'severity' => REQUIREMENT_WARNING,
'value' => t('Not writable'),
);
}
else {
$requirements['pdir'] = array(
'title' => t('Patterns files dir'),
'severity' => REQUIREMENT_OK,
'value' => t('Writable'),
);
}
switch ($phase) {
case 'runtime':
if (!ini_get('allow_url_fopen')) {
$requirements['allow_url_fopen'] = array(
'title' => t('Patterns import files from remote URL'),
'description' => t('To import patterns directly from remote URL \'allow_url_fopen\' must be enabled in your PHP configuration.'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Disabled'),
);
}
$library = libraries_detect('codemirror');
if (empty($library['installed'])) {
$requirements['codemirror'] = array(
'title' => t('CodeMirror (JavaScript based code editor)'),
'description' => t('Patterns editor can be better visualized with CodeMirror. To enable CodeMirror support, download the !codemirror and copy it into the libraries folder (e.g. sites/all/libraries/codemirror/). Error: !error', array(
'!codemirror' => l(t('library'), 'https://github.com/marijnh/CodeMirror/', array(
'absolute' => TRUE,
)),
'!error' => $library['error message'],
)),
'severity' => REQUIREMENT_WARNING,
'value' => t($library['error']),
);
}
else {
$requirements['codemirror'] = array(
'title' => t('CodeMirror Library (JavaScript based code editor)'),
'severity' => REQUIREMENT_OK,
'value' => $library['version'],
);
}
break;
}
return $requirements;
}