You are here

function getlocations_fields_views_pre_render in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/views/getlocations_fields.views.inc \getlocations_fields_views_pre_render()

Implements hook_views_pre_render().

This hook is called right before the render process. The query has been executed, and the pre_render() phase has already happened for handlers, so all data should be available.

Adding output to the view can be accomplished by placing text on $view->attachment_before and $view->attachment_after. Altering the content can be achieved by editing the items of $view->result.

This hook can be utilized by themes.

Parameters

$view: The view object about to be processed.

File

modules/getlocations_fields/views/getlocations_fields.views.inc, line 832
getlocations_fields.views.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_views_pre_render(&$view) {

  // look for the right view, machine name must end in getlocations_streetview
  if (preg_match('/getlocations_streetview$/i', $view->name)) {

    // streetview killswitch
    if (getlocations_fields_streetview_settings_allow()) {
      if (count($view->result) == 1) {
        if (isset($view->result[0]->getlocations_fields_data)) {

          // OK, now get the data, unserialize and get sv_enable
          $value = unserialize($view->result[0]->getlocations_fields_data);
          $enable = isset($value['data']['sv_enable']) ? $value['data']['sv_enable'] : 1;
          if (!$enable) {

            // scrub the result
            unset($view->result[0]);
          }
        }
      }
      else {

        // scrub the result
        $c = count($view->result);
        for ($i = 0; $i < $c; $i++) {
          unset($view->result[$i]);
        }
      }
    }
    else {

      // scrub the result
      $c = count($view->result);
      for ($i = 0; $i < $c; $i++) {
        unset($view->result[$i]);
      }
    }
  }
}