From 0969c8d4e4215e5afb50dad4e7dbdbbe68e19466 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Fri, 3 Jan 2020 20:15:41 +0100 Subject: [PATCH] Allow URLs in shortcut list --- DashboardPanelShortcuts.module | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/DashboardPanelShortcuts.module b/DashboardPanelShortcuts.module index 23c1a8c..e8d40d6 100755 --- a/DashboardPanelShortcuts.module +++ b/DashboardPanelShortcuts.module @@ -27,20 +27,28 @@ class DashboardPanelShortcuts extends DashboardPanel { } $rows = array_map(function ($shortcut, $key) { + $page = null; + $url = ''; if (is_object($shortcut) && $shortcut instanceof Page) { $page = $shortcut; } else if (is_int($shortcut)) { $page = $this->pages->get($shortcut); } else if (is_string($shortcut)) { - $page = $this->pages->get($shortcut); + if (Selectors::stringHasSelector($shortcut)) { + $page = $this->pages->get($shortcut); + } else { + $url = $shortcut; + } } - if (!$page) { + if ($page) { + $title = is_string($key) ? $key : $page->title; + $url = $page->url; + } else if ($url) { + $title = $key; + } else { return; } - - $title = is_string($key) ? $key : $page->title; - $url = $page->url; $icon = $this->renderPageIcon($page); return "
  • {$icon} {$title}
  • "; @@ -50,12 +58,15 @@ class DashboardPanelShortcuts extends DashboardPanel { return ""; } - protected function renderPageIcon($page) { - if ($this->icon === null) { - $icon = $page->getIcon() ?: $this->fallbackIcon; - } else if ($this->icon) { + protected function renderPageIcon($page = null) { + if ($this->icon !== null) { $icon = $this->icon; + } elseif ($page) { + $icon = $page->getIcon() ?: $this->fallbackIcon; + } else { + $icon = $this->fallbackIcon; } + return $icon ? wireIconMarkup($icon, 'fw') : ''; }