From 765f42a4dc402ff1497afb1b99725171fbe49d91 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 6 Mar 2020 13:45:36 -0500 Subject: [PATCH] Various minor adjustments, code plus improvements to ProcessSessionDB module --- wire/core/Modules.php | 2 +- wire/core/Pageimage.php | 12 ++- .../Process/ProcessField/ProcessField.module | 2 +- .../SessionHandlerDB/ProcessSessionDB.module | 85 +++++-------------- 4 files changed, 33 insertions(+), 68 deletions(-) diff --git a/wire/core/Modules.php b/wire/core/Modules.php index e2ba2e62..906b5c82 100644 --- a/wire/core/Modules.php +++ b/wire/core/Modules.php @@ -4133,7 +4133,7 @@ class Modules extends WireArray { } /** - * Is the given namespace a unique recognized module namespace? If yes, returns the path to it. If not, returns boolean false; + * Is the given namespace a unique recognized module namespace? If yes, returns the path to it. If not, returns boolean false. * * #pw-internal * diff --git a/wire/core/Pageimage.php b/wire/core/Pageimage.php index 3b0e5989..31c76ba5 100644 --- a/wire/core/Pageimage.php +++ b/wire/core/Pageimage.php @@ -955,15 +955,19 @@ class Pageimage extends Pagefile { * * #pw-internal * - * @param $width - * @param $height + * @param int|string $width + * @param int|array $height * @param array $options See options in size() method. * @return Pageimage * */ public function hidpiSize($width, $height, $options = array()) { - $options['hidpi'] = true; - return $this->size($width, $height, $options); + if(is_array($height)) { + $height['hidpi'] = true; + } else { + $options['hidpi'] = true; + } + return $this->size($width, $height, $options); } /** diff --git a/wire/modules/Process/ProcessField/ProcessField.module b/wire/modules/Process/ProcessField/ProcessField.module index 5999fabf..912e5eb0 100644 --- a/wire/modules/Process/ProcessField/ProcessField.module +++ b/wire/modules/Process/ProcessField/ProcessField.module @@ -1265,7 +1265,7 @@ class ProcessField extends Process implements ConfigurableModule { } $checkbox->attr('value', "$fieldgroup->id:$key"); - $checkbox->attr('id', '_remove_context' . ($n++)); + $checkbox->attr('id', '_remove_context_' . $fieldgroup->id . '_' . ($n++)); if(!$this->fieldgroup) $row[] = $fieldgroupLabel; diff --git a/wire/modules/Session/SessionHandlerDB/ProcessSessionDB.module b/wire/modules/Session/SessionHandlerDB/ProcessSessionDB.module index 9c897750..6e12faf0 100644 --- a/wire/modules/Session/SessionHandlerDB/ProcessSessionDB.module +++ b/wire/modules/Session/SessionHandlerDB/ProcessSessionDB.module @@ -5,7 +5,7 @@ * * This module accompanies installation of the SessionHandlerDB module * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2020 by Ryan Cramer * https://processwire.com * */ @@ -16,35 +16,46 @@ class ProcessSessionDB extends Process { return array( 'title' => __('Sessions', __FILE__), // getModuleInfo title 'summary' => __('Enables you to browse active database sessions.', __FILE__), // getModuleInfo summary - 'version' => 3, + 'version' => 4, 'permanent' => false, 'icon' => 'dashboard', 'requires' => array('SessionHandlerDB'), - ); + 'page' => array( + 'name' => self::pageName, + 'parent' => 'access', + 'title' => 'Sessions', + )); } const pageName = 'sessions-db'; - public function init() { - return parent::init(); - } - + /** + * Execute display of sessions + * + * @return string + * + */ public function ___execute() { // clean out any stray sessions that may have not yet hit the gc probability // because we don't want them in the list that we display + + /** @var SessionHandlerDB $sessionHandlerDB */ $sessionHandlerDB = $this->modules->get('SessionHandlerDB'); $sessionHandlerDB->gc($this->wire('config')->sessionExpireSeconds); + $useIP = $sessionHandlerDB->useIP; $useUA = $sessionHandlerDB->useUA; - $mins = $this->input->post->mins; - if(!$mins) $mins = (int) $this->session->ProcessSessionDB_mins; + $mins = (int) $this->input->post('mins'); + if(!$mins) $mins = (int) $this->session->get('ProcessSessionDB_mins'); if(!$mins) $mins = 5; - $this->session->ProcessSessionDB_mins = $mins; + $this->session->set('ProcessSessionDB_mins', $mins); + /** @var InputfieldForm $form */ $form = $this->wire('modules')->get('InputfieldForm'); - + + /** @var InputfieldInteger $field */ $field = $this->wire('modules')->get('InputfieldInteger'); $field->attr('name', 'mins'); $field->attr('value', $mins); @@ -137,6 +148,7 @@ class ProcessSessionDB extends Process { if($this->wire('config')->ajax) return $out; + /** @var InputfieldMarkup $markup */ $markup = $this->wire('modules')->get('InputfieldMarkup'); $markup->value = "
$out
"; $form->add($markup); @@ -151,56 +163,5 @@ class ProcessSessionDB extends Process { return $form->render(); } - - /** - * Called only when your module is installed - * - * This version creates a new page with this Process module assigned. - * - */ - public function ___install() { - - // create the page our module will be assigned to - $page = $this->wire('pages')->newPage(); - $page->template = 'admin'; - $page->name = self::pageName; - - // installs to the admin "Setup" menu ... change as you see fit - $page->parent = $this->pages->get($this->config->adminRootPageID)->child('name=setup'); - $page->process = $this; - - // we will make the page title the same as our module title - // but you can make it whatever you want - $info = self::getModuleInfo(); - $page->title = $info['title']; - - // save the page - $page->save(); - - // tell the user we created this page - $this->message("Created Page: {$page->path}"); - } - - /** - * Called only when your module is uninstalled - * - * This should return the site to the same state it was in before the module was installed. - * - */ - public function ___uninstall() { - - // find the page we installed, locating it by the process field (which has the module ID) - // it would probably be sufficient just to locate by name, but this is just to be extra sure. - $moduleID = $this->modules->getModuleID($this); - $page = $this->pages->get("template=admin, process=$moduleID, name=" . self::pageName); - - if($page->id) { - // if we found the page, let the user know and delete it - $this->message("Deleting Page: {$page->path}"); - $page->delete(); - } - } - - }