ONO::Lib::File::Server

package ONO::Lib::File::Server;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2000-2025 Jos KIRPS [ www.kirps.com | jos_AT_kirps_DOT_com ]
# and The Joopita Project [ www.joopita.org | contact_AT_joopita_DOT_com ]
#
# This file, as well as other parts of the ONO Software Project or related
# elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################

use strict;

use ONO::FW::User::Screen::Media;
use ONO::IO;

sub browse {

my (
$self,
$db,
$community,
$URL,
$lang,
$BLK_ref,
$vars_ref,
$sql_ref,
) = @_;

#: ONO Fileserver browser.

my %vars = %$vars_ref;
my %sql = %$sql_ref;

my $PAGE;

if ($vars{'server'} && $vars{'server'} !~ /\./) {

if (!$vars{'community_screen'}) {
$vars{'community_screen'} = "media_area";
}

$vars{'area'} = $vars{'server'};
$sql{'area'} = $vars{'server'};

my %setup;

$setup{'media_ext_mode'} = "svr";
$setup{'media_ext_dir'} = "servers";
$setup{'media_ext_lang'} = $lang;
$setup{'media_header'} = "hide";
# $setup{'media_auto_fix'} = 1;

my ($MAIN,$SIDE) = ONO::FW::User::Screen::Media->screen(
$db,
"",
"",
"",
\%setup,
$BLK_ref,
\%vars,
\%sql,
);

$PAGE .= $MAIN;

} else {

$PAGE .= qq~<table class="wide_table bt bb">~;

foreach my $server (ONO::IO->dir("servers")) {

if ($server !~ /\./) {

$PAGE .= qq~ <tr class="vtop row bt bb" onclick="window.location='$URL&server=$server';">
<td class="p10">
<a href="$URL&server=$server">
<img class="block64" src="/ono/osr/images/icons/crystal/64x64/devices/network_local.png" alt="">
</a>
</td>
<td class="p10 w100"><a href="$URL&server=$server">$server</a></td>
</tr>
~;

}

}

$PAGE .= qq~</table>~;


}

return $PAGE;

}

###############################################################################
# end of script
###############################################################################

1;

__END__