1<?php 2/** 3 * 4 * Syntax: ~~AUTHORS:param1¶m2~~ will be replaced by List of authors 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Martin Schulte <lebowski[at]corvus[dot]uberspace[dot]de> 8 */ 9 10//error_reporting (E_ALL | E_STRICT); 11//ini_set ('display_errors', 'On'); 12 13// must be run inside dokuwiki 14if(!defined('DOKU_INC')) die(); 15/** 16 * All DokuWiki plugins to extend the parser/rendering mechanism 17 * need to inherit from this class 18 */ 19class syntax_plugin_authorlist extends DokuWiki_Syntax_Plugin { 20 21 /** 22 * return some info 23 */ 24 function getInfo(){ 25 return array( 26 'author' => 'Martin Schulte', 'Vladimir Kuzmin', 27 'email' => '<lebowski[at]corvus[dot]uberspace[dot]de>', '<jl[dot]alice[at]yandex[dot]ru>', 28 'date' => '2017-01-04', 29 'name' => 'authorlist Plugin', 30 'desc' => 'Displays all contributors/authers of a wikipage', 31 'url' => 'http://dokuwiki.org/plugin:authorlist', 32 ); 33 } 34 35 36 /** 37 * What kind of syntax are we? 38 */ 39 function getType(){ 40 return 'substition'; 41 } 42 43 /** 44 * Where to sort in? 45 */ 46 function getSort(){ 47 return 999; 48 } 49 50 /** 51 * Close open paragraphs before 52 */ 53 function getPType(){ 54 return 'block'; 55 } 56 57 58 /** 59 * Connect lookup pattern to lexer. 60 */ 61 function connectTo($mode) { 62 $this->Lexer->addSpecialPattern('~~AUTHORS[:]?[a-zA-Z&=]*~~',$mode,'plugin_authorlist'); 63 } 64 65 66 /** 67 * Handler to prepare matched data for the rendering process. 68 * 69 * @param $match String The text matched by the patterns, somthing like ~~AUTHORS:displayaslist&tooltip=fullname...~~ 70 * @param $state Integer The lexer state for the match, doesn't matter because we only substitute. 71 * @param $pos Integer The character position of the matched text. 72 * @param $handler Object reference to the Doku_Handler object. 73 * @return Integer The current lexer state for the match. 74 */ 75 function handle($match, $state, $pos, Doku_Handler $handler){ 76 $match = strtolower(substr($match,10,-2)); //strip ~~AUTHORS: from start and ~~ from end 77 $options = explode('&',$match); 78 $data = array(); 79 foreach($options as $option){ 80 $tmp = explode("=",$option); 81 if(count($tmp)==1){ 82 $data[strtolower($tmp[0])] = true; 83 }else{ 84 $data[strtolower($tmp[0])] = strtolower($tmp[1]); 85 } 86 } 87 return $data; 88 } 89 90 /** 91 * Render the complete authorlist. 92 */ 93 function render($mode, Doku_Renderer $renderer, $data) { 94 // Only if XHTML 95 if($mode == 'xhtml' && !$data['off']){ 96 global $INFO; 97 $al = &plugin_load('helper', 'authorlist'); // A helper_plugin_authorlist object 98 if (!$al) return false; // Everything went well? 99 $al->setOptions($INFO['id'],$data); // Set options. Data was created by the handle-mode. If empty, default are used. 100 $al->fetchAuthorsFromMetadata(); 101 $al->sortAuthors(); 102 $al->startList(); 103 $al->renderAllAuthors(); 104 $al->finishList(); 105 $renderer->doc .= $al->getOutput(); 106 return true; 107 } 108 109 return false; 110 } 111} 112?> 113