From 98c32e8c86c8def2c981b6a917c71b202380c9a2 Mon Sep 17 00:00:00 2001 From: Alexander Rutz Date: Tue, 10 Mar 2020 13:37:09 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20`Fatal=20error:=20[]=20operator=20not?= =?UTF-8?q?=20supported=20for=20strings=20in=20=E2=80=A6`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension.meta.xml | 7 +++++-- fields/field.uploadselectbox.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/extension.meta.xml b/extension.meta.xml index a522f07..48309b9 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -20,8 +20,11 @@ Uploaded Files Select Box: Displays a select box list of files from a chosen folder - - - Add empty `option` to be able to NOT select a file + + - Fix `Fatal error: [] operator not supported for strings in …` + + + - Add empty `option` to NOT select a file - PHP7 Updates diff --git a/fields/field.uploadselectbox.php b/fields/field.uploadselectbox.php index 03494cf..cf45db4 100755 --- a/fields/field.uploadselectbox.php +++ b/fields/field.uploadselectbox.php @@ -126,7 +126,7 @@ function prepareTableValue($data, ?XMLElement $link = NULL, $entry_id = NULL){ if(!is_array($value)) $value = array($value); - $custom_link = ""; + $custom_link[] = ""; foreach($value as $file) { if($link){ From 3b5e7e013a45b4968920221129e71355d37db615 Mon Sep 17 00:00:00 2001 From: animaux Date: Fri, 13 Jan 2023 11:35:48 +0100 Subject: [PATCH 2/2] PHP 8.1 Fixes (may require PHP 7) --- extension.meta.xml | 5 ++++- fields/field.uploadselectbox.php | 27 ++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/extension.meta.xml b/extension.meta.xml index 48309b9..139cc2f 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -2,7 +2,7 @@ Uploaded Files Select Box Displays a select box list of files from a chosen folder - https://github.com/symphonists/uploadselectboxfield + https://github.com/animaux/uploadselectboxfield http://symphony-cms.com/discuss/thread/41232/ Field @@ -20,6 +20,9 @@ Uploaded Files Select Box: Displays a select box list of files from a chosen folder + + - PHP 8.1 Fixes (may require PHP 7) + - Fix `Fatal error: [] operator not supported for strings in …` diff --git a/fields/field.uploadselectbox.php b/fields/field.uploadselectbox.php index cf45db4..f7ae067 100755 --- a/fields/field.uploadselectbox.php +++ b/fields/field.uploadselectbox.php @@ -29,7 +29,7 @@ function canPrePopulate(){ return true; } - public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = NULL, $entry_id = NULL) { + public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null) { if (!is_array($data) || empty($data)) return; if (!is_array($data['file'])) { @@ -55,11 +55,11 @@ public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = fa $wrapper->appendChild($item); } - function displaySettingsPanel(XMLElement &$wrapper, $errors = NULL){ + function displaySettingsPanel(XMLElement &$wrapper, $errors = null){ Field::displaySettingsPanel($wrapper, $errors); - $div = new XMLElement('div', NULL, array('class' => 'group')); + $div = new XMLElement('div', null, array('class' => 'group')); $ignore = array( '/workspace/events', @@ -68,7 +68,7 @@ function displaySettingsPanel(XMLElement &$wrapper, $errors = NULL){ '/workspace/pages', '/workspace/utilities' ); - $directories = General::listDirStructure(WORKSPACE, NULL, 'asc', DOCROOT, $ignore); + $directories = General::listDirStructure(WORKSPACE, null, 'asc', DOCROOT, $ignore); $label = Widget::Label(__('Destination Directory')); @@ -98,7 +98,8 @@ function displaySettingsPanel(XMLElement &$wrapper, $errors = NULL){ } - function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL, $entry_id = NULL){ + function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null){ + $data['file'] = $data['file'] ?? null; if(!is_array($data['file'])) $data['file'] = array($data['file']); $options = array(); @@ -115,13 +116,13 @@ function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWithError if($this->get('allow_multiple_selection') == 'yes') $fieldname .= '[]'; $label = Widget::Label($this->get('label')); - $label->appendChild(Widget::Select($fieldname, $options, ($this->get('allow_multiple_selection') == 'yes' ? array('multiple' => 'multiple') : NULL))); + $label->appendChild(Widget::Select($fieldname, $options, ($this->get('allow_multiple_selection') == 'yes' ? array('multiple' => 'multiple') : null))); - if($flagWithError != NULL) $wrapper->appendChild(Widget::wrapFormElementWithError($label, $flagWithError)); + if($flagWithError != null) $wrapper->appendChild(Widget::wrapFormElementWithError($label, $flagWithError)); else $wrapper->appendChild($label); } - function prepareTableValue($data, ?XMLElement $link = NULL, $entry_id = NULL){ + function prepareTableValue($data, ?XMLElement $link = null, $entry_id = null){ $value = $data['file']; if(!is_array($value)) $value = array($value); @@ -221,11 +222,11 @@ function commit(){ } - public function processRawFieldData($data, &$status, &$message = NULL, $simulate = false, $entry_id = NULL){ + public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null){ $status = self::__OK__; if(!is_array($data)) return array('file' => General::sanitize($data)); - if(empty($data)) return NULL; + if(empty($data)) return null; $result = array('file' => array()); foreach($data as $file) { @@ -237,9 +238,9 @@ public function processRawFieldData($data, &$status, &$message = NULL, $simulate function createTable(){ return Symphony::Database()->query( "CREATE TABLE IF NOT EXISTS `tbl_entries_data_" . $this->get('id') . "` ( - `id` int(11) unsigned NOT NULL auto_increment, - `entry_id` int(11) unsigned NOT NULL, - `file` varchar(255) default NULL, + `id` int(11) unsigned NOT null auto_increment, + `entry_id` int(11) unsigned NOT null, + `file` varchar(255) default null, PRIMARY KEY (`id`), KEY `entry_id` (`entry_id`) );"