/**
  * Returns a pager with 'parameters' variable.
  *
  * The 'pager_calls' parameter counts the calls to the pager, subsequent
  * to the initial call.
  */
 public function queryParameters()
 {
     // Example query.
     $build['pager_table_0'] = $this->buildTestTable(0, 5);
     // Counter of calls to the current pager.
     $query_params = pager_get_query_parameters();
     $pager_calls = isset($query_params['pager_calls']) ? $query_params['pager_calls'] ? $query_params['pager_calls'] : 0 : 0;
     $build['l_pager_pager_0'] = array('#markup' => $this->t('Pager calls: @pager_calls', array('@pager_calls' => $pager_calls)));
     // Pager.
     $build['pager_pager_0'] = array('#type' => 'pager', '#element' => 0, '#parameters' => array('pager_calls' => ++$pager_calls), '#pre_render' => ['Drupal\\pager_test\\Controller\\PagerTestController::showPagerCacheContext']);
     return $build;
 }
 /**
  * Returns a pager with 'parameters' variable.
  *
  * The 'pager_calls' parameter counts the calls to the pager, subsequent
  * to the initial call.
  */
 public function queryParameters()
 {
     // Example query.
     $header_0 = array(array('data' => 'wid'), array('data' => 'type'), array('data' => 'timestamp'));
     $query_0 = db_select('watchdog', 'd')->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')->element(0);
     $query_0->fields('d', array('wid', 'type', 'timestamp'));
     $result_0 = $query_0->limit(5)->orderBy('d.wid')->execute();
     $rows_0 = array();
     foreach ($result_0 as $row) {
         $rows_0[] = array('data' => (array) $row);
     }
     $build['pager_table_0'] = array('#theme' => 'table', '#header' => $header_0, '#rows' => $rows_0, '#empty' => $this->t("There are no watchdog records found in the db"));
     // Counter of calls to the current pager.
     $query_params = pager_get_query_parameters();
     $pager_calls = isset($query_params['pager_calls']) ? $query_params['pager_calls'] ? $query_params['pager_calls'] : 0 : 0;
     $build['l_pager_pager_0'] = array('#markup' => $this->t('Pager calls: @pager_calls', array('@pager_calls' => $pager_calls)));
     // Pager.
     $build['pager_pager_0'] = array('#type' => 'pager', '#element' => 0, '#parameters' => array('pager_calls' => ++$pager_calls), '#pre_render' => ['Drupal\\pager_test\\Controller\\PagerTestController::showPagerCacheContext']);
     return $build;
 }
/**
 * Overrides theme_pager().
 */
function bootstrap_psdpt_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« first') => t('Go to first page'), t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), t('last »') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    // @todo l() cannot be used here, since it adds an 'active' class based on the
    //   path only (which is always the current path for pager links). Apparently,
    //   none of the pager links is active at any time - but it should still be
    //   possible to use l() here.
    // @see http://drupal.org/node/1410574
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    $text = filter_xss($text, array('span', 'em', 'strong'));
    return '<a' . drupal_attributes($attributes) . '>' . $text . '</a>';
}
Beispiel #4
0
function macragecn_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« 第一 页') => t('前往首 页'), t('‹ 上一页') => t('前往上一 页'), t('下一页 ›') => t('前往下一页'), t('最后一 页 »') => t('前往尾 页'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('前往第@number页', array('@number' => $text));
        }
    }
    // @todo l() cannot be used here, since it adds an 'active' class based on the
    //   path only (which is always the current path for pager links). Apparently,
    //   none of the pager links is active at any time - but it should still be
    //   possible to use l() here.
    // @see http://drupal.org/node/1410574
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}
Beispiel #5
0
/**
 * Return an array suitable for theme_links() rather than marked up HTML link.
 */
function tao_pager_link($vars)
{
    $text = $vars['text'];
    $page_new = $vars['page_new'];
    $element = $vars['element'];
    $parameters = $vars['parameters'];
    $attributes = $vars['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« first') => t('Go to first page'), t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), t('last »') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } else {
            if (is_numeric($text)) {
                $attributes['title'] = t('Go to page @number', array('@number' => $text));
            }
        }
    }
    return array('title' => $text, 'href' => $_GET['q'], 'attributes' => $attributes, 'query' => count($query) ? $query : NULL);
}
Beispiel #6
0
function stability_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« first') => t('Go to first page'), t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), t('last »') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    $replace_titles = array(t('‹ previous') => '«', t('next ›') => '»');
    $text = isset($replace_titles[$text]) ? $replace_titles[$text] : $text;
    if (!theme_get_setting('pager') || theme_get_setting('pager') == 1) {
        $attributes['class'] = array('btn', 'btn-sm', 'btn-default');
    }
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}
Beispiel #7
0
function progressive_sub_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('«') => t('Go to first page'), t('‹') => t('Go to previous page'), t('›') => t('Go to next page'), t('»') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    $replace_titles = array(t('« first') => '<i class="fa fa-angle-double-left"></i>', t('‹ previous') => '<i class="fa fa-angle-left"></i>', t('next ›') => '<i class="fa fa-angle-right"></i>', t('last »') => '<i class="fa fa-angle-double-right"></i>');
    $text = isset($replace_titles[$text]) ? $replace_titles[$text] : check_plain($text);
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    return '<a' . drupal_attributes($attributes) . '>' . $text . '</a>';
}
function spanjestrijders_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $text_first = theme('image', array('path' => path_to_theme() . '/images/first.png', 'alt' => t('First')));
            $text_previous = theme('image', array('path' => path_to_theme() . '/images/previous.png', 'alt' => t('Previous')));
            $text_next = theme('image', array('path' => path_to_theme() . '/images/next.png', 'alt' => t('Next')));
            $text_last = theme('image', array('path' => path_to_theme() . '/images/last.png', 'alt' => t('Last')));
            $titles = array($text_first => t('Go to first page'), $text_previous => t('Go to previous page'), $text_next => t('Go to next page'), $text_last => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    return l($text, $_GET['q'], array('html' => TRUE, 'attributes' => $attributes, 'query' => $query));
}
Beispiel #9
0
/**
 * Format pager link.
 */
function busy_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $wrap_title = isset($parameters['wrap']) ? $parameters['wrap'] : FALSE;
    $attributes = $variables['attributes'];
    unset($parameters['wrap']);
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« first') => t('Go to first page'), t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), t('last »') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    if ($wrap_title) {
        $text = '<span>' . $text . '</span>';
    }
    return l($text, $_GET['q'], array('attributes' => $attributes, 'query' => $query, 'html' => $wrap_title));
}