You are here

function computing_list_command_page in Drupal Computing 7.2

Generate the "Command" page. Code following the logic of system_admin_config_page().

1 string reference to 'computing_list_command_page'
computing_menu in ./computing.module
Implements hook_menu().

File

./computing.admin.inc, line 59

Code

function computing_list_command_page() {
  $apps = computing_get_applications();
  $computing_data = computing_fetch_data();
  $blocks = array();
  foreach ($computing_data as $app_name => $app_command_data) {

    // make sure hook_computing_data returns valid computing applications, which are stored as "computing application' entities
    if (!isset($apps[$app_name])) {
      continue;
    }

    // block data: title, content, description, position, show (see theme_admin_page(). theme_admin_block().
    $app_entity = $apps[$app_name];
    $block = array(
      'title' => $app_entity->label,
      // description is shown only when block content is empty.
      'description' => $app_entity->description,
      'show' => TRUE,
    );

    // build application command data.
    // block content data: title, href, localized_options, description.
    $commands = array();
    foreach ($app_command_data as $command_name => $command_data) {
      $commands[] = array(
        'title' => empty($command_data['title']) ? strtoupper($command_name) : $command_data['title'],
        'description' => empty($command_data['description']) ? t('Add a command: %command', array(
          '%command' => $command_name,
        )) : $command_data['description'],
        'href' => COMPUTING_MODULE_ADMIN_PATH . "/add/{$app_name}/{$command_name}",
        'localized_options' => array(),
      );
    }

    // if $commands is empty, it will show $block['description'] according to theme_admin_block().
    if ($commands) {
      $block['content'] = theme('admin_block_content', array(
        'content' => $commands,
      ));
    }
    $blocks[$app_entity->weight . ' ' . $app_entity->application] = $block;
  }

  // end of iterating $computing_data.
  if ($blocks) {
    ksort($blocks);
    return theme('admin_page', array(
      'blocks' => $blocks,
    ));
  }
  else {
    return t('You do not have any computing applications');
  }
}