From 40f03bdc807b0045a9b938ece33bbbc0343c26fb Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 9 May 2017 13:52:39 -0400 Subject: [PATCH 1/9] Update release version --- extension.meta.xml | 117 +++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/extension.meta.xml b/extension.meta.xml index 6c40fc9..3d6d6c9 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -1,57 +1,60 @@ - - - Image Preview - Replaces the textual link to the image with the real image - https://github.com/Solutions-Nitriques/image_preview - http://getsymphony.com/discuss/thread/71485/ - https://github.com/Solutions-Nitriques/image_preview/issues - - Interface - Field - Preview - - - - Deux Huit Huit - https://deuxhuithuit.com/ - - - - - - Add support for multi-upload field - - - - Supported on PHP 7 - - Fixed parameters to fit the parent method - - - - Added missing .field-multilingual_upload selector - - - - UI (css) fixes - - - - Added support for svg - - Do not request any file if there is already an image in the link - - - - Compatibility for custom url: assets are now loaded using full absolute url - - Support for Association Drawer - - - - Compatibility with multilingual fields (more than one file/link) - - - - Added a Image Preview Settings field : - It is now possible to customize how images are previewed. - You can change those settings by adding one or more `Image Preview Settings` field to you section. - - Minor UI updates - - - - Compatibility with Symphony 2.3 - - - - Initial release - - - \ No newline at end of file + + + Image Preview + Replaces the textual link to the image with the real image + https://github.com/Solutions-Nitriques/image_preview + http://getsymphony.com/discuss/thread/71485/ + https://github.com/Solutions-Nitriques/image_preview/issues + + Interface + Field + Preview + + + + Deux Huit Huit + https://deuxhuithuit.com/ + + + + + - Update for Symphony 4.x + + + - Add support for multi-upload field + + + - Supported on PHP 7 + - Fixed parameters to fit the parent method + + + - Added missing .field-multilingual_upload selector + + + - UI (css) fixes + + + - Added support for svg + - Do not request any file if there is already an image in the link + + + - Compatibility for custom url: assets are now loaded using full absolute url + - Support for Association Drawer + + + - Compatibility with multilingual fields (more than one file/link) + + + - Added a Image Preview Settings field : + It is now possible to customize how images are previewed. + You can change those settings by adding one or more `Image Preview Settings` field to you section. + - Minor UI updates + + + - Compatibility with Symphony 2.3 + + + - Initial release + + + From d8b8f70f7187edca10567dee86b4efcdc9d75167 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Wed, 17 May 2017 10:58:04 -0400 Subject: [PATCH 2/9] Update php-min/php-max info --- extension.meta.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.meta.xml b/extension.meta.xml index 3d6d6c9..f791358 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -17,7 +17,7 @@ - + - Update for Symphony 4.x From 4a035a67bc9ce0b02eeb4ab876125d38b67efc0b Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Fri, 26 May 2017 15:07:45 -0400 Subject: [PATCH 3/9] Add dependencies --- extension.meta.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extension.meta.xml b/extension.meta.xml index f791358..6eb1e98 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -16,6 +16,9 @@ https://deuxhuithuit.com/ + + jit_image_manipulation + - Update for Symphony 4.x From bb7fdb2627cbb6836d3cf1efb65972612d00fe9b Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 30 May 2017 15:47:09 -0400 Subject: [PATCH 4/9] Make extension work without JIT --- assets/image_preview.js | 9 +++++---- extension.meta.xml | 3 --- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/assets/image_preview.js b/assets/image_preview.js index 61b571b..c14ce38 100644 --- a/assets/image_preview.js +++ b/assets/image_preview.js @@ -20,7 +20,8 @@ resize: 1, position: 5, absolute: false, - isDefault: true + isDefault: true, + isJIT: false }; var params = { @@ -33,7 +34,6 @@ var SVG = '.svg'; var createUrl = function (imgSrc, params) { - var newSrc = 'image/{resize}/{width}/{height}{position}'; newSrc = newSrc.replace('{resize}', params.resize); @@ -66,7 +66,6 @@ } if (!!node.length) { - var width = parseInt(node.attr('data-width'), 10), height = parseInt(node.attr('data-height'), 10), @@ -80,9 +79,11 @@ params.position = position || params.position; params.absolute = absolute || params.absolute; params.isDefault = false; + params.isJIT = true; return false; //exit for } + return true; }); @@ -134,7 +135,7 @@ } var p = getParameters(classes, defaults); - var url = createUrl(imgSrc, p); + var url = (params.isJIT) ? createUrl(imgSrc, p) : imgSrc; // bind load event img.addEventListener('load', function (e) { _imageLoaded(e, p, this.src); }); diff --git a/extension.meta.xml b/extension.meta.xml index 6eb1e98..f791358 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -16,9 +16,6 @@ https://deuxhuithuit.com/ - - jit_image_manipulation - - Update for Symphony 4.x From 5a0ed617f8e680ca77debe0320bcdca50f9eb86a Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Thu, 24 Aug 2017 15:41:14 -0400 Subject: [PATCH 5/9] SQL and PHP cases PHP true,false,null in lowercase SQL keywords uppercase --- fields/field.image_preview_settings.php | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/fields/field.image_preview_settings.php b/fields/field.image_preview_settings.php index e879f6d..dded385 100644 --- a/fields/field.image_preview_settings.php +++ b/fields/field.image_preview_settings.php @@ -492,8 +492,8 @@ public 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, + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `entry_id` INT(11) UNSIGNED NOT NULL, PRIMARY KEY (`id`), KEY `entry_id` (`entry_id`) ) TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;" @@ -509,19 +509,19 @@ public static function createFieldTable() return Symphony::Database()->query(" CREATE TABLE IF NOT EXISTS `$tbl` ( - `id` int(11) unsigned NOT NULL auto_increment, - `field_id` int(11) unsigned NOT NULL, - `field-handles` varchar(255) NOT NULL, - `table-width` int(11) unsigned NULL, - `table-height` int(11) unsigned NULL, - `table-resize` int(11) unsigned NULL, - `table-position` int(11) unsigned NULL, - `table-absolute` enum('yes','no') NOT NULL DEFAULT 'no', - `entry-width` int(11) unsigned NULL, - `entry-height` int(11) unsigned NULL, - `entry-resize` int(11) unsigned NULL, - `entry-position` int(11) unsigned NULL, - `entry-absolute` enum('yes','no') NOT NULL DEFAULT 'no', + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `field_id` INT(11) UNSIGNED NOT NULL, + `field-handles` VARCHAR(255) NOT NULL, + `table-width` INT(11) UNSIGNED NULL, + `table-height` INT(11) UNSIGNED NULL, + `table-resize` INT(11) UNSIGNED NULL, + `table-position` INT(11) UNSIGNED NULL, + `table-absolute` ENUM('yes','no') NOT NULL DEFAULT 'no', + `entry-width` INT(11) UNSIGNED NULL, + `entry-height` INT(11) UNSIGNED NULL, + `entry-resize` INT(11) UNSIGNED NULL, + `entry-position` INT(11) UNSIGNED NULL, + `entry-absolute` ENUM('yes','no') NOT NULL DEFAULT 'no', PRIMARY KEY (`id`), KEY `field_id` (`field_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; From a4573327e30f3e6b444d1f8817b5610066d554c5 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Wed, 13 Jun 2018 11:36:33 -0400 Subject: [PATCH 6/9] Code refactoring for Database --- extension.meta.xml | 1 + fields/field.image_preview_settings.php | 133 +++++++++++++++++------- 2 files changed, 96 insertions(+), 38 deletions(-) diff --git a/extension.meta.xml b/extension.meta.xml index f791358..f4dd1aa 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -19,6 +19,7 @@ - Update for Symphony 4.x + - Code refactoring for Database and EQFA - Add support for multi-upload field diff --git a/fields/field.image_preview_settings.php b/fields/field.image_preview_settings.php index dded385..31ab1dc 100644 --- a/fields/field.image_preview_settings.php +++ b/fields/field.image_preview_settings.php @@ -249,12 +249,19 @@ public function commit() $settings['entry-absolute'] = empty($e_absolute) ? 'no' : $e_absolute; // DB - $tbl = self::FIELD_TBL_NAME; - - Symphony::Database()->query("DELETE FROM `$tbl` WHERE `field_id` = '$id' LIMIT 1"); + Symphony::Database() + ->delete(self::FIELD_TBL_NAME) + ->where(['field_id' => $id]) + ->limit(1) + ->execute() + ->success(); // return if the SQL command was successful - return Symphony::Database()->insert($settings, $tbl); + return Symphony::Database() + ->insert(self::FIELD_TBL_NAME) + ->values($settings) + ->execute() + ->success(); } @@ -490,14 +497,24 @@ public function tearDown() */ public 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, - PRIMARY KEY (`id`), - KEY `entry_id` (`entry_id`) - ) TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;" - ); + return Symphony::Database() + ->create('tbl_entries_data_' . $this->get('id')) + ->ifNotExists() + ->charset('utf8') + ->collate('utf8_unicode_ci') + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'entry_id' => 'int(11)', + ]) + ->keys([ + 'id' => 'primary', + 'entry_id' => 'key', + ]) + ->execute() + ->success(); } /** @@ -505,27 +522,67 @@ public function createTable() */ public static function createFieldTable() { - $tbl = self::FIELD_TBL_NAME; - - return Symphony::Database()->query(" - CREATE TABLE IF NOT EXISTS `$tbl` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `field_id` INT(11) UNSIGNED NOT NULL, - `field-handles` VARCHAR(255) NOT NULL, - `table-width` INT(11) UNSIGNED NULL, - `table-height` INT(11) UNSIGNED NULL, - `table-resize` INT(11) UNSIGNED NULL, - `table-position` INT(11) UNSIGNED NULL, - `table-absolute` ENUM('yes','no') NOT NULL DEFAULT 'no', - `entry-width` INT(11) UNSIGNED NULL, - `entry-height` INT(11) UNSIGNED NULL, - `entry-resize` INT(11) UNSIGNED NULL, - `entry-position` INT(11) UNSIGNED NULL, - `entry-absolute` ENUM('yes','no') NOT NULL DEFAULT 'no', - PRIMARY KEY (`id`), - KEY `field_id` (`field_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - "); + return Symphony::Database() + ->create(self::FIELD_TBL_NAME) + ->ifNotExists() + ->charset('utf8') + ->collate('utf8_unicode_ci') + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'field_id' => 'int(11)', + 'field-handles' => 'varchar(255)', + 'table-width' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-height' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-resize' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-position' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-absolute' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + 'entry-width' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-height' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-resize' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-position' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-absolute' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + ]) + ->keys([ + 'id' => 'primary', + 'field_id' => 'key', + ]) + ->execute() + ->success(); } @@ -535,10 +592,10 @@ public static function createFieldTable() */ public static function deleteFieldTable() { - $tbl = self::FIELD_TBL_NAME; - - return Symphony::Database()->query(" - DROP TABLE IF EXISTS `$tbl` - "); + return Symphony::Database() + ->drop(self::FIELD_TBL_NAME) + ->ifExists() + ->execute() + ->success(); } } From a3291a0c190996b59e4d7b4431219dde29026235 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 19 Jun 2018 11:12:32 -0400 Subject: [PATCH 7/9] Replace deprecated method fetch() by select() --- extension.meta.xml | 1 + fields/field.image_preview_settings.php | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/extension.meta.xml b/extension.meta.xml index f4dd1aa..4e13ddf 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -20,6 +20,7 @@ - Update for Symphony 4.x - Code refactoring for Database and EQFA + - Replace deprecated method fetch() by select() - Add support for multi-upload field diff --git a/fields/field.image_preview_settings.php b/fields/field.image_preview_settings.php index 31ab1dc..3be5ee3 100644 --- a/fields/field.image_preview_settings.php +++ b/fields/field.image_preview_settings.php @@ -304,8 +304,13 @@ private function convertHandlesIntoIds($handles) $parent_section = $this->get('parent_section'); foreach ($aHandles as $handle) { - $where = "AND t1.`element_name` = '$handle'"; - $field = FieldManager::fetch(null, $parent_section, 'ASC', 'sortorder', null, null, $where); + $field = (new FieldManager) + ->select() + ->sort('sortorder', 'asc') + ->section($parent_section) + ->where(['t1.element_name' => $handle]) + ->execute() + ->next(); $fieldId = array_keys($field); $fieldId = $fieldId[0]; From 658b2d80e9f0d55b3aacbeb474e6f8a6e17eb781 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Fri, 19 Oct 2018 14:32:35 -0400 Subject: [PATCH 8/9] Fix undefined variable Params in JS. --- assets/image_preview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/image_preview.js b/assets/image_preview.js index c14ce38..f3f208e 100644 --- a/assets/image_preview.js +++ b/assets/image_preview.js @@ -135,7 +135,7 @@ } var p = getParameters(classes, defaults); - var url = (params.isJIT) ? createUrl(imgSrc, p) : imgSrc; + var url = (p.isJIT) ? createUrl(imgSrc, p) : imgSrc; // bind load event img.addEventListener('load', function (e) { _imageLoaded(e, p, this.src); }); From de08715ebfdb02794afcbb3eed6f05a27f968c46 Mon Sep 17 00:00:00 2001 From: Alexandra Nantel Date: Tue, 18 Dec 2018 09:44:18 -0500 Subject: [PATCH 9/9] Remote SQL collate and charset definitions. --- fields/field.image_preview_settings.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fields/field.image_preview_settings.php b/fields/field.image_preview_settings.php index 3be5ee3..d440512 100644 --- a/fields/field.image_preview_settings.php +++ b/fields/field.image_preview_settings.php @@ -505,8 +505,6 @@ public function createTable() return Symphony::Database() ->create('tbl_entries_data_' . $this->get('id')) ->ifNotExists() - ->charset('utf8') - ->collate('utf8_unicode_ci') ->fields([ 'id' => [ 'type' => 'int(11)', @@ -530,8 +528,6 @@ public static function createFieldTable() return Symphony::Database() ->create(self::FIELD_TBL_NAME) ->ifNotExists() - ->charset('utf8') - ->collate('utf8_unicode_ci') ->fields([ 'id' => [ 'type' => 'int(11)',