1<?php 2 3// implementation of 4// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/cite 5 6// must be run within Dokuwiki 7if(!defined('DOKU_INC')) die(); 8 9 10class syntax_plugin_webcomponent_brand extends DokuWiki_Syntax_Plugin { 11 12 function getType() { 13 return 'formatting'; 14 } 15 16 function getPType() { 17 return 'block'; 18 } 19 20 function getAllowedTypes() { 21 return array ('substition','formatting','disabled'); 22 } 23 24 function getSort() { 25 return 201; 26 } 27 28 29 30 function connectTo($mode) { 31 32 $pattern = webcomponent::getLookAheadPattern(self::getTag()); 33 $this->Lexer->addEntryPattern($pattern, $mode, 'plugin_' . webcomponent::PLUGIN_NAME . '_' . $this->getPluginComponent()); 34 35 } 36 37 function postConnect() { 38 39 $this->Lexer->addExitPattern('</' . self::getTag() . '>', 'plugin_' . webcomponent::PLUGIN_NAME . '_' . $this->getPluginComponent()); 40 41 } 42 43 function handle($match, $state, $pos, Doku_Handler $handler) { 44 45 switch ($state) { 46 47 case DOKU_LEXER_ENTER : 48 $match = utf8_substr($match, strlen($this->getPluginComponent()) + 1, -1); 49 $parameters = webcomponent::parseMatch($match); 50 return array($state, $parameters); 51 52 case DOKU_LEXER_UNMATCHED : 53 return array ($state, $match); 54 55 case DOKU_LEXER_EXIT : 56 57 // Important otherwise we don't get an exit in the render 58 return array($state, ''); 59 60 61 } 62 return array(); 63 64 } 65 66 function render($mode, Doku_Renderer $renderer, $data) { 67 68 if ($mode == 'xhtml') { 69 70 /** @var Doku_Renderer_xhtml $renderer */ 71 list($state, $parameters) = $data; 72 switch ($state) { 73 case DOKU_LEXER_ENTER : 74 $renderer->doc .= '<a href="'.wl().'" accesskey="h"'; 75 76 $title = ' title="'; 77 if (array_key_exists("title", $parameters)) { 78 $title .= $parameters["title"]; 79 } else { 80 global $conf; 81 $title .= $conf['title']; 82 } 83 $title .='"'; 84 $renderer->doc .= $title; 85 86 $class = ' class="navbar-brand'; 87 if (array_key_exists("class", $parameters)) { 88 $class .= ' '.$parameters["class"]; 89 } 90 $class .='"'; 91 $renderer->doc .= $class.'>'; 92 break; 93 94 case DOKU_LEXER_UNMATCHED : 95 // What about: 96 // * the title of the website ? $conf['title'] 97 // * the logo ? $logo = tpl_getMediaFile(array(':wiki:logo.png', ':logo.png', 'images/logo.png'), false, $logoSize); 98 $renderer->doc .= $renderer->_xmlEntities($parameters); 99 break; 100 101 case DOKU_LEXER_EXIT : 102 $renderer->doc .= '</a>'; 103 break; 104 } 105 return true; 106 } 107 108 // unsupported $mode 109 return false; 110 } 111 112 public static function getTag() 113 { 114 list(/* $t */, /* $p */, /* $n */, $c) = explode('_', get_called_class(), 4); 115 return (isset($c) ? $c : ''); 116 } 117 118} 119 120