function cis_helper_page_build

cis7 cis_helper.module cis_helper_page_build(&$page)

Implements hook_page_build().

File

profiles/cis/modules/custom/cis_helper/cis_helper.module, line 114
Workflow and functionality glue based on the structure of the CIS.

Code

function cis_helper_page_build(&$page) {
  drupal_add_css(drupal_get_path('module', 'cis_helper') . '/css/cis_helper.css');
  $node = menu_get_object();
  if (arg(0) == 'cis-add-offering') {
    drupal_add_css(drupal_get_path('module', 'cis_helper') . '/css/cis_helper_add_offering_page.css');
  }
  elseif (arg(0) == 'cis-quick-setup') {
    // special js for hiding / displaying groups of form fields
    drupal_add_js(drupal_get_path('module', 'cis_helper') . '/js/cis_helper.js');
  }
  elseif (isset($node->type)) {
    // only apply these to course pages
    if (in_array($node->type, array('person', 'program', 'news', 'course')) && isset($node->field_academic_home[LANGUAGE_NONE])) {
      $unit = node_load($node->field_academic_home[LANGUAGE_NONE][0]['target_id']);
      // ensure we have a color for a unit
      if (isset($unit->field_color[LANGUAGE_NONE])) {
        $color = $unit->field_color[LANGUAGE_NONE][0]['jquery_colorpicker'];
        $css = '
        .unit-color-border li.active,
        .unit-color-border li.active-trail,
        .unit-color-border {
          border-color: #' . $color . ' !important;
        }
        .unit-color, .amp, .unit-color a {
          color: #' . $color . ' !important;
        }
        .unit-bg-color {
          background-color: #' . $color . ' !important;
        }
        ::-moz-selection {
          background-color: #' . $color . ';
        }
        ::selection {
          background-color: #' . $color . ';
        }';
        // make sure it's added very late so it takes priority, even with important
        $options = array(
          'type' => 'inline',
          'group' => CSS_THEME,
          'weight' => 100,
          'preprocess' => FALSE,
        );
        drupal_add_css($css, $options);
      }
    }
  }
  // build shortcuts to create other services, excluding current ones
  if (arg(2) == 'service-instances' && is_numeric(arg(1))) {
    $key = array('field_services', 'target_id');
    $fields = array('field_course' => array('target_id', arg(1)));
    // build a list of current services
    $current = _cis_helper_assemble_entity_list('node', 'service_instance', $key, 'title', $fields);
    $services = _cis_helper_assemble_entity_list('node', 'service', 'nid', 'title');
    foreach ($current as $k => $t) {
      unset($services[$k]);
    }
    $links = '<div class="cis-create-additional-services">' . "\n<ul>\n";
    foreach ($services as $snid => $name) {
      $options = array(
        'query' => array(
          'field_services' => $snid,
          'field_course' => arg(1),
          'destination' => current_path(),
        ),
      );
      $links .= '<li>' . l(t('Add `@service` service', array('@service' => $name)), 'node/add/service-instance', $options) . "</li>\n";
    }
    $links .= "\n</ul>\n</div>";
    $page['content']['system_main']['cis-links'] = array(
      '#markup' => $links,
      '#weight' => 1,
    );
  }
}