You are here

class views_php_plugin_pager in Views PHP 7.2

Same name and namespace in other branches
  1. 7 plugins/views/views_php_plugin_pager.inc \views_php_plugin_pager

A (fake) pager plugin that wraps around the actual pager.

Hierarchy

Expanded class hierarchy of views_php_plugin_pager

File

plugins/views/views_php_plugin_pager.inc, line 8

View source
class views_php_plugin_pager extends views_php_plugin_wrapper {

  /**
   * Perform any needed actions just prior to the query executing.
   */
  public function pre_execute($query) {
    $this->wrapped
      ->pre_execute($query);
    foreach (array(
      /*'argument',*/
      'field',
      'filter',
      'sort',
    ) as $type) {
      foreach ($this->wrapped->view->{$type} as $id => $handler) {
        if (is_callable(array(
          $handler,
          'php_pre_execute',
        ))) {
          $handler
            ->php_pre_execute();
        }
      }
    }
    $this->wrapped->view->query
      ->set_limit(0);
    $this->wrapped->view->query
      ->set_offset(0);
  }

  /**
   * Perform any needed actions just after the query executing.
   */
  public function post_execute(&$result) {
    foreach (array(
      /*'argument',*/
      'field',
      'filter',
      'sort',
    ) as $type) {
      foreach ($this->wrapped->view->{$type} as $id => $handler) {
        if (is_callable(array(
          $handler,
          'php_post_execute',
        ))) {
          $handler
            ->php_post_execute();
        }
      }
    }
    $this->wrapped
      ->post_execute($result);
  }
  public function pre_render() {
    foreach (array(
      /*'argument',*/
      'field',
      'filter',
      'sort',
    ) as $type) {
      foreach ($this->wrapped->view->{$type} as $id => $handler) {
        if (is_callable(array(
          $handler,
          'php_pre_render',
        ))) {
          $handler
            ->php_pre_render();
        }
      }
    }
    $this
      ->update_wrapped_pager();
    $this
      ->php_unwrap();
  }
  protected function update_wrapped_pager() {
    $this->wrapped->total_items = count($this->wrapped->view->result);
    $this->wrapped
      ->update_page_info();
    $item_per_page = $this->wrapped
      ->get_items_per_page();
    if ($item_per_page > 0) {
      $offset = $this->wrapped
        ->get_current_page() * $item_per_page + $this->wrapped
        ->get_offset();
      $this->wrapped->view->result = array_slice($this->wrapped->view->result, $offset, $item_per_page);
    }
  }

  /**
   * Execute the count query, which will be done just prior to the query
   * itself being executed.
   */
  function execute_count_query(&$count_query) {
    $this->wrapped
      ->execute_count_query($count_query);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_php_plugin_pager::execute_count_query function Execute the count query, which will be done just prior to the query itself being executed.
views_php_plugin_pager::post_execute public function Perform any needed actions just after the query executing.
views_php_plugin_pager::pre_execute public function Perform any needed actions just prior to the query executing.
views_php_plugin_pager::pre_render public function
views_php_plugin_pager::update_wrapped_pager protected function
views_php_plugin_wrapper::$wrapped protected property
views_php_plugin_wrapper::$wrapped_link protected property
views_php_plugin_wrapper::php_unwrap public function
views_php_plugin_wrapper::php_wrap public function
views_php_plugin_wrapper::__call public function
views_php_plugin_wrapper::__callStatic public static function As of PHP 5.3.0
views_php_plugin_wrapper::__get public function
views_php_plugin_wrapper::__isset public function
views_php_plugin_wrapper::__set public function
views_php_plugin_wrapper::__unset public function