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