From 584d03a9fe02b3b66b06f72ea5d69f7465d63976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Tue, 12 Jun 2018 09:44:53 +0200 Subject: [PATCH 1/5] [ticket/15689] Show statistics of storages on acp_storage PHPBB3-15689 --- phpBB/adm/style/acp_storage.html | 22 ++++++++++++++++++++++ phpBB/language/en/acp/storage.php | 4 ++++ phpBB/phpbb/template/twig/extension.php | 1 + 3 files changed, 27 insertions(+) diff --git a/phpBB/adm/style/acp_storage.html b/phpBB/adm/style/acp_storage.html index 4689a7546d..2d871a6e44 100644 --- a/phpBB/adm/style/acp_storage.html +++ b/phpBB/adm/style/acp_storage.html @@ -6,6 +6,28 @@

{{ lang('STORAGE_TITLE_EXPLAIN') }}

+ + + + + + + + + + + {% for storage in STORAGES %} + + + + + + + {% endfor %} + +
{L_STORAGE_NAME}{L_STORAGE_NUM_FILES}{L_STORAGE_SIZE}{L_STORAGE_FREE}
{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }}{{ storage.get_num_files }}{{ storage.get_size | format_bytes }}{{ storage.free_space | format_bytes }}
+ +
{% for storage in STORAGES %} diff --git a/phpBB/language/en/acp/storage.php b/phpBB/language/en/acp/storage.php index 8d20a24db7..1f43c6963a 100644 --- a/phpBB/language/en/acp/storage.php +++ b/phpBB/language/en/acp/storage.php @@ -43,6 +43,10 @@ $lang = array_merge($lang, array( 'STORAGE_TITLE_EXPLAIN' => 'Change storage providers for the file storage types of phpBB. Choose local or remote providers to store files added to or created by phpBB.', 'STORAGE_SELECT' => 'Select storage', 'STORAGE_SELECT_DESC' => 'Select a storage from the list.', + 'STORAGE_NAME' => 'Storage name', + 'STORAGE_NUM_FILES' => 'Number of files', + 'STORAGE_SIZE' => 'Size', + 'STORAGE_FREE' => 'Available space', // Storage names 'STORAGE_ATTACHMENT_TITLE' => 'Attachments storage', diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index cc8c2acf04..c42ad34692 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -73,6 +73,7 @@ class extension extends \Twig_Extension new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), // @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes new \Twig_SimpleFilter('addslashes', 'addslashes'), + new \Twig_SimpleFilter('format_bytes', 'get_formatted_filesize'), ); } From 0fed1054db5925f24570f6b34224a1bbe3a628d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 1 Jul 2018 19:08:20 +0200 Subject: [PATCH 2/5] [ticket/15689] Show unknown if can't retrieve free space PHPBB3-15689 --- phpBB/adm/style/acp_storage.html | 6 +++++- phpBB/language/en/acp/storage.php | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_storage.html b/phpBB/adm/style/acp_storage.html index 2d871a6e44..5107385834 100644 --- a/phpBB/adm/style/acp_storage.html +++ b/phpBB/adm/style/acp_storage.html @@ -21,7 +21,11 @@ {{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} {{ storage.get_num_files }} {{ storage.get_size | format_bytes }} - {{ storage.free_space | format_bytes }} + {% if storage.free_space !== false %} + {{ storage.free_space | format_bytes }} + {% else %} + {L_STORAGE_UNKNOWN} + {% endif %} {% endfor %} diff --git a/phpBB/language/en/acp/storage.php b/phpBB/language/en/acp/storage.php index 1f43c6963a..5e171ac6f0 100644 --- a/phpBB/language/en/acp/storage.php +++ b/phpBB/language/en/acp/storage.php @@ -47,6 +47,7 @@ $lang = array_merge($lang, array( 'STORAGE_NUM_FILES' => 'Number of files', 'STORAGE_SIZE' => 'Size', 'STORAGE_FREE' => 'Available space', + 'STORAGE_UNKNOWN' => 'Unknown', // Storage names 'STORAGE_ATTACHMENT_TITLE' => 'Attachments storage', From 50af5409a6cade2f4e244cab21ac86a5a585034a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Mon, 9 Jul 2018 15:36:30 +0200 Subject: [PATCH 3/5] [ticket/15689] Remove format_bytes filter from twig PHPBB3-15689 --- phpBB/phpbb/template/twig/extension.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index c42ad34692..cc8c2acf04 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -73,7 +73,6 @@ class extension extends \Twig_Extension new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), // @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes new \Twig_SimpleFilter('addslashes', 'addslashes'), - new \Twig_SimpleFilter('format_bytes', 'get_formatted_filesize'), ); } From f8423600b18fbdac2aa4337d8fb41702c51d2bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Mon, 9 Jul 2018 15:51:52 +0200 Subject: [PATCH 4/5] [ticket/15689] Handle storage stats outside template PHPBB3-15689 --- phpBB/adm/style/acp_storage.html | 15 +++++---------- phpBB/includes/acp/acp_storage.php | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/phpBB/adm/style/acp_storage.html b/phpBB/adm/style/acp_storage.html index 5107385834..79bb1ad79d 100644 --- a/phpBB/adm/style/acp_storage.html +++ b/phpBB/adm/style/acp_storage.html @@ -16,22 +16,17 @@ - {% for storage in STORAGES %} + {% for storage in STORAGE_STATS %} - {{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ storage.get_num_files }} - {{ storage.get_size | format_bytes }} - {% if storage.free_space !== false %} - {{ storage.free_space | format_bytes }} - {% else %} - {L_STORAGE_UNKNOWN} - {% endif %} + {{ storage.name }} + {{ storage.files }} + {{ storage.size }} + {{ storage.free_space }} {% endfor %} - {% for storage in STORAGES %} diff --git a/phpBB/includes/acp/acp_storage.php b/phpBB/includes/acp/acp_storage.php index 4348fb3b21..c08903f54e 100644 --- a/phpBB/includes/acp/acp_storage.php +++ b/phpBB/includes/acp/acp_storage.php @@ -162,8 +162,29 @@ class acp_storage trigger_error($this->lang->lang('STORAGE_NO_CHANGES') . adm_back_link($this->u_action), E_USER_WARNING); } + $storage_stats = []; + foreach ($this->storage_collection as $storage) + { + try + { + $free_space = get_formatted_filesize($storage->free_space()); + } + catch (\phpbb\storage\exception\exception $e) + { + $free_space = $this->lang->lang('STORAGE_UNKNOWN'); + } + + $storage_stats[] = [ + 'name' => $this->lang->lang('STORAGE_' . strtoupper($storage->get_name()) . '_TITLE'), + 'files' => $storage->get_num_files(), + 'size' => get_formatted_filesize($storage->get_size()), + 'free_space' => $free_space, + ]; + } + $this->template->assign_vars(array( 'STORAGES' => $this->storage_collection, + 'STORAGE_STATS' => $storage_stats, 'PROVIDERS' => $this->provider_collection, )); } From 38e657bec5d503c0ed3827a56811dd2fbd0d5a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 14 Jul 2018 11:24:41 +0200 Subject: [PATCH 5/5] [ticket/15689] Use twig syntax PHPBB3-15689 --- phpBB/adm/style/acp_storage.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/adm/style/acp_storage.html b/phpBB/adm/style/acp_storage.html index 79bb1ad79d..0a934cd325 100644 --- a/phpBB/adm/style/acp_storage.html +++ b/phpBB/adm/style/acp_storage.html @@ -9,10 +9,10 @@ - - - - + + + +
{L_STORAGE_NAME}{L_STORAGE_NUM_FILES}{L_STORAGE_SIZE}{L_STORAGE_FREE}{{ lang('STORAGE_NAME') }}{{ lang('STORAGE_NUM_FILES') }}{{ lang('STORAGE_SIZE') }}{{ lang('STORAGE_FREE') }}