function feed_import_list_feeds in Feed Import 7.3
Same name and namespace in other branches
- 7 feed_import.module \feed_import_list_feeds()
- 7.2 feed_import.module \feed_import_list_feeds()
List all feeds
Return value
string A formatted table containing all feeds
1 string reference to 'feed_import_list_feeds'
- feed_import_menu in ./
feed_import.module - Implements hook_menu().
File
- ./
feed_import.module, line 912 - User interface, cron functions for feed_import module
Code
function feed_import_list_feeds() {
// Show a warning about safe mode if is on.
if (ini_get('safe_mode')) {
$msg = array(
'@number' => ini_get('max_execution_time'),
);
$msg = t('Looks like safe mode is on, large imports can break if maximum time limit of @number seconds is exceeded.', $msg);
drupal_set_message($msg, 'warning');
}
// Load all feeds.
$feeds = FeedImport::loadAllFeeds();
$running = array();
if ($run = variable_get('feed_import_import_running', array())) {
foreach ($run as $r) {
$running += array_count_values($r);
}
}
unset($run);
$rows = array();
foreach ($feeds as &$feed) {
$name = l($feed->name, FEED_IMPORT_PATH . '/edit/' . $feed->machine_name . '/feed');
if ($feed->last_run) {
$run = format_date($feed->last_run);
$run .= '<br />';
$run .= t('Duration') . ': ' . gmdate('H:i:s', $feed->last_run_duration);
$run .= '<br />';
$run .= t('Source had @count items', array(
'@count' => $feed->last_run_items,
));
}
else {
$run = t('Never');
}
// Check for running instances
if (isset($running[$feed->machine_name])) {
$run .= '<br /><b>';
$run .= t('Running instances: @count', array(
'@count' => $running[$feed->machine_name],
));
$run .= '</b>';
unset($running[$feed->machine_name]);
}
if (strlen($feed->settings['uniq_path'])) {
$hashes = $feed->settings['hashes']['class'];
$hashes = $hashes::totalHashes($feed->machine_name);
}
else {
$hashes = t('Feed is not monitored');
}
// Add operations.
$op['edit'] = l(t('Edit'), FEED_IMPORT_PATH . '/edit/' . $feed->machine_name . '/feed');
$op['process'] = l(t('Process'), FEED_IMPORT_PATH . '/process/' . $feed->machine_name);
$op['export'] = l(t('Export'), FEED_IMPORT_PATH . '/export/' . $feed->machine_name);
$op['delete'] = l(t('Delete'), FEED_IMPORT_PATH . '/delete/' . $feed->machine_name);
$rows[] = array(
'data' => array(
$name,
$feed->entity,
$feed->cron_import ? t('Enabled') : t('Disabled'),
$run,
$hashes,
$op['edit'],
$op['process'],
$op['export'],
$op['delete'],
),
'class' => array(
$feed->cron_import ? 'enabled-feed' : 'disabled-feed',
),
);
}
// Path to CSS file.
$path = drupal_get_path('module', 'feed_import') . '/feed_import.css';
return array(
'#theme' => 'table',
'#header' => array(
t('Name'),
t('Entity'),
t('Cron import'),
t('Last run'),
t('Monitored items'),
array(
'data' => t('Operations'),
'colspan' => 4,
),
),
'#rows' => $rows,
'#empty' => t('There are no feeds.'),
'#attached' => array(
'css' => array(
$path => array(
'type' => 'file',
),
),
),
);
}