1<?php 2/** 3 * Mikio Syntax Plugin:Pagination 4 * 5 * @link http://github.com/nomadjimbob/mikioplugin 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author James Collins <james.collins@outlook.com.au> 8 */ 9if (!defined('DOKU_INC')) { die(); 10} 11if (!defined('DOKU_PLUGIN')) { define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 12} 13require_once dirname(__FILE__).'/core.php'; 14 15class syntax_plugin_mikioplugin_pagination extends syntax_plugin_mikioplugin_core 16{ 17 public $tag = 'pagination'; 18 public $hasEndTag = true; 19 20 public function __construct() 21 { 22 $this->addCommonOptions('shadow'); 23 } 24 25 public function getAllowedTypes() 26 { 27 return array(); 28 } 29 public function getPType() 30 { 31 return 'normal'; 32 } 33 34 public function render_lexer_enter(Doku_Renderer $renderer, $data) 35 { 36 global $conf; 37 38 $classes = $this->buildClass($data); 39 40 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'pagination" data-start="' . $conf['start'] . '">'; 41 $renderer->doc .= '<ul class="' . $this->elemClass . ' ' . $this->classPrefix . 'pagination-inner'. $classes . '">'; 42 $renderer->doc .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'pagination-item ' . $this->classPrefix . 'pagination-prev"><a href="#">Prev</a></li>'; 43 } 44 45 46 public function render_lexer_exit(Doku_Renderer $renderer, $data) 47 { 48 $renderer->doc .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'pagination-item ' . $this->classPrefix . 'pagination-next"><a href="#">Next</a></li>'; 49 $renderer->doc .= '</ul></div>'; 50 } 51 52 public function render_lexer_unmatched(Doku_Renderer $renderer, $data) 53 { 54 $i = 1; 55 56 $itemOptions = array( 57 'url' => array('type' => 'url', 'default' => ''), 58 'active' => array('type' => 'boolean', 'default'=> 'false', 'class' => true), 59 'disabled' => array('type' => 'boolean', 'default'=> 'false', 'class' => true), 60 ); 61 62 $items = array_merge( 63 $this->findTags($this->tagPrefix . 'pagination-item', $data, $itemOptions, false), 64 $this->findTags($this->tagPrefix . 'pagenation-item', $data, $itemOptions, false) 65 ); 66 67 foreach($items as $item) { 68 $classes = $this->buildClass($item['options'], null, false, $itemOptions); 69 70 $renderer->doc .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'pagination-item' . $classes . '"><a href="' . $item['options']['url'] . '">' . $i++ . '</a></li>'; 71 } 72 } 73} 74?> 75