mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
Fix issue processwire/processwire-issues#41 where uploading image in CKEditor image dialog to page other than the one being edited resulted in an uploaded image that had "temp" status
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* @property bool|int $noUpload Set to true or 1 to disable uploading to this field
|
||||
* @property bool|int $noLang Set to true or 1 to disable multi-language descriptions
|
||||
* @property bool|int $noAjax Set to true or 1 to disable ajax uploading
|
||||
* @property bool|int $uploadOnlyMode Set to true or 1 to disable existing file list display
|
||||
* @property int $uploadOnlyMode Set to true or 1 to disable existing file list display, or 2 to also prevent file from having 'temp' status.
|
||||
* @property bool|int $noCollapseItem Set to true to disable collapsed items (like for LanguageTranslator tool or other things that add tools to files)
|
||||
* @property bool|int $noShortName Set to true to disable shortened filenames in output
|
||||
* @property bool|int $noCustomButton Set to true to disable use of the styled <input type='file'>
|
||||
@@ -61,10 +61,10 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
/**
|
||||
* True when field should behave in an upload only mode
|
||||
*
|
||||
* @var bool
|
||||
* @var bool|int
|
||||
*
|
||||
*/
|
||||
protected $uploadOnlyMode = false;
|
||||
protected $uploadOnlyMode = 0;
|
||||
|
||||
protected $renderValueMode = false;
|
||||
|
||||
@@ -129,8 +129,8 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
else if($last == 'k') $this->maxFilesize = $filesize*1024;
|
||||
else if((int) $filesize > 0) $this->maxFilesize = (int) $filesize;
|
||||
else $this->maxFilesize = (5*1024)*1024;
|
||||
|
||||
if($this->wire('input')->get('uploadOnlyMode')) $this->uploadOnlyMode = true;
|
||||
|
||||
$this->uploadOnlyMode = (int) $this->wire('input')->get('uploadOnlyMode');
|
||||
$this->addClass('InputfieldItemList', 'wrapClass');
|
||||
$this->addClass('InputfieldHasFileList', 'wrapClass');
|
||||
}
|
||||
@@ -660,10 +660,14 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($this->uploadOnlyMode) {
|
||||
$sort = null;
|
||||
$changed = true;
|
||||
if($this->uploadOnlyMode === 2) {
|
||||
$sort = 0; // ensures an isTemp(false) call occurs below
|
||||
} else {
|
||||
$sort = null;
|
||||
}
|
||||
$changed = true;
|
||||
} else {
|
||||
$key = "sort_$id";
|
||||
$sort = $input->$key;
|
||||
|
@@ -616,8 +616,9 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
}
|
||||
|
||||
// for ProcessPageEditImageSelect support
|
||||
if($this->wire('input')->get('uploadOnlyMode') && !$this->wire('config')->ajax) {
|
||||
$action .= "&uploadOnlyMode=1";
|
||||
$uploadOnlyMode = (int) $this->wire('input')->get('uploadOnlyMode');
|
||||
if($uploadOnlyMode && !$this->wire('config')->ajax) {
|
||||
$action .= "&uploadOnlyMode=" . $uploadOnlyMode;
|
||||
$form->attr('action', $action);
|
||||
// for modal uploading with InputfieldFile or InputfieldImage
|
||||
if(count($this->fields) && $this->field->type instanceof FieldtypeImage) {
|
||||
|
@@ -435,7 +435,8 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
|
||||
if(count($imageFields)) {
|
||||
$imageFieldNames = implode(',', array_keys($imageFields));
|
||||
$btn = $this->modules->get('InputfieldButton');
|
||||
$btn->href = "../edit/?modal=1&id={$this->page->id}&fields=$imageFieldNames&uploadOnlyMode=1";
|
||||
$uploadOnlyMode = "$this->page" === "$this->editorPage" ? 1 : 2;
|
||||
$btn->href = "../edit/?modal=1&id={$this->page->id}&fields=$imageFieldNames&uploadOnlyMode=$uploadOnlyMode";
|
||||
$btn->value = $this->_('Upload Image');
|
||||
$btn->addClass('upload pw-modal-button pw-modal-button-visible');
|
||||
$btn->icon = 'upload';
|
||||
|
Reference in New Issue
Block a user