Skip to content

Commit fab2617

Browse files
authoredOct 26, 2023
🤖 Automatic code style fixes
1 parent 3b5e004 commit fab2617

15 files changed

+1931
-1550
lines changed
 

‎action.php

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
<?php
2+
3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
27
/**
38
* Removes entries from repository database when removed from page
49
*
510
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
611
*/
7-
812
/**
913
* Register actions for event hooks
1014
*/
11-
class action_plugin_pluginrepo extends DokuWiki_Action_Plugin {
12-
15+
class action_plugin_pluginrepo extends ActionPlugin
16+
{
1317
/**
1418
* Registers a callback function for a given event
1519
*
1620
* @param Doku_Event_Handler $controller
1721
*/
18-
public function register(Doku_Event_Handler $controller) {
22+
public function register(EventHandler $controller)
23+
{
1924
$controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, '_cleanOldEntry');
2025
}
2126

@@ -25,21 +30,24 @@ public function register(Doku_Event_Handler $controller) {
2530
*
2631
* @param Doku_Event $event event object
2732
*/
28-
public function _cleanOldEntry(Doku_Event $event) {
33+
public function _cleanOldEntry(Event $event)
34+
{
2935
global $ID;
3036

3137
$data = $event->data;
3238
$haspluginentry = preg_match('/----+ *plugin *-+/', $data[0][1]); // addSpecialPattern: ----+ *plugin *-+\n.*?\n----+
3339
$hastemplateentry = preg_match('/----+ *template *-+/', $data[0][1]); // addSpecialPattern: ----+ *template *-+\n.*?\n----+
34-
if($haspluginentry || $hastemplateentry) {
40+
if ($haspluginentry || $hastemplateentry) {
3541
return; // plugin seems still to be there
3642
}
3743

3844
/** @var helper_plugin_pluginrepo_repository $hlp */
3945
$hlp = $this->loadHelper('pluginrepo_repository');
40-
if(!$hlp) return;
46+
if (!$hlp) {
47+
return;
48+
}
4149

42-
if(curNS($ID) == 'plugin') {
50+
if (curNS($ID) == 'plugin') {
4351
$id = noNS($ID);
4452
} else {
4553
$id = curNS($ID) . ':' . noNS($ID);
@@ -48,4 +56,3 @@ public function _cleanOldEntry(Doku_Event $event) {
4856
$hlp->deletePlugin($id);
4957
}
5058
}
51-

‎api.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22

3-
if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../');
4-
require_once(DOKU_INC.'inc/init.php');
3+
if (!defined('DOKU_INC')) {
4+
define('DOKU_INC', __DIR__ . '/../../../');
5+
}
6+
require_once(DOKU_INC . 'inc/init.php');
57

68
require_once(DOKU_PLUGIN . 'pluginrepo/helper/repository.php');
79

@@ -26,24 +28,24 @@
2628
header('Pragma: public');
2729
header('X-Robots-Tag: noindex');
2830

29-
if($INPUT->str('cmd') == 'ping') {
31+
if ($INPUT->str('cmd') == 'ping') {
3032
header('Content-Type: text/plain; charset=utf-8');
3133
echo '1';
3234
} else {
33-
switch($INPUT->str('fmt')) {
35+
switch ($INPUT->str('fmt')) {
3436
case 'debug':
3537
header('Content-Type: text/plain; charset=utf-8');
3638
print_r($extensions);
3739
break;
3840
case 'xml':
3941
header('Content-Type: application/xml; charset=utf-8');
40-
require('classes/A2Xml.php');
42+
require(__DIR__ . '/classes/A2Xml.php');
4143
$xml = xml_encode((object) $extensions, "hash");
4244
echo $xml;
4345
break;
4446
case 'yaml':
4547
header('Content-Type: text/yaml');
46-
require('classes/Spyc.php');
48+
require(__DIR__ . '/classes/Spyc.php');
4749
echo Spyc::YAMLDump($extensions, false, 0);
4850
break;
4951
case 'php':
@@ -54,7 +56,7 @@
5456
$data = json_encode($extensions);
5557
$cb = $INPUT->str('cb');
5658
$cb = preg_replace('/\W+/', '', $cb);
57-
if($cb) {
59+
if ($cb) {
5860
header('Content-Type: text/javascript');
5961
echo "$cb($data);";
6062
} else {

‎classes/A2Xml.php

+33-29
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,39 @@
66
Source code from http://blog.waaile.com/array-to-xml
77
*/
88

9-
function xml_encode($value, $tag = "root") {
10-
if( !is_array($value)
11-
&& !is_string($value)
12-
&& !is_bool($value)
13-
&& !is_numeric($value)
14-
&& !is_object($value) ) {
15-
return false;
16-
}
17-
function x2str($xml,$key) {
18-
if (!is_array($xml) && !is_object($xml)) {
19-
return "<$key>".htmlspecialchars($xml)."</$key>";
20-
}
21-
$xml_str="";
22-
foreach ($xml as $k=>$v) {
23-
if(is_numeric($k)) {
24-
$k = "_".$k;
25-
}
26-
$xml_str.=x2str($v,$k);
27-
}
28-
return "<$key>$xml_str</$key>";
29-
}
30-
return simplexml_load_string(x2str($value,$tag))->asXml();
9+
function xml_encode($value, $tag = "root")
10+
{
11+
if (
12+
!is_array($value)
13+
&& !is_string($value)
14+
&& !is_bool($value)
15+
&& !is_numeric($value)
16+
&& !is_object($value)
17+
) {
18+
return false;
19+
}
20+
function x2str($xml, $key)
21+
{
22+
if (!is_array($xml) && !is_object($xml)) {
23+
return "<$key>" . htmlspecialchars($xml) . "</$key>";
24+
}
25+
$xml_str = "";
26+
foreach ($xml as $k => $v) {
27+
if (is_numeric($k)) {
28+
$k = "_" . $k;
29+
}
30+
$xml_str .= x2str($v, $k);
31+
}
32+
return "<$key>$xml_str</$key>";
33+
}
34+
return simplexml_load_string(x2str($value, $tag))->asXml();
3135
}
3236

33-
function xml_decode($xml) {
34-
if(!is_string($xml)) {
35-
return false;
36-
}
37-
$xml = @simplexml_load_string($xml);
38-
return $xml;
37+
function xml_decode($xml)
38+
{
39+
if (!is_string($xml)) {
40+
return false;
41+
}
42+
$xml = @simplexml_load_string($xml);
43+
return $xml;
3944
}
40-
?>

0 commit comments

Comments
 (0)
Please sign in to comment.