From a2a4e051f5f09e49e8489ef9d3085b61bb976bca Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 12 Apr 2020 12:31:52 +0200 Subject: [PATCH] Multi cache pool support --- plugins/dynamix/Browse.page | 10 +++++++--- plugins/dynamix/include/Browse.php | 22 ++++++++++------------ plugins/dynamix/include/DeviceList.php | 2 +- plugins/dynamix/include/Helpers.php | 8 ++++---- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/plugins/dynamix/Browse.page b/plugins/dynamix/Browse.page index 09a98fa38..e63a52df0 100644 --- a/plugins/dynamix/Browse.page +++ b/plugins/dynamix/Browse.page @@ -14,14 +14,18 @@ Markdown="false" * all copies or substantial portions of the Software. */ ?> + - +
_(Type)__(Name)__(Size)__(Last Modified)__(Location)_
_(Type)__(Name)__(Size)__(Last Modified)__(Location)_
 
diff --git a/plugins/dynamix/include/Browse.php b/plugins/dynamix/include/Browse.php index c565a3d21..00fcfe165 100644 --- a/plugins/dynamix/include/Browse.php +++ b/plugins/dynamix/include/Browse.php @@ -23,22 +23,20 @@ function parent_link() { return ($dir && dirname($dir)!='/' && dirname($dir)!='/mnt' && dirname($dir)!='/mnt/user') ? "Parent Directory" : ""; } function trim_slash($url){ - return preg_replace('/\/\/+/','/',$url); + return preg_replace('://+:','/',$url); } function my_devs(&$devs) { global $disks; $text = []; $i = 0; foreach ($devs as $dev) { - $text[$i] = my_lang(my_disk($dev),3); - if (substr($disks[$dev]['fsType'],0,5)=='luks:') { - switch ($disks[$dev]['luksState']) { - case 0: $text[$i] .= ""._('Not encrypted').""; break; - case 1: $text[$i] .= ""._('Encrypted and unlocked').""; break; - case 2: $text[$i] .= ""._('Locked: missing encryption key').""; break; - case 3: $text[$i] .= ""._('Locked: wrong encryption key').""; break; - default: $text[$i] .= ""._('Locked: unknown error').""; break;} + switch ($disks[$dev]['luksState']) { + case 0: $text[$i] = ""._('Not encrypted').""; break; + case 1: $text[$i] = ""._('Encrypted and unlocked').""; break; + case 2: $text[$i] = ""._('Locked: missing encryption key').""; break; + case 3: $text[$i] = ""._('Locked: wrong encryption key').""; break; + default: $text[$i] = ""._('Locked: unknown error').""; break; } - $i++; + $text[$i++] .= compress($dev,8,0); } return implode(', ',$text); } @@ -48,7 +46,7 @@ $dir = urldecode($_GET['dir']); $path = $_GET['path']; $user = $_GET['user']; $all = $docroot.preg_replace('/([\'" &()[\]\\\\])/','\\\\$1',$dir).'/*'; -$fix = substr($dir,0,4)=='/mnt' ? explode('/',trim_slash($dir))[2] : 'flash'; +$fix = substr($dir,0,4)=='/mnt' ? (explode('/',trim_slash($dir))[2] ?: _('---')) : _('flash'); $fmt = "%F {$display['time']}"; $dirs = $files = []; $total = $i = 0; @@ -64,7 +62,7 @@ while (($row = fgets($stat))!==false) { } pclose($stat); -echo ""._('Type').""._('Name').""._('Size').""._('Last Modified').""._('Location').""; +echo ""._('Type').""._('Name').""._('Size').""._('Last Modified').""._('Location').""; if ($link = parent_link()) echo "
$link"; echo ""; diff --git a/plugins/dynamix/include/DeviceList.php b/plugins/dynamix/include/DeviceList.php index a480c9d4e..a29608b0d 100644 --- a/plugins/dynamix/include/DeviceList.php +++ b/plugins/dynamix/include/DeviceList.php @@ -72,7 +72,7 @@ function device_info(&$disk,$online) { ($disk['type']=='Data' && $disk['status']!='DISK_NP') || ($disk['type']=='Cache' && $disk['status']!='DISK_NP') || ($disk['name']=='flash') || in_array($disk['name'],$pools) || - $disk['type']=='New' ? "".compress($fancyname,15,5)."" : compress($fancyname,15,5); + $disk['type']=='New' ? "".compress($fancyname,12,5)."" : compress($fancyname,12,5); if ($crypto) switch ($disk['luksState']) { case 0: if (!vfs_luks($disk['fsType'])) diff --git a/plugins/dynamix/include/Helpers.php b/plugins/dynamix/include/Helpers.php index 63d5ba309..ba0af5a5e 100644 --- a/plugins/dynamix/include/Helpers.php +++ b/plugins/dynamix/include/Helpers.php @@ -52,9 +52,9 @@ function my_temp($value) { $number = $display['number']; return is_numeric($value) ? (($unit=='F' ? round(9/5*$value+32) : str_replace('.', $number[0], $value))." $unit") : $value; } -function my_disk($name) { +function my_disk($name,$raw=false) { global $display; - return $display['raw'] ? $name : ucfirst(preg_replace('/(\d+)$/',' $1',$name)); + return $display['raw']||$raw ? $name : ucfirst(preg_replace('/(\d+)$/',' $1',$name)); } function my_disks($disk) { return strpos($disk['status'],'_NP')===false; @@ -188,8 +188,8 @@ function day_count($time) { function plus($val, $word, $last) { return $val>0 ? (($val || $last) ? ($val.' '.$word.($val!=1?'s':'').($last ?'':', ')) : '') : ''; } -function compress($name,$size=20,$end=6) { - return strlen($name)<=$size ? $name : substr($name,0,$size-$end-3).'...'.substr($name,-$end); +function compress($name,$size=18,$end=6) { + return strlen($name)<=$size ? $name : substr($name,0,$size-($end?$end-3:0)).'...'.($end?substr($name,-$end):''); } function read_parity_log($epoch, $busy=false) {