xref: /dokuwiki/inc/deprecated.php (revision 9db5ea067c49c3843cc06fe5bf42e182fa36fe16)
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<<<<<<< HEAD
209 * Adds/updates the search index for the given page
210 *
211 * Locking is handled internally.
212 *
213 * @param string        $page   name of the page to index
214 * @param boolean       $verbose    print status messages
215 * @param boolean       $force  force reindexing even when the index is up to date
216 * @return string|boolean  the function completed successfully
217 *
218 * @deprecated 2026-04-07 use Indexer class instead
219 */
220function idx_addPage($page, $verbose = false, $force = false)
221{
222    DebugHelper::dbgDeprecatedFunction('dokuwiki\Search\Indexer::addPage()');
223    try {
224        (new dokuwiki\Search\Indexer())->addPage($page, $force);
225        return true;
226    } catch (\dokuwiki\Search\Exception\SearchException $e) {
227        return false;
228    }
229}
230
231/**
232 * Create an instance of the indexer.
233 *
234 * @return dokuwiki\Search\Indexer
235 *
236 * @deprecated 2026-04-07 use dokuwiki\Search\Indexer directly
237 */
238function idx_get_indexer()
239{
240    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Indexer::class);
241    return new dokuwiki\Search\Indexer();
242}
243
244/**
245 * Read the list of words in an index (if it exists).
246 *
247 * @param string $idx
248 * @param string $suffix
249 * @return array
250 *
251 * @deprecated 2026-04-07 use Index classes directly
252 */
253function idx_getIndex($idx, $suffix)
254{
255    DebugHelper::dbgDeprecatedFunction('Index classes');
256    global $conf;
257    $fn = $conf['indexdir'] . '/' . $idx . $suffix . '.idx';
258    if (!file_exists($fn)) return [];
259    return file($fn);
260}
261
262/**
263 * Find tokens in the fulltext index
264 *
265 * @param array $words list of words to search for
266 * @return array list of pages found
267 *
268 * @deprecated 2026-04-07 use CollectionSearch on PageFulltextCollection instead
269 */
270function idx_lookup(&$words)
271{
272    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Collection\CollectionSearch::class);
273    return (new dokuwiki\Search\Indexer())->lookup($words);
274}
275
276/**
277 * Get the list of lengths indexed in the wiki.
278 *
279 * @return array
280 *
281 * @deprecated 2026-04-07 use PageFulltextCollection::getTokenIndexMaximum() instead
282 */
283function idx_listIndexLengths()
284{
285    DebugHelper::dbgDeprecatedFunction('PageFulltextCollection::getTokenIndexMaximum()');
286    global $conf;
287    $idx = [];
288    $files = glob($conf['indexdir'] . '/i*.idx');
289    if ($files) {
290        foreach ($files as $file) {
291            if (preg_match('/i(\d+)\.idx$/', $file, $match)) {
292                $idx[] = (int)$match[1];
293            }
294        }
295        sort($idx);
296    }
297    return $idx;
298}
299
300/**
301 * Get the word lengths that have been indexed.
302 *
303 * @param array|int $filter
304 * @return array
305 *
306 * @deprecated 2026-04-07 use PageFulltextCollection::getTokenIndexMaximum() instead
307 */
308function idx_indexLengths($filter)
309{
310    DebugHelper::dbgDeprecatedFunction('PageFulltextCollection::getTokenIndexMaximum()');
311    global $conf;
312    $idx = [];
313    if (is_array($filter)) {
314        $path = $conf['indexdir'] . "/i";
315        foreach (array_keys($filter) as $key) {
316            if (file_exists($path . $key . '.idx'))
317                $idx[] = $key;
318        }
319    } else {
320        $lengths = idx_listIndexLengths();
321        foreach ($lengths as $length) {
322            if ((int)$length >= (int)$filter)
323                $idx[] = $length;
324        }
325    }
326    return $idx;
327}
328
329/**
330 * Execute a fulltext search
331 *
332 * @param string $query search query
333 * @param array $highlight words to highlight
334 * @param string|null $sort sorting order
335 * @param int|string|null $after only show results after this date
336 * @param int|string|null $before only show results before this date
337 * @return array
338 *
339 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::pageSearch() instead
340 */
341function ft_pageSearch($query, &$highlight, $sort = null, $after = null, $before = null)
342{
343    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::pageSearch()');
344    if (!is_array($highlight)) $highlight = [];
345    return (new dokuwiki\Search\FulltextSearch())->pageSearch($query, $highlight, $sort, $after, $before);
346}
347
348/**
349 * Returns the backlinks for a given page
350 *
351 * @param string $id page id
352 * @param bool $ignore_perms
353 * @return string[]
354 *
355 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::backlinks() instead
356 */
357function ft_backlinks($id, $ignore_perms = false)
358{
359    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::backlinks()');
360    return (new dokuwiki\Search\MetadataSearch())->backlinks($id, $ignore_perms);
361}
362
363/**
364 * Returns the pages that use a given media file
365 *
366 * @param string $id media id
367 * @param bool $ignore_perms
368 * @return string[]
369 *
370 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::mediause() instead
371 */
372function ft_mediause($id, $ignore_perms = false)
373{
374    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::mediause()');
375    return (new dokuwiki\Search\MetadataSearch())->mediause($id, $ignore_perms);
376}
377
378/**
379 * Quicksearch for pagenames
380 *
381 * @param string $id page id
382 * @param bool $in_ns match namespace
383 * @param bool $in_title search in title
384 * @param int|string|null $after
385 * @param int|string|null $before
386 * @return string[]
387 *
388 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::pageLookup() instead
389 */
390function ft_pageLookup($id, $in_ns = false, $in_title = false, $after = null, $before = null)
391{
392    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::pageLookup()');
393    return (new dokuwiki\Search\MetadataSearch())->pageLookup($id, $in_ns, $in_title, $after, $before);
394}
395
396/**
397 * Creates a snippet extract
398 *
399 * @param string $id page id
400 * @param array $highlight words to highlight
401 * @return string
402 *
403 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::snippet() instead
404 */
405function ft_snippet($id, $highlight)
406{
407    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::snippet()');
408    return (new dokuwiki\Search\FulltextSearch())->snippet($id, $highlight);
409}
410
411/**
412 * Sort pages based on their namespace level first, then alphabetically
413 *
414 * @param string $a
415 * @param string $b
416 * @return int
417 *
418 * @deprecated 2026-04-07 use Utf8\Sort functions directly
419 */
420function ft_pagesorter($a, $b)
421{
422    DebugHelper::dbgDeprecatedFunction('Utf8\\Sort');
423    $diff = substr_count($a, ':') - substr_count($b, ':');
424    return $diff ?: dokuwiki\Utf8\Sort::strcmp($a, $b);
425}
426
427/**
428 * Wrap a search term in regex boundary checks
429 *
430 * @param string $term
431 * @return string
432 *
433 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::snippetRePreprocess() instead
434 */
435function ft_snippet_re_preprocess($term)
436{
437    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::snippetRePreprocess()');
438    return (new dokuwiki\Search\FulltextSearch())->snippetRePreprocess($term);
439}
440
441/**
442 * Parse a search query into its components
443 *
444 * @param mixed $Indexer ignored (legacy parameter)
445 * @param string $query search query
446 * @return array parsed query structure
447 *
448 * @deprecated 2026-04-07 use dokuwiki\Search\Query\QueryParser::convert() instead
449 */
450function ft_queryParser($Indexer, $query)
451{
452    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Query\QueryParser::class . '::convert()');
453    return (new dokuwiki\Search\Query\QueryParser())->convert($query);
454}
455
456/**
457 * @deprecated 2026-04-16 use \dokuwiki\Parsing\ParserMode\Media::parseMedia() instead
458 */
459function Doku_Handler_Parse_Media($match)
460{
461    DebugHelper::dbgDeprecatedFunction(\dokuwiki\Parsing\ParserMode\Media::class . '::parseMedia()');
462    return \dokuwiki\Parsing\ParserMode\Media::parseMedia($match);
463}
464