You are here

function object_log_build_log in Object Log 7

Build a render array showing objects stored in the object log.

Parameters

$label: If set, create links for viewing the new object alongside the current one.

Return value

A render array for a table of links to stored objects.

2 calls to object_log_build_log()
object_log_object_page in ./object_log.admin.inc
Menu callback function for "admin/reports/object_log/$label".
object_log_overview_page in ./object_log.admin.inc
Menu callback function for admin/reports/object_log.

File

./object_log.admin.inc, line 20

Code

function object_log_build_log($label = NULL) {
  $rows = array();
  $header = array(
    array(
      'data' => t('Label'),
      'field' => 'ol.label',
    ),
    array(
      'data' => t('Date'),
      'field' => 'ol.created',
      'sort' => 'desc',
    ),
  );
  $query = db_select('object_log', 'ol')
    ->extend('PagerDefault')
    ->extend('TableSort');
  $query
    ->fields('ol', array(
    'label',
    'created',
  ));
  $result = $query
    ->limit(25)
    ->orderByHeader($header)
    ->execute();
  foreach ($result as $item) {
    if ($label) {
      $link = l($item->label, 'admin/reports/object_log/' . $label . '/' . $item->label);
    }
    else {
      $link = l($item->label, 'admin/reports/object_log/' . $item->label);
    }
    $rows[] = array(
      $link,
      format_date($item->created, 'short'),
    );
  }
  $build = array(
    'object_log' => array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#attributes' => array(
        'id' => 'object_log',
      ),
      '#empty' => t('No objects stored.'),
    ),
    'object_log_pager' => array(
      '#theme' => 'pager',
    ),
  );
  return $build;
}