You are here

function _farm_ui_views_post_render in farmOS 7

Helper function to add asset cluster maps to Views.

1 call to _farm_ui_views_post_render()
farm_ui_views_post_render in modules/farm/farm_ui/farm_ui.module
Implements hook_views_post_render().

File

modules/farm/farm_ui/farm_ui.views.inc, line 9

Code

function _farm_ui_views_post_render(&$view, &$output, &$cache) {

  // Load entity UI info.
  $ui_info = farm_ui_entities();

  // Search for a matching asset list View.
  $found = FALSE;
  if (!empty($ui_info['farm_asset'])) {
    foreach ($ui_info['farm_asset'] as $bundle => $info) {

      // If an asset list View is not available, skip it.
      if (empty($info['view'])) {
        continue;
      }

      // If we are not working with the same View, skip it.
      if ($info['view'] != $view->name) {
        continue;
      }

      // We must have found it! We can stop now.
      $found = TRUE;
      break;
    }
  }

  // If nothing was found, bail.
  if (empty($found)) {
    return;
  }

  // We also only care about the 'page' display.
  if ($view->current_display != 'page') {
    return;
  }

  // Add JS setting to set the bundle.
  $settings = array(
    'farm_map' => array(
      'behaviors' => array(
        'assets_full' => array(
          'type' => $bundle,
        ),
        'assets_cluster' => array(
          'type' => $bundle,
        ),
      ),
    ),
  );
  drupal_add_js($settings, array(
    'type' => 'setting',
  ));

  // If there are no results in the View, bail.
  if (empty($view->result)) {
    return;
  }

  // If there are any arguments, bail.

  /**
   * @todo
   * Display a map that is filtered by the same arguments.
   */
  if (!empty($view->args)) {
    return;
  }
}