1 block.update.inc DashboardUpdateBlock::getContent()

Return the content of a block.

Return value

mixed:

Overrides Block::getContent

File

core/modules/dashboard/includes/block.update.inc, line 49
"Update" dashboard block.

Class

DashboardUpdateBlock

Code

function getContent() {
  if (!module_exists('update')) {
    return;
  }

  $items = array();
  $available = update_get_available();
  module_load_include('inc', 'update', 'update.compare');
  $data = update_calculate_project_data($available);

  foreach ($data as $key => $project) {
    // Filter out projects which are up to date already.
    if ($project['status'] == UPDATE_CURRENT) {
      continue;
    }

    $type = $project['project_type'];
    if (in_array($type, $this->settings['project_types'])) {
      $name = $project['info']['name'];
      if ($project['name'] == 'backdrop') {
        $name = t('Backdrop');
      }

      $item = $name . ' ' . $type;

      if (isset($project['recommended'])) {
        $new = t('version @new available', array('@new' => $project['recommended']));
        if (user_access('access_site_reports')) {
          $new = l($new, 'admin/reports/updates');
        }
        $item .= ' (' . $new . ')';

        if (module_exists('installer') && user_access('administer software updates')) {
          $options = array('attributes' => array('class' => array('hi')));
          $item .= ' - ' . l(t('Update'), 'admin/modules/update', $options);
        }
      }
      else {
        // No updates available.
        $item .= ' - ' . t('No recommended updates');
      }


      $items[] = $item;
    }
  }

  $panel = array(
    '#theme' => 'dashboard_panel__update',
  );
  $panel['list'] = array(
    '#theme' => 'item_list',
    '#items' => $items,
  );

  return $panel;
}