function entity_embed_requirements in Entity Embed 7
Same name and namespace in other branches
- 7.2 entity_embed.install \entity_embed_requirements()
Implements hook_requirements().
File
- ./
entity_embed.install, line 11 - Install, update and uninstall functions for the entity_embed module.
Code
function entity_embed_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
// Check if the site is running >= jQuery 1.7.
if (($library = drupal_get_library('system', 'jquery')) && version_compare($library['version'], 1.7, '>=')) {
$requirements['entity_embed_jquery'] = array(
'title' => t('Entity Embed jQuery version'),
'value' => t('jQuery @version', array(
'@version' => $library['version'],
)),
'severity' => REQUIREMENT_OK,
);
}
else {
$destination = drupal_get_destination();
$requirements['entity_embed_jquery'] = array(
'title' => t('Entity Embed jQuery version'),
'value' => t('jQuery @version', array(
'@version' => $library['version'],
)),
'description' => t('Entity Embed requires jQuery 1.7 or greater. Configure <a href="@jquery_update">jQuery Update</a>.', array(
'@jquery_update' => url('admin/config/development/jquery_update', array(
'query' => $destination,
)),
)),
'severity' => REQUIREMENT_ERROR,
);
}
// Check if the site is running >= CKEditor 4.3.
if (($version = ckeditor_get_version()) && version_compare($version, 4.3, '>=')) {
$requirements['entity_embed_ckeditor'] = array(
'title' => t('Entity Embed CKEditor version'),
'value' => t('CKEditor @version', array(
'@version' => $version,
)),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['entity_embed_ckeditor'] = array(
'title' => t('Entity Embed CKEditor version'),
'value' => t('CKEditor @version', array(
'@version' => $version,
)),
'description' => t('Entity Embed requires CKEditor 4.3 or greater. Download the latest version of <a href="@ckeditor">CKEditor</a>.', array(
'@ckeditor' => 'http://ckeditor.com/download',
)),
'severity' => REQUIREMENT_ERROR,
);
}
$ckeditor_path = ckeditor_path('local');
// CKEditor may either be installed locally or included via a CDN.
if ($ckeditor_path != '<URL>') {
$editor_path = _ckeditor_script_path();
$editor_path = strtr($editor_path, array(
"%b" => ckeditor_base_path('local'),
"%m" => ckeditor_module_path('local'),
"%l" => ckeditor_library_path('local'),
));
$lineutils_path = $editor_path . '/plugins/lineutils';
// Check if the CKEditor Line Utilities plugin is available.
if (file_exists($lineutils_path)) {
$requirements['entity_embed_lineutils'] = array(
'title' => t('Entity Embed CKEditor Line Utilities plugin'),
'value' => t('Line Utilities plugin found at <code>@path</code>', array(
'@path' => $lineutils_path,
)),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['entity_embed_lineutils'] = array(
'title' => t('Entity Embed CKEditor Line Utilities plugin'),
'value' => t('Widget plugin not found at <code>@path</code>', array(
'@path' => $lineutils_path,
)),
'description' => t('Entity Embed requires the CKEditor Line Utilities plugin. Download the latest version of the <a href="@lineutils">Line Utilities</a> plugin.', array(
'@lineutils' => 'http://ckeditor.com/addon/lineutils',
)),
'severity' => REQUIREMENT_ERROR,
);
}
$widget_path = $editor_path . '/plugins/widget';
// Check if the CKEditor Widget plugin is available.
if (file_exists($widget_path)) {
$requirements['entity_embed_widget'] = array(
'title' => t('Entity Embed CKEditor Widget plugin'),
'value' => t('Widget plugin found at <code>@path</code>', array(
'@path' => $widget_path,
)),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['entity_embed_widget'] = array(
'title' => t('Entity Embed CKEditor Widget plugin'),
'value' => t('Widget plugin not found at <code>@path</code>', array(
'@path' => $widget_path,
)),
'description' => t('Entity Embed requires the CKEditor Widget API provided by the Widget plugin. Download the latest version of the <a href="@widget">Widget</a> plugin.', array(
'@widget' => 'http://ckeditor.com/addon/widget',
)),
'severity' => REQUIREMENT_ERROR,
);
}
}
else {
$editor_url = ckeditor_path('url');
// The CKEditor Line Utilities and Widget plugins are included with the
// standard-all and full-all distributions.
if (preg_match("/\\/(standard|full)-all/", $editor_url)) {
$requirements['entity_embed_lineutils'] = array(
'title' => t('Entity Embed CKEditor Line Utilities plugin'),
'value' => t('Line Utilities plugin included with the current CKEditor CDN distribution.'),
'severity' => REQUIREMENT_OK,
);
$requirements['entity_embed_widget'] = array(
'title' => t('Entity Embed CKEditor Widget plugin'),
'value' => t('Widget plugin included with the current CKEditor CDN distribution.'),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['entity_embed_lineutils'] = array(
'title' => t('Entity Embed CKEditor Line Utilities plugin'),
'value' => t('Line Utilities plugin not included with the current CKEditor CDN distribution.'),
'description' => t('Entity Embed requires the CKEditor Line Utilities plugin. You must use either the standard-all or full-all <a href="@distributions">CKEditor CDN distributions</a>.', array(
'@distributions' => 'https://cdn.ckeditor.com/#url-structure',
)),
'severity' => REQUIREMENT_ERROR,
);
$requirements['entity_embed_widget'] = array(
'title' => t('Entity Embed CKEditor Widget plugin'),
'value' => t('Widget plugin not included with the current CKEditor CDN distribution.'),
'description' => t('Entity Embed requires the CKEditor Widget API provided by the Widget plugin. You must use either the standard-all or full-all <a href="@distributions">CKEditor CDN distributions</a>.', array(
'@distributions' => 'https://cdn.ckeditor.com/#url-structure',
)),
'severity' => REQUIREMENT_ERROR,
);
}
}
}
return $requirements;
}