diff --git a/README.md b/README.md
index d3fec79..8443845 100644
--- a/README.md
+++ b/README.md
@@ -3,9 +3,9 @@
FileCache ([`robinn/cache`](https://github.com/RobiNN1/Cache)) dashboard
for [phpCacheAdmin](https://github.com/RobiNN1/phpCacheAdmin).
-
+

-
+
## Installation
@@ -34,4 +34,4 @@ the project or have access to folders outside of website root.
## Requirements
- PHP >= 8.2
-- phpCacheAdmin >= 1.6.0
+- phpCacheAdmin >= 2.0.0
diff --git a/src/FileCacheDashboard.php b/src/FileCacheDashboard.php
index 7f2541f..65ee717 100644
--- a/src/FileCacheDashboard.php
+++ b/src/FileCacheDashboard.php
@@ -21,7 +21,7 @@
class FileCacheDashboard implements DashboardInterface {
use FileCacheTrait;
- final public const VERSION = '1.4.0';
+ final public const VERSION = '1.5.0';
/**
* @var array>
@@ -32,6 +32,11 @@ class FileCacheDashboard implements DashboardInterface {
private FileStorage $filecache;
+ /**
+ * @var array
+ */
+ private array $all_keys = [];
+
public function __construct(private readonly Template $template) {
$this->template->addPath('filecache', __DIR__.'/../templates');
@@ -100,6 +105,19 @@ public function dashboard(): string {
try {
$this->filecache = $this->connect($this->projects[$this->current_project]);
+ $this->all_keys = $this->filecache->keys();
+
+ $projects = [];
+
+ foreach ($this->projects as $id => $project) {
+ if (!isset($project['name'])) {
+ $projects[$id]['name'] = 'Project '.$id;
+ }
+ }
+
+ $select = Helpers::serverSelector($this->template, $projects, $this->current_project);
+
+ $this->template->addGlobal('side', $select.$this->panels());
if (isset($_GET['view'], $_GET['key'])) {
return $this->viewKey();
diff --git a/src/FileCacheTrait.php b/src/FileCacheTrait.php
index d07dc41..e0d8658 100644
--- a/src/FileCacheTrait.php
+++ b/src/FileCacheTrait.php
@@ -16,23 +16,20 @@
use RobiNN\Pca\Value;
trait FileCacheTrait {
- /**
- * @param array $all_keys
- */
- private function panels(array $all_keys): string {
+ private function panels(): string {
$project = $this->projects[$this->current_project];
$panels = [
[
- 'title' => 'FileCache v'.Cache::VERSION.'',
+ 'title' => 'FileCache v'.Cache::VERSION,
'data' => [
'Path' => is_dir((string) $project['path']) ? realpath((string) $project['path']) : $project['path'],
- 'Files' => count($all_keys),
+ 'Files' => count($this->all_keys),
],
],
];
- return $this->template->render('partials/info', ['panels' => $panels, 'thead' => false]);
+ return $this->template->render('partials/info', ['panels' => $panels, 'left' => true]);
}
private function viewKey(): string {
@@ -65,18 +62,16 @@ private function viewKey(): string {
}
/**
- * @param array $all_keys
- *
* @return array>
*/
- private function getAllKeys(array $all_keys): array {
+ private function getAllKeys(): array {
static $keys = [];
$search = Http::get('s', '');
$this->template->addGlobal('search_value', $search);
- foreach ($all_keys as $key) {
- if (count($all_keys) < 1000) {
+ foreach ($this->all_keys as $key) {
+ if (count($this->all_keys) < 1000) {
$ttl = $this->filecache->ttl($key);
$ttl = $ttl === 0 ? 'Doesn\'t expire' : $ttl;
}
@@ -96,24 +91,13 @@ private function getAllKeys(array $all_keys): array {
}
private function mainDashboard(): string {
- $all_keys = $this->filecache->keys();
- $keys = $this->getAllKeys($all_keys);
+ $keys = $this->getAllKeys();
$paginator = new Paginator($this->template, $keys);
- $projects = [];
-
- foreach ($this->projects as $id => $project) {
- if (!isset($project['name'])) {
- $projects[$id]['name'] = 'Project '.$id;
- }
- }
-
return $this->template->render('@filecache/filecache', [
- 'select' => Helpers::serverSelector($this->template, $projects, $this->current_project),
- 'panels' => $this->panels($all_keys),
'keys' => $paginator->getPaginated(),
- 'all_keys' => count($all_keys),
+ 'all_keys' => count($this->all_keys),
'new_key_url' => Http::queryString([], ['form' => 'new']),
'paginator' => $paginator->render(),
'view_key' => Http::queryString([], ['view' => 'key', 'key' => '__key__']),
diff --git a/templates/filecache.twig b/templates/filecache.twig
index c589d04..7634082 100644
--- a/templates/filecache.twig
+++ b/templates/filecache.twig
@@ -1,6 +1,4 @@
-{{ select|raw }}
-{{ panels|raw }}
-
+
{% if all_keys != 0 %}
{{ include('components/search_input.twig') }}