feedapi_get_settings
- 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
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 (!isset($settings['parsers'])) {
$settings['parsers'] = 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)) {
$node_type = db_result(db_query("SELECT type FROM {node} WHERE vid = %d", $vid));
}
}
else {
return $node_settings[$vid];
}
}
if (isset($node_type) && is_string($node_type)) {
if (($settings = variable_get('feedapi_settings_'. $node_type, FALSE)) && ($settings['enabled'] == 1)) {
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 {
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;
}
?>