10cecf9d5Sandi<?php 261faf446Schris/** 35587e44cSchris * Renderer output base class 461faf446Schris * 561faf446Schris * @author Harry Fuecks <hfuecks@gmail.com> 661faf446Schris * @author Andreas Gohr <andi@splitbrain.org> 761faf446Schris */ 861faf446Schris 9*e1d9dcc8SAndreas Gohruse dokuwiki\Extension\Plugin; 10*e1d9dcc8SAndreas Gohruse dokuwiki\Extension\SyntaxPlugin; 11*e1d9dcc8SAndreas Gohr 12863befa1SAndreas Gohr/** 1356bd9509SPhy * Allowed chars in $language for code highlighting 1456bd9509SPhy * @see GeSHi::set_language() 1556bd9509SPhy */ 1656bd9509SPhydefine('PREG_PATTERN_VALID_LANGUAGE', '#[^a-zA-Z0-9\-_]#'); 1756bd9509SPhy 1856bd9509SPhy/** 19863befa1SAndreas Gohr * An empty renderer, produces no output 20863befa1SAndreas Gohr * 21*e1d9dcc8SAndreas Gohr * Inherits from dokuwiki\Plugin\DokuWiki_Plugin for giving additional functions to render plugins 228e3a5477SAndreas Gohr * 238e3a5477SAndreas Gohr * The renderer transforms the syntax instructions created by the parser and handler into the 248e3a5477SAndreas Gohr * desired output format. For each instruction a corresponding method defined in this class will 258e3a5477SAndreas Gohr * be called. That method needs to produce the desired output for the instruction and add it to the 268e3a5477SAndreas Gohr * $doc field. When all instructions are processed, the $doc field contents will be cached by 278e3a5477SAndreas Gohr * DokuWiki and sent to the user. 28863befa1SAndreas Gohr */ 29*e1d9dcc8SAndreas Gohrabstract class Doku_Renderer extends Plugin { 30cfa2b40eSAndreas Gohr /** @var array Settings, control the behavior of the renderer */ 31cfa2b40eSAndreas Gohr public $info = array( 3244881bd0Shenning.noren 'cache' => true, // may the rendered result cached? 3344881bd0Shenning.noren 'toc' => true, // render the TOC? 349dc2c2afSandi ); 359dc2c2afSandi 36cfa2b40eSAndreas Gohr /** @var array contains the smiley configuration, set in p_render() */ 37cfa2b40eSAndreas Gohr public $smileys = array(); 38cfa2b40eSAndreas Gohr /** @var array contains the entity configuration, set in p_render() */ 39cfa2b40eSAndreas Gohr public $entities = array(); 40cfa2b40eSAndreas Gohr /** @var array contains the acronym configuration, set in p_render() */ 41cfa2b40eSAndreas Gohr public $acronyms = array(); 42cfa2b40eSAndreas Gohr /** @var array contains the interwiki configuration, set in p_render() */ 43cfa2b40eSAndreas Gohr public $interwiki = array(); 44e41c4da9SAndreas Gohr 45de369923SAndreas Gohr /** @var array the list of headers used to create unique link ids */ 46de369923SAndreas Gohr protected $headers = array(); 47de369923SAndreas Gohr 485f70445dSAndreas Gohr /** 49cfa2b40eSAndreas Gohr * @var string the rendered document, this will be cached after the renderer ran through 505f70445dSAndreas Gohr */ 51cfa2b40eSAndreas Gohr public $doc = ''; 52cfa2b40eSAndreas Gohr 53cfa2b40eSAndreas Gohr /** 54cfa2b40eSAndreas Gohr * clean out any per-use values 55cfa2b40eSAndreas Gohr * 56cfa2b40eSAndreas Gohr * This is called before each use of the renderer object and should be used to 57cfa2b40eSAndreas Gohr * completely reset the state of the renderer to be reused for a new document 58cfa2b40eSAndreas Gohr */ 59de369923SAndreas Gohr public function reset(){ 60de369923SAndreas Gohr $this->headers = array(); 615f70445dSAndreas Gohr } 625f70445dSAndreas Gohr 63f6ec8df8SAdrian Lang /** 64f6ec8df8SAdrian Lang * Allow the plugin to prevent DokuWiki from reusing an instance 65f6ec8df8SAdrian Lang * 66cfa2b40eSAndreas Gohr * Since most renderer plugins fail to implement Doku_Renderer::reset() we default 67cfa2b40eSAndreas Gohr * to reinstantiating the renderer here 68cfa2b40eSAndreas Gohr * 69f6ec8df8SAdrian Lang * @return bool false if the plugin has to be instantiated 70f6ec8df8SAdrian Lang */ 71de369923SAndreas Gohr public function isSingleton() { 72f6ec8df8SAdrian Lang return false; 73f6ec8df8SAdrian Lang } 74f6ec8df8SAdrian Lang 758cc41db0SAndreas Gohr /** 76cfa2b40eSAndreas Gohr * Returns the format produced by this renderer. 77cfa2b40eSAndreas Gohr * 78cfa2b40eSAndreas Gohr * Has to be overidden by sub classes 79cfa2b40eSAndreas Gohr * 80cfa2b40eSAndreas Gohr * @return string 81cfa2b40eSAndreas Gohr */ 82de369923SAndreas Gohr abstract public function getFormat(); 83cfa2b40eSAndreas Gohr 84cfa2b40eSAndreas Gohr /** 85cfa2b40eSAndreas Gohr * Disable caching of this renderer's output 86cfa2b40eSAndreas Gohr */ 87e1cdd96cSAndreas Gohr public function nocache() { 88cfa2b40eSAndreas Gohr $this->info['cache'] = false; 89cfa2b40eSAndreas Gohr } 90cfa2b40eSAndreas Gohr 91cfa2b40eSAndreas Gohr /** 92cfa2b40eSAndreas Gohr * Disable TOC generation for this renderer's output 93cfa2b40eSAndreas Gohr * 94cfa2b40eSAndreas Gohr * This might not be used for certain sub renderer 95cfa2b40eSAndreas Gohr */ 96e1cdd96cSAndreas Gohr public function notoc() { 97cfa2b40eSAndreas Gohr $this->info['toc'] = false; 98cfa2b40eSAndreas Gohr } 99cfa2b40eSAndreas Gohr 100cfa2b40eSAndreas Gohr /** 101cfa2b40eSAndreas Gohr * Handle plugin rendering 102cfa2b40eSAndreas Gohr * 103cfa2b40eSAndreas Gohr * Most likely this needs NOT to be overwritten by sub classes 1048cc41db0SAndreas Gohr * 1058cc41db0SAndreas Gohr * @param string $name Plugin name 1068cc41db0SAndreas Gohr * @param mixed $data custom data set by handler 1078cc41db0SAndreas Gohr * @param string $state matched state if any 1088cc41db0SAndreas Gohr * @param string $match raw matched syntax 1098cc41db0SAndreas Gohr */ 110de369923SAndreas Gohr public function plugin($name, $data, $state = '', $match = '') { 111*e1d9dcc8SAndreas Gohr /** @var SyntaxPlugin $plugin */ 112e8b5a4f9SAndreas Gohr $plugin = plugin_load('syntax', $name); 11361faf446Schris if($plugin != null) { 1145f70445dSAndreas Gohr $plugin->render($this->getFormat(), $this, $data); 11561faf446Schris } 11661faf446Schris } 11761faf446Schris 1185587e44cSchris /** 1195587e44cSchris * handle nested render instructions 1205587e44cSchris * this method (and nest_close method) should not be overloaded in actual renderer output classes 121cfa2b40eSAndreas Gohr * 122cfa2b40eSAndreas Gohr * @param array $instructions 1235587e44cSchris */ 124de369923SAndreas Gohr public function nest($instructions) { 1255587e44cSchris foreach($instructions as $instruction) { 1265587e44cSchris // execute the callback against ourself 127c2122b83SChristopher Smith if(method_exists($this, $instruction[0])) { 128d6a1a955SAndreas Gohr call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array()); 129c2122b83SChristopher Smith } 1305587e44cSchris } 1315587e44cSchris } 1325587e44cSchris 133cfa2b40eSAndreas Gohr /** 134cfa2b40eSAndreas Gohr * dummy closing instruction issued by Doku_Handler_Nest 135cfa2b40eSAndreas Gohr * 136cfa2b40eSAndreas Gohr * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest - 137cfa2b40eSAndreas Gohr * however plugins will not be able to - as their instructions require data. 138cfa2b40eSAndreas Gohr */ 139de369923SAndreas Gohr public function nest_close() { 1402c2835c2SAndreas Gohr } 1415587e44cSchris 142cfa2b40eSAndreas Gohr #region Syntax modes - sub classes will need to implement them to fill $doc 143cfa2b40eSAndreas Gohr 144cfa2b40eSAndreas Gohr /** 145cfa2b40eSAndreas Gohr * Initialize the document 146cfa2b40eSAndreas Gohr */ 147de369923SAndreas Gohr public function document_start() { 1482c2835c2SAndreas Gohr } 1490cecf9d5Sandi 150cfa2b40eSAndreas Gohr /** 151cfa2b40eSAndreas Gohr * Finalize the document 152cfa2b40eSAndreas Gohr */ 153de369923SAndreas Gohr public function document_end() { 1542c2835c2SAndreas Gohr } 1550cecf9d5Sandi 156cfa2b40eSAndreas Gohr /** 157cfa2b40eSAndreas Gohr * Render the Table of Contents 158cfa2b40eSAndreas Gohr * 159cfa2b40eSAndreas Gohr * @return string 160cfa2b40eSAndreas Gohr */ 161de369923SAndreas Gohr public function render_TOC() { 1622c2835c2SAndreas Gohr return ''; 1632c2835c2SAndreas Gohr } 1640cecf9d5Sandi 165cfa2b40eSAndreas Gohr /** 166cfa2b40eSAndreas Gohr * Add an item to the TOC 167cfa2b40eSAndreas Gohr * 168cfa2b40eSAndreas Gohr * @param string $id the hash link 169cfa2b40eSAndreas Gohr * @param string $text the text to display 170cfa2b40eSAndreas Gohr * @param int $level the nesting level 171cfa2b40eSAndreas Gohr */ 172de369923SAndreas Gohr public function toc_additem($id, $text, $level) { 1732c2835c2SAndreas Gohr } 174e7856beaSchris 175cfa2b40eSAndreas Gohr /** 176cfa2b40eSAndreas Gohr * Render a heading 177cfa2b40eSAndreas Gohr * 178cfa2b40eSAndreas Gohr * @param string $text the text to display 179cfa2b40eSAndreas Gohr * @param int $level header level 180cfa2b40eSAndreas Gohr * @param int $pos byte position in the original source 181cfa2b40eSAndreas Gohr */ 182de369923SAndreas Gohr public function header($text, $level, $pos) { 1832c2835c2SAndreas Gohr } 1840cecf9d5Sandi 185cfa2b40eSAndreas Gohr /** 186cfa2b40eSAndreas Gohr * Open a new section 187cfa2b40eSAndreas Gohr * 188cfa2b40eSAndreas Gohr * @param int $level section level (as determined by the previous header) 189cfa2b40eSAndreas Gohr */ 190de369923SAndreas Gohr public function section_open($level) { 1912c2835c2SAndreas Gohr } 1920cecf9d5Sandi 193cfa2b40eSAndreas Gohr /** 194cfa2b40eSAndreas Gohr * Close the current section 195cfa2b40eSAndreas Gohr */ 196de369923SAndreas Gohr public function section_close() { 1972c2835c2SAndreas Gohr } 1980cecf9d5Sandi 199cfa2b40eSAndreas Gohr /** 200cfa2b40eSAndreas Gohr * Render plain text data 201cfa2b40eSAndreas Gohr * 20242ea7f44SGerrit Uitslag * @param string $text 203cfa2b40eSAndreas Gohr */ 204de369923SAndreas Gohr public function cdata($text) { 2052c2835c2SAndreas Gohr } 2060cecf9d5Sandi 207cfa2b40eSAndreas Gohr /** 208cfa2b40eSAndreas Gohr * Open a paragraph 209cfa2b40eSAndreas Gohr */ 210de369923SAndreas Gohr public function p_open() { 2112c2835c2SAndreas Gohr } 2120cecf9d5Sandi 213cfa2b40eSAndreas Gohr /** 214cfa2b40eSAndreas Gohr * Close a paragraph 215cfa2b40eSAndreas Gohr */ 216de369923SAndreas Gohr public function p_close() { 2172c2835c2SAndreas Gohr } 2180cecf9d5Sandi 219cfa2b40eSAndreas Gohr /** 2203dd5c225SAndreas Gohr * Create a line break 221cfa2b40eSAndreas Gohr */ 222de369923SAndreas Gohr public function linebreak() { 2232c2835c2SAndreas Gohr } 2240cecf9d5Sandi 225cfa2b40eSAndreas Gohr /** 226cfa2b40eSAndreas Gohr * Create a horizontal line 227cfa2b40eSAndreas Gohr */ 228de369923SAndreas Gohr public function hr() { 2292c2835c2SAndreas Gohr } 2300cecf9d5Sandi 231cfa2b40eSAndreas Gohr /** 232cfa2b40eSAndreas Gohr * Start strong (bold) formatting 233cfa2b40eSAndreas Gohr */ 234de369923SAndreas Gohr public function strong_open() { 2352c2835c2SAndreas Gohr } 2360cecf9d5Sandi 237cfa2b40eSAndreas Gohr /** 238cfa2b40eSAndreas Gohr * Stop strong (bold) formatting 239cfa2b40eSAndreas Gohr */ 240de369923SAndreas Gohr public function strong_close() { 2412c2835c2SAndreas Gohr } 2420cecf9d5Sandi 243cfa2b40eSAndreas Gohr /** 244cfa2b40eSAndreas Gohr * Start emphasis (italics) formatting 245cfa2b40eSAndreas Gohr */ 246de369923SAndreas Gohr public function emphasis_open() { 2472c2835c2SAndreas Gohr } 2480cecf9d5Sandi 249cfa2b40eSAndreas Gohr /** 250cfa2b40eSAndreas Gohr * Stop emphasis (italics) formatting 251cfa2b40eSAndreas Gohr */ 252de369923SAndreas Gohr public function emphasis_close() { 2532c2835c2SAndreas Gohr } 2540cecf9d5Sandi 255cfa2b40eSAndreas Gohr /** 256cfa2b40eSAndreas Gohr * Start underline formatting 257cfa2b40eSAndreas Gohr */ 258de369923SAndreas Gohr public function underline_open() { 2592c2835c2SAndreas Gohr } 2600cecf9d5Sandi 261cfa2b40eSAndreas Gohr /** 262cfa2b40eSAndreas Gohr * Stop underline formatting 263cfa2b40eSAndreas Gohr */ 264de369923SAndreas Gohr public function underline_close() { 2652c2835c2SAndreas Gohr } 2660cecf9d5Sandi 267cfa2b40eSAndreas Gohr /** 268cfa2b40eSAndreas Gohr * Start monospace formatting 269cfa2b40eSAndreas Gohr */ 270de369923SAndreas Gohr public function monospace_open() { 2712c2835c2SAndreas Gohr } 2720cecf9d5Sandi 273cfa2b40eSAndreas Gohr /** 274cfa2b40eSAndreas Gohr * Stop monospace formatting 275cfa2b40eSAndreas Gohr */ 276de369923SAndreas Gohr public function monospace_close() { 2772c2835c2SAndreas Gohr } 2780cecf9d5Sandi 279cfa2b40eSAndreas Gohr /** 280cfa2b40eSAndreas Gohr * Start a subscript 281cfa2b40eSAndreas Gohr */ 282de369923SAndreas Gohr public function subscript_open() { 2832c2835c2SAndreas Gohr } 2840cecf9d5Sandi 285cfa2b40eSAndreas Gohr /** 286cfa2b40eSAndreas Gohr * Stop a subscript 287cfa2b40eSAndreas Gohr */ 288de369923SAndreas Gohr public function subscript_close() { 2892c2835c2SAndreas Gohr } 2900cecf9d5Sandi 291cfa2b40eSAndreas Gohr /** 292cfa2b40eSAndreas Gohr * Start a superscript 293cfa2b40eSAndreas Gohr */ 294de369923SAndreas Gohr public function superscript_open() { 2952c2835c2SAndreas Gohr } 2960cecf9d5Sandi 297cfa2b40eSAndreas Gohr /** 298cfa2b40eSAndreas Gohr * Stop a superscript 299cfa2b40eSAndreas Gohr */ 300de369923SAndreas Gohr public function superscript_close() { 3012c2835c2SAndreas Gohr } 3020cecf9d5Sandi 303cfa2b40eSAndreas Gohr /** 304cfa2b40eSAndreas Gohr * Start deleted (strike-through) formatting 305cfa2b40eSAndreas Gohr */ 306de369923SAndreas Gohr public function deleted_open() { 3072c2835c2SAndreas Gohr } 3080cecf9d5Sandi 309cfa2b40eSAndreas Gohr /** 310cfa2b40eSAndreas Gohr * Stop deleted (strike-through) formatting 311cfa2b40eSAndreas Gohr */ 312de369923SAndreas Gohr public function deleted_close() { 3132c2835c2SAndreas Gohr } 3140cecf9d5Sandi 315cfa2b40eSAndreas Gohr /** 316cfa2b40eSAndreas Gohr * Start a footnote 317cfa2b40eSAndreas Gohr */ 318de369923SAndreas Gohr public function footnote_open() { 3192c2835c2SAndreas Gohr } 3200cecf9d5Sandi 321cfa2b40eSAndreas Gohr /** 322cfa2b40eSAndreas Gohr * Stop a footnote 323cfa2b40eSAndreas Gohr */ 324de369923SAndreas Gohr public function footnote_close() { 3252c2835c2SAndreas Gohr } 3260cecf9d5Sandi 327cfa2b40eSAndreas Gohr /** 328cfa2b40eSAndreas Gohr * Open an unordered list 329cfa2b40eSAndreas Gohr */ 330de369923SAndreas Gohr public function listu_open() { 3312c2835c2SAndreas Gohr } 3320cecf9d5Sandi 333cfa2b40eSAndreas Gohr /** 334cfa2b40eSAndreas Gohr * Close an unordered list 335cfa2b40eSAndreas Gohr */ 336de369923SAndreas Gohr public function listu_close() { 3372c2835c2SAndreas Gohr } 3380cecf9d5Sandi 339cfa2b40eSAndreas Gohr /** 340cfa2b40eSAndreas Gohr * Open an ordered list 341cfa2b40eSAndreas Gohr */ 342de369923SAndreas Gohr public function listo_open() { 3432c2835c2SAndreas Gohr } 3440cecf9d5Sandi 345cfa2b40eSAndreas Gohr /** 346cfa2b40eSAndreas Gohr * Close an ordered list 347cfa2b40eSAndreas Gohr */ 348de369923SAndreas Gohr public function listo_close() { 3492c2835c2SAndreas Gohr } 3500cecf9d5Sandi 351cfa2b40eSAndreas Gohr /** 352cfa2b40eSAndreas Gohr * Open a list item 353cfa2b40eSAndreas Gohr * 354cfa2b40eSAndreas Gohr * @param int $level the nesting level 355e3a24861SChristopher Smith * @param bool $node true when a node; false when a leaf 356cfa2b40eSAndreas Gohr */ 357de369923SAndreas Gohr public function listitem_open($level,$node=false) { 3582c2835c2SAndreas Gohr } 3590cecf9d5Sandi 360cfa2b40eSAndreas Gohr /** 361cfa2b40eSAndreas Gohr * Close a list item 362cfa2b40eSAndreas Gohr */ 363de369923SAndreas Gohr public function listitem_close() { 3642c2835c2SAndreas Gohr } 3650cecf9d5Sandi 366cfa2b40eSAndreas Gohr /** 367cfa2b40eSAndreas Gohr * Start the content of a list item 368cfa2b40eSAndreas Gohr */ 369de369923SAndreas Gohr public function listcontent_open() { 3702c2835c2SAndreas Gohr } 3710cecf9d5Sandi 372cfa2b40eSAndreas Gohr /** 373cfa2b40eSAndreas Gohr * Stop the content of a list item 374cfa2b40eSAndreas Gohr */ 375de369923SAndreas Gohr public function listcontent_close() { 3762c2835c2SAndreas Gohr } 3770cecf9d5Sandi 378cfa2b40eSAndreas Gohr /** 379cfa2b40eSAndreas Gohr * Output unformatted $text 380cfa2b40eSAndreas Gohr * 381cfa2b40eSAndreas Gohr * Defaults to $this->cdata() 382cfa2b40eSAndreas Gohr * 383cfa2b40eSAndreas Gohr * @param string $text 384cfa2b40eSAndreas Gohr */ 385de369923SAndreas Gohr public function unformatted($text) { 386cfa2b40eSAndreas Gohr $this->cdata($text); 3872c2835c2SAndreas Gohr } 3880cecf9d5Sandi 389cfa2b40eSAndreas Gohr /** 390cfa2b40eSAndreas Gohr * Output inline PHP code 391cfa2b40eSAndreas Gohr * 392cfa2b40eSAndreas Gohr * If $conf['phpok'] is true this should evaluate the given code and append the result 393cfa2b40eSAndreas Gohr * to $doc 394cfa2b40eSAndreas Gohr * 395cfa2b40eSAndreas Gohr * @param string $text The PHP code 396cfa2b40eSAndreas Gohr */ 397de369923SAndreas Gohr public function php($text) { 3982c2835c2SAndreas Gohr } 3990cecf9d5Sandi 400cfa2b40eSAndreas Gohr /** 401cfa2b40eSAndreas Gohr * Output block level PHP code 402cfa2b40eSAndreas Gohr * 403cfa2b40eSAndreas Gohr * If $conf['phpok'] is true this should evaluate the given code and append the result 404cfa2b40eSAndreas Gohr * to $doc 405cfa2b40eSAndreas Gohr * 406cfa2b40eSAndreas Gohr * @param string $text The PHP code 407cfa2b40eSAndreas Gohr */ 408de369923SAndreas Gohr public function phpblock($text) { 4092c2835c2SAndreas Gohr } 41007f89c3cSAnika Henke 411cfa2b40eSAndreas Gohr /** 412cfa2b40eSAndreas Gohr * Output raw inline HTML 413cfa2b40eSAndreas Gohr * 414cfa2b40eSAndreas Gohr * If $conf['htmlok'] is true this should add the code as is to $doc 415cfa2b40eSAndreas Gohr * 416cfa2b40eSAndreas Gohr * @param string $text The HTML 417cfa2b40eSAndreas Gohr */ 418de369923SAndreas Gohr public function html($text) { 4192c2835c2SAndreas Gohr } 4200cecf9d5Sandi 421cfa2b40eSAndreas Gohr /** 422cfa2b40eSAndreas Gohr * Output raw block-level HTML 423cfa2b40eSAndreas Gohr * 424cfa2b40eSAndreas Gohr * If $conf['htmlok'] is true this should add the code as is to $doc 425cfa2b40eSAndreas Gohr * 426cfa2b40eSAndreas Gohr * @param string $text The HTML 427cfa2b40eSAndreas Gohr */ 428de369923SAndreas Gohr public function htmlblock($text) { 4292c2835c2SAndreas Gohr } 43007f89c3cSAnika Henke 431cfa2b40eSAndreas Gohr /** 432cfa2b40eSAndreas Gohr * Output preformatted text 433cfa2b40eSAndreas Gohr * 434cfa2b40eSAndreas Gohr * @param string $text 435cfa2b40eSAndreas Gohr */ 436de369923SAndreas Gohr public function preformatted($text) { 4372c2835c2SAndreas Gohr } 4380cecf9d5Sandi 439cfa2b40eSAndreas Gohr /** 440cfa2b40eSAndreas Gohr * Start a block quote 441cfa2b40eSAndreas Gohr */ 442de369923SAndreas Gohr public function quote_open() { 4432c2835c2SAndreas Gohr } 4440cecf9d5Sandi 445cfa2b40eSAndreas Gohr /** 446cfa2b40eSAndreas Gohr * Stop a block quote 447cfa2b40eSAndreas Gohr */ 448de369923SAndreas Gohr public function quote_close() { 4492c2835c2SAndreas Gohr } 4500cecf9d5Sandi 451cfa2b40eSAndreas Gohr /** 452cfa2b40eSAndreas Gohr * Display text as file content, optionally syntax highlighted 453cfa2b40eSAndreas Gohr * 454cfa2b40eSAndreas Gohr * @param string $text text to show 455cfa2b40eSAndreas Gohr * @param string $lang programming language to use for syntax highlighting 456cfa2b40eSAndreas Gohr * @param string $file file path label 457cfa2b40eSAndreas Gohr */ 458de369923SAndreas Gohr public function file($text, $lang = null, $file = null) { 4592c2835c2SAndreas Gohr } 4603d491f75SAndreas Gohr 461cfa2b40eSAndreas Gohr /** 462cfa2b40eSAndreas Gohr * Display text as code content, optionally syntax highlighted 463cfa2b40eSAndreas Gohr * 464cfa2b40eSAndreas Gohr * @param string $text text to show 465cfa2b40eSAndreas Gohr * @param string $lang programming language to use for syntax highlighting 466cfa2b40eSAndreas Gohr * @param string $file file path label 467cfa2b40eSAndreas Gohr */ 468de369923SAndreas Gohr public function code($text, $lang = null, $file = null) { 4692c2835c2SAndreas Gohr } 4700cecf9d5Sandi 471cfa2b40eSAndreas Gohr /** 472cfa2b40eSAndreas Gohr * Format an acronym 473cfa2b40eSAndreas Gohr * 474cfa2b40eSAndreas Gohr * Uses $this->acronyms 475cfa2b40eSAndreas Gohr * 476cfa2b40eSAndreas Gohr * @param string $acronym 477cfa2b40eSAndreas Gohr */ 478de369923SAndreas Gohr public function acronym($acronym) { 4792c2835c2SAndreas Gohr } 4800cecf9d5Sandi 481cfa2b40eSAndreas Gohr /** 482cfa2b40eSAndreas Gohr * Format a smiley 483cfa2b40eSAndreas Gohr * 484cfa2b40eSAndreas Gohr * Uses $this->smiley 485cfa2b40eSAndreas Gohr * 486cfa2b40eSAndreas Gohr * @param string $smiley 487cfa2b40eSAndreas Gohr */ 488de369923SAndreas Gohr public function smiley($smiley) { 4892c2835c2SAndreas Gohr } 4900cecf9d5Sandi 491cfa2b40eSAndreas Gohr /** 492cfa2b40eSAndreas Gohr * Format an entity 493cfa2b40eSAndreas Gohr * 494cfa2b40eSAndreas Gohr * Entities are basically small text replacements 495cfa2b40eSAndreas Gohr * 496cfa2b40eSAndreas Gohr * Uses $this->entities 497cfa2b40eSAndreas Gohr * 498cfa2b40eSAndreas Gohr * @param string $entity 499cfa2b40eSAndreas Gohr */ 500de369923SAndreas Gohr public function entity($entity) { 5012c2835c2SAndreas Gohr } 5020cecf9d5Sandi 503cfa2b40eSAndreas Gohr /** 504cfa2b40eSAndreas Gohr * Typographically format a multiply sign 505cfa2b40eSAndreas Gohr * 506cfa2b40eSAndreas Gohr * Example: ($x=640, $y=480) should result in "640×480" 507cfa2b40eSAndreas Gohr * 508cfa2b40eSAndreas Gohr * @param string|int $x first value 509cfa2b40eSAndreas Gohr * @param string|int $y second value 510cfa2b40eSAndreas Gohr */ 511de369923SAndreas Gohr public function multiplyentity($x, $y) { 5122c2835c2SAndreas Gohr } 5130cecf9d5Sandi 514cfa2b40eSAndreas Gohr /** 515cfa2b40eSAndreas Gohr * Render an opening single quote char (language specific) 516cfa2b40eSAndreas Gohr */ 517de369923SAndreas Gohr public function singlequoteopening() { 5182c2835c2SAndreas Gohr } 5190cecf9d5Sandi 520cfa2b40eSAndreas Gohr /** 521cfa2b40eSAndreas Gohr * Render a closing single quote char (language specific) 522cfa2b40eSAndreas Gohr */ 523de369923SAndreas Gohr public function singlequoteclosing() { 5242c2835c2SAndreas Gohr } 5250cecf9d5Sandi 526cfa2b40eSAndreas Gohr /** 527cfa2b40eSAndreas Gohr * Render an apostrophe char (language specific) 528cfa2b40eSAndreas Gohr */ 529de369923SAndreas Gohr public function apostrophe() { 5302c2835c2SAndreas Gohr } 53157d757d1SAndreas Gohr 532cfa2b40eSAndreas Gohr /** 533cfa2b40eSAndreas Gohr * Render an opening double quote char (language specific) 534cfa2b40eSAndreas Gohr */ 535de369923SAndreas Gohr public function doublequoteopening() { 5362c2835c2SAndreas Gohr } 5370cecf9d5Sandi 538cfa2b40eSAndreas Gohr /** 539cfa2b40eSAndreas Gohr * Render an closinging double quote char (language specific) 540cfa2b40eSAndreas Gohr */ 541de369923SAndreas Gohr public function doublequoteclosing() { 5422c2835c2SAndreas Gohr } 5430cecf9d5Sandi 544cfa2b40eSAndreas Gohr /** 545cfa2b40eSAndreas Gohr * Render a CamelCase link 546cfa2b40eSAndreas Gohr * 547cfa2b40eSAndreas Gohr * @param string $link The link name 548cfa2b40eSAndreas Gohr * @see http://en.wikipedia.org/wiki/CamelCase 549cfa2b40eSAndreas Gohr */ 550de369923SAndreas Gohr public function camelcaselink($link) { 5512c2835c2SAndreas Gohr } 5520cecf9d5Sandi 553cfa2b40eSAndreas Gohr /** 554cfa2b40eSAndreas Gohr * Render a page local link 555cfa2b40eSAndreas Gohr * 556cfa2b40eSAndreas Gohr * @param string $hash hash link identifier 557cfa2b40eSAndreas Gohr * @param string $name name for the link 558cfa2b40eSAndreas Gohr */ 559de369923SAndreas Gohr public function locallink($hash, $name = null) { 5602c2835c2SAndreas Gohr } 561a939d432SAndreas Gohr 562cfa2b40eSAndreas Gohr /** 563cfa2b40eSAndreas Gohr * Render a wiki internal link 564cfa2b40eSAndreas Gohr * 565cfa2b40eSAndreas Gohr * @param string $link page ID to link to. eg. 'wiki:syntax' 566cfa2b40eSAndreas Gohr * @param string|array $title name for the link, array for media file 567cfa2b40eSAndreas Gohr */ 568de369923SAndreas Gohr public function internallink($link, $title = null) { 5692c2835c2SAndreas Gohr } 5700cecf9d5Sandi 571cfa2b40eSAndreas Gohr /** 572cfa2b40eSAndreas Gohr * Render an external link 573cfa2b40eSAndreas Gohr * 574cfa2b40eSAndreas Gohr * @param string $link full URL with scheme 575cfa2b40eSAndreas Gohr * @param string|array $title name for the link, array for media file 576cfa2b40eSAndreas Gohr */ 577de369923SAndreas Gohr public function externallink($link, $title = null) { 5782c2835c2SAndreas Gohr } 5790cecf9d5Sandi 580cfa2b40eSAndreas Gohr /** 581cfa2b40eSAndreas Gohr * Render the output of an RSS feed 582cfa2b40eSAndreas Gohr * 583cfa2b40eSAndreas Gohr * @param string $url URL of the feed 584cfa2b40eSAndreas Gohr * @param array $params Finetuning of the output 585cfa2b40eSAndreas Gohr */ 586de369923SAndreas Gohr public function rss($url, $params) { 5872c2835c2SAndreas Gohr } 588c5cfca61SAndreas Gohr 589cfa2b40eSAndreas Gohr /** 590cfa2b40eSAndreas Gohr * Render an interwiki link 591cfa2b40eSAndreas Gohr * 592cfa2b40eSAndreas Gohr * You may want to use $this->_resolveInterWiki() here 593cfa2b40eSAndreas Gohr * 594cfa2b40eSAndreas Gohr * @param string $link original link - probably not much use 595cfa2b40eSAndreas Gohr * @param string|array $title name for the link, array for media file 596cfa2b40eSAndreas Gohr * @param string $wikiName indentifier (shortcut) for the remote wiki 597cfa2b40eSAndreas Gohr * @param string $wikiUri the fragment parsed from the original link 598cfa2b40eSAndreas Gohr */ 599de369923SAndreas Gohr public function interwikilink($link, $title, $wikiName, $wikiUri) { 6002c2835c2SAndreas Gohr } 6010cecf9d5Sandi 602cfa2b40eSAndreas Gohr /** 603cfa2b40eSAndreas Gohr * Link to file on users OS 604cfa2b40eSAndreas Gohr * 605cfa2b40eSAndreas Gohr * @param string $link the link 606cfa2b40eSAndreas Gohr * @param string|array $title name for the link, array for media file 607cfa2b40eSAndreas Gohr */ 608de369923SAndreas Gohr public function filelink($link, $title = null) { 6092c2835c2SAndreas Gohr } 6100cecf9d5Sandi 611cfa2b40eSAndreas Gohr /** 612cfa2b40eSAndreas Gohr * Link to windows share 613cfa2b40eSAndreas Gohr * 614cfa2b40eSAndreas Gohr * @param string $link the link 615cfa2b40eSAndreas Gohr * @param string|array $title name for the link, array for media file 616cfa2b40eSAndreas Gohr */ 617de369923SAndreas Gohr public function windowssharelink($link, $title = null) { 6182c2835c2SAndreas Gohr } 6190cecf9d5Sandi 620cfa2b40eSAndreas Gohr /** 621cfa2b40eSAndreas Gohr * Render a linked E-Mail Address 622cfa2b40eSAndreas Gohr * 623cfa2b40eSAndreas Gohr * Should honor $conf['mailguard'] setting 624cfa2b40eSAndreas Gohr * 625cfa2b40eSAndreas Gohr * @param string $address Email-Address 6263dd5c225SAndreas Gohr * @param string|array $name name for the link, array for media file 627cfa2b40eSAndreas Gohr */ 628de369923SAndreas Gohr public function emaillink($address, $name = null) { 6292c2835c2SAndreas Gohr } 6300cecf9d5Sandi 631cfa2b40eSAndreas Gohr /** 632cfa2b40eSAndreas Gohr * Render an internal media file 633cfa2b40eSAndreas Gohr * 634cfa2b40eSAndreas Gohr * @param string $src media ID 635cfa2b40eSAndreas Gohr * @param string $title descriptive text 636cfa2b40eSAndreas Gohr * @param string $align left|center|right 637cfa2b40eSAndreas Gohr * @param int $width width of media in pixel 638cfa2b40eSAndreas Gohr * @param int $height height of media in pixel 639cfa2b40eSAndreas Gohr * @param string $cache cache|recache|nocache 640cfa2b40eSAndreas Gohr * @param string $linking linkonly|detail|nolink 641cfa2b40eSAndreas Gohr */ 642de369923SAndreas Gohr public function internalmedia($src, $title = null, $align = null, $width = null, 6432c2835c2SAndreas Gohr $height = null, $cache = null, $linking = null) { 6442c2835c2SAndreas Gohr } 645a939d432SAndreas Gohr 646cfa2b40eSAndreas Gohr /** 647cfa2b40eSAndreas Gohr * Render an external media file 648cfa2b40eSAndreas Gohr * 649cfa2b40eSAndreas Gohr * @param string $src full media URL 650cfa2b40eSAndreas Gohr * @param string $title descriptive text 651cfa2b40eSAndreas Gohr * @param string $align left|center|right 652cfa2b40eSAndreas Gohr * @param int $width width of media in pixel 653cfa2b40eSAndreas Gohr * @param int $height height of media in pixel 654cfa2b40eSAndreas Gohr * @param string $cache cache|recache|nocache 655cfa2b40eSAndreas Gohr * @param string $linking linkonly|detail|nolink 656cfa2b40eSAndreas Gohr */ 657de369923SAndreas Gohr public function externalmedia($src, $title = null, $align = null, $width = null, 6582c2835c2SAndreas Gohr $height = null, $cache = null, $linking = null) { 6592c2835c2SAndreas Gohr } 660a939d432SAndreas Gohr 661cfa2b40eSAndreas Gohr /** 662cfa2b40eSAndreas Gohr * Render a link to an internal media file 663cfa2b40eSAndreas Gohr * 664cfa2b40eSAndreas Gohr * @param string $src media ID 665cfa2b40eSAndreas Gohr * @param string $title descriptive text 666cfa2b40eSAndreas Gohr * @param string $align left|center|right 667cfa2b40eSAndreas Gohr * @param int $width width of media in pixel 668cfa2b40eSAndreas Gohr * @param int $height height of media in pixel 669cfa2b40eSAndreas Gohr * @param string $cache cache|recache|nocache 670cfa2b40eSAndreas Gohr */ 671de369923SAndreas Gohr public function internalmedialink($src, $title = null, $align = null, 672cfa2b40eSAndreas Gohr $width = null, $height = null, $cache = null) { 6732c2835c2SAndreas Gohr } 6740cecf9d5Sandi 675cfa2b40eSAndreas Gohr /** 676cfa2b40eSAndreas Gohr * Render a link to an external media file 677cfa2b40eSAndreas Gohr * 678cfa2b40eSAndreas Gohr * @param string $src media ID 679cfa2b40eSAndreas Gohr * @param string $title descriptive text 680cfa2b40eSAndreas Gohr * @param string $align left|center|right 681cfa2b40eSAndreas Gohr * @param int $width width of media in pixel 682cfa2b40eSAndreas Gohr * @param int $height height of media in pixel 683cfa2b40eSAndreas Gohr * @param string $cache cache|recache|nocache 684cfa2b40eSAndreas Gohr */ 685de369923SAndreas Gohr public function externalmedialink($src, $title = null, $align = null, 686cfa2b40eSAndreas Gohr $width = null, $height = null, $cache = null) { 6872c2835c2SAndreas Gohr } 6880cecf9d5Sandi 689cfa2b40eSAndreas Gohr /** 690cfa2b40eSAndreas Gohr * Start a table 691cfa2b40eSAndreas Gohr * 692cfa2b40eSAndreas Gohr * @param int $maxcols maximum number of columns 693cfa2b40eSAndreas Gohr * @param int $numrows NOT IMPLEMENTED 694cfa2b40eSAndreas Gohr * @param int $pos byte position in the original source 695cfa2b40eSAndreas Gohr */ 696de369923SAndreas Gohr public function table_open($maxcols = null, $numrows = null, $pos = null) { 6972c2835c2SAndreas Gohr } 6980cecf9d5Sandi 699cfa2b40eSAndreas Gohr /** 700cfa2b40eSAndreas Gohr * Close a table 701cfa2b40eSAndreas Gohr * 702cfa2b40eSAndreas Gohr * @param int $pos byte position in the original source 703cfa2b40eSAndreas Gohr */ 704de369923SAndreas Gohr public function table_close($pos = null) { 7052c2835c2SAndreas Gohr } 7060cecf9d5Sandi 707cfa2b40eSAndreas Gohr /** 708cfa2b40eSAndreas Gohr * Open a table header 709cfa2b40eSAndreas Gohr */ 710de369923SAndreas Gohr public function tablethead_open() { 7112c2835c2SAndreas Gohr } 712f05a1cc5SGerrit Uitslag 713cfa2b40eSAndreas Gohr /** 714cfa2b40eSAndreas Gohr * Close a table header 715cfa2b40eSAndreas Gohr */ 716de369923SAndreas Gohr public function tablethead_close() { 7172c2835c2SAndreas Gohr } 718f05a1cc5SGerrit Uitslag 719cfa2b40eSAndreas Gohr /** 7205a93f869SAnika Henke * Open a table body 7215a93f869SAnika Henke */ 722de369923SAndreas Gohr public function tabletbody_open() { 7235a93f869SAnika Henke } 7245a93f869SAnika Henke 7255a93f869SAnika Henke /** 7265a93f869SAnika Henke * Close a table body 7275a93f869SAnika Henke */ 728de369923SAndreas Gohr public function tabletbody_close() { 7295a93f869SAnika Henke } 7305a93f869SAnika Henke 7315a93f869SAnika Henke /** 732d2a99739SAndreas Gohr * Open a table footer 733d2a99739SAndreas Gohr */ 734de369923SAndreas Gohr public function tabletfoot_open() { 735d2a99739SAndreas Gohr } 736d2a99739SAndreas Gohr 737d2a99739SAndreas Gohr /** 738d2a99739SAndreas Gohr * Close a table footer 739d2a99739SAndreas Gohr */ 740de369923SAndreas Gohr public function tabletfoot_close() { 741d2a99739SAndreas Gohr } 742d2a99739SAndreas Gohr 743d2a99739SAndreas Gohr /** 744cfa2b40eSAndreas Gohr * Open a table row 745cfa2b40eSAndreas Gohr */ 746de369923SAndreas Gohr public function tablerow_open() { 7472c2835c2SAndreas Gohr } 7480cecf9d5Sandi 749cfa2b40eSAndreas Gohr /** 750cfa2b40eSAndreas Gohr * Close a table row 751cfa2b40eSAndreas Gohr */ 752de369923SAndreas Gohr public function tablerow_close() { 7532c2835c2SAndreas Gohr } 7540cecf9d5Sandi 755cfa2b40eSAndreas Gohr /** 756cfa2b40eSAndreas Gohr * Open a table header cell 757cfa2b40eSAndreas Gohr * 758cfa2b40eSAndreas Gohr * @param int $colspan 759cfa2b40eSAndreas Gohr * @param string $align left|center|right 760cfa2b40eSAndreas Gohr * @param int $rowspan 761cfa2b40eSAndreas Gohr */ 762de369923SAndreas Gohr public function tableheader_open($colspan = 1, $align = null, $rowspan = 1) { 7632c2835c2SAndreas Gohr } 7640cecf9d5Sandi 765cfa2b40eSAndreas Gohr /** 766cfa2b40eSAndreas Gohr * Close a table header cell 767cfa2b40eSAndreas Gohr */ 768de369923SAndreas Gohr public function tableheader_close() { 7692c2835c2SAndreas Gohr } 7700cecf9d5Sandi 771cfa2b40eSAndreas Gohr /** 772cfa2b40eSAndreas Gohr * Open a table cell 773cfa2b40eSAndreas Gohr * 774cfa2b40eSAndreas Gohr * @param int $colspan 775cfa2b40eSAndreas Gohr * @param string $align left|center|right 776cfa2b40eSAndreas Gohr * @param int $rowspan 777cfa2b40eSAndreas Gohr */ 778de369923SAndreas Gohr public function tablecell_open($colspan = 1, $align = null, $rowspan = 1) { 7792c2835c2SAndreas Gohr } 7800cecf9d5Sandi 781cfa2b40eSAndreas Gohr /** 782cfa2b40eSAndreas Gohr * Close a table cell 783cfa2b40eSAndreas Gohr */ 784de369923SAndreas Gohr public function tablecell_close() { 7852c2835c2SAndreas Gohr } 7862ea4044fSAndreas Gohr 787cfa2b40eSAndreas Gohr #endregion 788cfa2b40eSAndreas Gohr 789cfa2b40eSAndreas Gohr #region util functions, you probably won't need to reimplement them 7902ea4044fSAndreas Gohr 7912ea4044fSAndreas Gohr /** 792de369923SAndreas Gohr * Creates a linkid from a headline 793de369923SAndreas Gohr * 794de369923SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 795de369923SAndreas Gohr * @param string $title The headline title 796de369923SAndreas Gohr * @param boolean $create Create a new unique ID? 797de369923SAndreas Gohr * @return string 798de369923SAndreas Gohr */ 799de369923SAndreas Gohr public function _headerToLink($title, $create = false) { 800de369923SAndreas Gohr if($create) { 801de369923SAndreas Gohr return sectionID($title, $this->headers); 802de369923SAndreas Gohr } else { 803de369923SAndreas Gohr $check = false; 804de369923SAndreas Gohr return sectionID($title, $check); 805de369923SAndreas Gohr } 806de369923SAndreas Gohr } 807de369923SAndreas Gohr 808de369923SAndreas Gohr /** 8092ea4044fSAndreas Gohr * Removes any Namespace from the given name but keeps 8102ea4044fSAndreas Gohr * casing and special chars 8112ea4044fSAndreas Gohr * 8122ea4044fSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 81342ea7f44SGerrit Uitslag * 81442ea7f44SGerrit Uitslag * @param string $name 81542ea7f44SGerrit Uitslag * @return string 8162ea4044fSAndreas Gohr */ 817de369923SAndreas Gohr protected function _simpleTitle($name) { 8182ea4044fSAndreas Gohr global $conf; 8192ea4044fSAndreas Gohr 8202ea4044fSAndreas Gohr //if there is a hash we use the ancor name only 8216d2af55dSChristopher Smith @list($name, $hash) = explode('#', $name, 2); 8222ea4044fSAndreas Gohr if($hash) return $hash; 8232ea4044fSAndreas Gohr 8242ea4044fSAndreas Gohr if($conf['useslash']) { 8253755fc25STom N Harris $name = strtr($name, ';/', ';:'); 8263755fc25STom N Harris } else { 8273755fc25STom N Harris $name = strtr($name, ';', ':'); 8282ea4044fSAndreas Gohr } 8292ea4044fSAndreas Gohr 8309708106bSAdrian Lang return noNSorNS($name); 8312ea4044fSAndreas Gohr } 8322ea4044fSAndreas Gohr 8331f82fabeSAndreas Gohr /** 8341f82fabeSAndreas Gohr * Resolve an interwikilink 83542ea7f44SGerrit Uitslag * 83642ea7f44SGerrit Uitslag * @param string $shortcut identifier for the interwiki link 83742ea7f44SGerrit Uitslag * @param string $reference fragment that refers the content 83842ea7f44SGerrit Uitslag * @param null|bool $exists reference which returns if an internal page exists 83942ea7f44SGerrit Uitslag * @return string interwikilink 8401f82fabeSAndreas Gohr */ 841de369923SAndreas Gohr public function _resolveInterWiki(&$shortcut, $reference, &$exists = null) { 8421f82fabeSAndreas Gohr //get interwiki URL 8431f82fabeSAndreas Gohr if(isset($this->interwiki[$shortcut])) { 8441f82fabeSAndreas Gohr $url = $this->interwiki[$shortcut]; 8451f82fabeSAndreas Gohr } else { 8461f82fabeSAndreas Gohr // Default to Google I'm feeling lucky 847ccee93d9SPatrick Brown $url = 'https://www.google.com/search?q={URL}&btnI=lucky'; 8481f82fabeSAndreas Gohr $shortcut = 'go'; 8491f82fabeSAndreas Gohr } 8502ea4044fSAndreas Gohr 8511f82fabeSAndreas Gohr //split into hash and url part 85217e17ae2SPatrick Brown $hash = strrchr($reference, '#'); 85317e17ae2SPatrick Brown if($hash) { 85417e17ae2SPatrick Brown $reference = substr($reference, 0, -strlen($hash)); 85517e17ae2SPatrick Brown $hash = substr($hash, 1); 85617e17ae2SPatrick Brown } 8571f82fabeSAndreas Gohr 8581f82fabeSAndreas Gohr //replace placeholder 8591f82fabeSAndreas Gohr if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) { 8601f82fabeSAndreas Gohr //use placeholders 8611f82fabeSAndreas Gohr $url = str_replace('{URL}', rawurlencode($reference), $url); 86217e17ae2SPatrick Brown //wiki names will be cleaned next, otherwise urlencode unsafe chars 86317e17ae2SPatrick Brown $url = str_replace('{NAME}', ($url{0} === ':') ? $reference : 86417e17ae2SPatrick Brown preg_replace_callback('/[[\\\\\]^`{|}#%]/', function($match) { 86517e17ae2SPatrick Brown return rawurlencode($match[0]); 86617e17ae2SPatrick Brown }, $reference), $url); 8671f82fabeSAndreas Gohr $parsed = parse_url($reference); 8688f34cf3dSMichael Große if (empty($parsed['scheme'])) $parsed['scheme'] = ''; 8698f34cf3dSMichael Große if (empty($parsed['host'])) $parsed['host'] = ''; 8708f34cf3dSMichael Große if (empty($parsed['port'])) $parsed['port'] = 80; 8718f34cf3dSMichael Große if (empty($parsed['path'])) $parsed['path'] = ''; 8728f34cf3dSMichael Große if (empty($parsed['query'])) $parsed['query'] = ''; 8738f34cf3dSMichael Große $url = strtr($url,[ 8748f34cf3dSMichael Große '{SCHEME}' => $parsed['scheme'], 8758f34cf3dSMichael Große '{HOST}' => $parsed['host'], 8768f34cf3dSMichael Große '{PORT}' => $parsed['port'], 8778f34cf3dSMichael Große '{PATH}' => $parsed['path'], 8788f34cf3dSMichael Große '{QUERY}' => $parsed['query'] , 8798f34cf3dSMichael Große ]); 8801f82fabeSAndreas Gohr } else { 8811f82fabeSAndreas Gohr //default 8821f82fabeSAndreas Gohr $url = $url.rawurlencode($reference); 8831f82fabeSAndreas Gohr } 884f379edc2SGerrit Uitslag //handle as wiki links 8856496c33fSGerrit Uitslag if($url{0} === ':') { 886c55b109cSMichael Große $urlparam = null; 887c55b109cSMichael Große $id = $url; 888c55b109cSMichael Große if (strpos($url, '?') !== false) { 8896496c33fSGerrit Uitslag list($id, $urlparam) = explode('?', $url, 2); 890c55b109cSMichael Große } 8916496c33fSGerrit Uitslag $url = wl(cleanID($id), $urlparam); 8926496c33fSGerrit Uitslag $exists = page_exists($id); 8932345e871SGerrit Uitslag } 8941f82fabeSAndreas Gohr if($hash) $url .= '#'.rawurlencode($hash); 8951f82fabeSAndreas Gohr 8961f82fabeSAndreas Gohr return $url; 8971f82fabeSAndreas Gohr } 898cfa2b40eSAndreas Gohr 899cfa2b40eSAndreas Gohr #endregion 9000cecf9d5Sandi} 9010cecf9d5Sandi 902340756e4Sandi 903e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 : 904