parser_simplepie.install in FeedAPI 5
File
parser_simplepie/parser_simplepie.install
View source
<?php
function parser_simplepie_install() {
$path = drupal_get_path('module', 'parser_simplepie') . '/simplepie.inc';
if (!file_exists($path)) {
drupal_set_message('<b>' . t("To use SimplePie parser, obtain the !simplepie package and copy simplepie.inc to the parser_simplepie directory.", array(
'!simplepie' => l('SimplePie', 'http://simplepie.org/downloads', array(), NULL, NULL, TRUE),
)) . '</b>');
}
$default_processors = array(
'feed',
'feedapi_aggregator',
);
$set_simplepie = array(
"parsers" => array(
"parser_simplepie" => array(
"enabled" => TRUE,
"weight" => 0,
),
),
);
foreach ($default_processors as $processor) {
$settings = variable_get('feedapi_settings_' . $processor, FALSE);
if (!isset($settings['parsers'])) {
$settings = is_array($settings) ? array_merge($settings, $set_simplepie) : $set_simplepie;
variable_set('feedapi_settings_' . $processor, $settings);
}
}
}
function parser_simplepie_uninstall() {
$cache_dir = variable_get('parser_simplepie_cache', FALSE);
if (is_dir($cache_dir)) {
$dp = opendir($cache_dir);
while (($file = readdir($dp)) !== FALSE) {
if (is_file($file)) {
unlink($cache_dir . '/' . $file);
}
}
closedir($dp);
rmdir($cache_dir);
}
variable_del('parser_simplepie_cache');
}
function parser_simplepie_update_1() {
$path_to_files = file_create_path(file_directory_path() . '/simplepie_cache');
if (!file_exists($path_to_files)) {
mkdir($path_to_files);
}
if (!is_writeable($path_to_files)) {
return FALSE;
}
variable_set('parser_simplepie_cache', $path_to_files);
return array();
}