1<?php 2/** 3 * Display Orphans Plugin (Syntax Component) 4 * 5 * Description: The Display Orphans Plugin can display tables of orphaned, wanted, and linked pages. 6 * 7 * Syntax: <<displayorphans)>> 8 * <<displaywanted)>> 9 * <<displaylinked)>> 10 * 11 * @license The MIT License (https://opensource.org/licenses/MIT) 12 * @author Jay Jeckel <jeckelmail@gmail.com> 13 * 14 * Copyright (c) 2016 Jay Jeckel 15 * Licensed under the MIT license: https://opensource.org/licenses/MIT 16 * Permission is granted to use, copy, modify, and distribute the work. 17 * Full license information available in the project LICENSE file. 18 */ 19 20if (!defined('DOKU_INC')) { die(); } 21 22require_once(DOKU_INC . 'inc' . '/' . 'search.php'); 23require_once(dirname(__FILE__) . '/'. '_local.php'); 24use plugin\displayorphans\PageType; 25 26class syntax_plugin_displayorphans extends DokuWiki_Syntax_Plugin 27{ 28 public function __construct() 29 { 30 $this->helper = plugin_load('helper', 'displayorphans'); 31 $this->renderer = plugin_load('renderer', 'displayorphans'); 32 } 33 34 public $helper; 35 36 public $renderer; 37 38 function getInfo() { return confToHash(dirname(__FILE__) . '/plugin.info.txt'); } 39 40 function getType() { return 'substition'; } 41 42 function getPType() { return 'block'; } 43 44 function getSort() { return 5; }// Must come before {{media}} pattern is formatted at 320. 45 46 function connectTo($mode) 47 { 48 $pattern = '<<display\s(?:' . PageType::ORPHAN . '|' . PageType::WANTED . '|' . PageType::LINKED . ')>>'; 49 $this->Lexer->addSpecialPattern($pattern, $mode, 'plugin_displayorphans'); 50 } 51 52 function handle($match, $state, $pos, Doku_Handler $handler) 53 { 54 $match = substr($match, 9, -2); 55 $type = trim($match); 56 return array($type); 57 } 58 59 function render($format, Doku_Renderer $renderer, $data) 60 { 61 global $conf; 62 63 $renderer->nocache(); 64 if ($format != 'xhtml') { return false; } 65 66 list($type) = $data; 67 $items = $this->helper->items($conf['datadir'], $type); 68 $showHeader = $this->getConf('show_table_header'); 69 $showColumns = array(true, true, $type != PageType::WANTED, $type != PageType::ORPHAN); 70 $this->renderer->table($renderer, $type, $items, $showHeader, $showColumns); 71 72 return true; 73 } 74} 75 76//Setup VIM: ex: et ts=4 enc=utf-8 : 77?>