Skip to content

Commit

Permalink
Allow URLs in shortcut list
Browse files Browse the repository at this point in the history
  • Loading branch information
daun committed Jan 3, 2020
1 parent 9856683 commit 0969c8d
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions DashboardPanelShortcuts.module
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<li><a href='{$url}'>{$icon} {$title}</a></li>";
Expand All @@ -50,12 +58,15 @@ class DashboardPanelShortcuts extends DashboardPanel {
return "<ul>{$output}</ul>";
}

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') : '';
}

Expand Down

0 comments on commit 0969c8d

Please sign in to comment.