Skip to content

Commit b7b9d8d

Browse files
committed
Semi-automatic code style fixes
1 parent 495caa2 commit b7b9d8d

File tree

16 files changed

+307
-317
lines changed

16 files changed

+307
-317
lines changed

Form/DropdownElement.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace dokuwiki\plugin\data\Form;
44

5+
use dokuwiki\Form\InputElement;
56
use dokuwiki\Form\OptGroup;
67

78
/**
@@ -14,7 +15,7 @@ class DropdownElement extends \dokuwiki\Form\DropdownElement
1415
protected $values = [];
1516

1617
/** @var \dokuwiki\plugin\data\Form\OptGroup[] */
17-
protected $optGroups = array();
18+
protected $optGroups = [];
1819

1920

2021
/**
@@ -27,7 +28,7 @@ class DropdownElement extends \dokuwiki\Form\DropdownElement
2728
*/
2829
public function __construct($name, $options, $label = '')
2930
{
30-
\dokuwiki\Form\InputElement::__construct('dropdown', $name, $label);
31+
InputElement::__construct('dropdown', $name, $label);
3132
$this->rmattr('type');
3233
$this->optGroups[''] = new \dokuwiki\plugin\data\Form\OptGroup(null, $options);
3334
$this->val('');
@@ -69,7 +70,7 @@ public function val($value = null)
6970
*/
7071
public function attr($name, $value = null)
7172
{
72-
return \dokuwiki\Form\InputElement::attr($name, $value);
73+
return InputElement::attr($name, $value);
7374
}
7475

7576
/**
@@ -143,5 +144,4 @@ function ($html, OptGroup $optGroup) {
143144

144145
return $html;
145146
}
146-
147147
}

action.php

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
<?php
2+
3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
use dokuwiki\Utf8\PhpString;
7+
28
/**
39
*
410
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
511
* @author Andreas Gohr <andi@splitbrain.org>
612
*/
7-
813
/**
914
* Class action_plugin_data
1015
*/
11-
class action_plugin_data extends DokuWiki_Action_Plugin
16+
class action_plugin_data extends ActionPlugin
1217
{
13-
1418
/**
1519
* will hold the data helper plugin
1620
* @var helper_plugin_data
1721
*/
18-
var $dthlp = null;
22+
public $dthlp;
1923

2024
/**
2125
* Constructor. Load helper plugin
2226
*/
23-
function __construct()
27+
public function __construct()
2428
{
2529
$this->dthlp = plugin_load('helper', 'data');
2630
}
2731

2832
/**
2933
* Registers a callback function for a given event
3034
*/
31-
function register(Doku_Event_Handler $controller)
35+
public function register(EventHandler $controller)
3236
{
3337
$controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, '_handle');
3438
$controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, '_editbutton');
@@ -42,10 +46,10 @@ function register(Doku_Event_Handler $controller)
4246
* Handles the page write event and removes the database info
4347
* when the plugin code is no longer in the source
4448
*
45-
* @param Doku_Event $event
49+
* @param Event $event
4650
* @param null $param
4751
*/
48-
function _handle(Doku_Event $event, $param)
52+
public function _handle(Event $event, $param)
4953
{
5054
$data = $event->data;
5155
if (strpos($data[0][1], 'dataentry') !== false) return; // plugin seems still to be there
@@ -63,10 +67,10 @@ function _handle(Doku_Event $event, $param)
6367
}
6468

6569
/**
66-
* @param Doku_Event $event
70+
* @param Event $event
6771
* @param null $param
6872
*/
69-
function _editbutton($event, $param)
73+
public function _editbutton($event, $param)
7074
{
7175
if ($event->data['target'] !== 'plugin_data') {
7276
return;
@@ -76,10 +80,10 @@ function _editbutton($event, $param)
7680
}
7781

7882
/**
79-
* @param Doku_Event $event
83+
* @param Event $event
8084
* @param null $param
8185
*/
82-
function _editform(Doku_Event $event, $param)
86+
public function _editform(Event $event, $param)
8387
{
8488
global $TEXT;
8589
if ($event->data['target'] !== 'plugin_data') {
@@ -94,36 +98,36 @@ function _editform(Doku_Event $event, $param)
9498

9599
echo $this->locale_xhtml('edit_intro' . ($this->getConf('edit_content_only') ? '_contentonly' : ''));
96100

97-
require_once 'renderer_data_edit.php';
101+
require_once __DIR__ . '/renderer_data_edit.php';
98102
$Renderer = new Doku_Renderer_plugin_data_edit();
99103
$Renderer->form = $event->data['form'];
100104

101105
// Loop through the instructions
102106
$instructions = p_get_instructions($TEXT);
103107
foreach ($instructions as $instruction) {
104108
// Execute the callback against the Renderer
105-
call_user_func_array(array($Renderer, $instruction[0]), $instruction[1]);
109+
call_user_func_array([$Renderer, $instruction[0]], $instruction[1]);
106110
}
107111
}
108112

109113
/**
110-
* @param Doku_Event $event
114+
* @param Event $event
111115
*/
112-
function _handle_edit_post(Doku_Event $event)
116+
public function _handle_edit_post(Event $event)
113117
{
114118
if (!isset($_POST['data_edit'])) {
115119
return;
116120
}
117121
global $TEXT;
118122

119-
require_once 'syntax/entry.php';
123+
require_once __DIR__ . '/syntax/entry.php';
120124
$TEXT = syntax_plugin_data_entry::editToWiki($_POST['data_edit']);
121125
}
122126

123127
/**
124-
* @param Doku_Event $event
128+
* @param Event $event
125129
*/
126-
function _handle_ajax(Doku_Event $event)
130+
public function _handle_ajax(Event $event)
127131
{
128132
if ($event->data !== 'data_page') {
129133
return;
@@ -172,31 +176,32 @@ function _handle_ajax(Doku_Event $event)
172176
}
173177
$regexp .= '$/';
174178

175-
$result = array();
179+
$result = [];
176180
foreach ($pages as $page => $title) {
177-
$id = array();
181+
$id = [];
178182
if (!preg_match($regexp, $page, $id)) {
179183
// Does not satisfy the postfix and prefix criteria
180184
continue;
181185
}
182186

183187
$id = $id[1];
184188

185-
if ($search !== '' &&
189+
if (
190+
$search !== '' &&
186191
stripos($id, cleanID($search)) === false &&
187-
stripos($title, $search) === false) {
192+
stripos($title, (string) $search) === false
193+
) {
188194
// Search string is not in id part or title
189195
continue;
190196
}
191197

192198
if ($title === '') {
193-
$title = utf8_ucwords(str_replace('_', ' ', $id));
199+
$title = PhpString::ucwords(str_replace('_', ' ', $id));
194200
}
195201
$result[hsc($id)] = hsc($title);
196202
}
197203

198-
$json = new JSON();
199204
header('Content-Type: application/json');
200-
echo $json->encode($result);
205+
echo json_encode($result);
201206
}
202207
}

admin/aliases.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<?php
2+
23
/**
34
* DokuWiki Plugin data (Admin Component)
45
*
56
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
67
* @author Andreas Gohr <gohr@cosmocode.de>
78
*/
89

10+
use dokuwiki\Extension\AdminPlugin;
911
use dokuwiki\ErrorHandler;
1012
use dokuwiki\Utf8\PhpString;
1113

1214
/**
1315
* Administration form for configuring the type aliases
1416
*/
15-
class admin_plugin_data_aliases extends DokuWiki_Admin_Plugin
17+
class admin_plugin_data_aliases extends AdminPlugin
1618
{
17-
1819
/**
1920
* will hold the data helper plugin
2021
* @var helper_plugin_data
2122
*/
22-
protected $dthlp = null;
23+
protected $dthlp;
2324

2425
/**
2526
* Constructor. Load helper plugin
@@ -78,7 +79,7 @@ public function handle()
7879

7980
foreach ($INPUT->arr('d') as $row) {
8081
$row = array_map('trim', $row);
81-
$row['name'] = PHPString::strtolower($row['name']);
82+
$row['name'] = PhpString::strtolower($row['name']);
8283
$row['name'] = rtrim($row['name'], 's');
8384
if (!$row['name']) continue;
8485

@@ -110,7 +111,7 @@ public function html()
110111
$sql = 'SELECT * FROM aliases ORDER BY name';
111112
$rows = $sqlite->queryAll($sql);
112113

113-
$form = new Doku_Form(array('method' => 'post'));
114+
$form = new Doku_Form(['method' => 'post']);
114115
$form->addHidden('page', 'data_aliases');
115116
$form->addElement(
116117
'<table class="inline">' .
@@ -124,7 +125,7 @@ public function html()
124125
);
125126

126127
// add empty row for adding a new entry
127-
$rows[] = array('name' => '', 'type' => '', 'prefix' => '', 'postfix' => '', 'enum' => '');
128+
$rows[] = ['name' => '', 'type' => '', 'prefix' => '', 'postfix' => '', 'enum' => ''];
128129

129130
$cur = 0;
130131
foreach ($rows as $row) {
@@ -137,8 +138,9 @@ public function html()
137138
$form->addElement('<td>');
138139
$form->addElement(form_makeMenuField(
139140
'd[' . $cur . '][type]',
140-
array('', 'page', 'title', 'mail', 'url', 'dt', 'wiki', 'tag', 'hidden', 'img'),//'nspage' don't support post/prefixes
141-
$row['type'], ''
141+
['', 'page', 'title', 'mail', 'url', 'dt', 'wiki', 'tag', 'hidden', 'img'], //'nspage' don't support post/prefixes
142+
$row['type'],
143+
''
142144
));
143145
$form->addElement('</td>');
144146

@@ -163,5 +165,4 @@ public function html()
163165
$form->addElement(form_makeButton('submit', 'admin', $this->getLang('submit')));
164166
$form->printForm();
165167
}
166-
167168
}

admin/clean.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<?php
2+
3+
use dokuwiki\Extension\AdminPlugin;
4+
25
/**
36
* DokuWiki Plugin data (Admin Component)
47
*
58
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
69
* @author Andreas Gohr <gohr@cosmocode.de>
710
*/
8-
911
/**
1012
* Let admin remove non-existing pages from sqlite db
1113
*/
12-
class admin_plugin_data_clean extends DokuWiki_Admin_Plugin
14+
class admin_plugin_data_clean extends AdminPlugin
1315
{
14-
1516
/**
1617
* will hold the data helper plugin
1718
* @var helper_plugin_data
1819
*/
19-
protected $dthlp = null;
20+
protected $dthlp;
2021

2122
/**
2223
* Constructor. Load helper plugin
@@ -90,12 +91,11 @@ public function html()
9091

9192
echo $this->locale_xhtml('intro_clean');
9293

93-
$form = new Doku_Form(array('method' => 'post'));
94+
$form = new Doku_Form(['method' => 'post']);
9495
$form->addHidden('page', 'data_clean');
9596
$form->addHidden('data_go', 'go');
9697

9798
$form->addElement(form_makeButton('submit', 'admin', $this->getLang('submit_clean')));
9899
$form->printForm();
99100
}
100-
101101
}

bureaucracy_field.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
*/
1212
class syntax_plugin_bureaucracy_field_dataplugin extends syntax_plugin_bureaucracy_field
1313
{
14-
15-
private $args;
14+
private $args = [];
1615
private $additional;
1716

1817
/**
@@ -27,8 +26,7 @@ class syntax_plugin_bureaucracy_field_dataplugin extends syntax_plugin_bureaucra
2726
public function __construct($args)
2827
{
2928
$this->init($args);
30-
$n_args = array();
31-
$this->args = array();
29+
$n_args = [];
3230
foreach ($args as $arg) {
3331
if ($arg[0] !== '_') {
3432
$n_args[] = $arg;
@@ -37,7 +35,6 @@ public function __construct($args)
3735
$this->args[] = $arg;
3836
}
3937
$this->standardArgs($n_args);
40-
4138
}
4239

4340
/**
@@ -67,7 +64,7 @@ private function prepareColumns($args)
6764
$values = preg_split('/\s*,\s*/', $datatype['enum']);
6865
if (!$datatype['multi'] && $this->opt['optional']) array_unshift($values, '');
6966
$this->opt['args'] = $values;
70-
$this->additional = ($datatype['multi'] ? array('multiple' => 'multiple') : array());
67+
$this->additional = ($datatype['multi'] ? ['multiple' => 'multiple'] : []);
7168
} else {
7269
$classes = 'data_type_' . $datatype['type'] . ($datatype['multi'] ? 's' : '') . ' ' .
7370
'data_type_' . $datatype['basetype'] . ($datatype['multi'] ? 's' : '');
@@ -78,7 +75,6 @@ private function prepareColumns($args)
7875
if (!isset($this->opt['display'])) {
7976
$this->opt['display'] = $this->opt['label'];
8077
}
81-
8278
}
8379

8480
/**
@@ -116,15 +112,15 @@ public function renderfield($params, Doku_Form $form, $formid)
116112

117113
$form->addElement(call_user_func_array('form_makeListboxField',
118114
$this->_parse_tpl(
119-
array(
115+
[
120116
'@@NAME@@[]',
121117
$params['args'],
122118
$params['value'],
123119
'@@DISPLAY@@',
124120
'',
125121
'@@CLASS@@',
126122
$this->additional
127-
),
123+
],
128124
$params
129125
)));
130126
}
@@ -144,7 +140,7 @@ public function renderfield($params, Doku_Form $form, $formid)
144140
public function handle_post($value, &$fields, $index, $formid)
145141
{
146142
if (is_array($value)) {
147-
$value = join(', ', $value);
143+
$value = implode(', ', $value);
148144
}
149145

150146
return parent::handle_post($value, $fields, $index, $formid);

0 commit comments

Comments
 (0)