1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-09 17:46:31 +02:00

More coding-style fixes.

Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
Marco Dickert
2020-10-15 17:13:04 +02:00
parent 5ee3e4a8dc
commit 2edf48cb9b
3 changed files with 15 additions and 14 deletions

View File

@@ -2035,12 +2035,15 @@ function IFM(params) {
// handle window.onbeforeunload // handle window.onbeforeunload
window.onbeforeunload = self.onbeforeunloadHandler; window.onbeforeunload = self.onbeforeunloadHandler;
/*
// load initial file table // load initial file table
if( window.location.hash ) { if( window.location.hash ) {
self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) ); self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) );
} else { } else {
this.refreshFileTable(); this.refreshFileTable();
} }
*/
console.log("Finished initialisation without file table");
}; };
this.init = function(id) { this.init = function(id) {

View File

@@ -164,9 +164,9 @@ f00bar;
else else
$this->getInlineApplication(); $this->getInlineApplication();
} catch (IFMException $e) { } catch (IFMException $e) {
throw new IFMException($e->getMessage()); $this->jsonResponse(["status" => "ERROR", "message" => $e->getMessage()]);
} catch (Exception $e) { } catch (Exception $e) {
throw new IFMException($e->getMessage()); $this->jsonResponse(["status" => "ERROR", "message" => $e->getMessage()]);
} }
} }
@@ -243,9 +243,7 @@ f00bar;
*/ */
private function getI18N($lang="en") { private function getI18N($lang="en") {
if (in_array($lang, array_keys($this->i18n)))
if (in_array($lang, array_keys($i18n)))
// Merge english with the language in case of missing keys
return array_merge($this->i18n['en'], $this->i18n[$lang]); return array_merge($this->i18n['en'], $this->i18n[$lang]);
else else
return $this->i18n['en']; return $this->i18n['en'];
@@ -342,7 +340,7 @@ f00bar;
usort($dirs, [$this, "sortByName"]); usort($dirs, [$this, "sortByName"]);
usort($files, [$this, "sortByName"]); usort($files, [$this, "sortByName"]);
return array_merge($dirs, $files); return ["data" => array_merge($dirs, $files)];
} }
private function getItemInformation($name) { private function getItemInformation($name) {
@@ -556,7 +554,7 @@ f00bar;
throw new IFMException($this->l('invalid_dir')); throw new IFMException($this->l('invalid_dir'));
if (@mkdir($dn)) if (@mkdir($dn))
return ["status" => "OK", "message" => $this->l('folder_create_success')]); return ["status" => "OK", "message" => $this->l('folder_create_success')];
else else
throw new IFMException($this->l('folder_create_error').". ".error_get_last()['message']); throw new IFMException($this->l('folder_create_error').". ".error_get_last()['message']);
} }
@@ -574,7 +572,7 @@ f00bar;
// work around magic quotes // work around magic quotes
$content = get_magic_quotes_gpc() == 1 ? stripslashes($d['content']) : $d['content']; $content = get_magic_quotes_gpc() == 1 ? stripslashes($d['content']) : $d['content'];
if (@file_put_contents($d['filename'], $content) !== false) if (@file_put_contents($d['filename'], $content) !== false)
return ["status" => "OK", "message" => $this->l('file_save_success')]); return ["status" => "OK", "message" => $this->l('file_save_success')];
else else
throw new Exception($this->l('file_save_error')); throw new Exception($this->l('file_save_error'));
} else } else
@@ -593,7 +591,7 @@ f00bar;
$content = @file_get_contents($d['filename']); $content = @file_get_contents($d['filename']);
if (function_exists("mb_check_encoding") && !mb_check_encoding($content, "UTF-8")) if (function_exists("mb_check_encoding") && !mb_check_encoding($content, "UTF-8"))
$content = utf8_encode($content); $content = utf8_encode($content);
return ["status" => "OK", "data" => ["filename" => $d['filename'], "content" => $content]]); return ["status" => "OK", "data" => ["filename" => $d['filename'], "content" => $content]];
} else } else
throw new IFMException($this->l('file_not_found')); throw new IFMException($this->l('file_not_found'));
} }
@@ -623,7 +621,7 @@ f00bar;
} }
} }
if (empty($err)) if (empty($err))
return ["status" => "OK", "message" => $this->l('file_delete_success'), "errflag" => "1"]); return ["status" => "OK", "message" => $this->l('file_delete_success'), "errflag" => "1"];
else { else {
$errmsg = $this->l('file_delete_error') . "<ul>"; $errmsg = $this->l('file_delete_error') . "<ul>";
foreach ($err as $item) foreach ($err as $item)
@@ -638,7 +636,7 @@ f00bar;
if ($this->config['rename'] != 1) if ($this->config['rename'] != 1)
throw new IFMException($this->l('nopermissions')); throw new IFMException($this->l('nopermissions'));
elseif (!$this->isFilenameValid($d['filename']) || !$this->isFilenameValid($d['newname'])) elseif (!$this->isFilenameValid($d['filename']) || !$this->isFilenameValid($d['newname']))
throw new IFMException($this->l('invalid_filename'))); throw new IFMException($this->l('invalid_filename'));
if (@rename($d['filename'], $d['newname'])) if (@rename($d['filename'], $d['newname']))
return ["status" => "OK", "message" => $this->l('file_rename_success')]; return ["status" => "OK", "message" => $this->l('file_rename_success')];
@@ -912,8 +910,8 @@ f00bar;
private function l($str) { private function l($str) {
if (isset($_REQUEST['lang']) if (isset($_REQUEST['lang'])
&& in_array($_REQUEST['lang'], array_keys($this->i18n)) && in_array($_REQUEST['lang'], array_keys($this->i18n))
&& isset($this->i18n[$_REQUEST['lang'][$str])) && isset($this->i18n[$_REQUEST['lang']][$str]))
return $this->i18n[$_REQUEST['lang'][$str]; return $this->i18n[$_REQUEST['lang']][$str];
else else
return $this->i18n['en'][$str]; return $this->i18n['en'][$str];
} }

View File

@@ -103,7 +103,7 @@ body {
} }
</style> </style>
<form id="loginForm" class="form-signin"> <form id="loginForm" class="form-signin" method="post">
<div class="text-center mb-4"> <div class="text-center mb-4">
<h1 class="h3 mb-3 font-weight-normal">IFM {{i18n.login}}</h1> <h1 class="h3 mb-3 font-weight-normal">IFM {{i18n.login}}</h1>
</div> </div>