1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00

Various minor updates

This commit is contained in:
Ryan Cramer
2019-06-07 12:08:55 -04:00
parent a88c6a49c7
commit f6c210f686
7 changed files with 75 additions and 52 deletions

View File

@@ -621,6 +621,8 @@ $config->fileContentTypes = array(
* #property string sharpening Sharpening mode, enter one of: none, soft, medium, strong * #property string sharpening Sharpening mode, enter one of: none, soft, medium, strong
* #property int quality Image quality, enter a value between 1 and 100, where 100 is highest quality (and largest files) * #property int quality Image quality, enter a value between 1 and 100, where 100 is highest quality (and largest files)
* #property float defaultGamma Default gamma of 0.5 to 4.0 or -1 to disable gamma correction (default=2.0) * #property float defaultGamma Default gamma of 0.5 to 4.0 or -1 to disable gamma correction (default=2.0)
* #property bool webpAdd Create a WEBP copy with every new image variation? (default=false)
* #property int webpQuality Quality setting of 1-100 where higher is better but bigger (default=90)
* *
* @var array * @var array
* *

View File

@@ -708,6 +708,7 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
* *
*/ */
public function ___renderValue() { public function ___renderValue() {
if(!count($this->children)) return '';
$this->addClass('InputfieldRenderValueMode'); $this->addClass('InputfieldRenderValueMode');
$this->set('renderValueMode', true); $this->set('renderValueMode', true);
$out = $this->render(); $out = $this->render();
@@ -806,7 +807,7 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
$inputfield->resetTrackChanges(); $inputfield->resetTrackChanges();
} }
if(is_null($out)) return ''; if(is_null($out)) return '';
if(!strlen($out)) $out = ' '; // prevent output from being skipped over if(!strlen($out) && !$inputfield instanceof InputfieldWrapper) $out = ' '; // prevent output from being skipped over
return $out; return $out;
} }

View File

@@ -310,6 +310,7 @@ class Modules extends WireArray {
* *
*/ */
public function __construct($path) { public function __construct($path) {
parent::__construct();
$this->addPath($path); $this->addPath($path);
$this->coreModulesDir = '/' . $this->wire('config')->urls->data('modules'); $this->coreModulesDir = '/' . $this->wire('config')->urls->data('modules');
} }
@@ -2690,7 +2691,6 @@ class Modules extends WireArray {
* - `minify` (bool): Remove non-applicable and properties that match defaults? (default=false, or true when getting `all`) * - `minify` (bool): Remove non-applicable and properties that match defaults? (default=false, or true when getting `all`)
* - `noCache` (bool): prevents use of cache to retrieve the module info. (default=false) * - `noCache` (bool): prevents use of cache to retrieve the module info. (default=false)
* @return array Associative array of module information * @return array Associative array of module information
* @throws WireException when a module exists but has no means of returning module info
* @see Modules::getModuleInfoVerbose() * @see Modules::getModuleInfoVerbose()
* @todo move all getModuleInfo methods to their own ModuleInfo class and break this method down further. * @todo move all getModuleInfo methods to their own ModuleInfo class and break this method down further.
* *
@@ -3014,7 +3014,6 @@ class Modules extends WireArray {
* - `noCache` (bool): prevents use of cache to retrieve the module info * - `noCache` (bool): prevents use of cache to retrieve the module info
* - `noInclude` (bool): prevents include() of the module file, applicable only if it hasn't already been included * - `noInclude` (bool): prevents include() of the module file, applicable only if it hasn't already been included
* @return array Associative array of module information * @return array Associative array of module information
* @throws WireException when a module exists but has no means of returning module info
* @see Modules::getModuleInfo() * @see Modules::getModuleInfo()
* *
*/ */

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,9 @@
& > .InputfieldContent > ul.Inputfields { & > .InputfieldContent > ul.Inputfields {
margin-bottom: 1em; margin-bottom: 1em;
&:last-child {
margin-bottom: 0;
}
} }
.InputfieldRepeaterItem > .InputfieldHeader { .InputfieldRepeaterItem > .InputfieldHeader {

View File

@@ -115,7 +115,8 @@ class ImageSizerEngineIMagick extends ImageSizerEngine {
* *
*/ */
protected function validSourceImageFormats() { protected function validSourceImageFormats() {
return array('JPG', 'JPEG', 'PNG24', 'PNG8', 'PNG', 'GIF', 'GIF87'); // 2019/06/07: “PNG8” removed because some versions of ImageMagick have some bug, may be able to add back later
return array('JPG', 'JPEG', 'PNG24', 'PNG', 'GIF', 'GIF87');
//return array( //return array(
// 'PNG', 'PNG8', 'PNG24', // 'PNG', 'PNG8', 'PNG24',
// 'JPG', 'JPEG', // 'JPG', 'JPEG',

View File

@@ -11,7 +11,7 @@
* This version also lifts several pieces of code from Soma's Modules Manager * This version also lifts several pieces of code from Soma's Modules Manager
* specific to the parts involved with downloading modules from the directory. * specific to the parts involved with downloading modules from the directory.
* *
* ProcessWire 3.x, Copyright 2018 by Ryan Cramer * ProcessWire 3.x, Copyright 2019 by Ryan Cramer
* https://processwire.com * https://processwire.com
* *
* @todo add support for module configuration inputfields with useLanguages option * @todo add support for module configuration inputfields with useLanguages option
@@ -123,7 +123,7 @@ class ProcessModule extends Process {
public function __construct() { public function __construct() {
$this->labels['download'] = $this->_('Download'); $this->labels['download'] = $this->_('Download');
if($this->input->get->update) { if($this->input->get('update')) {
$this->labels['download_install'] = $this->_('Download and Update'); $this->labels['download_install'] = $this->_('Download and Update');
} else { } else {
$this->labels['download_install'] = $this->_('Download and Install'); $this->labels['download_install'] = $this->_('Download and Install');
@@ -263,9 +263,9 @@ class ProcessModule extends Process {
} }
ksort($this->modulesArray); ksort($this->modulesArray);
if($this->input->post->install) { if($this->input->post('install')) {
$this->session->CSRF->validate(); $this->session->CSRF->validate();
$name = $this->wire('sanitizer')->name($this->input->post->install); $name = $this->wire('sanitizer')->name($this->input->post('install'));
if($name && isset($this->modulesArray[$name]) && !$this->modulesArray[$name]) { if($name && isset($this->modulesArray[$name]) && !$this->modulesArray[$name]) {
$module = $this->modules->install($name, array('force' => true)); $module = $this->modules->install($name, array('force' => true));
if($module) { if($module) {
@@ -279,9 +279,9 @@ class ProcessModule extends Process {
} }
} }
if($this->input->post->delete) { if($this->input->post('delete')) {
$this->session->CSRF->validate(); $this->session->CSRF->validate();
$name = $this->input->post->delete; $name = $this->input->post('delete');
if($name && isset($this->modulesArray[$name])) { if($name && isset($this->modulesArray[$name])) {
$info = $this->modules->getModuleInfoVerbose($name); $info = $this->modules->getModuleInfoVerbose($name);
try { try {
@@ -295,24 +295,24 @@ class ProcessModule extends Process {
} }
} }
if($this->input->post->download && $this->input->post->download_name) { if($this->input->post('download') && $this->input->post('download_name')) {
$this->session->CSRF->validate(); $this->session->CSRF->validate();
return $this->downloadConfirm($this->input->post->download_name); return $this->downloadConfirm($this->input->post('download_name'));
} else if($this->input->get->download_name) { } else if($this->input->get('download_name')) {
return $this->downloadConfirm($this->input->get->download_name); return $this->downloadConfirm($this->input->get('download_name'));
} }
if($this->input->post->upload) { if($this->input->post('upload')) {
$this->session->CSRF->validate(); $this->session->CSRF->validate();
$this->executeUpload('upload_module'); $this->executeUpload('upload_module');
} }
if($this->input->post->download_zip && $this->input->post->download_zip_url) { if($this->input->post('download_zip') && $this->input->post('download_zip_url')) {
$this->session->CSRF->validate(); $this->session->CSRF->validate();
$this->executeDownloadURL($this->input->post->download_zip_url); $this->executeDownloadURL($this->input->post('download_zip_url'));
} }
if($this->input->post->clear_file_compiler) { if($this->input->post('clear_file_compiler')) {
$this->session->CSRF->validate(); $this->session->CSRF->validate();
$compiler = new FileCompiler($this->wire('config')->paths->siteModules); $compiler = new FileCompiler($this->wire('config')->paths->siteModules);
$compiler->clearCache(true); $compiler->clearCache(true);
@@ -320,15 +320,15 @@ class ProcessModule extends Process {
$this->session->redirect('./'); $this->session->redirect('./');
} }
if($this->input->get->update) { if($this->input->get('update')) {
$name = $this->sanitizer->name($this->input->get->update); $name = $this->sanitizer->name($this->input->get('update'));
if(isset($this->modulesArray[$name])) return $this->downloadConfirm($name, true); if(isset($this->modulesArray[$name])) return $this->downloadConfirm($name, true);
} }
if($this->input->get->reset == 1) { if($this->input->get('reset') == 1) {
$this->modules->resetCache(); $this->modules->resetCache();
$this->message(sprintf($this->_('Modules cache refreshed (%d modules)'), count($this->modules))); $this->message(sprintf($this->_('Modules cache refreshed (%d modules)'), count($this->modules)));
$edit = $this->input->get->edit; $edit = $this->input->get->fieldName('edit');
$duplicates = $this->modules->duplicates()->getDuplicates(); $duplicates = $this->modules->duplicates()->getDuplicates();
foreach($duplicates as $className => $files) { foreach($duplicates as $className => $files) {
$dup = $this->modules->duplicates()->getDuplicates($className); $dup = $this->modules->duplicates()->getDuplicates($className);
@@ -341,8 +341,11 @@ class ProcessModule extends Process {
} }
$this->message("$msg</pre>", Notice::allowMarkup); $this->message("$msg</pre>", Notice::allowMarkup);
} }
if($edit) $this->session->redirect("./edit?name=" . $this->sanitizer->fieldName($edit) . "&reset=2"); if($edit) {
else $this->session->redirect("./?reset=2"); $this->session->redirect("./edit?name=$edit&reset=2");
} else {
$this->session->redirect("./?reset=2");
}
} }
return $this->renderList(); return $this->renderList();
@@ -426,6 +429,7 @@ class ProcessModule extends Process {
$button->addClass('ui-priority-secondary'); $button->addClass('ui-priority-secondary');
$button->icon = 'trash-o'; $button->icon = 'trash-o';
/** @var InputfieldMarkup $markup */
$markup = $this->modules->get('InputfieldMarkup'); $markup = $this->modules->get('InputfieldMarkup');
$markup->label = $this->_('/site/modules/ - Modules specific to your site'); $markup->label = $this->_('/site/modules/ - Modules specific to your site');
$markup->icon = 'folder-open-o'; $markup->icon = 'folder-open-o';
@@ -440,11 +444,13 @@ class ProcessModule extends Process {
// core // core
/** @var InputfieldWrapper $tab */
$tab = $this->wire(new InputfieldWrapper()); $tab = $this->wire(new InputfieldWrapper());
$tab->attr('id', 'tab_core_modules'); $tab->attr('id', 'tab_core_modules');
$tab->attr('title', $this->labels['core']); $tab->attr('title', $this->labels['core']);
$tab->attr('class', 'WireTab'); $tab->attr('class', 'WireTab');
/** @var InputfieldMarkup $markup */
$markup = $this->modules->get('InputfieldMarkup'); $markup = $this->modules->get('InputfieldMarkup');
$markup->value = $this->renderListTable($coreModulesArray); $markup->value = $this->renderListTable($coreModulesArray);
$markup->label = $this->_('/wire/modules/ - Modules included with the ProcessWire core'); $markup->label = $this->_('/wire/modules/ - Modules included with the ProcessWire core');
@@ -536,6 +542,7 @@ class ProcessModule extends Process {
$f->required = false; $f->required = false;
$fieldset->add($f); $fieldset->add($f);
/** @var InputfieldSubmit $f */
$f = $this->modules->get('InputfieldSubmit'); $f = $this->modules->get('InputfieldSubmit');
$f->attr('id+name', 'download'); $f->attr('id+name', 'download');
$f->value = $this->labels['get_module_info']; $f->value = $this->labels['get_module_info'];
@@ -543,12 +550,14 @@ class ProcessModule extends Process {
$fieldset->add($f); $fieldset->add($f);
$tab->add($fieldset); $tab->add($fieldset);
/** @var InputfieldFieldset $fieldset */
$fieldset = $this->modules->get('InputfieldFieldset'); $fieldset = $this->modules->get('InputfieldFieldset');
$fieldset->label = $this->labels['download_zip']; $fieldset->label = $this->labels['download_zip'];
$fieldset->icon = 'download'; $fieldset->icon = 'download';
$fieldset->collapsed = Inputfield::collapsedYes; $fieldset->collapsed = Inputfield::collapsedYes;
$trustNote = $this->_('Be absolutely certain that you trust the source of the ZIP file.'); $trustNote = $this->_('Be absolutely certain that you trust the source of the ZIP file.');
/** @var InputfieldURL $f */
$f = $this->modules->get('InputfieldURL'); $f = $this->modules->get('InputfieldURL');
$f->attr('id+name', 'download_zip_url'); $f->attr('id+name', 'download_zip_url');
$f->label = $this->_('Module ZIP file URL'); $f->label = $this->_('Module ZIP file URL');
@@ -558,6 +567,7 @@ class ProcessModule extends Process {
$f->required = false; $f->required = false;
$fieldset->add($f); $fieldset->add($f);
/** @var InputfieldSubmit $f */
$f = $this->modules->get('InputfieldSubmit'); $f = $this->modules->get('InputfieldSubmit');
$f->attr('id+name', 'download_zip'); $f->attr('id+name', 'download_zip');
$f->value = $this->labels['download']; $f->value = $this->labels['download'];
@@ -565,10 +575,13 @@ class ProcessModule extends Process {
$fieldset->add($f); $fieldset->add($f);
$tab->add($fieldset); $tab->add($fieldset);
/** @var InputfieldFieldset $fieldset */
$fieldset = $this->modules->get('InputfieldFieldset'); $fieldset = $this->modules->get('InputfieldFieldset');
$fieldset->label = $this->labels['upload_zip']; $fieldset->label = $this->labels['upload_zip'];
$fieldset->icon = 'upload'; $fieldset->icon = 'upload';
$fieldset->collapsed = Inputfield::collapsedYes; $fieldset->collapsed = Inputfield::collapsedYes;
/** @var InputfieldFile $f */
$f = $this->modules->get('InputfieldFile'); $f = $this->modules->get('InputfieldFile');
$f->extensions = 'zip'; $f->extensions = 'zip';
$f->maxFiles = 1; $f->maxFiles = 1;
@@ -610,7 +623,7 @@ class ProcessModule extends Process {
$form->add($tab); $form->add($tab);
// if($this->input->get->reset == 2 && !$this->numFound) $this->message($this->_("No new modules found")); // if($this->input->get->reset == 2 && !$this->numFound) $this->message($this->_("No new modules found"));
$this->session->ModulesUninstalled = $uninstalledNames; $this->session->set('ModulesUninstalled', $uninstalledNames);
return $form->render(); return $form->render();
} }
@@ -634,7 +647,7 @@ class ProcessModule extends Process {
static $numCalls = 0; static $numCalls = 0;
$numCalls++; $numCalls++;
$uninstalledPrev = is_array($this->session->ModulesUninstalled) ? $this->session->ModulesUninstalled : array(); $uninstalledPrev = is_array($this->session->get('ModulesUninstalled')) ? $this->session->get('ModulesUninstalled') : array();
$section = 'none'; $section = 'none';
$tableHeader = array( $tableHeader = array(
$this->_x('Module', 'list'), // Modules list table header for 'Module' column $this->_x('Module', 'list'), // Modules list table header for 'Module' column
@@ -710,7 +723,7 @@ class ProcessModule extends Process {
$class = 'not_installed'; $class = 'not_installed';
if(count($uninstalledPrev) && !in_array($name, $uninstalledPrev)) { if(count($uninstalledPrev) && !in_array($name, $uninstalledPrev)) {
$class .= " new_module"; $class .= " new_module";
if(!$this->input->get->uninstalled) $this->message($this->_("Found new module") . " - $name"); // Message that precedes module name when new module is found if(!$this->input->get('uninstalled')) $this->message($this->_("Found new module") . " - $name"); // Message that precedes module name when new module is found
$newModules[$name] = time(); $newModules[$name] = time();
$this->numFound++; $this->numFound++;
} }
@@ -729,7 +742,7 @@ class ProcessModule extends Process {
$icon = 'fa-sign-in'; $icon = 'fa-sign-in';
} }
$buttons .= $buttons .=
"<button type='$buttonType' name='install'$buttonWarning data-install='$name' " . "<button type='$buttonType' name='install' $buttonWarning data-install='$name' " .
"class='install_$name $buttonState ui-button $buttonPriority' value='$name'>" . "class='install_$name $buttonState ui-button $buttonPriority' value='$name'>" .
"<span class='ui-button-text'>" . "<span class='ui-button-text'>" .
"<i class='fa $icon'></i> " . "<i class='fa $icon'></i> " .
@@ -836,9 +849,9 @@ class ProcessModule extends Process {
$name = $this->wire('sanitizer')->name($name); $name = $this->wire('sanitizer')->name($name);
$info = self::getModuleInfo(); $info = self::getModuleInfo();
$this->wire('processHeadline', $this->labels['download_install']); $this->headline($this->labels['download_install']);
$this->wire('breadcrumbs')->add(new Breadcrumb('./', $info['title'])); $this->breadcrumb('./', $info['title']);
if($update) $this->wire('breadcrumbs')->add(new Breadcrumb("./?edit=$name", $name)); if($update) $this->breadcrumb("./?edit=$name", $name);
$redirectURL = $update ? "./edit?name=$name" : "./"; $redirectURL = $update ? "./edit?name=$name" : "./";
$className = $name; $className = $name;
@@ -1011,8 +1024,8 @@ class ProcessModule extends Process {
$btn->showInHeader(true); $btn->showInHeader(true);
if($update) $btn->value .= " ($data[module_version])"; if($update) $btn->value .= " ($data[module_version])";
$form->add($btn); $form->add($btn);
$this->session->ProcessModuleDownloadURL = $data['download_url']; $this->session->set('ProcessModuleDownloadURL', $data['download_url']);
$this->session->ProcessModuleClassName = $data['class_name']; $this->session->set('ProcessModuleClassName', $data['class_name']);
} else { } else {
$this->session->remove('ProcessModuleDownloadURL'); $this->session->remove('ProcessModuleDownloadURL');
$this->session->remove('ProcessModuleClassName'); $this->session->remove('ProcessModuleClassName');
@@ -1040,16 +1053,17 @@ class ProcessModule extends Process {
*/ */
public function ___executeDownload() { public function ___executeDownload() {
if(!$this->input->post->godownload) { if(!$this->input->post('godownload')) {
$this->message($this->_('Download cancelled')); $this->message($this->_('Download cancelled'));
return $this->session->redirect('../'); $this->session->redirect('../');
return '';
} }
$this->session->CSRF->validate(); $this->session->CSRF->validate();
$this->modules->resetCache(); $this->modules->resetCache();
$url = $this->session->ProcessModuleDownloadURL; $url = $this->session->get('ProcessModuleDownloadURL');
$className = $this->session->ProcessModuleClassName; $className = $this->session->get('ProcessModuleClassName');
$this->session->remove('ProcessModuleDownloadURL'); $this->session->remove('ProcessModuleDownloadURL');
$this->session->remove('ProcessModuleClassName'); $this->session->remove('ProcessModuleClassName');
@@ -1064,7 +1078,8 @@ class ProcessModule extends Process {
if($completedDir) { if($completedDir) {
return $this->buildDownloadSuccessForm($className)->render(); return $this->buildDownloadSuccessForm($className)->render();
} else { } else {
return $this->session->redirect('../'); $this->session->redirect('../');
return '';
} }
} }
@@ -1093,7 +1108,7 @@ class ProcessModule extends Process {
$this->wire('session')->redirect('../'); $this->wire('session')->redirect('../');
} }
$this->wire('processHeadline', $this->_('Downloaded:') . ' ' . $className); $this->headline($this->_('Downloaded:') . ' ' . $className);
$form->description = sprintf($this->_('%s is ready to install'), $className); $form->description = sprintf($this->_('%s is ready to install'), $className);
$form->attr('action', '../'); $form->attr('action', '../');
@@ -1125,7 +1140,7 @@ class ProcessModule extends Process {
} else { } else {
$this->wire('processHeadline', $this->_('Updated:') . ' ' . $className); $this->headline($this->_('Updated:') . ' ' . $className);
$form->description = sprintf($this->_('%s was updated successfully.'), $className); $form->description = sprintf($this->_('%s was updated successfully.'), $className);
/** @var InputfieldButton $button */ /** @var InputfieldButton $button */
$button = $this->modules->get('InputfieldButton'); $button = $this->modules->get('InputfieldButton');
@@ -1215,8 +1230,9 @@ class ProcessModule extends Process {
($this->wire('config')->debug && $this->wire('config')->advanced && ($flags & Modules::flagsAutoload)) || ($this->wire('config')->debug && $this->wire('config')->advanced && ($flags & Modules::flagsAutoload)) ||
($flags & Modules::flagsDisabled); ($flags & Modules::flagsDisabled);
$this->wire('breadcrumbs')->add(new Breadcrumb('./', $sinfo['title'])); $this->breadcrumb('./', $sinfo['title']);
$this->wire('processHeadline', $moduleInfo['title']); $this->headline($moduleInfo['title']);
$this->browserTitle(sprintf($this->_('Module: %s'), $moduleInfo['title']));
/** @var InputfieldForm $form */ /** @var InputfieldForm $form */
$form = $this->modules->get("InputfieldForm"); $form = $this->modules->get("InputfieldForm");
@@ -1349,7 +1365,7 @@ class ProcessModule extends Process {
} }
} }
if($uninstallable && $this->input->post->uninstall === $moduleName) { if($uninstallable && $this->input->post('uninstall') === $moduleName) {
$this->modules->uninstall($moduleName); $this->modules->uninstall($moduleName);
$this->session->message($this->_("Uninstalled Module") . " - $moduleName"); // Message shown before the name of a module that was just uninstalled $this->session->message($this->_("Uninstalled Module") . " - $moduleName"); // Message shown before the name of a module that was just uninstalled
$redirectURL = './?uninstalled=1'; $redirectURL = './?uninstalled=1';
@@ -1484,6 +1500,7 @@ class ProcessModule extends Process {
$form->description = sprintf($this->_('Install %s?'), $name); $form->description = sprintf($this->_('Install %s?'), $name);
$modulesArray[$name] = (int) $this->modules->isInstalled($name); $modulesArray[$name] = (int) $this->modules->isInstalled($name);
/** @var InputfieldMarkup $markup */
$markup = $this->modules->get('InputfieldMarkup'); $markup = $this->modules->get('InputfieldMarkup');
$markup->value = $this->renderListTable($modulesArray, false, false, false, true, true); $markup->value = $this->renderListTable($modulesArray, false, false, false, true, true);
$form->add($markup); $form->add($markup);