feedapi_get_settings

Versions
5
feedapi_get_settings($node_type, $nid = FALSE, $reset = FALSE)
6
feedapi_get_settings($node_type, $vid = FALSE, $reset = FALSE)

Retrieve settings per content type or per node.

@todo: Use node type settings for pulling on/off and weight of parsers/processors, use per node settings to override their configuration, this allows us a more predictable presets/settings behaviour. See d. o. #191692 Watch out: cache permutations of node_type or node_type+nid or nid. Watch out: changes within page load likely.

Parameters

$node_type Content type name or NULL if per node

$vid Node vid or NULL if per content type

$reset If TRUE, the data is returned from the database.

Return value

The associative array of feedapi settings

▾ 14 functions call feedapi_get_settings()

feedapi_create_node in contributions/feedapi/feedapi.module
Create a feedapi node programatically.
feedapi_drush_parse in contributions/feedapi/feedapi.drush.inc
Invokes the parser and displays the output
feedapi_enabled_type in contributions/feedapi/feedapi.module
Determines wether feedapi is enabled for given node type. If parser or processor is passed in, this function determines wether given parser or processor is enabled for given node type.
feedapi_expire in contributions/feedapi/feedapi.module
Delete expired items and return informations about the feed refreshing
feedapi_form_alter in contributions/feedapi/feedapi.module
Implementation of hook_form_alter().
feedapi_imagegrabber_form_alter in contributions/feedapi_imagegrabber/feedapi_imagegrabber.module
Implementation of hook_form_alter().
feedapi_nodeapi in contributions/feedapi/feedapi.module
Implementation of hook_nodeapi().
feedapi_update_6106 in contributions/feedapi/feedapi.install
Convert checked to next_refresh_time and consolidate skip and next_refresh_time, add an index on next_refresh_time, make next_refresh_time unsigned.
feedapi_update_6107 in contributions/feedapi/feedapi.install
Convert refresh_time values to new constants FEEDAPI_CRON_NEVER_REFRESH and FEEDAPI_CRON_ALWAYS_REFRESH.
_calais_build_semanticproxy_config in contributions/opencalais/calais.admin.inc
Configuration for Semantic Proxy integration. This will
_feedapi_build_feed_object in contributions/feedapi/feedapi.module
Builds feed object ready to be sticked onto node.
_feedapi_insert in contributions/feedapi/feedapi.module
Insert feedapi data to the DB when it's a new for for FeedAPI
_feedapi_invoke_refresh in contributions/feedapi/feedapi.module
Helper function for feedapi_invoke(). Refresh the feed, call the proper parsers and processors' hooks. Don't call this function directly, use feedapi_refresh() instead.
_feedapi_store_settings in contributions/feedapi/feedapi.module
Stores settings per content type or per node.

Code

contributions/feedapi/feedapi.module, line 1399

<?php
function feedapi_get_settings($node_type, $vid = FALSE, $reset = FALSE) {
  static $node_settings;

  if (is_numeric($vid)) {
    if (!isset($node_settings[$vid]) || $reset) {
      if ($settings = db_fetch_object(db_query('SELECT settings FROM {feedapi} WHERE vid = %d', $vid))) {
        $settings = unserialize($settings->settings);
        // If parsers don't have any settings, create an empty array
        if (!isset($settings['parsers'])) {
          $settings['parsers'] = array();
        }
        // If processors don't have any settings, create an empty array
        if (!isset($settings['processors'])) {
          $settings['processors'] = array();
        }
      }
      if (is_array($settings) && count($settings['processors']) == 0 && count($settings['parsers']) == 0) {
        $settings = NULL;
      }
      $node_settings[$vid] = !empty($settings) && is_array($settings) ? $settings : FALSE;
    }
    if (!is_array($node_settings[$vid])) {
      if (empty($node_type)) {
        // In normal case, this shouldn't happen. This is an emergency branch
        $node_type = db_result(db_query("SELECT type FROM {node} WHERE vid = %d", $vid));
      }
    }
    else {
      return $node_settings[$vid];
    }
  }

  // Fallback: node_type.
  if (isset($node_type) && is_string($node_type)) {
    if (($settings = variable_get('feedapi_settings_'. $node_type, FALSE)) && ($settings['enabled'] == 1)) {
      // Sanitize data right now, tricky users may turned off the module
      foreach (array('parsers', 'processors') as $type) {
        if (isset($settings[$type]) && is_array($settings[$type])) {
          $modules = array_keys($settings[$type]);
          foreach ($modules as $module) {
            if (!module_exists($module)) {
              unset($settings['parsers'][$module]);
            }
          }
        }
        else {
          // Missing parser or processor, set error message.
          if (user_access('administer content types')) {
            drupal_set_message(t('There are no !type defined for this content type. Go to !edit_page and enable at least one.', array('!type' => $type, '!edit_page' => l('admin/content/node-type/'. $node_type, 'admin/content/node-type/'. $node_type))), 'warning', FALSE);
          }
          else {
            drupal_set_message(t('There are no !type defined for this content type. Contact your site administrator.', array('!type' => $type)), 'warning', FALSE);
          }
        }
      }
      return $settings;
    }
  }
  return FALSE;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.