1<?php 2/** 3 * "Anchor" (Link) element component for the adhoctags plugin 4 * 5 * Defines <a> ... </a> syntax 6 * More info: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b 7 * 8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 9 * @author Anika Henke <anika@selfthinker.org> 10 * @author Sascha Leib <sascha.leib(at)kolmio.com> 11 */ 12 13class syntax_plugin_adhoctags_a extends syntax_plugin_adhoctags_abstractinline { 14 15 protected $tag = 'a'; 16 17 /* allow link attributes: */ 18 function allowAttribute(&$name, &$value) { 19 20 switch ($name) { 21 case 'href': 22 23 if ($this->getConf('allowJSLinks') == '0' 24 && substr($value, 0, 11) === 'javascript:') { 25 return false; 26 } 27 return true; 28 29 case 'rel': 30 return (preg_match('/^([\w\d]+ ?)+$/', trim($value))); 31 break; 32 33 case 'target': 34 return (preg_match('/^[\w\d_-]+$/', trim($value))); 35 break; 36 37 case 'hreflang': 38 return (preg_match('/^[\w\-]+$/', trim($value))); 39 break; 40 41 case 'download': 42 return (preg_match('/^[\w\-_\.]+$/', trim($value))); 43 break; 44 45 return true; 46 break; 47 default: 48 return false; 49 } 50 } 51 52 /** 53 * ODT Renderer Functions 54 */ 55 function renderODTElementOpen($renderer, $HTMLelement, $data) { 56 57 $helper = $this->loadHelper('adhoctags', true); 58 $attr = $helper->getAttributes($data); 59 $href = ( array_key_exists('href', $attr) ? $attr['href'] : '#' ); 60 $renderer->externallink($href, '#'); 61 $renderer->underline_open(); 62 } 63 function renderODTElementClose($renderer, $element) { 64 $renderer->underline_close(); 65 } 66}