Skip to content

Commit a7e2318

Browse files
committed
Merge branch 'develop'
2 parents 04beea6 + d9cfcc7 commit a7e2318

22 files changed

+2845
-2136
lines changed

Dashboard.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dashboard.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dashboard.module

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use function ProcessWire\wireIconMarkup;
1313
* @author Philipp Daun <post@philippdaun.net>
1414
* @license GPL-3.0
1515
*
16-
* @version 1.4.2
16+
* @version 1.5.0
1717
*/
1818

1919
// Include abstract panel base class
@@ -31,7 +31,7 @@ class Dashboard extends Process implements Module
3131
'summary' => __('Configurable dashboard page', __FILE__),
3232
'href' => 'https://github.com/daun/processwire-dashboard',
3333
'author' => 'Philipp Daun',
34-
'version' => '1.4.2',
34+
'version' => '1.5.0',
3535
'icon' => 'compass',
3636
'permission' => 'dashboard-view',
3737
'permissions' => [
@@ -70,6 +70,7 @@ class Dashboard extends Process implements Module
7070
* Supported panel sizes.
7171
*/
7272
const panelSizes = [
73+
'micro', // 1/6
7374
'mini', // 1/4
7475
'small', // 1/3
7576
'normal', // 1/2
@@ -116,7 +117,7 @@ class Dashboard extends Process implements Module
116117
'headline_without_user' => $this->_('Welcome'),
117118
'panel_not_found' => $this->_('Dashboard panel not found: %s'),
118119
'empty_panel_notice' => $this->_('Your dashboard is empty'),
119-
'setup_hint' => $this->sanitizer->entitiesMarkdown(
120+
'setup_hint' => $this->wire()->sanitizer->entitiesMarkdown(
120121
$this->_('Learn how to add and configure panels reading the [documentation](%s).')
121122
),
122123
'get_started' => $this->_('Get started'),
@@ -174,19 +175,17 @@ class Dashboard extends Process implements Module
174175
protected function addUserNavItem()
175176
{
176177
$this->addHookAfter('AdminThemeFramework::getUserNavArray', function ($event) {
177-
$navArray = $event->return;
178-
179178
$page = $this->getDashboardPageInNav() ?: $this->getDashboardPage();
180179
if ($page && $page->viewable) {
181180
$icon = $this->modules->getModuleInfoProperty($this, 'icon');
182-
array_unshift($navArray, [
181+
$nav = $event->return;
182+
array_unshift($nav, [
183183
'url' => $page->url,
184184
'title' => $this->texts->usernav,
185185
'icon' => $icon,
186186
]);
187+
$event->return = $nav;
187188
}
188-
189-
$event->return = $navArray;
190189
});
191190
}
192191

@@ -195,7 +194,7 @@ class Dashboard extends Process implements Module
195194
*/
196195
protected function getDashboardPage()
197196
{
198-
$admin = $this->pages->get(2);
197+
$admin = $this->wire()->pages->get($this->wire()->config->adminRootPageID);
199198
$children = $admin->children('include=hidden, check_access=0');
200199

201200
return $admin->and($children)->get("process={$this}");
@@ -206,7 +205,7 @@ class Dashboard extends Process implements Module
206205
*/
207206
protected function getDashboardPageInNav()
208207
{
209-
$admin = $this->pages->get(2);
208+
$admin = $this->wire()->pages->get($this->wire()->config->adminRootPageID);
210209
$pages = $admin->children('check_access=0');
211210

212211
return $pages->get("process={$this}");
@@ -218,10 +217,11 @@ class Dashboard extends Process implements Module
218217
public function ___execute()
219218
{
220219
// Redirect admin homepage to process page if in navigation
221-
if ($this->page->id === 2) {
220+
if ($this->page->id === $this->wire()->config->adminRootPageID) {
222221
$page = $this->getDashboardPageInNav();
223222
if ($page) {
224223
$this->session->redirect($page->url);
224+
return;
225225
}
226226
}
227227

@@ -231,11 +231,16 @@ class Dashboard extends Process implements Module
231231
// Load panel instances from hook
232232
$this->panels = $this->getPanels();
233233

234-
// Ajax request? Render requested panel directly
235-
if ($this->config->ajax && $this->input->post->dashboard) {
236-
$key = $this->input->post->key;
237-
$panel = $this->input->post->panel;
238-
return $this->renderInstanceByKey($key, $panel);
234+
if ($this->config->ajax) {
235+
if ($this->input->post->dashboard) {
236+
// Ajax request? (Re)render a single requested panel
237+
$key = $this->input->post->key;
238+
$panel = $this->input->post->panel;
239+
return $this->renderInstanceByKey($key, $panel);
240+
} else {
241+
// Disregard all other ajax requests
242+
return;
243+
}
239244
}
240245

241246
// Set browser title
@@ -399,7 +404,7 @@ class Dashboard extends Process implements Module
399404
*/
400405
private function getPanelClassName($name)
401406
{
402-
$panelName = $this->sanitizer()->pascalCase($name);
407+
$panelName = $this->wire()->sanitizer->pascalCase($name);
403408

404409
return self::panelModulePrefix.$panelName;
405410
}
@@ -409,10 +414,10 @@ class Dashboard extends Process implements Module
409414
*/
410415
public function sanitizePanelSize($input)
411416
{
412-
$size = $this->sanitizer->option($input, self::panelSizes);
417+
$size = $this->wire()->sanitizer->option($input, self::panelSizes);
413418
if (!$size) {
414419
$default = $this->settings->defaultPanelSize;
415-
$size = $this->sanitizer->option($default, self::panelSizes);
420+
$size = $this->wire()->sanitizer->option($default, self::panelSizes);
416421
}
417422

418423
return $size ?: self::fallbackPanelSize;
@@ -554,7 +559,7 @@ class Dashboard extends Process implements Module
554559
parent::___install();
555560
if ($this->installOnHomepage) {
556561
// Set the admin process to use this module
557-
$admin = $this->pages->get(2);
562+
$admin = $this->wire()->pages->get($this->wire()->config->adminRootPageID);
558563
$admin->process = $this;
559564
$admin->save();
560565
}
@@ -572,7 +577,7 @@ class Dashboard extends Process implements Module
572577
parent::___uninstall();
573578
if ($this->installOnHomepage) {
574579
// Restore the admin process to use ProcessHome again
575-
$admin = $this->pages->get(2);
580+
$admin = $this->wire()->pages->get($this->wire()->config->adminRootPageID);
576581
$admin->process = 'ProcessHome';
577582
$admin->save();
578583
}

DashboardPanel.class.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,20 @@ protected function renderAttributes($attributes = [])
429429
*
430430
* @return string Updated URL
431431
*/
432-
protected function setQueryParameter($url, $key, $value)
432+
protected function setQueryParameter($url, $key, $value = null)
433433
{
434434
$info = parse_url($url);
435435
$query = $info['query'] ?? '';
436436
parse_str($query, $params);
437437

438-
$params[$key] = $value;
438+
if (is_array($key)) {
439+
foreach ($key as $k => $v) {
440+
$params[$k] = $v;
441+
}
442+
} else {
443+
$params[$key] = $value;
444+
}
445+
439446
$query = http_build_query($params);
440447

441448
$result = $info['path'] ?? '';
@@ -543,12 +550,12 @@ final protected function view($view, $variables)
543550
*
544551
* @param Page|int|string|null $input
545552
*
546-
* @return Page|null
553+
* @return Page|NullPage|null
547554
*/
548555
protected function getPageFromObjectOrSelectorOrID($input)
549556
{
550557
if (!$input) {
551-
return;
558+
return null;
552559
}
553560

554561
if (is_object($input) && $input instanceof Page) {
@@ -559,6 +566,6 @@ protected function getPageFromObjectOrSelectorOrID($input)
559566
$page = $this->pages->get($input);
560567
}
561568

562-
return $page;
569+
return $page ?? null;
563570
}
564571
}

DashboardPanelAddNew.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DashboardPanelAddNew extends DashboardPanel
1919
'title' => __('Dashboard Panel: Add New Page', __FILE__),
2020
'summary' => __('Allow adding new pages from the dashboard', __FILE__),
2121
'author' => 'Philipp Daun',
22-
'version' => '1.4.2',
22+
'version' => '1.5.0',
2323
]
2424
);
2525
}

DashboardPanelChart.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DashboardPanelChart extends DashboardPanel
1515
'title' => __('Dashboard Panel: Chart', __FILE__),
1616
'summary' => __('Display a customizable chart from any data source', __FILE__),
1717
'author' => 'Philipp Daun',
18-
'version' => '1.4.2',
18+
'version' => '1.5.0',
1919
]
2020
);
2121
}

0 commit comments

Comments
 (0)