[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/layouts/joomla/pagination/ -> links.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Layout
   6   *
   7   * @copyright   (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\Layout\LayoutHelper;
  15  use Joomla\Registry\Registry;
  16  
  17  $list  = $displayData['list'];
  18  $pages = $list['pages'];
  19  
  20  $options = new Registry($displayData['options']);
  21  
  22  $showLimitBox   = $options->get('showLimitBox', false);
  23  $showPagesLinks = $options->get('showPagesLinks', true);
  24  $showLimitStart = $options->get('showLimitStart', true);
  25  
  26  // Calculate to display range of pages
  27  $currentPage = 1;
  28  $range       = 1;
  29  $step        = 5;
  30  
  31  if (!empty($pages['pages'])) {
  32      foreach ($pages['pages'] as $k => $page) {
  33          if (!$page['active']) {
  34              $currentPage = $k;
  35          }
  36      }
  37  }
  38  
  39  if ($currentPage >= $step) {
  40      if ($currentPage % $step === 0) {
  41          $range = ceil($currentPage / $step) + 1;
  42      } else {
  43          $range = ceil($currentPage / $step);
  44      }
  45  }
  46  ?>
  47  
  48  
  49  <?php if (!empty($pages)) : ?>
  50      <nav class="pagination__wrapper" aria-label="<?php echo Text::_('JLIB_HTML_PAGINATION'); ?>">
  51          <div class="pagination pagination-toolbar text-center">
  52  
  53              <?php if ($showLimitBox) : ?>
  54                  <div class="limit float-end">
  55                      <?php echo Text::_('JGLOBAL_DISPLAY_NUM') . $list['limitfield']; ?>
  56                  </div>
  57              <?php endif; ?>
  58  
  59              <?php if ($showPagesLinks) : ?>
  60                  <ul class="pagination ms-auto mb-4 me-0">
  61                      <?php echo LayoutHelper::render('joomla.pagination.link', $pages['start']); ?>
  62                      <?php echo LayoutHelper::render('joomla.pagination.link', $pages['previous']); ?>
  63                      <?php foreach ($pages['pages'] as $k => $page) : ?>
  64                          <?php $output = LayoutHelper::render('joomla.pagination.link', $page); ?>
  65                          <?php if (in_array($k, range($range * $step - ($step + 1), $range * $step), true)) : ?>
  66                              <?php if (($k % $step === 0 || $k === $range * $step - ($step + 1)) && $k !== $currentPage && $k !== $range * $step - $step) : ?>
  67                                  <?php $output = preg_replace('#(<a.*?>).*?(</a>)#', '$1...$2', $output); ?>
  68                              <?php endif; ?>
  69                          <?php endif; ?>
  70  
  71                          <?php echo $output; ?>
  72                      <?php endforeach; ?>
  73                      <?php echo LayoutHelper::render('joomla.pagination.link', $pages['next']); ?>
  74                      <?php echo LayoutHelper::render('joomla.pagination.link', $pages['end']); ?>
  75                  </ul>
  76              <?php endif; ?>
  77  
  78              <?php if ($showLimitStart) : ?>
  79                  <input type="hidden" name="<?php echo $list['prefix']; ?>limitstart" value="<?php echo $list['limitstart']; ?>">
  80              <?php endif; ?>
  81  
  82          </div>
  83      </nav>
  84  <?php endif; ?>


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer