You are here

function hosting_platform_view in Hosting 7.4

Same name and namespace in other branches
  1. 5 platform/hosting_platform.module \hosting_platform_view()
  2. 6.2 platform/hosting_platform.module \hosting_platform_view()
  3. 7.3 platform/hosting_platform.module \hosting_platform_view()

Implements hook_view().

1 call to hosting_platform_view()
hosting_site_view in site/hosting_site.nodeapi.inc
Implements hook_view().

File

platform/hosting_platform.module, line 830
Platform node type definition.

Code

function hosting_platform_view($node, $view_mode, $langcode = NULL) {
  hosting_set_breadcrumb($node);
  $node->content['info'] = array(
    '#type' => 'fieldset',
  );
  $node->content['info']['git_remote'] = array(
    '#type' => 'item',
    '#title' => t('Git Remote'),
    '#markup' => $node->git_remote ?: t('None'),
  );
  $node->content['info']['git_root'] = array(
    '#type' => 'item',
    '#title' => t('Repository Path'),
    '#markup' => $node->git_root ?: t('Unknown'),
  );
  $node->content['info']['git_reference'] = array(
    '#type' => 'item',
    '#title' => t('Git Reference'),
    '#markup' => $node->git_reference ?: t('Unknown'),
  );
  $node->content['info']['git_docroot'] = array(
    '#type' => 'item',
    '#title' => t('Relative Docroot'),
    '#markup' => $node->git_docroot ?: '',
    '#access' => !empty($node->git_docroot),
  );

  // Show an Edit Platform button.
  $platform_nid = $node->type == 'platform' ? $node->nid : $node->platform;
  $platform_edit_url = "node/{$platform_nid}/edit";
  $page_is_platform_page = arg(1) == $platform_nid;
  $platform_edit_url_query = $page_is_platform_page ? array() : drupal_get_destination();
  $node->content['info']['verified'] = array(
    '#type' => 'item',
    '#title' => t('Verified'),
    '#markup' => hosting_format_interval($node->verified),
    '#weight' => -10,
  );
  $node->content['info']['publish_path'] = array(
    '#type' => 'item',
    '#title' => t('Publish path'),
    '#markup' => filter_xss($node->publish_path),
    '#weight' => -8,
  );
  $node->content['info']['web_server'] = array(
    '#type' => 'item',
    '#title' => t('Web server'),
    '#markup' => _hosting_node_link($node->web_server),
    '#weight' => -7,
  );
  $node->content['info']['status'] = array(
    '#type' => 'item',
    '#title' => t('Status'),
    '#markup' => _hosting_platform_status($node->platform_status),
  );
  if ($node->makefile) {
    $node->content['info']['makefile'] = array(
      '#type' => 'item',
      '#title' => t('Drush makefile'),
      '#markup' => preg_match('/^http|^ftp/', $node->makefile) ? l(t('makefile'), $node->makefile) : filter_xss($node->makefile),
    );
  }
  if ($node->release) {
    $release = sprintf("%s %s", $node->release->title, $node->release->version);
    $node->content['info']['release'] = array(
      '#type' => 'item',
      '#title' => t('Release'),
      '#markup' => _hosting_node_link($node->release->nid, $release),
      '#weight' => -6,
    );
  }

  // Task list.
  if ($view_mode == 'full' && $node->nid) {
    $node->content['tasks_view'] = array(
      '#type' => 'item',
      '#markup' => hosting_task_table($node),
      '#prefix' => '<div id="hosting-task-list">',
      '#suffix' => '</div>',
      '#weight' => 9,
    );
    $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');
  }
  return $node;
}