1<?php 2// phpcs:ignoreFile -- this file violates PSR-12 by definition 3/** 4 * These classes and functions are deprecated and will be removed in future releases 5 * 6 * Note: when adding to this file, please also add appropriate actions to _test/rector.php 7 */ 8 9use dokuwiki\Debug\DebugHelper; 10 11/** 12 * @deprecated since 2021-11-11 use \dokuwiki\Remote\IXR\Client instead! 13 */ 14class IXR_Client extends \dokuwiki\Remote\IXR\Client 15{ 16 /** 17 * @inheritdoc 18 * @deprecated 2021-11-11 19 */ 20 public function __construct($server, $path = false, $port = 80, $timeout = 15, $timeout_io = null) 21 { 22 DebugHelper::dbgDeprecatedFunction(dokuwiki\Remote\IXR\Client::class); 23 parent::__construct($server, $path, $port, $timeout, $timeout_io); 24 } 25} 26/** 27 * @deprecated since 2021-11-11 use \IXR\Client\ClientMulticall instead! 28 */ 29class IXR_ClientMulticall extends \IXR\Client\ClientMulticall 30{ 31 /** 32 * @inheritdoc 33 * @deprecated 2021-11-11 34 */ 35 public function __construct($server, $path = false, $port = 80) 36 { 37 DebugHelper::dbgDeprecatedFunction(IXR\Client\ClientMulticall::class); 38 parent::__construct($server, $path, $port); 39 } 40} 41/** 42 * @deprecated since 2021-11-11 use \IXR\Server\Server instead! 43 */ 44class IXR_Server extends \IXR\Server\Server 45{ 46 /** 47 * @inheritdoc 48 * @deprecated 2021-11-11 49 */ 50 public function __construct($callbacks = false, $data = false, $wait = false) 51 { 52 DebugHelper::dbgDeprecatedFunction(IXR\Server\Server::class); 53 parent::__construct($callbacks, $data, $wait); 54 } 55} 56/** 57 * @deprecated since 2021-11-11 use \IXR\Server\IntrospectionServer instead! 58 */ 59class IXR_IntrospectionServer extends \IXR\Server\IntrospectionServer 60{ 61 /** 62 * @inheritdoc 63 * @deprecated 2021-11-11 64 */ 65 public function __construct() 66 { 67 DebugHelper::dbgDeprecatedFunction(IXR\Server\IntrospectionServer::class); 68 parent::__construct(); 69 } 70} 71/** 72 * @deprecated since 2021-11-11 use \IXR\Request\Request instead! 73 */ 74class IXR_Request extends \IXR\Request\Request 75{ 76 /** 77 * @inheritdoc 78 * @deprecated 2021-11-11 79 */ 80 public function __construct($method, $args) 81 { 82 DebugHelper::dbgDeprecatedFunction(IXR\Request\Request::class); 83 parent::__construct($method, $args); 84 } 85} 86/** 87 * @deprecated since 2021-11-11 use \IXR\Message\Message instead! 88 */ 89class IXR_Message extends IXR\Message\Message 90{ 91 /** 92 * @inheritdoc 93 * @deprecated 2021-11-11 94 */ 95 public function __construct($message) 96 { 97 DebugHelper::dbgDeprecatedFunction(IXR\Message\Message::class); 98 parent::__construct($message); 99 } 100} 101/** 102 * @deprecated since 2021-11-11 use \IXR\Message\Error instead! 103 */ 104class IXR_Error extends \IXR\Message\Error 105{ 106 /** 107 * @inheritdoc 108 * @deprecated 2021-11-11 109 */ 110 public function __construct($code, $message) 111 { 112 DebugHelper::dbgDeprecatedFunction(IXR\Message\Error::class); 113 parent::__construct($code, $message); 114 } 115} 116/** 117 * @deprecated since 2021-11-11 use \IXR\DataType\Date instead! 118 */ 119class IXR_Date extends \IXR\DataType\Date 120{ 121 /** 122 * @inheritdoc 123 * @deprecated 2021-11-11 124 */ 125 public function __construct($time) 126 { 127 DebugHelper::dbgDeprecatedFunction(IXR\DataType\Date::class); 128 parent::__construct($time); 129 } 130} 131/** 132 * @deprecated since 2021-11-11 use \IXR\DataType\Base64 instead! 133 */ 134class IXR_Base64 extends \IXR\DataType\Base64 135{ 136 /** 137 * @inheritdoc 138 * @deprecated 2021-11-11 139 */ 140 public function __construct($data) 141 { 142 DebugHelper::dbgDeprecatedFunction(IXR\DataType\Base64::class); 143 parent::__construct($data); 144 } 145} 146/** 147 * @deprecated since 2021-11-11 use \IXR\DataType\Value instead! 148 */ 149class IXR_Value extends \IXR\DataType\Value 150{ 151 /** 152 * @inheritdoc 153 * @deprecated 2021-11-11 154 */ 155 public function __construct($data, $type = null) 156 { 157 DebugHelper::dbgDeprecatedFunction(IXR\DataType\Value::class); 158 parent::__construct($data, $type); 159 } 160} 161 162/** 163 * returns all available parser syntax modes in correct order 164 * 165 * @return array[] with for each plugin the array('sort' => sortnumber, 'mode' => mode string, 'obj' => plugin object) 166 * @author Andreas Gohr <andi@splitbrain.org> 167 * @deprecated 2026-04-16 use \dokuwiki\Parsing\ModeRegistry::getModes() instead 168 */ 169function p_get_parsermodes() 170{ 171 DebugHelper::dbgDeprecatedFunction(\dokuwiki\Parsing\ModeRegistry::class . '::getModes()'); 172 return \dokuwiki\Parsing\ModeRegistry::getInstance()->getModes(); 173} 174 175/** 176 * Callback function for usort 177 * 178 * @param array $a 179 * @param array $b 180 * @return int $a is lower/equal/higher than $b 181 * @author Andreas Gohr <andi@splitbrain.org> 182 * @deprecated 2026-04-16 use \dokuwiki\Parsing\ModeRegistry::sortModes() instead 183 */ 184function p_sort_modes($a, $b) 185{ 186 DebugHelper::dbgDeprecatedFunction(\dokuwiki\Parsing\ModeRegistry::class . '::sortModes()'); 187 return \dokuwiki\Parsing\ModeRegistry::sortModes($a, $b); 188} 189 190/** 191 * print a newline terminated string 192 * 193 * You can give an indention as optional parameter 194 * 195 * @author Andreas Gohr <andi@splitbrain.org> 196 * 197 * @param string $string line of text 198 * @param int $indent number of spaces indention 199 * @deprecated 2023-08-31 use echo instead 200 */ 201function ptln($string, $indent = 0) 202{ 203 DebugHelper::dbgDeprecatedFunction('echo'); 204 echo str_repeat(' ', $indent) . "$string\n"; 205} 206 207/** 208 * Adds/updates the search index for the given page 209 * 210 * Locking is handled internally. 211 * 212 * @param string $page name of the page to index 213 * @param boolean $verbose print status messages 214 * @param boolean $force force reindexing even when the index is up to date 215 * @return string|boolean the function completed successfully 216 * 217 * @deprecated 2026-04-07 use Indexer class instead 218 */ 219function idx_addPage($page, $verbose = false, $force = false) 220{ 221 DebugHelper::dbgDeprecatedFunction('dokuwiki\Search\Indexer::addPage()'); 222 try { 223 (new dokuwiki\Search\Indexer())->addPage($page, $force); 224 return true; 225 } catch (\dokuwiki\Search\Exception\SearchException $e) { 226 return false; 227 } 228} 229 230/** 231 * Create an instance of the indexer. 232 * 233 * Returns a {@see dokuwiki\Search\LegacyIndexer} that preserves the legacy 234 * Doku_Indexer return contract (true|string on success/failure for the four 235 * mutating methods) so existing plugins keep working without try/catch. 236 * 237 * @return dokuwiki\Search\LegacyIndexer 238 * 239 * @deprecated 2026-04-07 use dokuwiki\Search\Indexer directly 240 */ 241function idx_get_indexer() 242{ 243 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Indexer::class); 244 return new dokuwiki\Search\LegacyIndexer(); 245} 246 247/** 248 * Read the list of words in an index (if it exists). 249 * 250 * @param string $idx 251 * @param string $suffix 252 * @return array 253 * 254 * @deprecated 2026-04-07 use Index classes directly 255 */ 256function idx_getIndex($idx, $suffix) 257{ 258 DebugHelper::dbgDeprecatedFunction('Index classes'); 259 global $conf; 260 $fn = $conf['indexdir'] . '/' . $idx . $suffix . '.idx'; 261 if (!file_exists($fn)) return []; 262 return file($fn); 263} 264 265/** 266 * Find tokens in the fulltext index 267 * 268 * @param array $words list of words to search for 269 * @return array list of pages found 270 * 271 * @deprecated 2026-04-07 use CollectionSearch on PageFulltextCollection instead 272 */ 273function idx_lookup(&$words) 274{ 275 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Collection\CollectionSearch::class); 276 return (new dokuwiki\Search\LegacyIndexer())->lookup($words); 277} 278 279/** 280 * Get the list of lengths indexed in the wiki. 281 * 282 * @return array 283 * 284 * @deprecated 2026-04-07 use PageFulltextCollection::getTokenIndexMaximum() instead 285 */ 286function idx_listIndexLengths() 287{ 288 DebugHelper::dbgDeprecatedFunction('PageFulltextCollection::getTokenIndexMaximum()'); 289 global $conf; 290 $idx = []; 291 $files = glob($conf['indexdir'] . '/i*.idx'); 292 if ($files) { 293 foreach ($files as $file) { 294 if (preg_match('/i(\d+)\.idx$/', $file, $match)) { 295 $idx[] = (int)$match[1]; 296 } 297 } 298 sort($idx); 299 } 300 return $idx; 301} 302 303/** 304 * Get the word lengths that have been indexed. 305 * 306 * @param array|int $filter 307 * @return array 308 * 309 * @deprecated 2026-04-07 use PageFulltextCollection::getTokenIndexMaximum() instead 310 */ 311function idx_indexLengths($filter) 312{ 313 DebugHelper::dbgDeprecatedFunction('PageFulltextCollection::getTokenIndexMaximum()'); 314 global $conf; 315 $idx = []; 316 if (is_array($filter)) { 317 $path = $conf['indexdir'] . "/i"; 318 foreach (array_keys($filter) as $key) { 319 if (file_exists($path . $key . '.idx')) 320 $idx[] = $key; 321 } 322 } else { 323 $lengths = idx_listIndexLengths(); 324 foreach ($lengths as $length) { 325 if ((int)$length >= (int)$filter) 326 $idx[] = $length; 327 } 328 } 329 return $idx; 330} 331 332/** 333 * Execute a fulltext search 334 * 335 * @param string $query search query 336 * @param array $highlight words to highlight 337 * @param string|null $sort sorting order 338 * @param int|string|null $after only show results after this date 339 * @param int|string|null $before only show results before this date 340 * @return array 341 * 342 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::pageSearch() instead 343 */ 344function ft_pageSearch($query, &$highlight, $sort = null, $after = null, $before = null) 345{ 346 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::pageSearch()'); 347 if (!is_array($highlight)) $highlight = []; 348 return (new dokuwiki\Search\FulltextSearch())->pageSearch($query, $highlight, $sort, $after, $before); 349} 350 351/** 352 * Returns the backlinks for a given page 353 * 354 * @param string $id page id 355 * @param bool $ignore_perms 356 * @return string[] 357 * 358 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::backlinks() instead 359 */ 360function ft_backlinks($id, $ignore_perms = false) 361{ 362 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::backlinks()'); 363 return (new dokuwiki\Search\MetadataSearch())->backlinks($id, $ignore_perms); 364} 365 366/** 367 * Returns the pages that use a given media file 368 * 369 * @param string $id media id 370 * @param bool $ignore_perms 371 * @return string[] 372 * 373 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::mediause() instead 374 */ 375function ft_mediause($id, $ignore_perms = false) 376{ 377 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::mediause()'); 378 return (new dokuwiki\Search\MetadataSearch())->mediause($id, $ignore_perms); 379} 380 381/** 382 * Quicksearch for pagenames 383 * 384 * @param string $id page id 385 * @param bool $in_ns match namespace 386 * @param bool $in_title search in title 387 * @param int|string|null $after 388 * @param int|string|null $before 389 * @return string[] 390 * 391 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::pageLookup() instead 392 */ 393function ft_pageLookup($id, $in_ns = false, $in_title = false, $after = null, $before = null) 394{ 395 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::pageLookup()'); 396 return (new dokuwiki\Search\MetadataSearch())->pageLookup($id, $in_ns, $in_title, $after, $before); 397} 398 399/** 400 * Creates a snippet extract 401 * 402 * @param string $id page id 403 * @param array $highlight words to highlight 404 * @return string 405 * 406 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::snippet() instead 407 */ 408function ft_snippet($id, $highlight) 409{ 410 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::snippet()'); 411 return (new dokuwiki\Search\FulltextSearch())->snippet($id, $highlight); 412} 413 414/** 415 * Sort pages based on their namespace level first, then alphabetically 416 * 417 * @param string $a 418 * @param string $b 419 * @return int 420 * 421 * @deprecated 2026-04-07 use Utf8\Sort functions directly 422 */ 423function ft_pagesorter($a, $b) 424{ 425 DebugHelper::dbgDeprecatedFunction('Utf8\\Sort'); 426 $diff = substr_count($a, ':') - substr_count($b, ':'); 427 return $diff ?: dokuwiki\Utf8\Sort::strcmp($a, $b); 428} 429 430/** 431 * Wrap a search term in regex boundary checks 432 * 433 * @param string $term 434 * @return string 435 * 436 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::snippetRePreprocess() instead 437 */ 438function ft_snippet_re_preprocess($term) 439{ 440 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::snippetRePreprocess()'); 441 return (new dokuwiki\Search\FulltextSearch())->snippetRePreprocess($term); 442} 443 444/** 445 * Parse a search query into its components 446 * 447 * @param mixed $Indexer ignored (legacy parameter) 448 * @param string $query search query 449 * @return array parsed query structure 450 * 451 * @deprecated 2026-04-07 use dokuwiki\Search\Query\QueryParser::convert() instead 452 */ 453function ft_queryParser($Indexer, $query) 454{ 455 DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Query\QueryParser::class . '::convert()'); 456 return (new dokuwiki\Search\Query\QueryParser())->convert($query); 457} 458 459/** 460 * @deprecated 2026-04-16 use \dokuwiki\Parsing\ParserMode\Media::parseMedia() instead 461 */ 462function Doku_Handler_Parse_Media($match) 463{ 464 DebugHelper::dbgDeprecatedFunction(\dokuwiki\Parsing\ParserMode\Media::class . '::parseMedia()'); 465 return \dokuwiki\Parsing\ParserMode\Media::parseMedia($match); 466} 467