Skip to content

Commit ca33838

Browse files
committed
Code style fixes
1 parent 5cd8e0f commit ca33838

File tree

6 files changed

+78
-92
lines changed

6 files changed

+78
-92
lines changed

action/ajax.php

Lines changed: 43 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* @author Andreas Gohr <[email protected]>
88
*/
99

10-
// must be run within Dokuwiki
1110
use dokuwiki\Extension\ActionPlugin;
1211
use dokuwiki\Extension\EventHandler;
1312
use dokuwiki\Extension\Event;
@@ -17,10 +16,6 @@
1716
use dokuwiki\plugin\prosemirror\parser\InternalLinkNode;
1817
use dokuwiki\plugin\prosemirror\parser\LinkNode;
1918

20-
if (!defined('DOKU_INC')) {
21-
die();
22-
}
23-
2419
class action_plugin_prosemirror_ajax extends ActionPlugin
2520
{
2621
/**
@@ -42,12 +37,10 @@ public function register(EventHandler $controller)
4237
* Event: AJAX_CALL_UNKNOWN
4338
*
4439
* @param Event $event event object by reference
45-
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
46-
* handler was registered]
4740
*
4841
* @return void
4942
*/
50-
public function handleAjax(Event $event, $param)
43+
public function handleAjax(Event $event)
5144
{
5245
if ($event->data !== 'plugin_prosemirror') {
5346
return;
@@ -61,61 +54,52 @@ public function handleAjax(Event $event, $param)
6154
foreach ($INPUT->arr('actions') as $action) {
6255
switch ($action) {
6356
case 'resolveInternalLink':
64-
{
65-
$inner = $INPUT->str('inner');
66-
$responseData[$action] = $this->resolveInternalLink($inner, $ID);
67-
break;
68-
}
57+
$inner = $INPUT->str('inner');
58+
$responseData[$action] = $this->resolveInternalLink($inner, $ID);
59+
break;
6960
case 'resolveInterWikiLink':
70-
{
71-
$inner = $INPUT->str('inner');
72-
[$shortcut, $reference] = explode('>', $inner);
73-
$responseData[$action] = $this->resolveInterWikiLink($shortcut, $reference);
74-
break;
75-
}
61+
$inner = $INPUT->str('inner');
62+
[$shortcut, $reference] = explode('>', $inner);
63+
$responseData[$action] = $this->resolveInterWikiLink($shortcut, $reference);
64+
break;
7665
case 'resolveMedia':
77-
{
78-
$attrs = $INPUT->arr('attrs');
79-
$responseData[$action] = [
80-
'data-resolvedHtml' => ImageNode::resolveMedia(
81-
$attrs['id'],
82-
$attrs['title'],
83-
$attrs['align'],
84-
$attrs['width'],
85-
$attrs['height'],
86-
$attrs['cache'],
87-
$attrs['linking']
88-
)
89-
];
90-
break;
91-
}
66+
$attrs = $INPUT->arr('attrs');
67+
$responseData[$action] = [
68+
'data-resolvedHtml' => ImageNode::resolveMedia(
69+
$attrs['id'],
70+
$attrs['title'],
71+
$attrs['align'],
72+
$attrs['width'],
73+
$attrs['height'],
74+
$attrs['cache'],
75+
$attrs['linking']
76+
)
77+
];
78+
break;
9279
case 'resolveImageTitle':
93-
{
94-
$image = $INPUT->arr('image');
95-
$responseData[$action] = [];
96-
$responseData[$action]['data-resolvedImage'] = LinkNode::resolveImageTitle(
97-
$ID,
98-
$image['id'],
99-
$image['title'],
100-
$image['align'],
101-
$image['width'],
102-
$image['height'],
103-
$image['cache']
104-
);
105-
break;
106-
}
80+
$image = $INPUT->arr('image');
81+
$responseData[$action] = [];
82+
$responseData[$action]['data-resolvedImage'] = LinkNode::resolveImageTitle(
83+
$ID,
84+
$image['id'],
85+
$image['title'],
86+
$image['align'],
87+
$image['width'],
88+
$image['height'],
89+
$image['cache']
90+
);
91+
break;
10792
case 'resolveRSS':
108-
{
109-
$attrs = json_decode($INPUT->str('attrs'), true);
110-
$responseData[$action] = RSSNode::renderAttrsToHTML($attrs);
111-
break;
112-
}
93+
$attrs = json_decode($INPUT->str('attrs'), true);
94+
$responseData[$action] = RSSNode::renderAttrsToHTML($attrs);
95+
break;
11396
default:
114-
{
115-
dbglog('Unknown action: ' . $action, __FILE__ . ': ' . __LINE__);
116-
http_status(400, 'unknown action');
117-
return;
118-
}
97+
dokuwiki\Logger::getInstance(dokuwiki\Logger::LOG_DEBUG)->log(
98+
__FILE__ . ': ' . __LINE__,
99+
'Unknown action: ' . $action
100+
);
101+
http_status(400, 'unknown action');
102+
return;
119103
}
120104
}
121105

@@ -148,12 +132,10 @@ protected function resolveInternalLink($inner, $curId)
148132
* Event: AJAX_CALL_UNKNOWN
149133
*
150134
* @param Event $event event object by reference
151-
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
152-
* handler was registered]
153135
*
154136
* @return void
155137
*/
156-
public function switchEditors(Event $event, $param)
138+
public function switchEditors(Event $event)
157139
{
158140
if ($event->data !== 'plugin_prosemirror_switch_editors') {
159141
return;

action/editor.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
* @author Andreas Gohr <[email protected]>
88
*/
99

10-
// must be run within Dokuwiki
1110
use dokuwiki\Extension\ActionPlugin;
1211
use dokuwiki\Extension\EventHandler;
1312
use dokuwiki\Extension\Event;
1413
use dokuwiki\Form\Form;
1514
use dokuwiki\Form\ButtonElement;
1615

17-
if (!defined('DOKU_INC')) {
18-
die();
19-
}
20-
2116
class action_plugin_prosemirror_editor extends ActionPlugin
2217
{
2318
/**
@@ -208,7 +203,9 @@ public function addAddtionalForms(Event $event)
208203
$linkForm->addRadioButton('linktype', $this->getLang('type:wiki page'))->val('internallink');
209204
$linkForm->addRadioButton('linktype', $this->getLang('type:interwiki'))->val('interwikilink');
210205
$linkForm->addRadioButton('linktype', $this->getLang('type:email'))->val('emaillink');
211-
$linkForm->addRadioButton('linktype', $this->getLang('type:external'))->val('externallink')->attr('checked', 'checked');
206+
$linkForm->addRadioButton('linktype', $this->getLang('type:external'))
207+
->val('externallink')
208+
->attr('checked', 'checked');
212209
$linkForm->addRadioButton('linktype', $this->getLang('type:other'))->val('other');
213210
$linkForm->addTagClose('fieldset');
214211
$linkForm->addTagClose('div');
@@ -218,7 +215,9 @@ public function addAddtionalForms(Event $event)
218215
$linkForm->addTagOpen('legend');
219216
$linkForm->addHTML('Link Name Type');
220217
$linkForm->addTagClose('legend');
221-
$linkForm->addRadioButton('nametype', $this->getLang('type:automatic title'))->val('automatic')->attr('checked', 'checked');
218+
$linkForm->addRadioButton('nametype', $this->getLang('type:automatic title'))
219+
->val('automatic')
220+
->attr('checked', 'checked');
222221
$linkForm->addRadioButton('nametype', $this->getLang('type:custom title'))->val('custom');
223222
$linkForm->addRadioButton('nametype', $this->getLang('type:image'))->val('image');
224223
$linkForm->addTextInput('linkname', 'Link name')->attr('placeholder', $this->getLang('placeholder:link name'));
@@ -240,9 +239,12 @@ public function addAddtionalForms(Event $event)
240239
'style' => 'display: none;',
241240
]);
242241
$mediaForm->addFieldsetOpen($this->getLang('legend:media'))->addClass('js-media-fieldset');
243-
$mediaForm->addButtonHTML('mediamanager', inlineSVG(DOKU_PLUGIN . 'prosemirror/images/file-image-outline.svg'))->attrs([
244-
'type' => 'button',
245-
'class' => 'js-open-mediamanager mediaform_mediamanager'
242+
$mediaForm->addButtonHTML(
243+
'mediamanager',
244+
inlineSVG(DOKU_PLUGIN . 'prosemirror/images/file-image-outline.svg')
245+
)->attrs([
246+
'type' => 'button',
247+
'class' => 'js-open-mediamanager mediaform_mediamanager'
246248
]);
247249
$mediaForm->addTextInput('mediatarget', $this->getLang('media target'))->attrs(
248250
[
@@ -272,7 +274,9 @@ public function addAddtionalForms(Event $event)
272274
$mediaForm->addTagOpen('legend');
273275
$mediaForm->addHTML($this->getLang('legend:alignment'));
274276
$mediaForm->addTagClose('legend');
275-
$mediaForm->addRadioButton('alignment', $this->getLang('label:default alignment'))->val('')->attr('checked', 'checked');
277+
$mediaForm->addRadioButton('alignment', $this->getLang('label:default alignment'))
278+
->val('')
279+
->attr('checked', 'checked');
276280
$mediaForm->addRadioButton('alignment', $this->getLang('label:float left'))->val('left');
277281
$mediaForm->addRadioButton('alignment', $this->getLang('label:center alignment'))->val('center');
278282
$mediaForm->addRadioButton('alignment', $this->getLang('label:float right'))->val('right');
@@ -284,7 +288,9 @@ public function addAddtionalForms(Event $event)
284288
$mediaForm->addTagOpen('legend');
285289
$mediaForm->addHTML($this->getLang('legend:linking'));
286290
$mediaForm->addTagClose('legend');
287-
$mediaForm->addRadioButton('linking', $this->getLang('label:default linking'))->val('details')->attr('checked', 'checked');
291+
$mediaForm->addRadioButton('linking', $this->getLang('label:default linking'))
292+
->val('details')
293+
->attr('checked', 'checked');
288294
$mediaForm->addRadioButton('linking', $this->getLang('label:direct linking'))->val('direct');
289295
$mediaForm->addRadioButton('linking', $this->getLang('label:nolink'))->val('nolink');
290296
$mediaForm->addRadioButton('linking', $this->getLang('label:linkonly'))->val('linkonly');
@@ -296,7 +302,9 @@ public function addAddtionalForms(Event $event)
296302
$mediaForm->addTagOpen('legend');
297303
$mediaForm->addHTML($this->getLang('legend:caching'));
298304
$mediaForm->addTagClose('legend');
299-
$mediaForm->addRadioButton('caching', $this->getLang('label:default caching'))->val('')->attr('checked', 'checked');
305+
$mediaForm->addRadioButton('caching', $this->getLang('label:default caching'))
306+
->val('')
307+
->attr('checked', 'checked');
300308
$mediaForm->addRadioButton('caching', $this->getLang('label:recache'))->val('recache');
301309
$mediaForm->addRadioButton('caching', $this->getLang('label:nocache'))->val('nocache');
302310
$mediaForm->addTagClose('fieldset');

action/parser.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@
77
* @author Andreas Gohr <[email protected]>
88
*/
99

10-
// must be run within Dokuwiki
1110
use dokuwiki\Extension\ActionPlugin;
1211
use dokuwiki\Extension\EventHandler;
1312
use dokuwiki\Extension\Event;
1413
use dokuwiki\plugin\prosemirror\parser\SyntaxTreeBuilder;
1514

16-
if (!defined('DOKU_INC')) {
17-
die();
18-
}
19-
2015
class action_plugin_prosemirror_parser extends ActionPlugin
2116
{
2217
/**
@@ -28,8 +23,8 @@ class action_plugin_prosemirror_parser extends ActionPlugin
2823
*/
2924
public function register(EventHandler $controller)
3025
{
31-
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_preprocess');
32-
$controller->register_hook('DRAFT_SAVE', 'BEFORE', $this, 'handle_draft');
26+
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handlePreprocess');
27+
$controller->register_hook('DRAFT_SAVE', 'BEFORE', $this, 'handleDraft');
3328
}
3429

3530
/**
@@ -38,7 +33,7 @@ public function register(EventHandler $controller)
3833
* @param Event $event
3934
* @param $param
4035
*/
41-
public function handle_draft(Event $event, $param)
36+
public function handleDraft(Event $event, $param)
4237
{
4338
global $INPUT;
4439
$unparsedJSON = $INPUT->post->str('prosemirror_json');
@@ -80,7 +75,7 @@ public function handle_draft(Event $event, $param)
8075
*
8176
* @return void
8277
*/
83-
public function handle_preprocess(Event $event, $param)
78+
public function handlePreprocess(Event $event, $param)
8479
{
8580
global $TEXT, $INPUT;
8681
if (

parser/Node.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ public static function getSubNode($node, Node $parent, Node $previous = null)
7676
}
7777
return $eventData['newNode'];
7878
} catch (\Error $e) {
79-
$exception = new ProsemirrorException('FIXME: better message for general error! Invalid node type received: ' . $node['type'], 0, $e);
79+
$exception = new ProsemirrorException(
80+
'FIXME: better message for general error! Invalid node type received: ' . $node['type'],
81+
0,
82+
$e
83+
);
8084
$exception->addExtraData('nodeData', $node);
8185
$exception->addExtraData('parentNodeType', get_class($parent));
8286

renderer.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

3+
// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
4+
35
/**
46
* DokuWiki Plugin prosemirror (Renderer Component)
57
*
68
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
79
* @author Andreas Gohr <[email protected]>
810
*/
911

10-
// must be run within Dokuwiki
1112
use dokuwiki\plugin\prosemirror\parser\ImageNode;
1213
use dokuwiki\plugin\prosemirror\parser\LocalLinkNode;
1314
use dokuwiki\plugin\prosemirror\parser\InternalLinkNode;
@@ -20,12 +21,6 @@
2021
use dokuwiki\plugin\prosemirror\schema\Node;
2122
use dokuwiki\plugin\prosemirror\schema\NodeStack;
2223

23-
if (!defined('DOKU_INC')) {
24-
die();
25-
}
26-
27-
require_once DOKU_INC . 'inc/parser/renderer.php';
28-
2924
class renderer_plugin_prosemirror extends Doku_Renderer
3025
{
3126
/** @var NodeStack */

schema/NodeStack.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ public function drop($type)
8787
$node = array_pop($this->stack);
8888
$this->stacklength--;
8989
if ($node->getType() != $type) {
90-
throw new \RuntimeException("Expected the current node to be of type $type found " . $node->getType() . " instead.");
90+
throw new \RuntimeException(
91+
"Expected the current node to be of type $type found " . $node->getType() . " instead."
92+
);
9193
}
9294
return $node;
9395
}

0 commit comments

Comments
 (0)