Skip to content

Commit

Permalink
Support passing any attribute to the pagination control wrapper. #1030
Browse files Browse the repository at this point in the history
  • Loading branch information
kimisgold committed Sep 6, 2024
1 parent 9fc5cd5 commit ca67896
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions admin/themes/default/collections/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
?>

<?php if (total_records('Collection') > 0): ?>
<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>
<?php if (is_allowed('Collections', 'add')): ?>
<a href="<?php echo html_escape(url('collections/add')); ?>" class="green button">
<?php echo __('Add a Collection'); ?>
Expand Down Expand Up @@ -86,7 +86,7 @@
</table>
</div>

<?php echo pagination_links(['aria-label' => __('Bottom pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Bottom pagination')]]); ?>
<?php if (is_allowed('Collections', 'add')): ?>
<a href="<?php echo html_escape(url('collections/add')); ?>" class="green button"><?php echo __('Add a Collection'); ?></a>
<?php endif; ?>
Expand Down
4 changes: 2 additions & 2 deletions admin/themes/default/item-types/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?php echo link_to('item-types', 'add', __('Add an Item Type'), array('class'=>'add green button')); ?>
<?php endif ?>

<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>

<p class="without-item-type">
<?php if ($totalItemsWithoutType):
Expand Down Expand Up @@ -54,7 +54,7 @@
<?php echo link_to('item-types', 'add', __('Add an Item Type'), array('class'=>'add green button')); ?>
<?php endif ?>

<?php echo pagination_links(['aria-label' => __('Bottom pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Bottom pagination')]]); ?>

<p class="without-item-type"><?php echo $withoutTypeMessage; ?></p>

Expand Down
4 changes: 2 additions & 2 deletions admin/themes/default/items/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
?>

<?php if ($total_results): ?>
<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>
<?php if (is_allowed('Items', 'add')): ?>
<a href="<?php echo html_escape(url('items/add')); ?>" class="add full-width-mobile button green"><?php echo __('Add an Item'); ?></a>
<?php endif; ?>
Expand Down Expand Up @@ -149,7 +149,7 @@
</div>
</form>

<?php echo pagination_links(['aria-label' => __('Bottom pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Bottom pagination')]]); ?>
<?php if (is_allowed('Items', 'add')): ?>
<a href="<?php echo html_escape(url('items/add')); ?>" class="add full-width-mobile button green"><?php echo __('Add an Item'); ?></a>
<?php endif; ?>
Expand Down
4 changes: 2 additions & 2 deletions admin/themes/default/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
?>
<?php echo search_filters(); ?>
<?php if ($total_results): ?>
<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>
<table id="search-results">
<thead>
<tr>
Expand Down Expand Up @@ -33,7 +33,7 @@
<?php endforeach; ?>
</tbody>
</table>
<?php echo pagination_links(['aria-label' => __('Bottom pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Bottom pagination')]]); ?>
<?php else: ?>
<div id="no-results">
<p><?php echo __('Your query returned no results.');?></p>
Expand Down
2 changes: 1 addition & 1 deletion admin/themes/default/tags/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

<?php if ($total_results): ?>

<?php echo pagination_links(['aria_label' => __('Pagination')]); ?>
<?php echo pagination_links(); ?>

<section>
<div id="tags-nav">
Expand Down
2 changes: 1 addition & 1 deletion admin/themes/default/users/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<button id="search-users-button"><?php echo __('Search users'); ?></button>
</form>

<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>
<div class="table-responsive">
<table id="users">
<thead>
Expand Down
9 changes: 5 additions & 4 deletions application/libraries/globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -2807,10 +2807,11 @@ function pagination_links($options = array())
$totalCount = isset($options['total_results']) ? (int) $options['total_results'] : (int) $p['total_results'];
$pageNumber = isset($options['page']) ? (int) $options['page'] : (int) $p['page'];
$itemCountPerPage = isset($options['per_page']) ? (int) $options['per_page'] : (int) $p['per_page'];
$ariaLabel = isset($options['aria_label']) ? $options['aria_label'] : '';
$params = [
'ariaLabel' => $ariaLabel
$defaultAttrs = [
'class' => 'pagination-nav',
'aria-label' => __('Pagination')
];
$attrs = isset($options['attributes']) ? $options['attributes'] + $defaultAttrs : $defaultAttrs;

// Create an instance of Zend_Paginator.
$paginator = Zend_Paginator::factory($totalCount);
Expand All @@ -2820,7 +2821,7 @@ function pagination_links($options = array())
->setItemCountPerPage($itemCountPerPage)
->setPageRange($pageRange);

return get_view()->paginationControl($paginator, $scrollingStyle, $partial, $params);
return get_view()->paginationControl($paginator, $scrollingStyle, $partial, ['attrs' => $attrs]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions application/views/scripts/collections/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
?>

<h1><?php echo $pageTitle; ?> <?php echo __('(%s total)', $total_results); ?></h1>
<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>

<?php
$sortLinks[__('Title')] = 'Dublin Core,Title';
Expand Down Expand Up @@ -46,7 +46,7 @@

<?php endforeach; ?>

<?php echo pagination_links(['aria-label' => __('Bottom pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Bottom pagination')]]); ?>

<?php fire_plugin_hook('public_collections_browse', array('collections' => $collections, 'view' => $this)); ?>

Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/common/pagination_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
if ($this->pageCount > 1):
$getParams = $_GET;
?>
<nav class="pagination-nav" aria-label="<?php echo $ariaLabel; ?>">
<nav <?php echo tag_attributes($attrs); ?>>
<ul class="pagination">
<?php if (isset($this->previous)): ?>
<!-- Previous page link -->
Expand Down
4 changes: 2 additions & 2 deletions application/views/scripts/items/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<?php echo item_search_filters(); ?>

<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>

<?php if ($total_results > 0): ?>

Expand Down Expand Up @@ -54,7 +54,7 @@
</div><!-- end class="item hentry" -->
<?php endforeach; ?>

<?php echo pagination_links(['aria-label' => __('Bottom pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Bottom pagination')]]); ?>

<div id="outputs">
<span class="outputs-label"><?php echo __('Output Formats'); ?></span>
Expand Down
4 changes: 2 additions & 2 deletions application/views/scripts/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h1><?php echo $pageTitle; ?></h1>
<?php echo search_filters(); ?>
<?php if ($total_results): ?>
<?php echo pagination_links(['aria_label' => __('Top pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Top pagination')]]); ?>
<table id="search-results">
<thead>
<tr>
Expand Down Expand Up @@ -34,7 +34,7 @@
<?php endforeach; ?>
</tbody>
</table>
<?php echo pagination_links(['aria-label' => __('Bottom pagination')]); ?>
<?php echo pagination_links(['attributes' => ['aria-label' => __('Bottom pagination')]]); ?>
<?php else: ?>
<div id="no-results">
<p><?php echo __('Your query returned no results.');?></p>
Expand Down

0 comments on commit ca67896

Please sign in to comment.