You are here

function social_content_instances_overview in Social Content 7.2

Callback for hook_menu.

Build the overview page for all the instances for a given global.

Parameters

mixed $class: The social content class for this global.

1 string reference to 'social_content_instances_overview'
social_content_menu in ./social_content.module
Implements hook_menu().

File

./social_content.admin.inc, line 48
Social Content administration area. Provides menu callbacks for the Social Content administration area.

Code

function social_content_instances_overview($class) {

  // $classes = social_content_get_classes();
  $instances = $class
    ->getInstances();
  $header = array(
    t('Name'),
    t('Cron'),
    t('Count'),
    t('Settings'),
  );
  $rows = array();
  $destination = drupal_get_destination();
  drupal_set_title($class
    ->getLabel());
  foreach ($instances as $id => $instance) {
    $edit_link = l(t('edit'), 'admin/config/services/social-content/instance/' . $id . '/edit', array(
      'query' => $destination,
    ));
    $delete_link = l(t('delete'), 'admin/config/services/social-content/instance/' . $id . '/delete', array(
      'query' => $destination,
    ));
    $run_link = l(t('run'), 'admin/config/services/social-content/instance/' . $id . '/run', array(
      'query' => $destination,
    ));
    $enabled = $instance->settings['enabled'] ? '✔' : t('disabled');
    $rows[] = array(
      check_plain($instance->settings['title']),
      $enabled,
      $instance->settings['count'],
      $run_link . ' | ' . $edit_link . ' | ' . $delete_link,
    );
  }
  $build['node_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No instances found.'),
  );
  $build['add_instance'] = array(
    '#type' => 'link',
    '#title' => t('Add instance'),
    '#href' => 'admin/config/services/social-content/instance/' . $class
      ->getMachineName() . '/add',
    '#options' => array(
      'query' => $destination,
    ),
    '#attributes' => array(
      'class' => array(
        'button',
      ),
    ),
  );
  return $build;
}