mirror of
https://github.com/processwire/processwire.git
synced 2025-08-07 23:38:29 +02:00
Optimizations and improvements to $config->demo mode.
This commit is contained in:
@@ -229,6 +229,7 @@ class WireUpload extends Wire {
|
|||||||
if(!$this->initialized) $this->init();
|
if(!$this->initialized) $this->init();
|
||||||
if(!$this->name) throw new WireException("You must set the name for WireUpload before executing it");
|
if(!$this->name) throw new WireException("You must set the name for WireUpload before executing it");
|
||||||
if(!$this->destinationPath) throw new WireException("You must set the destination path for WireUpload before executing it");
|
if(!$this->destinationPath) throw new WireException("You must set the destination path for WireUpload before executing it");
|
||||||
|
if($this->wire()->config->demo) return array();
|
||||||
|
|
||||||
$uploadFiles = array();
|
$uploadFiles = array();
|
||||||
|
|
||||||
@@ -887,5 +888,3 @@ class WireUpload extends Wire {
|
|||||||
return !empty($_SERVER['HTTP_X_FILENAME']);
|
return !empty($_SERVER['HTTP_X_FILENAME']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* This file is designed for inclusion by /site/templates/admin.php template and all the variables
|
* This file is designed for inclusion by /site/templates/admin.php template and all the variables
|
||||||
* it references are from your template namespace.
|
* it references are from your template namespace.
|
||||||
*
|
*
|
||||||
* Copyright 2022 by Ryan Cramer
|
* Copyright 2024 by Ryan Cramer
|
||||||
*
|
*
|
||||||
* @var Config $config
|
* @var Config $config
|
||||||
* @var User $user
|
* @var User $user
|
||||||
@@ -100,6 +100,24 @@ function _checkForMaxInputVars(WireInput $input) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup for demo mode
|
||||||
|
*
|
||||||
|
* @param Page $page
|
||||||
|
* @param ProcessWire $wire
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function _setupForDemoMode($page, $wire) {
|
||||||
|
if("$page->process" !== 'ProcessLogin') {
|
||||||
|
if(!empty($_POST)) $wire->error("Features that use POST variables are disabled in this demo");
|
||||||
|
foreach($_POST as $k => $v) unset($_POST[$k]); $_POST = array();
|
||||||
|
$wire->input->post->removeAll();
|
||||||
|
$wire->config->js('demo', true);
|
||||||
|
}
|
||||||
|
unset($_SERVER['HTTP_X_FIELDNAME'], $_SERVER['HTTP_X_FILENAME']);
|
||||||
|
foreach($_FILES as $k => $v) unset($_FILES[$k]); $_FILES = array();
|
||||||
|
}
|
||||||
|
|
||||||
// fallback theme if one not already present
|
// fallback theme if one not already present
|
||||||
if(empty($adminTheme)) {
|
if(empty($adminTheme)) {
|
||||||
$adminTheme = $modules->get($config->defaultAdminTheme ? $config->defaultAdminTheme : 'AdminThemeUikit');
|
$adminTheme = $modules->get($config->defaultAdminTheme ? $config->defaultAdminTheme : 'AdminThemeUikit');
|
||||||
@@ -131,16 +149,12 @@ $demo = $config->demo;
|
|||||||
|
|
||||||
// enable modules to output their own ajax responses if they choose to
|
// enable modules to output their own ajax responses if they choose to
|
||||||
if($ajax) ob_start();
|
if($ajax) ob_start();
|
||||||
|
if($demo) _setupForDemoMode($page, $wire);
|
||||||
|
|
||||||
if($page->process && $page->process != 'ProcessPageView') {
|
if($page->process && $page->process != 'ProcessPageView') {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if($demo && $page->process != 'ProcessLogin') {
|
if($input->requestMethod('POST') && $user->isLoggedin() && $user->hasPermission('page-edit')) {
|
||||||
if(count($_POST)) $wire->error("Features that use POST variables are disabled in this demo");
|
|
||||||
foreach($_POST as $k => $v) unset($_POST[$k]);
|
|
||||||
foreach($_FILES as $k => $v) unset($_FILES[$k]);
|
|
||||||
$input->post->removeAll();
|
|
||||||
} else if($input->requestMethod('POST') && $user->isLoggedin() && $user->hasPermission('page-edit')) {
|
|
||||||
_checkForMaxInputVars($input);
|
_checkForMaxInputVars($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ function InputfieldImage($) {
|
|||||||
* @returns bool
|
* @returns bool
|
||||||
*/
|
*/
|
||||||
function useAjaxUpload() {
|
function useAjaxUpload() {
|
||||||
|
if(typeof ProcessWire.config.demo !== 'undefined') return false;
|
||||||
var isFileReaderSupport = window.File && window.FileList && window.FileReader;
|
var isFileReaderSupport = window.File && window.FileList && window.FileReader;
|
||||||
var isAjaxUpload = $('.InputfieldAllowAjaxUpload').length > 0;
|
var isAjaxUpload = $('.InputfieldAllowAjaxUpload').length > 0;
|
||||||
var isPageIDIndicator = $("#PageIDIndicator").length > 0;
|
var isPageIDIndicator = $("#PageIDIndicator").length > 0;
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user