You are here

function parser_common_syndication_install in FeedAPI 5

Same name and namespace in other branches
  1. 6 parser_common_syndication/parser_common_syndication.install \parser_common_syndication_install()

Implementation of hook_install().

File

parser_common_syndication/parser_common_syndication.install, line 6

Code

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;
  }

  // Set the parser of defaultly shipped processors if it's not done previously
  $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);
    }
  }
}