You are here

function hosting_server_view in Hosting 7.3

Same name and namespace in other branches
  1. 6.2 server/hosting_server.module \hosting_server_view()
  2. 7.4 server/hosting_server.module \hosting_server_view()

Implements hook_view().

File

server/hosting_server.module, line 669

Code

function hosting_server_view($node, $view_mode, $langcode = NULL) {
  hosting_set_breadcrumb($node);
  $services = hosting_server_services();
  $node->content['info'] = array(
    '#prefix' => '<div id="hosting-server-info" class="hosting-info-list">',
    '#suffix' => '</div>',
  );
  $node->content['info']['status'] = array(
    '#type' => 'item',
    '#title' => t('Status'),
    '#markup' => _hosting_server_status($node->server_status),
  );
  $node->content['info']['verified'] = array(
    '#type' => 'item',
    '#title' => t('Verified'),
    '#markup' => hosting_format_interval($node->verified),
    '#weight' => -10,
  );
  $node->content['info']['hostname'] = array(
    '#title' => 'hostname',
    '#type' => 'item',
    '#markup' => $node->title,
    '#weight' => -50,
  );
  _hosting_ip_view($node);
  if (isset($node->content->info->ip_addresses['#weight'])) {
    $node->content->info->ip_addresses['#weight'] = -30;
  }
  if (isset($node->services)) {
    foreach ($node->services as $name => $service) {
      $node->content['info'][$name] = array(
        '#prefix' => '<div class="hosting-service-info hosting-service-' . $name . '-info">',
        '#suffix' => '</div>',
      );
      if (isset($services[$name]['weight'])) {
        $node->content['info'][$name]['#weight'] = $services[$name]['weight'];
      }
      $node->content['info'][$name]['title'] = array(
        '#title' => $services[$name]['title'],
        '#markup' => $service->type,
        '#type' => 'item',
        '#weight' => -20,
      );
      $service
        ->view($node->content['info'][$name]);
    }
  }
  if ($view_mode == 'full') {

    // Task list.
    if (isset($node->nid)) {
      $node->content['tasks_view'] = array(
        '#type' => 'item',
        '#markup' => hosting_task_table($node),
        '#prefix' => '<div id="hosting-task-list">',
        '#suffix' => '</div>',
        '#weight' => 10,
      );
      $settings['hostingTaskRefresh'] = array(
        'nid' => $node->nid,
        'changed' => $node->changed,
      );
      drupal_add_js($settings, array(
        'type' => 'setting',
        'scope' => JS_DEFAULT,
      ));
      drupal_add_js(drupal_get_path('module', 'hosting_task') . '/hosting_task.js');
    }
  }
  if ($node->human_name) {
    $node->title = $node->human_name;
  }
  return $node;
}