Skip to content

Commit c74010b

Browse files
michituxgithub-actions[bot]
authored andcommitted
🤖 Automatic code style fixes
1 parent 941af2b commit c74010b

File tree

12 files changed

+667
-586
lines changed

12 files changed

+667
-586
lines changed

MenuItem.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
<?php
2+
23
namespace dokuwiki\plugin\move;
4+
35
use dokuwiki\Menu\Item\AbstractItem;
6+
47
/**
58
* Class MenuItem
69
*
710
* Implements the Rename button for DokuWiki's menu system
811
*
912
* @package dokuwiki\plugin\move
1013
*/
11-
class MenuItem extends AbstractItem {
12-
14+
class MenuItem extends AbstractItem
15+
{
1316
/** @var string icon file */
1417
protected $svg = __DIR__ . '/images/rename.svg';
1518

1619
protected $type = "plugin_move";
1720

18-
public function getLinkAttributes($classprefix = 'menuitem ') {
21+
public function getLinkAttributes($classprefix = 'menuitem ')
22+
{
1923
$attr = parent::getLinkAttributes($classprefix);
2024
if (empty($attr['class'])) {
2125
$attr['class'] = '';
@@ -28,7 +32,8 @@ public function getLinkAttributes($classprefix = 'menuitem ') {
2832
*
2933
* @return string
3034
*/
31-
public function getLabel() {
35+
public function getLabel()
36+
{
3237
$hlp = plugin_load('action', 'move_rename');
3338
return $hlp->getLang('renamepage');
3439
}

action/progress.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,70 @@
11
<?php
2+
3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
27
/**
38
* Move Plugin AJAX handler to step through a move plan
49
*
510
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
611
* @author Andreas Gohr <[email protected]>
712
*/
13+
814
// must be run within Dokuwiki
9-
if(!defined('DOKU_INC')) die();
15+
if (!defined('DOKU_INC')) die();
1016

1117
/**
1218
* Class action_plugin_move_progress
1319
*/
14-
class action_plugin_move_progress extends DokuWiki_Action_Plugin {
15-
20+
class action_plugin_move_progress extends ActionPlugin
21+
{
1622
/**
1723
* Register event handlers.
1824
*
19-
* @param Doku_Event_Handler $controller The plugin controller
25+
* @param EventHandler $controller The plugin controller
2026
*/
21-
public function register(Doku_Event_Handler $controller) {
27+
public function register(EventHandler $controller)
28+
{
2229
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax');
2330
}
2431

2532
/**
2633
* Step up
2734
*
28-
* @param Doku_Event $event
35+
* @param Event $event
2936
*/
30-
public function handle_ajax(Doku_Event $event) {
31-
if($event->data != 'plugin_move_progress') return;
37+
public function handle_ajax(Event $event)
38+
{
39+
if ($event->data != 'plugin_move_progress') return;
3240
$event->preventDefault();
3341
$event->stopPropagation();
3442

3543
global $INPUT;
3644
global $USERINFO;
3745

38-
if(!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
46+
if (!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
3947
http_status(403);
4048
exit;
4149
}
4250

43-
$return = array(
44-
'error' => '',
45-
'complete' => false,
46-
'progress' => 0
47-
);
51+
$return = ['error' => '', 'complete' => false, 'progress' => 0];
4852

4953
/** @var helper_plugin_move_plan $plan */
5054
$plan = plugin_load('helper', 'move_plan');
5155

52-
if(!$plan->isCommited()) {
56+
if (!$plan->isCommited()) {
5357
// There is no plan. Something went wrong
5458
$return['complete'] = true;
5559
} else {
5660
$todo = $plan->nextStep($INPUT->bool('skip'));
5761
$return['progress'] = $plan->getProgress();
5862
$return['error'] = $plan->getLastError();
59-
if($todo === 0) $return['complete'] = true;
63+
if ($todo === 0) $return['complete'] = true;
6064
}
6165

6266
$json = new JSON();
6367
header('Content-Type: application/json');
6468
echo $json->encode($return);
6569
}
66-
}
70+
}

action/rename.php

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
11
<?php
2+
3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
use dokuwiki\plugin\move\MenuItem;
7+
28
/**
39
* Move Plugin Page Rename Functionality
410
*
511
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
612
* @author Andreas Gohr <[email protected]>
713
*/
14+
815
// must be run within Dokuwiki
9-
if(!defined('DOKU_INC')) die();
16+
if (!defined('DOKU_INC')) die();
1017

1118
/**
1219
* Class action_plugin_move_rename
1320
*/
14-
class action_plugin_move_rename extends DokuWiki_Action_Plugin {
15-
21+
class action_plugin_move_rename extends ActionPlugin
22+
{
1623
/**
1724
* Register event handlers.
1825
*
19-
* @param Doku_Event_Handler $controller The plugin controller
26+
* @param EventHandler $controller The plugin controller
2027
*/
21-
public function register(Doku_Event_Handler $controller) {
28+
public function register(EventHandler $controller)
29+
{
2230
$controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'handle_init');
2331

2432
// TODO: DEPRECATED JAN 2018
2533
$controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'handle_pagetools');
2634

27-
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addsvgbutton', array());
35+
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addsvgbutton', []);
2836
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax');
2937
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handleAjaxMediaManager');
3038
}
3139

3240
/**
3341
* set JavaScript info if renaming of current page is possible
3442
*/
35-
public function handle_init() {
43+
public function handle_init()
44+
{
3645
global $JSINFO;
3746
global $INFO;
3847
global $INPUT;
@@ -56,10 +65,11 @@ public function handle_init() {
5665
*
5766
* TODO: DEPRECATED JAN 2018
5867
*
59-
* @param Doku_Event $event
68+
* @param Event $event
6069
*/
61-
public function handle_pagetools(Doku_Event $event) {
62-
if($event->data['view'] != 'main') return;
70+
public function handle_pagetools(Event $event)
71+
{
72+
if ($event->data['view'] != 'main') return;
6373
if (!$this->getConf('pagetools_integration')) {
6474
return;
6575
}
@@ -68,35 +78,37 @@ public function handle_pagetools(Doku_Event $event) {
6878
$offset = count($event->data['items']) - 1;
6979
$event->data['items'] =
7080
array_slice($event->data['items'], 0, $offset, true) +
71-
array('plugin_move' => $newitem) +
81+
['plugin_move' => $newitem] +
7282
array_slice($event->data['items'], $offset, null, true);
7383
}
7484

7585
/**
7686
* Add 'rename' button to page tools, new SVG based mechanism
7787
*
78-
* @param Doku_Event $event
88+
* @param Event $event
7989
*/
80-
public function addsvgbutton(Doku_Event $event) {
90+
public function addsvgbutton(Event $event)
91+
{
8192
global $INFO, $JSINFO;
82-
if(
93+
if (
8394
$event->data['view'] !== 'page' ||
8495
!$this->getConf('pagetools_integration') ||
8596
empty($JSINFO['move_renameokay'])
8697
) {
8798
return;
8899
}
89-
if(!$INFO['exists']) {
100+
if (!$INFO['exists']) {
90101
return;
91102
}
92-
array_splice($event->data['items'], -1, 0, array(new \dokuwiki\plugin\move\MenuItem()));
103+
array_splice($event->data['items'], -1, 0, [new MenuItem()]);
93104
}
94105

95106
/**
96107
* Rename a single page
97108
*/
98-
public function handle_ajax(Doku_Event $event) {
99-
if($event->data != 'plugin_move_rename') return;
109+
public function handle_ajax(Event $event)
110+
{
111+
if ($event->data != 'plugin_move_rename') return;
100112
$event->preventDefault();
101113
$event->stopPropagation();
102114

@@ -113,26 +125,26 @@ public function handle_ajax(Doku_Event $event) {
113125

114126
header('Content-Type: application/json');
115127

116-
if($this->renameOkay($src) && $MoveOperator->movePage($src, $dst)) {
128+
if ($this->renameOkay($src) && $MoveOperator->movePage($src, $dst)) {
117129
// all went well, redirect
118-
echo $JSON->encode(array('redirect_url' => wl($dst, '', true, '&')));
130+
echo $JSON->encode(['redirect_url' => wl($dst, '', true, '&')]);
119131
} else {
120-
if(isset($MSG[0])) {
132+
if (isset($MSG[0])) {
121133
$error = $MSG[0]; // first error
122134
} else {
123135
$error = $this->getLang('cantrename');
124136
}
125-
echo $JSON->encode(array('error' => $error));
137+
echo $JSON->encode(['error' => $error]);
126138
}
127139
}
128140

129141
/**
130142
* Handle media renames in media manager
131143
*
132-
* @param Doku_Event $event
144+
* @param Event $event
133145
* @return void
134146
*/
135-
public function handleAjaxMediaManager(Doku_Event $event)
147+
public function handleAjaxMediaManager(Event $event)
136148
{
137149
if ($event->data !== 'plugin_move_rename_mediamanager') return;
138150

@@ -191,17 +203,18 @@ public function handleAjaxMediaManager(Doku_Event $event)
191203
* @param $id
192204
* @return bool
193205
*/
194-
public function renameOkay($id) {
206+
public function renameOkay($id)
207+
{
195208
global $conf;
196209
global $ACT;
197210
global $USERINFO;
198-
if(!($ACT == 'show' || empty($ACT))) return false;
199-
if(!page_exists($id)) return false;
200-
if(auth_quickaclcheck($id) < AUTH_EDIT) return false;
201-
if(checklock($id) !== false || @file_exists(wikiLockFN($id))) return false;
202-
if(!$conf['useacl']) return true;
203-
if(!isset($_SERVER['REMOTE_USER'])) return false;
204-
if(!auth_isMember($this->getConf('allowrename'), $_SERVER['REMOTE_USER'], (array) $USERINFO['grps'])) return false;
211+
if ($ACT != 'show' && !empty($ACT)) return false;
212+
if (!page_exists($id)) return false;
213+
if (auth_quickaclcheck($id) < AUTH_EDIT) return false;
214+
if (checklock($id) !== false || @file_exists(wikiLockFN($id))) return false;
215+
if (!$conf['useacl']) return true;
216+
if (!isset($_SERVER['REMOTE_USER'])) return false;
217+
if (!auth_isMember($this->getConf('allowrename'), $_SERVER['REMOTE_USER'], (array) $USERINFO['grps'])) return false;
205218

206219
return true;
207220
}
@@ -212,10 +225,10 @@ public function renameOkay($id) {
212225
* Alternatively give anything the class "plugin_move_page" - it will automatically be hidden and shown and
213226
* trigger the page move dialog.
214227
*/
215-
public function tpl() {
228+
public function tpl()
229+
{
216230
echo '<a href="" class="plugin_move_page">';
217231
echo $this->getLang('renamepage');
218232
echo '</a>';
219233
}
220-
221234
}

0 commit comments

Comments
 (0)