mirror of
https://github.com/misterunknown/ifm.git
synced 2025-01-17 12:48:19 +01:00
Sane coding style for PHP part.
Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
parent
65ea1b206a
commit
08742970a4
76
compiler.php
76
compiler.php
@ -9,21 +9,21 @@
|
||||
chdir(realpath(dirname(__FILE__)));
|
||||
|
||||
// output files and common attrs
|
||||
define( "IFM_VERSION", "v2.6.2" );
|
||||
define( "IFM_RELEASE_DIR", "dist/");
|
||||
define( "IFM_STANDALONE", "ifm.php" );
|
||||
define( "IFM_STANDALONE_GZ", "ifm.min.php" );
|
||||
define( "IFM_LIB", "libifm.php" );
|
||||
define("IFM_VERSION", "v2.6.2");
|
||||
define("IFM_RELEASE_DIR", "dist/");
|
||||
define("IFM_STANDALONE", "ifm.php");
|
||||
define("IFM_STANDALONE_GZ", "ifm.min.php");
|
||||
define("IFM_LIB", "libifm.php");
|
||||
|
||||
// php source files
|
||||
$IFM_SRC_PHP = array(
|
||||
$IFM_SRC_PHP = [
|
||||
0 => "src/main.php",
|
||||
1 => "src/ifmarchive.php",
|
||||
2 => "src/htpasswd.php"
|
||||
);
|
||||
];
|
||||
|
||||
// get options
|
||||
$options = getopt(null, array("language::", "languages::", "lang::", "cdn"));
|
||||
$options = getopt(null, ["language::", "languages::", "lang::", "cdn"]);
|
||||
|
||||
// build CDN version?
|
||||
if (isset($options['cdn']))
|
||||
@ -36,6 +36,7 @@ $langs = [];
|
||||
foreach ($options as $key => $value)
|
||||
if (substr($key, 0, 4) == "lang")
|
||||
$langs = array_merge($langs, explode(",", $value));
|
||||
|
||||
$langs = array_unique($langs);
|
||||
if (!empty($langs)) {
|
||||
$vars['default_lang'] = ($langs[0] == "all") ? "en" : $langs[0];
|
||||
@ -65,68 +66,65 @@ foreach ($langs as $l)
|
||||
print "WARNING: Language file src/i18n/".$l.".json not found.\n";
|
||||
|
||||
// Concat PHP Files
|
||||
$compiled = array( "<?php" );
|
||||
foreach( $IFM_SRC_PHP as $phpfile ) {
|
||||
$lines = file( $phpfile );
|
||||
unset( $lines[0] ); // remove <?php line
|
||||
$compiled = array_merge( $compiled, $lines );
|
||||
$compiled = ["<?php"];
|
||||
foreach ($IFM_SRC_PHP as $phpfile) {
|
||||
$lines = file($phpfile);
|
||||
unset($lines[0]); // remove <?php line
|
||||
$compiled = array_merge($compiled, $lines);
|
||||
}
|
||||
$compiled = join( $compiled );
|
||||
$compiled = join($compiled);
|
||||
|
||||
if( IFM_CDN )
|
||||
$IFM_ASSETS = "src/assets.cdn.part";
|
||||
else
|
||||
$IFM_ASSETS = "src/assets.part";
|
||||
$compiled = str_replace( "IFM_ASSETS", file_get_contents("src/assets".(IFM_CDN?".cdn":"").".part"), $compiled );
|
||||
// Include assets
|
||||
$compiled = str_replace("@@@ASSETS_CSS@@@", file_get_contents("src/assets".(IFM_CDN?".cdn":"").".css"), $compiled);
|
||||
$compiled = str_replace("@@@ASSETS_JS@@@", file_get_contents("src/assets".(IFM_CDN?".cdn":"").".js"), $compiled);
|
||||
|
||||
// Process file includes
|
||||
$includes = NULL;
|
||||
preg_match_all( "/\@\@\@file:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
|
||||
foreach( $includes as $file )
|
||||
$compiled = str_replace( $file[0], file_get_contents( $file[1] ), $compiled );
|
||||
preg_match_all("/\@\@\@file:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER);
|
||||
foreach ($includes as $file)
|
||||
$compiled = str_replace($file[0], file_get_contents($file[1]), $compiled);
|
||||
|
||||
// Process ace includes
|
||||
$includes = NULL;
|
||||
$vars['ace_includes'] = "";
|
||||
preg_match_all( "/\@\@\@acedir:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
|
||||
foreach( $includes as $dir ) {
|
||||
preg_match_all("/\@\@\@acedir:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER);
|
||||
foreach ($includes as $dir) {
|
||||
$dircontent = "";
|
||||
foreach( glob( $dir[1]."/*" ) as $file ) {
|
||||
if( is_file( $file ) && is_readable( $file ) ) {
|
||||
$vars['ace_includes'] .= "|" . substr( basename( $file ), 0, strrpos( basename( $file ), "." ) );
|
||||
$dircontent .= file_get_contents( $file )."\n\n";
|
||||
foreach (glob($dir[1] . "/*") as $file) {
|
||||
if (is_file($file) && is_readable($file)) {
|
||||
$vars['ace_includes'] .= "|" . substr(basename($file), 0, strrpos(basename($file), "."));
|
||||
$dircontent .= file_get_contents($file)."\n\n";
|
||||
}
|
||||
}
|
||||
$compiled = str_replace( $dir[0], $dircontent, $compiled );
|
||||
$compiled = str_replace($dir[0], $dircontent, $compiled);
|
||||
}
|
||||
|
||||
// Process variable includes
|
||||
$includes = NULL;
|
||||
preg_match_all( "/\@\@\@vars:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
|
||||
preg_match_all("/\@\@\@vars:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER);
|
||||
foreach( $includes as $var )
|
||||
$compiled = str_replace( $var[0], $vars[$var[1]], $compiled );
|
||||
$compiled = str_replace($var[0], $vars[$var[1]], $compiled);
|
||||
|
||||
$compiled = str_replace( 'IFM_VERSION', IFM_VERSION, $compiled );
|
||||
$compiled = str_replace('IFM_VERSION', IFM_VERSION, $compiled);
|
||||
|
||||
if (!is_dir(IFM_RELEASE_DIR)){
|
||||
if (!is_dir(IFM_RELEASE_DIR))
|
||||
mkdir(IFM_RELEASE_DIR);
|
||||
}
|
||||
|
||||
// build standalone ifm
|
||||
file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE, $compiled );
|
||||
file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE, '
|
||||
file_put_contents(IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE, $compiled);
|
||||
file_put_contents(IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE, '
|
||||
/**
|
||||
* start IFM
|
||||
*/
|
||||
$ifm = new IFM();
|
||||
$ifm->run();
|
||||
', FILE_APPEND );
|
||||
', FILE_APPEND);
|
||||
|
||||
// build compressed ifm
|
||||
file_put_contents(
|
||||
IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE_GZ,
|
||||
'<?php eval( gzdecode( file_get_contents( __FILE__, false, null, 85 ) ) ); exit(0); ?>'
|
||||
. gzencode( file_get_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') .IFM_STANDALONE, false, null, 5 ) )
|
||||
. gzencode(file_get_contents(IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_STANDALONE, false, null, 5))
|
||||
);
|
||||
// build lib
|
||||
file_put_contents( IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_LIB, $compiled );
|
||||
file_put_contents(IFM_RELEASE_DIR . (IFM_CDN ? 'cdn.' : '') . IFM_LIB, $compiled);
|
||||
|
8
src/assets.cdn.css
Normal file
8
src/assets.cdn.css
Normal file
@ -0,0 +1,8 @@
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.css"/>
|
||||
<style type="text/css">
|
||||
@@@file:src/includes/bootstrap-treeview.min.css@@@
|
||||
@@@file:src/includes/fontello-embedded.css@@@
|
||||
@@@file:src/includes/animation.css@@@
|
||||
@@@file:src/style.css@@@
|
||||
</style>
|
15
src/assets.cdn.js
Normal file
15
src/assets.cdn.js
Normal file
@ -0,0 +1,15 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.8/ace.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.3.2/mustache.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mouse0270-bootstrap-notify/3.1.7/bootstrap-notify.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/classnames/2.2.6/index.min.js"></script>
|
||||
<script>
|
||||
@@@file:src/includes/bootstrap-treeview.min.js@@@
|
||||
@@@file:src/includes/BootstrapMenu.min.js@@@
|
||||
@@@file:src/ifm.js@@@
|
||||
</script>
|
@ -1,32 +0,0 @@
|
||||
public function getCSS() {
|
||||
print '
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.css"/>
|
||||
<style type="text/css">';?> @@@file:src/includes/bootstrap-treeview.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/fontello-embedded.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/animation.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/style.css@@@ <?php print '</style>
|
||||
';
|
||||
}
|
||||
|
||||
public function getJS() {
|
||||
print '
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.8/ace.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.3.2/mustache.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mouse0270-bootstrap-notify/3.1.7/bootstrap-notify.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/classnames/2.2.6/index.min.js"></script>
|
||||
';
|
||||
echo <<<'f00bar'
|
||||
<script>
|
||||
@@@file:src/includes/bootstrap-treeview.min.js@@@
|
||||
@@@file:src/includes/BootstrapMenu.min.js@@@
|
||||
@@@file:src/ifm.js@@@
|
||||
</script>
|
||||
f00bar;
|
||||
}
|
8
src/assets.css
Normal file
8
src/assets.css
Normal file
@ -0,0 +1,8 @@
|
||||
<style type="text/css">
|
||||
@@@file:src/includes/bootstrap.min.css@@@
|
||||
@@@file:src/includes/bootstrap-treeview.min.css@@@
|
||||
@@@file:src/includes/datatables.min.css@@@
|
||||
@@@file:src/includes/fontello-embedded.css@@@
|
||||
@@@file:src/includes/animation.css@@@
|
||||
@@@file:src/style.css@@@
|
||||
</style>
|
16
src/assets.js
Normal file
16
src/assets.js
Normal file
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
@@@file:src/includes/jquery.min.js@@@
|
||||
@@@file:src/includes/jquery-ui.min.js@@@
|
||||
@@@file:src/includes/popper.min.js@@@
|
||||
@@@file:src/includes/bootstrap.min.js@@@
|
||||
@@@file:src/includes/bootstrap-notify.min.js@@@
|
||||
@@@file:src/includes/bootstrap-treeview.min.js@@@
|
||||
@@@file:src/includes/datatables.min.js@@@
|
||||
@@@file:src/includes/lodash.min.js@@@
|
||||
@@@file:src/includes/classnames.js@@@
|
||||
@@@file:src/includes/BootstrapMenu.min.js@@@
|
||||
@@@file:src/includes/mustache.min.js@@@
|
||||
@@@file:src/includes/ace.js@@@
|
||||
@@@acedir:src/includes/ace@@@
|
||||
@@@file:src/ifm.js@@@
|
||||
</script>
|
@ -1,31 +0,0 @@
|
||||
public function getCSS() {
|
||||
print '
|
||||
<style type="text/css">';?> @@@file:src/includes/bootstrap.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/bootstrap-treeview.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/datatables.min.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/fontello-embedded.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/includes/animation.css@@@ <?php print '</style>
|
||||
<style type="text/css">';?> @@@file:src/style.css@@@ <?php print '</style>
|
||||
';
|
||||
}
|
||||
|
||||
public function getJS() {
|
||||
echo <<<'f00bar'
|
||||
<script>
|
||||
@@@file:src/includes/jquery.min.js@@@
|
||||
@@@file:src/includes/jquery-ui.min.js@@@
|
||||
@@@file:src/includes/popper.min.js@@@
|
||||
@@@file:src/includes/bootstrap.min.js@@@
|
||||
@@@file:src/includes/bootstrap-notify.min.js@@@
|
||||
@@@file:src/includes/bootstrap-treeview.min.js@@@
|
||||
@@@file:src/includes/datatables.min.js@@@
|
||||
@@@file:src/includes/lodash.min.js@@@
|
||||
@@@file:src/includes/classnames.js@@@
|
||||
@@@file:src/includes/BootstrapMenu.min.js@@@
|
||||
@@@file:src/includes/mustache.min.js@@@
|
||||
@@@file:src/includes/ace.js@@@
|
||||
@@@acedir:src/includes/ace@@@
|
||||
@@@file:src/ifm.js@@@
|
||||
</script>
|
||||
f00bar;
|
||||
}
|
291
src/ifm.js
291
src/ifm.js
@ -290,132 +290,133 @@ function IFM(params) {
|
||||
});
|
||||
|
||||
if( self.config.contextmenu && !!( self.config.edit || self.config.extract || self.config.rename || self.config.copymove || self.config.download || self.config.delete ) ) {
|
||||
// create the context menu, this also uses jquery, AFAIK
|
||||
var contextMenu = new BootstrapMenu( '.clickable-row', {
|
||||
fetchElementData: function( row ) {
|
||||
var data = {};
|
||||
data.selected =
|
||||
Array.prototype.slice.call( document.getElementsByClassName( 'selectedItem' ) )
|
||||
.map( function(e){ return self.fileCache.find( x => x.guid == e.children[0].children[0].id ); } );
|
||||
data.clicked = self.fileCache.find( x => x.guid == row[0].children[0].children[0].id );
|
||||
return data;
|
||||
},
|
||||
actionsGroups:[
|
||||
['edit', 'extract', 'rename', 'copylink'],
|
||||
['copymove', 'download', 'createarchive', 'delete']
|
||||
],
|
||||
actions: {
|
||||
edit: {
|
||||
name: self.i18n.edit,
|
||||
onClick: function( data ) {
|
||||
self.editFile( data.clicked.name );
|
||||
},
|
||||
iconClass: "icon icon-pencil",
|
||||
isShown: function( data ) {
|
||||
return !!( self.config.edit && data.clicked.eaction == "edit" && !data.selected.length );
|
||||
}
|
||||
// initialize the context menu, this also uses jquery, AFAIK
|
||||
if (!self.contextMenu)
|
||||
self.contextMenu = new BootstrapMenu( '.clickable-row', {
|
||||
fetchElementData: function( row ) {
|
||||
var data = {};
|
||||
data.selected =
|
||||
Array.prototype.slice.call( document.getElementsByClassName( 'selectedItem' ) )
|
||||
.map( function(e){ return self.fileCache.find( x => x.guid == e.children[0].children[0].id ); } );
|
||||
data.clicked = self.fileCache.find( x => x.guid == row[0].children[0].children[0].id );
|
||||
return data;
|
||||
},
|
||||
extract: {
|
||||
name: self.i18n.extract,
|
||||
onClick: function( data ) {
|
||||
self.showExtractFileDialog( data.clicked.name );
|
||||
},
|
||||
iconClass: "icon icon-archive",
|
||||
isShown: function( data ) {
|
||||
return !!( self.config.extract && data.clicked.eaction == "extract" && !data.selected.length );
|
||||
}
|
||||
},
|
||||
rename: {
|
||||
name: self.i18n.rename,
|
||||
onClick: function( data ) {
|
||||
self.showRenameFileDialog( data.clicked.name );
|
||||
},
|
||||
iconClass: "icon icon-terminal",
|
||||
isShown: function( data ) { return !!( self.config.rename && !data.selected.length && data.clicked.name != ".." ); }
|
||||
},
|
||||
copylink: {
|
||||
name: self.i18n.copylink,
|
||||
onClick: function( data ) {
|
||||
if( data.clicked.link.toLowerCase().substr(0,4) == "http" )
|
||||
self.copyToClipboard( data.clicked.link );
|
||||
else {
|
||||
var pathname = window.location.pathname.replace( /^\/*/g, '' ).split( '/' );
|
||||
pathname.pop();
|
||||
var link = self.pathCombine( window.location.origin, data.clicked.link )
|
||||
if( pathname.length > 0 )
|
||||
link = self.pathCombine( window.location.origin, pathname.join( '/' ), data.clicked.link )
|
||||
self.copyToClipboard( link );
|
||||
actionsGroups:[
|
||||
['edit', 'extract', 'rename', 'copylink'],
|
||||
['copymove', 'download', 'createarchive', 'delete']
|
||||
],
|
||||
actions: {
|
||||
edit: {
|
||||
name: self.i18n.edit,
|
||||
onClick: function( data ) {
|
||||
self.editFile( data.clicked.name );
|
||||
},
|
||||
iconClass: "icon icon-pencil",
|
||||
isShown: function( data ) {
|
||||
return !!( self.config.edit && data.clicked.eaction == "edit" && !data.selected.length );
|
||||
}
|
||||
},
|
||||
iconClass: "icon icon-link-ext",
|
||||
isShown: function( data ) { return !!( !data.selected.length && data.clicked.name != ".." ); }
|
||||
},
|
||||
copymove: {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.copy+'/'+self.i18n.move+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.copy+'/'+self.i18n.move;
|
||||
extract: {
|
||||
name: self.i18n.extract,
|
||||
onClick: function( data ) {
|
||||
self.showExtractFileDialog( data.clicked.name );
|
||||
},
|
||||
iconClass: "icon icon-archive",
|
||||
isShown: function( data ) {
|
||||
return !!( self.config.extract && data.clicked.eaction == "extract" && !data.selected.length );
|
||||
}
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showCopyMoveDialog( data.selected );
|
||||
else
|
||||
self.showCopyMoveDialog( data.clicked );
|
||||
rename: {
|
||||
name: self.i18n.rename,
|
||||
onClick: function( data ) {
|
||||
self.showRenameFileDialog( data.clicked.name );
|
||||
},
|
||||
iconClass: "icon icon-terminal",
|
||||
isShown: function( data ) { return !!( self.config.rename && !data.selected.length && data.clicked.name != ".." ); }
|
||||
},
|
||||
iconClass: "icon icon-folder-empty",
|
||||
isShown: function( data ) { return !!( self.config.copymove && data.clicked.name != ".." ); }
|
||||
},
|
||||
download: {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.download+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.download;
|
||||
copylink: {
|
||||
name: self.i18n.copylink,
|
||||
onClick: function( data ) {
|
||||
if( data.clicked.link.toLowerCase().substr(0,4) == "http" )
|
||||
self.copyToClipboard( data.clicked.link );
|
||||
else {
|
||||
var pathname = window.location.pathname.replace( /^\/*/g, '' ).split( '/' );
|
||||
pathname.pop();
|
||||
var link = self.pathCombine( window.location.origin, data.clicked.link )
|
||||
if( pathname.length > 0 )
|
||||
link = self.pathCombine( window.location.origin, pathname.join( '/' ), data.clicked.link )
|
||||
self.copyToClipboard( link );
|
||||
}
|
||||
},
|
||||
iconClass: "icon icon-link-ext",
|
||||
isShown: function( data ) { return !!( !data.selected.length && data.clicked.name != ".." ); }
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showMessage( "At the moment it is not possible to download a set of files." );
|
||||
else
|
||||
window.location = data.clicked.download.link;
|
||||
copymove: {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.copy+'/'+self.i18n.move+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.copy+'/'+self.i18n.move;
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showCopyMoveDialog( data.selected );
|
||||
else
|
||||
self.showCopyMoveDialog( data.clicked );
|
||||
},
|
||||
iconClass: "icon icon-folder-empty",
|
||||
isShown: function( data ) { return !!( self.config.copymove && data.clicked.name != ".." ); }
|
||||
},
|
||||
iconClass: "icon icon-download",
|
||||
isShown: function() { return !!self.config.download; }
|
||||
},
|
||||
createarchive: {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.create_archive+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.create_archive;
|
||||
download: {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.download+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.download;
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showMessage( "At the moment it is not possible to download a set of files." );
|
||||
else
|
||||
window.location = data.clicked.download.link;
|
||||
},
|
||||
iconClass: "icon icon-download",
|
||||
isShown: function() { return !!self.config.download; }
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showCreateArchiveDialog( data.selected );
|
||||
else
|
||||
self.showCreateArchiveDialog( data.clicked );
|
||||
createarchive: {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.create_archive+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.create_archive;
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showCreateArchiveDialog( data.selected );
|
||||
else
|
||||
self.showCreateArchiveDialog( data.clicked );
|
||||
},
|
||||
iconClass: "icon icon-archive",
|
||||
isShown: function( data ) { return !!( self.config.createarchive && data.clicked.name != ".." ); }
|
||||
},
|
||||
iconClass: "icon icon-archive",
|
||||
isShown: function( data ) { return !!( self.config.createarchive && data.clicked.name != ".." ); }
|
||||
},
|
||||
'delete': {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.delete+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.delete;
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showDeleteDialog( data.selected );
|
||||
else
|
||||
self.showDeleteDialog( data.clicked );
|
||||
},
|
||||
iconClass: "icon icon-trash",
|
||||
isShown: function( data ) { return !!( self.config.delete && data.clicked.name != ".." ); }
|
||||
'delete': {
|
||||
name: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
return self.i18n.delete+' <span class="badge">'+data.selected.length+'</span>';
|
||||
else
|
||||
return self.i18n.delete;
|
||||
},
|
||||
onClick: function( data ) {
|
||||
if( data.selected.length > 0 )
|
||||
self.showDeleteDialog( data.selected );
|
||||
else
|
||||
self.showDeleteDialog( data.clicked );
|
||||
},
|
||||
iconClass: "icon icon-trash",
|
||||
isShown: function( data ) { return !!( self.config.delete && data.clicked.name != ".." ); }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -1534,9 +1535,9 @@ function IFM(params) {
|
||||
*
|
||||
* @param string m - message text
|
||||
*/
|
||||
this.log = function( m ) {
|
||||
if( self.config.debug ) {
|
||||
console.log( "IFM (debug): " + m );
|
||||
this.log = function(m) {
|
||||
if (self.config.debug) {
|
||||
console.log("IFM (debug): " + m);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1835,8 +1836,8 @@ function IFM(params) {
|
||||
dataType: "json",
|
||||
success: function(d) {
|
||||
self.i18n = d;
|
||||
self.log( "I18N loaded" );
|
||||
self.initApplication();
|
||||
self.log("I18N loaded");
|
||||
self.initCheckAuth();
|
||||
},
|
||||
error: function() {
|
||||
throw new Error( self.i18n.load_text_error );
|
||||
@ -1844,6 +1845,50 @@ function IFM(params) {
|
||||
});
|
||||
};
|
||||
|
||||
this.initCheckAuth = function() {
|
||||
$.ajax({
|
||||
url: self.api,
|
||||
type: "POST",
|
||||
data: {
|
||||
api: "checkAuth"
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(d) {
|
||||
if (d.status == "ERROR") {
|
||||
self.showModal(Mustache.render(self.templates.login, {i18n: self.i18n}), {large: true});
|
||||
|
||||
var form = document.forms.loginForm;
|
||||
form.addEventListener('click', function(e) {
|
||||
if (e.target.id == "buttonLogin") {
|
||||
$.ajax({
|
||||
url: self.api,
|
||||
type: "POST",
|
||||
data: {
|
||||
api: "checkAuth",
|
||||
inputLogin: form.elements[0].value,
|
||||
inputPassword: form.elements[1].value
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(e) {
|
||||
self.hideModal();
|
||||
self.initApplication();
|
||||
},
|
||||
error: function(e) {
|
||||
self.showMessage("Authentication failed", "e");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
self.initApplication();
|
||||
}
|
||||
},
|
||||
error: function(resp) {
|
||||
throw new Error("Not authenticated");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.initApplication = function() {
|
||||
self.rootElement.innerHTML = Mustache.render(
|
||||
self.templates.app,
|
||||
@ -1998,8 +2043,8 @@ function IFM(params) {
|
||||
}
|
||||
};
|
||||
|
||||
this.init = function( id ) {
|
||||
self.rootElement = document.getElementById( id );
|
||||
this.init = function(id) {
|
||||
self.rootElement = document.getElementById(id);
|
||||
this.initLoadConfig();
|
||||
};
|
||||
}
|
||||
|
1533
src/main.php
1533
src/main.php
File diff suppressed because it is too large
Load Diff
@ -103,7 +103,7 @@ body {
|
||||
}
|
||||
</style>
|
||||
|
||||
<form class="form-signin" method="POST" action>
|
||||
<form id="loginForm" class="form-signin">
|
||||
<div class="text-center mb-4">
|
||||
<h1 class="h3 mb-3 font-weight-normal">IFM {{i18n.login}}</h1>
|
||||
</div>
|
||||
@ -118,6 +118,6 @@ body {
|
||||
</div>
|
||||
<div class="alert alert-danger d-none" role="alert"></div>
|
||||
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{{i18n.login}}</button>
|
||||
<button id="buttonLogin" class="btn btn-lg btn-primary btn-block" type="submit">{{i18n.login}}</button>
|
||||
|
||||
</form>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user