Total Complexity | 18 |
Total Lines | 184 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
17 | class action_plugin_prosemirror_ajax extends DokuWiki_Action_Plugin |
||
1 ignored issue
–
show
|
|||
18 | { |
||
19 | /** |
||
20 | * Registers a callback function for a given event |
||
21 | * |
||
22 | * @param Doku_Event_Handler $controller DokuWiki's event controller object |
||
23 | * |
||
24 | * @return void |
||
25 | */ |
||
26 | public function register(Doku_Event_Handler $controller) |
||
1 ignored issue
–
show
|
|||
27 | { |
||
28 | $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handleAjax'); |
||
29 | $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'switchEditors'); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * [Custom event handler which performs action] |
||
34 | * |
||
35 | * Event: AJAX_CALL_UNKNOWN |
||
36 | * |
||
37 | * @param Doku_Event $event event object by reference |
||
38 | * @param mixed $param [the parameters passed as fifth argument to register_hook() when this |
||
39 | * handler was registered] |
||
40 | * |
||
41 | * @return void |
||
42 | */ |
||
43 | public function handleAjax(Doku_Event $event, $param) |
||
1 ignored issue
–
show
|
|||
44 | { |
||
45 | if ($event->data !== 'plugin_prosemirror') { |
||
46 | return; |
||
47 | } |
||
48 | $event->preventDefault(); |
||
49 | $event->stopPropagation(); |
||
50 | |||
51 | global $INPUT, $ID; |
||
52 | $ID = $INPUT->str('id'); |
||
53 | $responseData = []; |
||
54 | foreach ($INPUT->arr('actions') as $action) { |
||
55 | switch ($action) { |
||
56 | case 'resolveInternalLink': |
||
57 | { |
||
58 | $inner = $INPUT->str('inner'); |
||
59 | $responseData[$action] = $this->resolveInternalLink($inner, $ID); |
||
60 | break; |
||
61 | } |
||
62 | case 'resolveInterWikiLink': |
||
63 | { |
||
64 | $inner = $INPUT->str('inner'); |
||
65 | list($shortcut, $reference) = explode('>', $inner); |
||
66 | $responseData[$action] = $this->resolveInterWikiLink($shortcut, $reference); |
||
67 | break; |
||
68 | } |
||
69 | case 'resolveMedia': |
||
70 | { |
||
71 | $attrs = $INPUT->arr('attrs'); |
||
72 | $responseData[$action] = [ |
||
73 | 'data-resolvedHtml' => \dokuwiki\plugin\prosemirror\parser\ImageNode::resolveMedia( |
||
74 | $attrs['id'], |
||
75 | $attrs['title'], |
||
76 | $attrs['align'], |
||
77 | $attrs['width'], |
||
78 | $attrs['height'], |
||
79 | $attrs['cache'], |
||
80 | $attrs['linking'] |
||
81 | ) |
||
82 | ]; |
||
83 | break; |
||
84 | } |
||
85 | case 'resolveImageTitle': |
||
86 | { |
||
87 | $image = $INPUT->arr('image'); |
||
88 | $responseData[$action] = []; |
||
89 | $responseData[$action]['data-resolvedImage'] = LinkNode::resolveImageTitle( |
||
90 | $ID, |
||
91 | $image['id'], |
||
92 | $image['title'], |
||
93 | $image['align'], |
||
94 | $image['width'], |
||
95 | $image['height'], |
||
96 | $image['cache'] |
||
97 | ); |
||
98 | break; |
||
99 | } |
||
100 | default: |
||
101 | { |
||
102 | dbglog('Unknown action: ' . $INPUT->str('action'), __FILE__ . ': ' . __LINE__); |
||
1 ignored issue
–
show
|
|||
103 | http_status(400, 'unknown action'); |
||
1 ignored issue
–
show
|
|||
104 | return; |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | |||
109 | echo json_encode($responseData); |
||
110 | } |
||
111 | |||
112 | protected function resolveInterWikiLink($shortcut, $reference) |
||
113 | { |
||
114 | $xhtml_renderer = p_get_renderer('xhtml'); |
||
1 ignored issue
–
show
|
|||
115 | $xhtml_renderer->interwiki = getInterwiki(); |
||
1 ignored issue
–
show
|
|||
116 | $url = $xhtml_renderer->_resolveInterWiki($shortcut, $reference, $exits); |
||
117 | return [ |
||
118 | 'url' => $url, |
||
119 | 'resolvedClass' => 'interwikilink interwiki iw_' . $shortcut, |
||
120 | ]; |
||
121 | } |
||
122 | |||
123 | protected function resolveInternalLink($inner, $curId) |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * [Custom event handler which performs action] |
||
133 | * |
||
134 | * Event: AJAX_CALL_UNKNOWN |
||
135 | * |
||
136 | * @param Doku_Event $event event object by reference |
||
137 | * @param mixed $param [the parameters passed as fifth argument to register_hook() when this |
||
138 | * handler was registered] |
||
139 | * |
||
140 | * @return void |
||
141 | */ |
||
142 | public function switchEditors(Doku_Event $event, $param) |
||
201 | } |
||
202 | } |
||
203 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths