mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 10:15:28 +02:00
Various minor adjustments, code plus improvements to ProcessSessionDB module
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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 = "<div id='SessionList'>$out</div>";
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user