diff options
author | Andreas Gohr <andi@splitbrain.org> | 2023-09-02 14:42:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-02 14:42:51 +0200 |
commit | 5ff5424d8c81c7123d8656a787af2ff85b3dec21 (patch) | |
tree | 322929ee01d892bb3c927e7fe1238369c647f820 /inc/Action | |
parent | 0613df3287b82a98b1e97cf86ed9d4c8fbd16f1c (diff) | |
parent | 91560755291852b8302767d454183a7662666f7e (diff) | |
download | dokuwiki-5ff5424d8c81c7123d8656a787af2ff85b3dec21.tar.gz dokuwiki-5ff5424d8c81c7123d8656a787af2ff85b3dec21.zip |
Merge pull request #4045 from dokuwiki/autofix
Use Rector to autofix code smell
Diffstat (limited to 'inc/Action')
44 files changed, 251 insertions, 219 deletions
diff --git a/inc/Action/AbstractAclAction.php b/inc/Action/AbstractAclAction.php index 871edb0ae..27b514d52 100644 --- a/inc/Action/AbstractAclAction.php +++ b/inc/Action/AbstractAclAction.php @@ -3,6 +3,7 @@ namespace dokuwiki\Action; use dokuwiki\Action\Exception\ActionAclRequiredException; +use dokuwiki\Extension\AuthPlugin; /** * Class AbstractAclAction @@ -11,15 +12,15 @@ use dokuwiki\Action\Exception\ActionAclRequiredException; * * @package dokuwiki\Action */ -abstract class AbstractAclAction extends AbstractAction { - +abstract class AbstractAclAction extends AbstractAction +{ /** @inheritdoc */ - public function checkPreconditions() { + public function checkPreconditions() + { parent::checkPreconditions(); global $conf; global $auth; - if(!$conf['useacl']) throw new ActionAclRequiredException(); - if(!$auth) throw new ActionAclRequiredException(); + if (!$conf['useacl']) throw new ActionAclRequiredException(); + if (!$auth instanceof AuthPlugin) throw new ActionAclRequiredException(); } - } diff --git a/inc/Action/AbstractAction.php b/inc/Action/AbstractAction.php index 37eab3a8e..54dd459c2 100644 --- a/inc/Action/AbstractAction.php +++ b/inc/Action/AbstractAction.php @@ -12,8 +12,8 @@ use dokuwiki\Action\Exception\FatalException; * * @package dokuwiki\Action */ -abstract class AbstractAction { - +abstract class AbstractAction +{ /** @var string holds the name of the action (lowercase class name, no namespace) */ protected $actionname; @@ -22,8 +22,9 @@ abstract class AbstractAction { * * @param string $actionname the name of this action (see getActionName() for caveats) */ - public function __construct($actionname = '') { - if($actionname !== '') { + public function __construct($actionname = '') + { + if ($actionname !== '') { $this->actionname = $actionname; } else { // http://stackoverflow.com/a/27457689/172068 @@ -48,7 +49,8 @@ abstract class AbstractAction { * @throws ActionException * @return void */ - public function checkPreconditions() { + public function checkPreconditions() + { } /** @@ -61,7 +63,8 @@ abstract class AbstractAction { * @throws ActionException * @return void */ - public function preProcess() { + public function preProcess() + { } /** @@ -70,7 +73,8 @@ abstract class AbstractAction { * @fixme we may want to return a Ui class here * @throws FatalException */ - public function tplContent() { + public function tplContent() + { throw new FatalException('No content for Action ' . $this->actionname); } @@ -82,7 +86,8 @@ abstract class AbstractAction { * * @return string */ - public function getActionName() { + public function getActionName() + { return $this->actionname; } } diff --git a/inc/Action/AbstractAliasAction.php b/inc/Action/AbstractAliasAction.php index 771664a37..605e1c136 100644 --- a/inc/Action/AbstractAliasAction.php +++ b/inc/Action/AbstractAliasAction.php @@ -14,18 +14,19 @@ use dokuwiki\Action\Exception\FatalException; * * @package dokuwiki\Action */ -abstract class AbstractAliasAction extends AbstractAction { - +abstract class AbstractAliasAction extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_NONE; } /** * @throws FatalException */ - public function preProcess() { + public function preProcess() + { throw new FatalException('Alias Actions need to implement preProcess to load the aliased action'); } - } diff --git a/inc/Action/AbstractUserAction.php b/inc/Action/AbstractUserAction.php index 233f52edb..623860d67 100644 --- a/inc/Action/AbstractUserAction.php +++ b/inc/Action/AbstractUserAction.php @@ -11,15 +11,15 @@ use dokuwiki\Action\Exception\ActionUserRequiredException; * * @package dokuwiki\Action */ -abstract class AbstractUserAction extends AbstractAclAction { - +abstract class AbstractUserAction extends AbstractAclAction +{ /** @inheritdoc */ - public function checkPreconditions() { + public function checkPreconditions() + { parent::checkPreconditions(); global $INPUT; - if($INPUT->server->str('REMOTE_USER') === '') { + if ($INPUT->server->str('REMOTE_USER') === '') { throw new ActionUserRequiredException(); } } - } diff --git a/inc/Action/Admin.php b/inc/Action/Admin.php index 7a884b5b5..d292dee22 100644 --- a/inc/Action/Admin.php +++ b/inc/Action/Admin.php @@ -12,22 +12,24 @@ use dokuwiki\Extension\AdminPlugin; * * @package dokuwiki\Action */ -class Admin extends AbstractUserAction { - +class Admin extends AbstractUserAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_READ; // let in check later } /** @inheritDoc */ - public function preProcess() { + public function preProcess() + { global $INPUT; // retrieve admin plugin name from $_REQUEST['page'] - if($INPUT->str('page', '', true) != '') { + if ($INPUT->str('page', '', true) != '') { /** @var AdminPlugin $plugin */ - if($plugin = plugin_getRequestAdminPlugin()) { // FIXME this method does also permission checking - if(!$plugin->isAccessibleByCurrentUser()) { + if ($plugin = plugin_getRequestAdminPlugin()) { // FIXME this method does also permission checking + if (!$plugin->isAccessibleByCurrentUser()) { throw new ActionException('denied'); } $plugin->handle(); @@ -36,7 +38,8 @@ class Admin extends AbstractUserAction { } /** @inheritDoc */ - public function tplContent() { + public function tplContent() + { tpl_admin(); } } diff --git a/inc/Action/Backlink.php b/inc/Action/Backlink.php index 5c51014b5..6e1735f60 100644 --- a/inc/Action/Backlink.php +++ b/inc/Action/Backlink.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\Backlinks; use dokuwiki\Ui; /** @@ -22,7 +23,6 @@ class Backlink extends AbstractAction /** @inheritdoc */ public function tplContent() { - (new Ui\Backlinks)->show(); + (new Backlinks())->show(); } - } diff --git a/inc/Action/Cancel.php b/inc/Action/Cancel.php index d7505e4cc..31b481e99 100644 --- a/inc/Action/Cancel.php +++ b/inc/Action/Cancel.php @@ -11,18 +11,18 @@ use dokuwiki\Action\Exception\ActionAbort; * * @package dokuwiki\Action */ -class Cancel extends AbstractAliasAction { - +class Cancel extends AbstractAliasAction +{ /** * @inheritdoc * @throws ActionAbort */ - public function preProcess() { + public function preProcess() + { global $ID; unlock($ID); // continue with draftdel -> redirect -> show throw new ActionAbort('draftdel'); } - } diff --git a/inc/Action/Check.php b/inc/Action/Check.php index 36ae8e8bd..88d3a3e27 100644 --- a/inc/Action/Check.php +++ b/inc/Action/Check.php @@ -11,16 +11,17 @@ use dokuwiki\Action\Exception\ActionAbort; * * @package dokuwiki\Action */ -class Check extends AbstractAction { - +class Check extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_READ; } - public function preProcess() { + public function preProcess() + { check(); throw new ActionAbort(); } - } diff --git a/inc/Action/Conflict.php b/inc/Action/Conflict.php index f3b9521b9..020d60532 100644 --- a/inc/Action/Conflict.php +++ b/inc/Action/Conflict.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\PageConflict; use dokuwiki\Ui; /** @@ -33,7 +34,6 @@ class Conflict extends AbstractAction global $SUM; $text = con($PRE, $TEXT, $SUF); - (new Ui\PageConflict($text, $SUM))->show(); + (new PageConflict($text, $SUM))->show(); } - } diff --git a/inc/Action/Denied.php b/inc/Action/Denied.php index ab2f0d8f4..14cbd8953 100644 --- a/inc/Action/Denied.php +++ b/inc/Action/Denied.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\Login; use dokuwiki\Extension\Event; use dokuwiki\Ui; @@ -30,7 +31,7 @@ class Denied extends AbstractAction if ($event->advise_before()) { global $INPUT; if (empty($INPUT->server->str('REMOTE_USER')) && actionOK('login')) { - (new Ui\Login)->show(); + (new Login())->show(); } } $event->advise_after(); @@ -46,7 +47,6 @@ class Denied extends AbstractAction public function showBanner() { // print intro - print p_locale_xhtml('denied'); + echo p_locale_xhtml('denied'); } - } diff --git a/inc/Action/Diff.php b/inc/Action/Diff.php index 31024b6cd..c12de9cab 100644 --- a/inc/Action/Diff.php +++ b/inc/Action/Diff.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\PageDiff; use dokuwiki\Ui; /** @@ -35,7 +36,6 @@ class Diff extends AbstractAction public function tplContent() { global $INFO; - (new Ui\PageDiff($INFO['id']))->preference('showIntro', true)->show(); + (new PageDiff($INFO['id']))->preference('showIntro', true)->show(); } - } diff --git a/inc/Action/Draft.php b/inc/Action/Draft.php index 0c33dab54..1abb56d69 100644 --- a/inc/Action/Draft.php +++ b/inc/Action/Draft.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\PageDraft; use dokuwiki\Action\Exception\ActionException; use dokuwiki\Ui; @@ -37,7 +38,6 @@ class Draft extends AbstractAction /** @inheritdoc */ public function tplContent() { - (new Ui\PageDraft)->show(); + (new PageDraft())->show(); } - } diff --git a/inc/Action/Draftdel.php b/inc/Action/Draftdel.php index 1fb796601..770a8c7d7 100644 --- a/inc/Action/Draftdel.php +++ b/inc/Action/Draftdel.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Draft; use dokuwiki\Action\Exception\ActionAbort; /** @@ -11,10 +12,11 @@ use dokuwiki\Action\Exception\ActionAbort; * * @package dokuwiki\Action */ -class Draftdel extends AbstractAction { - +class Draftdel extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_EDIT; } @@ -25,14 +27,14 @@ class Draftdel extends AbstractAction { * * @throws ActionAbort */ - public function preProcess() { + public function preProcess() + { global $INFO, $ID; - $draft = new \dokuwiki\Draft($ID, $INFO['client']); + $draft = new Draft($ID, $INFO['client']); if ($draft->isDraftAvailable() && checkSecurityToken()) { $draft->deleteDraft(); } throw new ActionAbort('redirect'); } - } diff --git a/inc/Action/Edit.php b/inc/Action/Edit.php index 417fdb075..e8ac347b2 100644 --- a/inc/Action/Edit.php +++ b/inc/Action/Edit.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\Editor; use dokuwiki\Action\Exception\ActionAbort; use dokuwiki\Ui; @@ -57,7 +58,7 @@ class Edit extends AbstractAction if (!isset($TEXT)) { if ($INFO['exists']) { if ($RANGE) { - list($PRE, $TEXT, $SUF) = rawWikiSlices($RANGE, $ID, $REV); + [$PRE, $TEXT, $SUF] = rawWikiSlices($RANGE, $ID, $REV); } else { $TEXT = rawWiki($ID, $REV); } @@ -90,7 +91,6 @@ class Edit extends AbstractAction /** @inheritdoc */ public function tplContent() { - (new Ui\Editor)->show(); + (new Editor())->show(); } - } diff --git a/inc/Action/Exception/ActionAbort.php b/inc/Action/Exception/ActionAbort.php index 9c188bb4b..4f9006be5 100644 --- a/inc/Action/Exception/ActionAbort.php +++ b/inc/Action/Exception/ActionAbort.php @@ -15,6 +15,6 @@ namespace dokuwiki\Action\Exception; * * @package dokuwiki\Action\Exception */ -class ActionAbort extends ActionException { - +class ActionAbort extends ActionException +{ } diff --git a/inc/Action/Exception/ActionAclRequiredException.php b/inc/Action/Exception/ActionAclRequiredException.php index 64a2c61e3..083fe2a17 100644 --- a/inc/Action/Exception/ActionAclRequiredException.php +++ b/inc/Action/Exception/ActionAclRequiredException.php @@ -12,6 +12,6 @@ namespace dokuwiki\Action\Exception; * * @package dokuwiki\Action\Exception */ -class ActionAclRequiredException extends ActionException { - +class ActionAclRequiredException extends ActionException +{ } diff --git a/inc/Action/Exception/ActionDisabledException.php b/inc/Action/Exception/ActionDisabledException.php index 40a0c7dd7..cf3c07781 100644 --- a/inc/Action/Exception/ActionDisabledException.php +++ b/inc/Action/Exception/ActionDisabledException.php @@ -12,6 +12,6 @@ namespace dokuwiki\Action\Exception; * * @package dokuwiki\Action\Exception */ -class ActionDisabledException extends ActionException { - +class ActionDisabledException extends ActionException +{ } diff --git a/inc/Action/Exception/ActionException.php b/inc/Action/Exception/ActionException.php index 381584c15..57318fb04 100644 --- a/inc/Action/Exception/ActionException.php +++ b/inc/Action/Exception/ActionException.php @@ -13,8 +13,8 @@ namespace dokuwiki\Action\Exception; * * @package dokuwiki\Action\Exception */ -class ActionException extends \Exception { - +class ActionException extends \Exception +{ /** @var string the new action */ protected $newaction; @@ -30,11 +30,12 @@ class ActionException extends \Exception { * @param string|null $newaction the action that should be used next * @param string $message optional message, will not be shown except for some dub classes */ - public function __construct($newaction = null, $message = '') { + public function __construct($newaction = null, $message = '') + { global $INPUT; parent::__construct($message); - if(is_null($newaction)) { - if(strtolower($INPUT->server->str('REQUEST_METHOD')) == 'post') { + if (is_null($newaction)) { + if (strtolower($INPUT->server->str('REQUEST_METHOD')) == 'post') { $newaction = 'redirect'; } else { $newaction = 'show'; @@ -49,7 +50,8 @@ class ActionException extends \Exception { * * @return string */ - public function getNewAction() { + public function getNewAction() + { return $this->newaction; } @@ -59,8 +61,9 @@ class ActionException extends \Exception { * @param null|bool $set when null is given, the current setting is not changed * @return bool */ - public function displayToUser($set = null) { - if(!is_null($set)) $this->displayToUser = $set; + public function displayToUser($set = null) + { + if (!is_null($set)) $this->displayToUser = $set; return $set; } } diff --git a/inc/Action/Exception/ActionUserRequiredException.php b/inc/Action/Exception/ActionUserRequiredException.php index aab06cca1..33ff328a1 100644 --- a/inc/Action/Exception/ActionUserRequiredException.php +++ b/inc/Action/Exception/ActionUserRequiredException.php @@ -12,6 +12,6 @@ namespace dokuwiki\Action\Exception; * * @package dokuwiki\Action\Exception */ -class ActionUserRequiredException extends ActionException { - +class ActionUserRequiredException extends ActionException +{ } diff --git a/inc/Action/Exception/FatalException.php b/inc/Action/Exception/FatalException.php index 42e30ccae..74f45cccb 100644 --- a/inc/Action/Exception/FatalException.php +++ b/inc/Action/Exception/FatalException.php @@ -12,7 +12,8 @@ namespace dokuwiki\Action\Exception; * * @package dokuwiki\Action\Exception */ -class FatalException extends \Exception { +class FatalException extends \Exception +{ /** * FatalException constructor. * @@ -20,7 +21,8 @@ class FatalException extends \Exception { * @param int $status the HTTP status to send * @param null|\Exception $previous previous exception */ - public function __construct($message = 'A fatal error occured', $status = 500, $previous = null) { + public function __construct($message = 'A fatal error occured', $status = 500, $previous = null) + { parent::__construct($message, $status, $previous); } } diff --git a/inc/Action/Exception/NoActionException.php b/inc/Action/Exception/NoActionException.php index 1c4e4d094..23838972f 100644 --- a/inc/Action/Exception/NoActionException.php +++ b/inc/Action/Exception/NoActionException.php @@ -10,6 +10,6 @@ namespace dokuwiki\Action\Exception; * * @package dokuwiki\Action\Exception */ -class NoActionException extends \Exception { - +class NoActionException extends \Exception +{ } diff --git a/inc/Action/Export.php b/inc/Action/Export.php index 6b46b276e..61458e298 100644 --- a/inc/Action/Export.php +++ b/inc/Action/Export.php @@ -12,10 +12,11 @@ use dokuwiki\Extension\Event; * * @package dokuwiki\Action */ -class Export extends AbstractAction { - +class Export extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_READ; } @@ -34,7 +35,8 @@ class Export extends AbstractAction { * @author Michael Klier <chi@chimeric.de> * @inheritdoc */ - public function preProcess() { + public function preProcess() + { global $ID; global $REV; global $conf; @@ -42,13 +44,13 @@ class Export extends AbstractAction { $pre = ''; $post = ''; - $headers = array(); + $headers = []; // search engines: never cache exported docs! (Google only currently) $headers['X-Robots-Tag'] = 'noindex'; $mode = substr($this->actionname, 7); - switch($mode) { + switch ($mode) { case 'raw': $headers['Content-Type'] = 'text/plain; charset=utf-8'; $headers['Content-Disposition'] = 'attachment; filename=' . noNS($ID) . '.txt'; @@ -91,7 +93,7 @@ class Export extends AbstractAction { } // prepare event data - $data = array(); + $data = []; $data['id'] = $ID; $data['mode'] = $mode; $data['headers'] = $headers; @@ -99,15 +101,14 @@ class Export extends AbstractAction { Event::createAndTrigger('ACTION_EXPORT_POSTPROCESS', $data); - if(!empty($data['output'])) { - if(is_array($data['headers'])) foreach($data['headers'] as $key => $val) { + if (!empty($data['output'])) { + if (is_array($data['headers'])) foreach ($data['headers'] as $key => $val) { header("$key: $val"); } - print $pre . $data['output'] . $post; + echo $pre . $data['output'] . $post; exit; } throw new ActionAbort(); } - } diff --git a/inc/Action/Index.php b/inc/Action/Index.php index 17ef6b7fd..5a2120d76 100644 --- a/inc/Action/Index.php +++ b/inc/Action/Index.php @@ -25,5 +25,4 @@ class Index extends AbstractAction global $IDX; (new Ui\Index($IDX))->show(); } - } diff --git a/inc/Action/Locked.php b/inc/Action/Locked.php index bb8437370..6849777bd 100644 --- a/inc/Action/Locked.php +++ b/inc/Action/Locked.php @@ -2,7 +2,7 @@ namespace dokuwiki\Action; -use dokuwiki\Ui; +use dokuwiki\Ui\Editor; /** * Class Locked @@ -23,15 +23,15 @@ class Locked extends AbstractAction public function tplContent() { $this->showBanner(); - (new Ui\Editor)->show(); + (new Editor())->show(); } /** * Display error on locked pages * + * @return void * @author Andreas Gohr <andi@splitbrain.org> * - * @return void */ public function showBanner() { @@ -42,15 +42,16 @@ class Locked extends AbstractAction $locktime = filemtime(wikiLockFN($ID)); $expire = dformat($locktime + $conf['locktime']); - $min = round(($conf['locktime'] - (time() - $locktime) )/60); + $min = round(($conf['locktime'] - (time() - $locktime)) / 60); // print intro - print p_locale_xhtml('locked'); - - print '<ul>'; - print '<li><div class="li"><strong>'.$lang['lockedby'].'</strong> '.editorinfo($INFO['locked']).'</div></li>'; - print '<li><div class="li"><strong>'.$lang['lockexpire'].'</strong> '.$expire.' ('.$min.' min)</div></li>'; - print '</ul>'.DOKU_LF; + echo p_locale_xhtml('locked'); + + echo '<ul>'; + echo '<li><div class="li"><strong>' . $lang['lockedby'] . '</strong> ' . + editorinfo($INFO['locked']) . '</div></li>'; + echo '<li><div class="li"><strong>' . $lang['lockexpire'] . '</strong> ' . + $expire . ' (' . $min . ' min)</div></li>'; + echo '</ul>' . DOKU_LF; } - } diff --git a/inc/Action/Login.php b/inc/Action/Login.php index 6b553f384..6d3d12407 100644 --- a/inc/Action/Login.php +++ b/inc/Action/Login.php @@ -34,7 +34,6 @@ class Login extends AbstractAclAction /** @inheritdoc */ public function tplContent() { - (new Ui\Login)->show(); + (new Ui\Login())->show(); } - } diff --git a/inc/Action/Logout.php b/inc/Action/Logout.php index d9aead529..a4cbfcca5 100644 --- a/inc/Action/Logout.php +++ b/inc/Action/Logout.php @@ -13,24 +13,27 @@ use dokuwiki\Extension\AuthPlugin; * * @package dokuwiki\Action */ -class Logout extends AbstractUserAction { - +class Logout extends AbstractUserAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_NONE; } /** @inheritdoc */ - public function checkPreconditions() { + public function checkPreconditions() + { parent::checkPreconditions(); /** @var AuthPlugin $auth */ global $auth; - if(!$auth->canDo('logout')) throw new ActionDisabledException(); + if (!$auth->canDo('logout')) throw new ActionDisabledException(); } /** @inheritdoc */ - public function preProcess() { + public function preProcess() + { global $ID; global $INPUT; @@ -38,16 +41,15 @@ class Logout extends AbstractUserAction { // when logging out during an edit session, unlock the page $lockedby = checklock($ID); - if($lockedby == $INPUT->server->str('REMOTE_USER')) { + if ($lockedby == $INPUT->server->str('REMOTE_USER')) { unlock($ID); } // do the logout stuff and redirect to login auth_logoff(); - send_redirect(wl($ID, array('do' => 'login'), true, '&')); + send_redirect(wl($ID, ['do' => 'login'], true, '&')); // should never be reached throw new ActionException('login'); } - } diff --git a/inc/Action/Media.php b/inc/Action/Media.php index 77a2a6f0d..0571af855 100644 --- a/inc/Action/Media.php +++ b/inc/Action/Media.php @@ -9,16 +9,17 @@ namespace dokuwiki\Action; * * @package dokuwiki\Action */ -class Media extends AbstractAction { - +class Media extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_READ; } /** @inheritdoc */ - public function tplContent() { + public function tplContent() + { tpl_media(); } - } diff --git a/inc/Action/Plugin.php b/inc/Action/Plugin.php index cbc407839..a38697186 100644 --- a/inc/Action/Plugin.php +++ b/inc/Action/Plugin.php @@ -11,10 +11,11 @@ use dokuwiki\Extension\Event; * * @package dokuwiki\Action */ -class Plugin extends AbstractAction { - +class Plugin extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_NONE; } @@ -24,9 +25,10 @@ class Plugin extends AbstractAction { * @inheritdoc * @triggers TPL_ACT_UNKNOWN */ - public function tplContent() { + public function tplContent() + { $evt = new Event('TPL_ACT_UNKNOWN', $this->actionname); - if($evt->advise_before()) { + if ($evt->advise_before()) { msg('Failed to handle action: ' . hsc($this->actionname), -1); } $evt->advise_after(); diff --git a/inc/Action/Preview.php b/inc/Action/Preview.php index dfe5afaa5..7ab6941df 100644 --- a/inc/Action/Preview.php +++ b/inc/Action/Preview.php @@ -2,6 +2,9 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\Editor; +use dokuwiki\Ui\PageView; +use dokuwiki\Draft; use dokuwiki\Ui; /** @@ -25,8 +28,8 @@ class Preview extends Edit public function tplContent() { global $TEXT; - (new Ui\Editor)->show(); - (new Ui\PageView($TEXT))->show(); + (new Editor())->show(); + (new PageView($TEXT))->show(); } /** @@ -35,7 +38,7 @@ class Preview extends Edit protected function savedraft() { global $ID, $INFO; - $draft = new \dokuwiki\Draft($ID, $INFO['client']); + $draft = new Draft($ID, $INFO['client']); if (!$draft->saveDraft()) { $errors = $draft->getErrors(); foreach ($errors as $error) { @@ -43,5 +46,4 @@ class Preview extends Edit } } } - } diff --git a/inc/Action/Profile.php b/inc/Action/Profile.php index 0ffcb260b..41615af07 100644 --- a/inc/Action/Profile.php +++ b/inc/Action/Profile.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\UserProfile; use dokuwiki\Action\Exception\ActionAbort; use dokuwiki\Action\Exception\ActionDisabledException; use dokuwiki\Extension\AuthPlugin; @@ -29,7 +30,7 @@ class Profile extends AbstractUserAction /** @var AuthPlugin $auth */ global $auth; - if(!$auth->canDo('Profile')) throw new ActionDisabledException(); + if (!$auth->canDo('Profile')) throw new ActionDisabledException(); } /** @inheritdoc */ @@ -45,7 +46,6 @@ class Profile extends AbstractUserAction /** @inheritdoc */ public function tplContent() { - (new Ui\UserProfile)->show(); + (new UserProfile())->show(); } - } diff --git a/inc/Action/ProfileDelete.php b/inc/Action/ProfileDelete.php index d8e434011..5c190cd69 100644 --- a/inc/Action/ProfileDelete.php +++ b/inc/Action/ProfileDelete.php @@ -13,31 +13,33 @@ use dokuwiki\Extension\AuthPlugin; * * @package dokuwiki\Action */ -class ProfileDelete extends AbstractUserAction { - +class ProfileDelete extends AbstractUserAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_NONE; } /** @inheritdoc */ - public function checkPreconditions() { + public function checkPreconditions() + { parent::checkPreconditions(); /** @var AuthPlugin $auth */ global $auth; - if(!$auth->canDo('delUser')) throw new ActionDisabledException(); + if (!$auth->canDo('delUser')) throw new ActionDisabledException(); } /** @inheritdoc */ - public function preProcess() { + public function preProcess() + { global $lang; - if(auth_deleteprofile()) { + if (auth_deleteprofile()) { msg($lang['profdeleted'], 1); throw new ActionAbort('show'); } else { throw new ActionAbort('profile'); } } - } diff --git a/inc/Action/Recent.php b/inc/Action/Recent.php index 203c91d81..f5b45a1ac 100644 --- a/inc/Action/Recent.php +++ b/inc/Action/Recent.php @@ -41,5 +41,4 @@ class Recent extends AbstractAction global $INPUT; (new Ui\Recent($INPUT->extract('first')->int('first'), $this->showType))->show(); } - } diff --git a/inc/Action/Recover.php b/inc/Action/Recover.php index c0e744663..5e5c95dd2 100644 --- a/inc/Action/Recover.php +++ b/inc/Action/Recover.php @@ -11,14 +11,14 @@ use dokuwiki\Action\Exception\ActionAbort; * * @package dokuwiki\Action */ -class Recover extends AbstractAliasAction { - +class Recover extends AbstractAliasAction +{ /** * @inheritdoc * @throws ActionAbort */ - public function preProcess() { + public function preProcess() + { throw new ActionAbort('edit'); } - } diff --git a/inc/Action/Redirect.php b/inc/Action/Redirect.php index dca911a22..5a8309f44 100644 --- a/inc/Action/Redirect.php +++ b/inc/Action/Redirect.php @@ -12,37 +12,35 @@ use dokuwiki\Extension\Event; * * @package dokuwiki\Action */ -class Redirect extends AbstractAliasAction { - +class Redirect extends AbstractAliasAction +{ /** * Redirect to the show action, trying to jump to the previously edited section * * @triggers ACTION_SHOW_REDIRECT * @throws ActionAbort */ - public function preProcess() { + public function preProcess() + { global $PRE; global $TEXT; global $INPUT; global $ID; global $ACT; - $opts = array( - 'id' => $ID, - 'preact' => $ACT - ); + $opts = ['id' => $ID, 'preact' => $ACT]; //get section name when coming from section edit - if($INPUT->has('hid')) { + if ($INPUT->has('hid')) { // Use explicitly transmitted header id $opts['fragment'] = $INPUT->str('hid'); - } else if($PRE && preg_match('/^\s*==+([^=\n]+)/', $TEXT, $match)) { + } elseif ($PRE && preg_match('/^\s*==+([^=\n]+)/', $TEXT, $match)) { // Fallback to old mechanism $check = false; //Byref $opts['fragment'] = sectionID($match[0], $check); } // execute the redirect - Event::createAndTrigger('ACTION_SHOW_REDIRECT', $opts, array($this, 'redirect')); + Event::createAndTrigger('ACTION_SHOW_REDIRECT', $opts, [$this, 'redirect']); // should never be reached throw new ActionAbort('show'); @@ -55,9 +53,10 @@ class Redirect extends AbstractAliasAction { * * @param array $opts id and fragment for the redirect and the preact */ - public function redirect($opts) { + public function redirect($opts) + { $go = wl($opts['id'], '', true, '&'); - if(isset($opts['fragment'])) $go .= '#' . $opts['fragment']; + if (isset($opts['fragment'])) $go .= '#' . $opts['fragment']; //show it send_redirect($go); diff --git a/inc/Action/Register.php b/inc/Action/Register.php index 4c3da19bb..232d21a01 100644 --- a/inc/Action/Register.php +++ b/inc/Action/Register.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\UserRegister; use dokuwiki\Action\Exception\ActionAbort; use dokuwiki\Action\Exception\ActionDisabledException; use dokuwiki\Extension\AuthPlugin; @@ -45,7 +46,6 @@ class Register extends AbstractAclAction /** @inheritdoc */ public function tplContent() { - (new Ui\UserRegister)->show(); + (new UserRegister())->show(); } - } diff --git a/inc/Action/Resendpwd.php b/inc/Action/Resendpwd.php index 0e442346a..2813bfcac 100644 --- a/inc/Action/Resendpwd.php +++ b/inc/Action/Resendpwd.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\UserResendPwd; use dokuwiki\Action\Exception\ActionAbort; use dokuwiki\Action\Exception\ActionDisabledException; use dokuwiki\Extension\AuthPlugin; @@ -46,7 +47,7 @@ class Resendpwd extends AbstractAclAction /** @inheritdoc */ public function tplContent() { - (new Ui\UserResendPwd)->show(); + (new UserResendPwd())->show(); } /** @@ -81,7 +82,7 @@ class Resendpwd extends AbstractAclAction if ($token) { // we're in token phase - get user info from token - $tfile = $conf['cachedir'] .'/'. $token[0] .'/'. $token . '.pwauth'; + $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth'; if (!file_exists($tfile)) { msg($lang['resendpwdbadauth'], -1); $INPUT->remove('pwauth'); @@ -113,15 +114,13 @@ class Resendpwd extends AbstractAclAction } // change it - if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) { + if (!$auth->triggerUserMod('modify', [$user, ['pass' => $pass]])) { msg($lang['proffail'], -1); return false; } - } else { // autogenerate the password and send by mail - $pass = auth_pwgen($user); - if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) { + if (!$auth->triggerUserMod('modify', [$user, ['pass' => $pass]])) { msg($lang['proffail'], -1); return false; } @@ -135,7 +134,6 @@ class Resendpwd extends AbstractAclAction @unlink($tfile); return true; - } else { // we're in request phase @@ -156,20 +154,20 @@ class Resendpwd extends AbstractAclAction // generate auth token $token = md5(auth_randombytes(16)); // random secret - $tfile = $conf['cachedir'] .'/'. $token[0] .'/'. $token .'.pwauth'; - $url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&'); + $tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth'; + $url = wl('', ['do' => 'resendpwd', 'pwauth' => $token], true, '&'); io_saveFile($tfile, $user); $text = rawLocale('pwconfirm'); - $trep = array( + $trep = [ 'FULLNAME' => $userinfo['name'], 'LOGIN' => $user, 'CONFIRM' => $url - ); + ]; $mail = new \Mailer(); - $mail->to($userinfo['name'] .' <'. $userinfo['mail'] .'>'); + $mail->to($userinfo['name'] . ' <' . $userinfo['mail'] . '>'); $mail->subject($lang['regpwmail']); $mail->setBody($text, $trep); if ($mail->send()) { @@ -181,5 +179,4 @@ class Resendpwd extends AbstractAclAction } // never reached } - } diff --git a/inc/Action/Revert.php b/inc/Action/Revert.php index b7ee75313..4a42fe019 100644 --- a/inc/Action/Revert.php +++ b/inc/Action/Revert.php @@ -14,7 +14,6 @@ use dokuwiki\Action\Exception\ActionException; */ class Revert extends AbstractUserAction { - /** @inheritdoc */ public function minimumPermission() { @@ -59,5 +58,4 @@ class Revert extends AbstractUserAction // continue with draftdel -> redirect -> show throw new ActionAbort('draftdel'); } - } diff --git a/inc/Action/Revisions.php b/inc/Action/Revisions.php index 511a0dc7c..9d8e6047c 100644 --- a/inc/Action/Revisions.php +++ b/inc/Action/Revisions.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\PageRevisions; use dokuwiki\Ui; /** @@ -23,6 +24,6 @@ class Revisions extends AbstractAction public function tplContent() { global $INFO, $INPUT; - (new Ui\PageRevisions($INFO['id']))->show($INPUT->int('first', -1)); + (new PageRevisions($INFO['id']))->show($INPUT->int('first', -1)); } } diff --git a/inc/Action/Save.php b/inc/Action/Save.php index a577e379f..3df208b05 100644 --- a/inc/Action/Save.php +++ b/inc/Action/Save.php @@ -12,12 +12,13 @@ use dokuwiki\Action\Exception\ActionException; * * @package dokuwiki\Action */ -class Save extends AbstractAction { - +class Save extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { global $INFO; - if($INFO['exists']) { + if ($INFO['exists']) { return AUTH_EDIT; } else { return AUTH_CREATE; @@ -25,8 +26,9 @@ class Save extends AbstractAction { } /** @inheritdoc */ - public function preProcess() { - if(!checkSecurityToken()) throw new ActionException('preview'); + public function preProcess() + { + if (!checkSecurityToken()) throw new ActionException('preview'); global $ID; global $DATE; @@ -39,12 +41,13 @@ class Save extends AbstractAction { global $INPUT; //spam check - if(checkwordblock()) { + if (checkwordblock()) { msg($lang['wordblock'], -1); throw new ActionException('edit'); } //conflict check - if($DATE != 0 + if ( + $DATE != 0 && isset($INFO['meta']['date']['modified']) && $INFO['meta']['date']['modified'] > $DATE ) { @@ -59,5 +62,4 @@ class Save extends AbstractAction { // continue with draftdel -> redirect -> show throw new ActionAbort('draftdel'); } - } diff --git a/inc/Action/Search.php b/inc/Action/Search.php index 88bd0baa3..10433d373 100644 --- a/inc/Action/Search.php +++ b/inc/Action/Search.php @@ -11,14 +11,15 @@ use dokuwiki\Action\Exception\ActionAbort; * * @package dokuwiki\Action */ -class Search extends AbstractAction { - - protected $pageLookupResults = array(); - protected $fullTextResults = array(); - protected $highlight = array(); +class Search extends AbstractAction +{ + protected $pageLookupResults = []; + protected $fullTextResults = []; + protected $highlight = []; /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_NONE; } @@ -27,7 +28,8 @@ class Search extends AbstractAction { * * @inheritdoc */ - public function checkPreconditions() { + public function checkPreconditions() + { parent::checkPreconditions(); } @@ -125,7 +127,6 @@ class Search extends AbstractAction { } return '*' . $part . '*'; - }, $queryParts); $QUERY = implode(' ', $queryParts); } diff --git a/inc/Action/Show.php b/inc/Action/Show.php index 14da7fd16..c274e06e6 100644 --- a/inc/Action/Show.php +++ b/inc/Action/Show.php @@ -1,4 +1,5 @@ <?php + /** * Created by IntelliJ IDEA. * User: andi @@ -8,6 +9,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\PageView; use dokuwiki\Ui; /** @@ -20,7 +22,8 @@ use dokuwiki\Ui; class Show extends AbstractAction { /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_READ; } @@ -34,7 +37,6 @@ class Show extends AbstractAction /** @inheritdoc */ public function tplContent() { - (new Ui\PageView())->show(); + (new PageView())->show(); } - } diff --git a/inc/Action/Sitemap.php b/inc/Action/Sitemap.php index eba9c2813..f1f22ab2e 100644 --- a/inc/Action/Sitemap.php +++ b/inc/Action/Sitemap.php @@ -13,10 +13,11 @@ use dokuwiki\Utf8\PhpString; * * @package dokuwiki\Action */ -class Sitemap extends AbstractAction { - +class Sitemap extends AbstractAction +{ /** @inheritdoc */ - public function minimumPermission() { + public function minimumPermission() + { return AUTH_NONE; } @@ -27,26 +28,27 @@ class Sitemap extends AbstractAction { * @throws FatalException * @inheritdoc */ - public function preProcess() { + public function preProcess() + { global $conf; - if($conf['sitemap'] < 1 || !is_numeric($conf['sitemap'])) { + if ($conf['sitemap'] < 1 || !is_numeric($conf['sitemap'])) { throw new FatalException('Sitemap generation is disabled', 404); } $sitemap = Mapper::getFilePath(); - if(Mapper::sitemapIsCompressed()) { + if (Mapper::sitemapIsCompressed()) { $mime = 'application/x-gzip'; } else { $mime = 'application/xml; charset=utf-8'; } // Check if sitemap file exists, otherwise create it - if(!is_readable($sitemap)) { + if (!is_readable($sitemap)) { Mapper::generate(); } - if(is_readable($sitemap)) { + if (is_readable($sitemap)) { // Send headers header('Content-Type: ' . $mime); header('Content-Disposition: attachment; filename=' . PhpString::basename($sitemap)); @@ -63,5 +65,4 @@ class Sitemap extends AbstractAction { throw new FatalException('Could not read the sitemap file - bad permissions?'); } - } diff --git a/inc/Action/Source.php b/inc/Action/Source.php index 92b38552b..0d2f822e4 100644 --- a/inc/Action/Source.php +++ b/inc/Action/Source.php @@ -2,6 +2,7 @@ namespace dokuwiki\Action; +use dokuwiki\Ui\Editor; use dokuwiki\Ui; /** @@ -35,7 +36,6 @@ class Source extends AbstractAction /** @inheritdoc */ public function tplContent() { - (new Ui\Editor)->show(); + (new Editor())->show(); } - } diff --git a/inc/Action/Subscribe.php b/inc/Action/Subscribe.php index 5aa3cf1fc..974feb6fd 100644 --- a/inc/Action/Subscribe.php +++ b/inc/Action/Subscribe.php @@ -30,7 +30,7 @@ class Subscribe extends AbstractUserAction parent::checkPreconditions(); global $conf; - if(isset($conf['subscribers']) && !$conf['subscribers']) throw new ActionDisabledException(); + if (isset($conf['subscribers']) && !$conf['subscribers']) throw new ActionDisabledException(); } /** @inheritdoc */ @@ -48,7 +48,7 @@ class Subscribe extends AbstractUserAction /** @inheritdoc */ public function tplContent() { - (new Ui\Subscribe)->show(); + (new Ui\Subscribe())->show(); } /** @@ -65,8 +65,8 @@ class Subscribe extends AbstractUserAction global $INPUT; // get and preprocess data. - $params = array(); - foreach (array('target', 'style', 'action') as $param) { + $params = []; + foreach (['target', 'style', 'action'] as $param) { if ($INPUT->has("sub_$param")) { $params[$param] = $INPUT->str("sub_$param"); } @@ -76,7 +76,7 @@ class Subscribe extends AbstractUserAction if (empty($params['action']) || !checkSecurityToken()) return; // Handle POST data, may throw exception. - Event::createAndTrigger('ACTION_HANDLE_SUBSCRIBE', $params, array($this, 'handlePostData')); + Event::createAndTrigger('ACTION_HANDLE_SUBSCRIBE', $params, [$this, 'handlePostData']); $target = $params['target']; $style = $params['style']; @@ -93,9 +93,11 @@ class Subscribe extends AbstractUserAction if ($ok) { msg( sprintf( - $lang["subscr_{$action}_success"], hsc($INFO['userinfo']['name']), + $lang["subscr_{$action}_success"], + hsc($INFO['userinfo']['name']), prettyprint_id($target) - ), 1 + ), + 1 ); throw new ActionAbort('redirect'); } @@ -131,18 +133,22 @@ class Subscribe extends AbstractUserAction throw new Exception('no subscription target given'); } $target = $params['target']; - $valid_styles = array('every', 'digest'); + $valid_styles = ['every', 'digest']; if (substr($target, -1, 1) === ':') { // Allow “list” subscribe style since the target is a namespace. $valid_styles[] = 'list'; } $style = valid_input_set( - 'style', $valid_styles, $params, + 'style', + $valid_styles, + $params, 'invalid subscription style given' ); $action = valid_input_set( - 'action', array('subscribe', 'unsubscribe'), - $params, 'invalid subscription action given' + 'action', + ['subscribe', 'unsubscribe'], + $params, + 'invalid subscription action given' ); // Check other conditions. @@ -170,7 +176,6 @@ class Subscribe extends AbstractUserAction $style = null; } - $params = compact('target', 'style', 'action'); + $params = ['target' => $target, 'style' => $style, 'action' => $action]; } - } |