From 4c8736c3a1dc38b9815a08c91fead004430d6f5e Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Mon, 8 Apr 2019 10:31:04 +0200 Subject: [PATCH] Visual Console Refactor: refactored the visual console view Former-commit-id: dbbed082521ea878edd4765971f058733f691c51 --- .../visual_console/visual_console_view.php | 67 ++++++++++--------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/pandora_console/operation/visual_console/visual_console_view.php b/pandora_console/operation/visual_console/visual_console_view.php index 6922c972c8..b5050b136b 100644 --- a/pandora_console/operation/visual_console/visual_console_view.php +++ b/pandora_console/operation/visual_console/visual_console_view.php @@ -19,11 +19,7 @@ check_login(); require_once $config['homedir'].'/vendor/autoload.php'; require_once $config['homedir'].'/include/functions_visual_map.php'; -if (!defined('METACONSOLE')) { - $id_layout = (int) get_parameter('id'); -} else { - $id_layout = (int) get_parameter('id_visualmap'); -} +$id_layout = (int) get_parameter(!is_metaconsole() ? 'id' : 'id_visualmap'); // Get input parameter for layout id. if (!$id_layout) { @@ -138,31 +134,35 @@ if (!is_metaconsole()) { html_print_input_hidden('metaconsole', 1); } -use Models\VisualConsole\Container; +use Models\VisualConsole\Container as VisualConsole; -$container = (string) Container::fromArray($layout); -$items = Container::getItemsFromDB($id_layout); +$visualConsole = VisualConsole::fromArray($layout); +$visualConsoleItems = VisualConsole::getItemsFromDB($id_layout); echo '
'; -$dir = $config['homedir'].'/include/visual-console/'; +// TODO: Extract to a function. +$vcClientPath = 'include/visual-console-client'; +$dir = $config['homedir'].'/'.$vcClientPath; if (is_dir($dir)) { $dh = opendir($dir); if ($dh) { while (($file = readdir($dh)) !== false) { - if ($file !== '.' && $file !== '..') { - preg_match('/.*.js$/', $file, $match_js, PREG_OFFSET_CAPTURE); - if (!empty($match_js)) { - echo ''; - continue; - } + if ($file === '.' || $file === '..') { + continue; + } - preg_match('/.*.css$/', $file, $match_css, PREG_OFFSET_CAPTURE); - if (!empty($match_css)) { - echo ''; - } + preg_match('/.*.js$/', $file, $match, PREG_OFFSET_CAPTURE); + if (empty($match) === false) { + $url = ui_get_full_url(false, false, false, false).$vcClientPath.'/'.$match[0][0]; + echo ''; + continue; + } + + preg_match('/.*.css$/', $file, $match, PREG_OFFSET_CAPTURE); + if (empty($match) === false) { + $url = ui_get_full_url(false, false, false, false).$vcClientPath.'/'.$match[0][0]; + echo ''; } } @@ -170,16 +170,19 @@ if (is_dir($dir)) { } } -echo ''; - ?> - +