parser_common_syndication.install in FeedAPI 5
File
parser_common_syndication/parser_common_syndication.install
View source
<?php
function parser_common_syndication_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
db_query("CREATE TABLE {parser_common_syndication} (\n url varchar(255) NOT NULL default '',\n etag TEXT,\n last_modified TEXT)\n ");
break;
case 'pgsql':
db_query("CREATE TABLE {parser_common_syndication} (\n url varchar(255) NOT NULL default '',\n etag TEXT,\n last_modified TEXT)\n ");
break;
}
$default_processors = array(
'feed',
'feedapi_aggregator',
);
$set_common = array(
"parsers" => array(
"parser_common_syndication" => 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_common) : $set_common;
variable_set('feedapi_settings_' . $processor, $settings);
}
}
}
function parser_common_syndication_uninstall() {
db_query("DROP TABLE {parser_common_syndication}");
$cache_dir = variable_get('parser_common_syndication_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_common_syndication_cache');
}
function parser_common_syndication_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$ret[] = update_sql("CREATE TABLE if not exists {parser_common_syndication} (\n url varchar(255) NOT NULL default '',\n etag TEXT,\n last_modified TEXT)\n ");
break;
case 'pgsql':
$ret[] = update_sql("CREATE TABLE {parser_common_syndication} (\n url varchar(255) NOT NULL default '',\n etag TEXT,\n last_modified TEXT)\n ");
break;
}
return $ret;
}