View source
<?php
define('FEEDS_EX_JSONPATH_LIBRARY_VERSION', '0.5.0');
function feeds_ex_menu() {
$items = array();
$items['_feeds_ex/encoding_autocomplete'] = array(
'title' => 'Encoding autocomplete',
'page callback' => 'feeds_ex_encoding_autocomplete',
'access arguments' => array(
'administer feeds',
),
'type' => MENU_CALLBACK,
'file' => 'feeds_ex.pages.inc',
);
return $items;
}
function feeds_ex_theme() {
return array(
'feeds_ex_configuration_table' => array(
'file' => 'feeds_ex.theme.inc',
'render element' => 'element',
),
);
}
function feeds_ex_modules_enabled(array $modules) {
if (in_array('querypath', $modules)) {
cache_clear_all('plugins:feeds:plugins', 'cache');
}
}
function feeds_ex_registry_files_alter(array &$files, array $modules) {
if (version_compare(PHP_VERSION, '5.4.0', '<') || !module_exists('simpletest')) {
return;
}
if (!feeds_ex_library_path('jmespath.php', 'vendor/autoload.php')) {
return;
}
$path = drupal_get_path('module', 'feeds_ex');
$files[$path . '/src/Tests/FeedsExJmesPath.test'] = array(
'module' => 'feeds_ex',
'weight' => 1,
);
$files[$path . '/src/Tests/FeedsExJmesPathLines.test'] = array(
'module' => 'feeds_ex',
'weight' => 1,
);
}
function feeds_ex_libraries_info() {
$libraries = array();
$libraries['jsonpath'] = array(
'name' => 'JSONPath',
'vendor url' => 'https://github.com/FlowCommunications/JSONPath',
'download url' => 'https://github.com/FlowCommunications/JSONPath/archive/' . FEEDS_EX_JSONPATH_LIBRARY_VERSION . '.tar.gz',
'version' => FEEDS_EX_JSONPATH_LIBRARY_VERSION,
'xautoload' => '_feeds_ex_xautoload_callback',
);
return $libraries;
}
function _feeds_ex_xautoload_callback($adapter) {
try {
$adapter
->composerJson('composer.json');
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error', FALSE);
}
}
function feeds_ex_library_path($library, $file) {
$libraries_path = module_exists('libraries') ? libraries_get_path($library) : FALSE;
if ($libraries_path && is_file($libraries_path . '/' . $file)) {
return $libraries_path . '/' . $file;
}
elseif (is_file(DRUPAL_ROOT . '/sites/all/libraries/' . $library . '/' . $file)) {
return 'sites/all/libraries/' . $library . '/' . $file;
}
return FALSE;
}
function feeds_ex_source_exists($source_id, array $element) {
$sources = feeds_importer($element['#feeds_importer'])->parser
->getMappingSources();
return isset($sources[$source_id]);
}