PSR-12 coding style

This commit is contained in:
Satoshi Sahara 2020-02-12 08:13:06 +09:00
parent 7be7cd38d3
commit cf83359537
3 changed files with 38 additions and 32 deletions

View File

@ -16,7 +16,6 @@ class action_plugin_extension extends DokuWiki_Action_Plugin
*/
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'info');
}
@ -26,7 +25,7 @@ class action_plugin_extension extends DokuWiki_Action_Plugin
* @param Doku_Event $event
* @param $param
*/
public function info(Doku_Event &$event, $param)
public function info(Doku_Event $event, $param)
{
global $USERINFO;
global $INPUT;

View File

@ -51,9 +51,11 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
/* @var helper_plugin_extension_repository $repository */
$repository = $this->loadHelper('extension_repository');
if(!$repository->hasAccess(!$INPUT->bool('purge'))) {
if (!$repository->hasAccess(!$INPUT->bool('purge'))) {
$url = $this->gui->tabURL('', array('purge' => 1));
msg($this->getLang('repo_error').' [<a href="'.$url.'">'.$this->getLang('repo_retry').'</a>]', -1);
msg($this->getLang('repo_error').
' [<a href="'.$url.'">'.$this->getLang('repo_retry').'</a>]', -1
);
}
if (!in_array('ssl', stream_get_transports())) {
@ -75,12 +77,9 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
$extension->setExtension($extname);
$installed = $extension->installOrUpdate();
foreach ($installed as $ext => $info) {
msg(
sprintf(
$this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'),
$info['base']
),
1
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
$info['base']), 1
);
}
break;
@ -88,20 +87,14 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
$extension->setExtension($extname);
$status = $extension->uninstall();
if ($status) {
msg(
sprintf(
$this->getLang('msg_delete_success'),
hsc($extension->getDisplayName())
),
1
msg(sprintf(
$this->getLang('msg_delete_success'),
hsc($extension->getDisplayName())), 1
);
} else {
msg(
sprintf(
$this->getLang('msg_delete_failed'),
hsc($extension->getDisplayName())
),
-1
msg(sprintf(
$this->getLang('msg_delete_failed'),
hsc($extension->getDisplayName())), -1
);
}
break;
@ -111,7 +104,10 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
if ($status !== true) {
msg($status, -1);
} else {
msg(sprintf($this->getLang('msg_enabled'), hsc($extension->getDisplayName())), 1);
msg(sprintf(
$this->getLang('msg_enabled'),
hsc($extension->getDisplayName())), 1
);
}
break;
case 'disable':
@ -120,7 +116,10 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
if ($status !== true) {
msg($status, -1);
} else {
msg(sprintf($this->getLang('msg_disabled'), hsc($extension->getDisplayName())), 1);
msg(sprintf(
$this->getLang('msg_disabled'),
hsc($extension->getDisplayName())), 1
);
}
break;
}
@ -130,13 +129,19 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
} elseif ($INPUT->post->str('installurl') && checkSecurityToken()) {
$installed = $extension->installFromURL($INPUT->post->str('installurl'));
foreach ($installed as $ext => $info) {
msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1);
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
$info['base']), 1
);
}
send_redirect($this->gui->tabURL('', array(), '&', true));
} elseif (isset($_FILES['installfile']) && checkSecurityToken()) {
$installed = $extension->installFromUpload('installfile');
foreach ($installed as $ext => $info) {
msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1);
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
$info['base']), 1
);
}
send_redirect($this->gui->tabURL('', array(), '&', true));
}

View File

@ -895,7 +895,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
* @param string $defaultName fallback for name of download
* @return bool|string if failed false, otherwise true or the name of the file in the given dir
*/
protected function downloadToFile($url,$file,$defaultName=''){
protected function downloadToFile($url,$file,$defaultName='')
{
global $conf;
$http = new DokuHTTPClient();
$http->max_bodysize = 0;
@ -911,8 +912,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$content_disposition = $http->resp_headers['content-disposition'];
$match=array();
if (is_string($content_disposition) &&
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) {
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)
) {
$name = \dokuwiki\Utf8\PhpString::basename($match[1]);
}
@ -927,10 +928,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$fileexists = file_exists($file);
$fp = @fopen($file,"w");
if(!$fp) return false;
if (!$fp) return false;
fwrite($fp,$data);
fclose($fp);
if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
if (!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
return $name;
}
@ -1187,7 +1188,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
return true;
}
// the only case when we don't get one of the recognized archive types is when the archive file can't be read
// the only case when we don't get one of the recognized archive types is
// when the archive file can't be read
throw new Exception($this->getLang('error_decompress').' Couldn\'t read archive file');
}