xref: /dokuwiki/inc/deprecated.php (revision 451969ab7559b14e82720d165019a94010752965)
1<?php
2// phpcs:ignoreFile -- this file violates PSR2 by definition
3/**
4 * These classes and functions are deprecated and will be removed in future releases
5 */
6
7use dokuwiki\Debug\DebugHelper;
8use dokuwiki\Subscriptions\BulkSubscriptionSender;
9use dokuwiki\Subscriptions\MediaSubscriptionSender;
10use dokuwiki\Subscriptions\PageSubscriptionSender;
11use dokuwiki\Subscriptions\RegistrationSubscriptionSender;
12use dokuwiki\Subscriptions\SubscriberManager;
13
14/**
15 * @inheritdoc
16 * @deprecated 2018-05-07
17 */
18class RemoteAccessDeniedException extends \dokuwiki\Remote\AccessDeniedException
19{
20    /** @inheritdoc */
21    public function __construct($message = "", $code = 0, Throwable $previous = null)
22    {
23        dbg_deprecated(\dokuwiki\Remote\AccessDeniedException::class);
24        parent::__construct($message, $code, $previous);
25    }
26
27}
28
29/**
30 * @inheritdoc
31 * @deprecated 2018-05-07
32 */
33class RemoteException extends \dokuwiki\Remote\RemoteException
34{
35    /** @inheritdoc */
36    public function __construct($message = "", $code = 0, Throwable $previous = null)
37    {
38        dbg_deprecated(\dokuwiki\Remote\RemoteException::class);
39        parent::__construct($message, $code, $previous);
40    }
41
42}
43
44/**
45 * Escapes regex characters other than (, ) and /
46 *
47 * @param string $str
48 * @return string
49 * @deprecated 2018-05-04
50 */
51function Doku_Lexer_Escape($str)
52{
53    dbg_deprecated('\\dokuwiki\\Parsing\\Lexer\\Lexer::escape()');
54    return \dokuwiki\Parsing\Lexer\Lexer::escape($str);
55}
56
57/**
58 * @inheritdoc
59 * @deprecated 2018-06-01
60 */
61class setting extends \dokuwiki\plugin\config\core\Setting\Setting
62{
63    /** @inheritdoc */
64    public function __construct($key, array $params = null)
65    {
66        dbg_deprecated(\dokuwiki\plugin\config\core\Setting\Setting::class);
67        parent::__construct($key, $params);
68    }
69}
70
71/**
72 * @inheritdoc
73 * @deprecated 2018-06-01
74 */
75class setting_authtype extends \dokuwiki\plugin\config\core\Setting\SettingAuthtype
76{
77    /** @inheritdoc */
78    public function __construct($key, array $params = null)
79    {
80        dbg_deprecated(\dokuwiki\plugin\config\core\Setting\SettingAuthtype::class);
81        parent::__construct($key, $params);
82    }
83}
84
85/**
86 * @inheritdoc
87 * @deprecated 2018-06-01
88 */
89class setting_string extends \dokuwiki\plugin\config\core\Setting\SettingString
90{
91    /** @inheritdoc */
92    public function __construct($key, array $params = null)
93    {
94        dbg_deprecated(\dokuwiki\plugin\config\core\Setting\SettingString::class);
95        parent::__construct($key, $params);
96    }
97}
98
99/**
100 * @inheritdoc
101 * @deprecated 2018-06-15
102 */
103class PageChangelog extends \dokuwiki\ChangeLog\PageChangeLog
104{
105    /** @inheritdoc */
106    public function __construct($id, $chunk_size = 8192)
107    {
108        dbg_deprecated(\dokuwiki\ChangeLog\PageChangeLog::class);
109        parent::__construct($id, $chunk_size);
110    }
111}
112
113/**
114 * @inheritdoc
115 * @deprecated 2018-06-15
116 */
117class MediaChangelog extends \dokuwiki\ChangeLog\MediaChangeLog
118{
119    /** @inheritdoc */
120    public function __construct($id, $chunk_size = 8192)
121    {
122        dbg_deprecated(\dokuwiki\ChangeLog\MediaChangeLog::class);
123        parent::__construct($id, $chunk_size);
124    }
125}
126
127/** Behavior switch for JSON::decode() */
128define('JSON_LOOSE_TYPE', 16);
129
130/** Behavior switch for JSON::decode() */
131define('JSON_STRICT_TYPE', 0);
132
133/**
134 * Encode/Decode JSON
135 * @deprecated 2018-07-27
136 */
137class JSON
138{
139    protected $use = 0;
140
141    /**
142     * @param int $use JSON_*_TYPE flag
143     * @deprecated  2018-07-27
144     */
145    public function __construct($use = JSON_STRICT_TYPE)
146    {
147        $this->use = $use;
148    }
149
150    /**
151     * Encode given structure to JSON
152     *
153     * @param mixed $var
154     * @return string
155     * @deprecated  2018-07-27
156     */
157    public function encode($var)
158    {
159        dbg_deprecated('json_encode');
160        return json_encode($var);
161    }
162
163    /**
164     * Alias for encode()
165     * @param $var
166     * @return string
167     * @deprecated  2018-07-27
168     */
169    public function enc($var) {
170        return $this->encode($var);
171    }
172
173    /**
174     * Decode given string from JSON
175     *
176     * @param string $str
177     * @return mixed
178     * @deprecated  2018-07-27
179     */
180    public function decode($str)
181    {
182        dbg_deprecated('json_encode');
183        return json_decode($str, ($this->use == JSON_LOOSE_TYPE));
184    }
185
186    /**
187     * Alias for decode
188     *
189     * @param $str
190     * @return mixed
191     * @deprecated  2018-07-27
192     */
193    public function dec($str) {
194        return $this->decode($str);
195    }
196}
197
198/**
199 * @inheritdoc
200 * @deprecated 2019-02-19
201 */
202class Input extends \dokuwiki\Input\Input {
203    /**
204     * @inheritdoc
205     * @deprecated 2019-02-19
206     */
207    public function __construct()
208    {
209        dbg_deprecated(\dokuwiki\Input\Input::class);
210        parent::__construct();
211    }
212}
213
214/**
215 * @inheritdoc
216 * @deprecated 2019-02-19
217 */
218class PostInput extends \dokuwiki\Input\Post {
219    /**
220     * @inheritdoc
221     * @deprecated 2019-02-19
222     */
223    public function __construct()
224    {
225        dbg_deprecated(\dokuwiki\Input\Post::class);
226        parent::__construct();
227    }
228}
229
230/**
231 * @inheritdoc
232 * @deprecated 2019-02-19
233 */
234class GetInput extends \dokuwiki\Input\Get {
235    /**
236     * @inheritdoc
237     * @deprecated 2019-02-19
238     */
239    public function __construct()
240    {
241        dbg_deprecated(\dokuwiki\Input\Get::class);
242        parent::__construct();
243    }
244}
245
246/**
247 * @inheritdoc
248 * @deprecated 2019-02-19
249 */
250class ServerInput extends \dokuwiki\Input\Server {
251    /**
252     * @inheritdoc
253     * @deprecated 2019-02-19
254     */
255    public function __construct()
256    {
257        dbg_deprecated(\dokuwiki\Input\Server::class);
258        parent::__construct();
259    }
260}
261
262/**
263 * @inheritdoc
264 * @deprecated 2019-03-06
265 */
266class PassHash extends \dokuwiki\PassHash {
267    /**
268     * @inheritdoc
269     * @deprecated 2019-03-06
270     */
271    public function __construct()
272    {
273        dbg_deprecated(\dokuwiki\PassHash::class);
274    }
275}
276
277/**
278 * @deprecated since 2019-03-17 use \dokuwiki\HTTP\HTTPClientException instead!
279 */
280class HTTPClientException extends \dokuwiki\HTTP\HTTPClientException {
281
282    /**
283     * @inheritdoc
284     * @deprecated 2019-03-17
285     */
286    public function __construct($message = '', $code = 0, $previous = null)
287    {
288        DebugHelper::dbgDeprecatedFunction(dokuwiki\HTTP\HTTPClientException::class);
289        parent::__construct($message, $code, $previous);
290    }
291}
292
293/**
294 * @deprecated since 2019-03-17 use \dokuwiki\HTTP\HTTPClient instead!
295 */
296class HTTPClient extends \dokuwiki\HTTP\HTTPClient {
297
298    /**
299     * @inheritdoc
300     * @deprecated 2019-03-17
301     */
302    public function __construct()
303    {
304        DebugHelper::dbgDeprecatedFunction(dokuwiki\HTTP\HTTPClient::class);
305        parent::__construct();
306    }
307}
308
309/**
310 * @deprecated since 2019-03-17 use \dokuwiki\HTTP\DokuHTTPClient instead!
311 */
312class DokuHTTPClient extends \dokuwiki\HTTP\DokuHTTPClient {
313
314    /**
315     * @inheritdoc
316     * @deprecated 2019-03-17
317     */
318    public function __construct()
319    {
320        DebugHelper::dbgDeprecatedFunction(dokuwiki\HTTP\DokuHTTPClient::class);
321        parent::__construct();
322    }
323
324}
325
326
327/**
328 * Class for handling (email) subscriptions
329 *
330 * @author  Adrian Lang <lang@cosmocode.de>
331 * @author  Andreas Gohr <andi@splitbrain.org>
332 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
333 *
334 * @deprecated 2019-04-22 Use the classes in the \dokuwiki\Subscriptions namespace instead!
335 */
336class Subscription {
337
338    /**
339     * Check if subscription system is enabled
340     *
341     * @return bool
342     *
343     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::isenabled
344     */
345    public function isenabled() {
346        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::isenabled');
347        $subscriberManager = new SubscriberManager();
348        return $subscriberManager->isenabled();
349    }
350
351    /**
352     * Recursively search for matching subscriptions
353     *
354     * This function searches all relevant subscription files for a page or
355     * namespace.
356     *
357     * @author Adrian Lang <lang@cosmocode.de>
358     *
359     * @param string         $page The target object’s (namespace or page) id
360     * @param string|array   $user
361     * @param string|array   $style
362     * @param string|array   $data
363     * @return array
364     *
365     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::subscribers
366     */
367    public function subscribers($page, $user = null, $style = null, $data = null) {
368        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::subscribers');
369        $manager = new SubscriberManager();
370        return $manager->subscribers($page, $user, $style, $data);
371    }
372
373    /**
374     * Adds a new subscription for the given page or namespace
375     *
376     * This will automatically overwrite any existent subscription for the given user on this
377     * *exact* page or namespace. It will *not* modify any subscription that may exist in higher namespaces.
378     *
379     * @param string $id The target page or namespace, specified by id; Namespaces
380     *                   are identified by appending a colon.
381     * @param string $user
382     * @param string $style
383     * @param string $data
384     * @throws Exception when user or style is empty
385     * @return bool
386     *
387     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::add
388     */
389    public function add($id, $user, $style, $data = '') {
390        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::add');
391        $manager = new SubscriberManager();
392        return $manager->add($id, $user, $style, $data);
393    }
394
395    /**
396     * Removes a subscription for the given page or namespace
397     *
398     * This removes all subscriptions matching the given criteria on the given page or
399     * namespace. It will *not* modify any subscriptions that may exist in higher
400     * namespaces.
401     *
402     * @param string         $id   The target object’s (namespace or page) id
403     * @param string|array   $user
404     * @param string|array   $style
405     * @param string|array   $data
406     * @return bool
407     *
408     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::remove
409     */
410    public function remove($id, $user = null, $style = null, $data = null) {
411        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::remove');
412        $manager = new SubscriberManager();
413        return $manager->remove($id, $user, $style, $data);
414    }
415
416    /**
417     * Get data for $INFO['subscribed']
418     *
419     * $INFO['subscribed'] is either false if no subscription for the current page
420     * and user is in effect. Else it contains an array of arrays with the fields
421     * “target”, “style”, and optionally “data”.
422     *
423     * @param string $id  Page ID, defaults to global $ID
424     * @param string $user User, defaults to $_SERVER['REMOTE_USER']
425     * @return array|false
426     * @author Adrian Lang <lang@cosmocode.de>
427     *
428     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::userSubscription
429     */
430    public function user_subscription($id = '', $user = '') {
431        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::userSubscription');
432        $manager = new SubscriberManager();
433        return $manager->userSubscription($id, $user);
434    }
435
436    /**
437     * Send digest and list subscriptions
438     *
439     * This sends mails to all subscribers that have a subscription for namespaces above
440     * the given page if the needed $conf['subscribe_time'] has passed already.
441     *
442     * This function is called form lib/exe/indexer.php
443     *
444     * @param string $page
445     * @return int number of sent mails
446     *
447     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\BulkSubscriptionSender::sendBulk
448     */
449    public function send_bulk($page) {
450        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\BulkSubscriptionSender::sendBulk');
451        $subscriptionSender = new BulkSubscriptionSender();
452        return $subscriptionSender->sendBulk($page);
453    }
454
455    /**
456     * Send the diff for some page change
457     *
458     * @param string   $subscriber_mail The target mail address
459     * @param string   $template        Mail template ('subscr_digest', 'subscr_single', 'mailtext', ...)
460     * @param string   $id              Page for which the notification is
461     * @param int|null $rev             Old revision if any
462     * @param string   $summary         Change summary if any
463     * @return bool                     true if successfully sent
464     *
465     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\PageSubscriptionSender::sendPageDiff
466     */
467    public function send_diff($subscriber_mail, $template, $id, $rev = null, $summary = '') {
468        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\PageSubscriptionSender::sendPageDiff');
469        $subscriptionSender = new PageSubscriptionSender();
470        return $subscriptionSender->sendPageDiff($subscriber_mail, $template, $id, $rev, $summary);
471    }
472
473    /**
474     * Send the diff for some media change
475     *
476     * @fixme this should embed thumbnails of images in HTML version
477     *
478     * @param string   $subscriber_mail The target mail address
479     * @param string   $template        Mail template ('uploadmail', ...)
480     * @param string   $id              Media file for which the notification is
481     * @param int|bool $rev             Old revision if any
482     *
483     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\MediaSubscriptionSender::sendMediaDiff
484     */
485    public function send_media_diff($subscriber_mail, $template, $id, $rev = false) {
486        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\MediaSubscriptionSender::sendMediaDiff');
487        $subscriptionSender = new MediaSubscriptionSender();
488        return $subscriptionSender->sendMediaDiff($subscriber_mail, $template, $id, $rev);
489    }
490
491    /**
492     * Send a notify mail on new registration
493     *
494     * @author Andreas Gohr <andi@splitbrain.org>
495     *
496     * @param string $login    login name of the new user
497     * @param string $fullname full name of the new user
498     * @param string $email    email address of the new user
499     * @return bool true if a mail was sent
500     *
501     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\RegistrationSubscriptionSender::sendRegister
502     */
503    public function send_register($login, $fullname, $email) {
504        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\RegistrationSubscriptionSender::sendRegister');
505        $subscriptionSender = new RegistrationSubscriptionSender();
506        return $subscriptionSender->sendRegister($login, $fullname, $email);
507    }
508
509
510    /**
511     * Default callback for COMMON_NOTIFY_ADDRESSLIST
512     *
513     * Aggregates all email addresses of user who have subscribed the given page with 'every' style
514     *
515     * @author Steven Danz <steven-danz@kc.rr.com>
516     * @author Adrian Lang <lang@cosmocode.de>
517     *
518     * @todo move the whole functionality into this class, trigger SUBSCRIPTION_NOTIFY_ADDRESSLIST instead,
519     *       use an array for the addresses within it
520     *
521     * @param array &$data Containing the entries:
522     *    - $id (the page id),
523     *    - $self (whether the author should be notified,
524     *    - $addresslist (current email address list)
525     *    - $replacements (array of additional string substitutions, @KEY@ to be replaced by value)
526     *
527     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::notifyAddresses
528     */
529    public function notifyaddresses(&$data) {
530        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::notifyAddresses');
531        $manager = new SubscriberManager();
532        $manager->notifyAddresses($data);
533    }
534}
535