public function AggregatorController::adminOverview

Displays the aggregator administration page.

Return value

array A render array as expected by drupal_render().

1 string reference to 'AggregatorController::adminOverview'
aggregator.routing.yml in drupal/core/modules/aggregator/aggregator.routing.yml
drupal/core/modules/aggregator/aggregator.routing.yml

File

drupal/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php, line 137
Contains \Drupal\aggregator\Controller\AggregatorController.

Class

AggregatorController
Returns responses for aggregator module routes.

Namespace

Drupal\aggregator\Controller

Code

public function adminOverview() {
  $result = $this->database
    ->query('SELECT f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block ORDER BY f.title');
  $header = array(
    t('Title'),
    t('Items'),
    t('Last update'),
    t('Next update'),
    t('Operations'),
  );
  $rows = array();
  foreach ($result as $feed) {
    $row = array();
    $row[] = l($feed->title, "aggregator/sources/{$feed->fid}");
    $row[] = format_plural($feed->items, '1 item', '@count items');
    $row[] = $feed->checked ? t('@time ago', array(
      '@time' => format_interval(REQUEST_TIME - $feed->checked),
    )) : t('never');
    $row[] = $feed->checked && $feed->refresh ? t('%time left', array(
      '%time' => format_interval($feed->checked + $feed->refresh - REQUEST_TIME),
    )) : t('never');
    $links = array();
    $links['edit'] = array(
      'title' => t('Edit'),
      'href' => "admin/config/services/aggregator/edit/feed/{$feed->fid}",
    );
    $links['delete'] = array(
      'title' => t('Delete'),
      'href' => "admin/config/services/aggregator/delete/feed/{$feed->fid}",
    );
    $links['remove'] = array(
      'title' => t('Remove items'),
      'href' => "admin/config/services/aggregator/remove/{$feed->fid}",
    );
    $links['update'] = array(
      'title' => t('Update items'),
      'href' => "admin/config/services/aggregator/update/{$feed->fid}",
      'query' => array(
        'token' => drupal_get_token("aggregator/update/{$feed->fid}"),
      ),
    );
    $row[] = array(
      'data' => array(
        '#type' => 'operations',
        '#links' => $links,
      ),
    );
    $rows[] = $row;
  }
  $build['feeds'] = array(
    '#prefix' => '<h3>' . t('Feed overview') . '</h3>',
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No feeds available. <a href="@link">Add feed</a>.', array(
      '@link' => url('admin/config/services/aggregator/add/feed'),
    )),
  );
  $result = $this->database
    ->query('SELECT c.cid, c.title, COUNT(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
  $header = array(
    t('Title'),
    t('Items'),
    t('Operations'),
  );
  $rows = array();
  foreach ($result as $category) {
    $row = array();
    $row[] = l($category->title, "aggregator/categories/{$category->cid}");
    $row[] = format_plural($category->items, '1 item', '@count items');
    $links = array();
    $links['edit'] = array(
      'title' => t('Edit'),
      'href' => "admin/config/services/aggregator/edit/category/{$category->cid}",
    );
    $row[] = array(
      'data' => array(
        '#type' => 'operations',
        '#links' => $links,
      ),
    );
    $rows[] = $row;
  }
  $build['categories'] = array(
    '#prefix' => '<h3>' . t('Category overview') . '</h3>',
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No categories available. <a href="@link">Add category</a>.', array(
      '@link' => url('admin/config/services/aggregator/add/category'),
    )),
  );
  return $build;
}