edit: this is an old bug, but I've just moved it to Mobile devices issues. As well as fixing some bugs and generally making the pagination bar look a bit nicer and making the HTML easier to theme, a primary impact of this change is to make the pagination links more finger friendly on touch based devices.
While working on a theme I found that the existing paging bar used in Moodle had various issues, detailed here:
I wrote a renderer (and some supporting code) to fix this, and I'll like to integrate the changes back into core Moodle.
Just to be clear, I'm more interested in getting it fixed than in my code being used. If you want to treat the following as a very specific and detailed bug report then feel free.
On the other hand, as long as someone can point me in the right direction on how to do this "the Moodle way" I'm happy to entirely rewrite the code to fit in with the core code guidelines.
I'm not sure which of the above choices is appropriate so for the time being I'll link to the code I wrote in a theme renderer. I went out of my way to avoid touching core code, some of which has bugs I needed to work around, basically reimplementing paging_bar within my theme so someone needs to re-write this before it can be included in core.
So the actual renderer code is here:
The code that decides which pages to link to (and which to leave out if space is tight) is here:
And the code that takes that list of page numbers and turns it into a series of HTML list items with appropriate classnames and containing links is here:
And, just for completeness the bit that wraps those in an appropriately classed ul tag is here:
There's unit tests for all of that too.
I notice that there's some other bugs against paging_bar with work ongoing at the moment, I'll mark them as related to this. I also noticed that mod_glossary has it's own implementation of this idea, with an added ALL button, so there should probably be some harmonisation done there.