From bb41a50314e2fa1130935b9284a29cf9061f554f Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Wed, 14 Feb 2018 18:39:41 +0100 Subject: [PATCH] Bugfix --- add.php | 12 ++++++------ modules/emails/edit.php | 2 +- modules/interventi/add_firma.php | 2 +- src/HTMLBuilder/HTMLBuilder.php | 6 ++++++ src/HTMLBuilder/Manager/FieldManager.php | 16 +++++++++++++++- update/2_4.sql | 6 +++++- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/add.php b/add.php index 834d6f984..ddb5094d8 100644 --- a/add.php +++ b/add.php @@ -37,19 +37,19 @@ echo ' // Campi personalizzati echo ' -
- {( "name": "custom_fields", "id_module": "'.$id_module.'", "position": "top" )} +
+ {( "name": "custom_fields", "id_module": "'.$id_module.'", "position": "top", "place": "add" )}
-
- {( "name": "custom_fields", "id_module": "'.$id_module.'", "position": "bottom" )} +
+ {( "name": "custom_fields", "id_module": "'.$id_module.'", "position": "bottom", "place": "add" )}
'; diff --git a/modules/emails/edit.php b/modules/emails/edit.php index 00aea8917..50b9c002e 100644 --- a/modules/emails/edit.php +++ b/modules/emails/edit.php @@ -38,7 +38,7 @@ echo '
- {[ "type": "email", "label": "", "name": "subject", "value": "$subject$" ]} + {[ "type": "text", "label": "", "name": "subject", "value": "$subject$" ]}
diff --git a/modules/interventi/add_firma.php b/modules/interventi/add_firma.php index 2445b24ef..fd38f8d32 100644 --- a/modules/interventi/add_firma.php +++ b/modules/interventi/add_firma.php @@ -33,7 +33,7 @@ if (get('anteprima') !== null) { } ?> -
+ diff --git a/src/HTMLBuilder/HTMLBuilder.php b/src/HTMLBuilder/HTMLBuilder.php index a0323b1a5..0807ba84a 100644 --- a/src/HTMLBuilder/HTMLBuilder.php +++ b/src/HTMLBuilder/HTMLBuilder.php @@ -100,6 +100,9 @@ class HTMLBuilder $result = !empty($class) ? $class->manage($json) : ''; $html = str_replace($value, !empty($result) ? $result : $value, $html); + + // Ricorsione + $html = self::replace($html); } // Gestione del formato di input HTML semplificato @@ -110,6 +113,9 @@ class HTMLBuilder $result = self::generate($json); $html = str_replace($value, !empty($result) ? $result : $value, $html); + + // Ricorsione + $html = self::replace($html); } return $html; diff --git a/src/HTMLBuilder/Manager/FieldManager.php b/src/HTMLBuilder/Manager/FieldManager.php index 0dd7ae5ba..5a2222f1f 100644 --- a/src/HTMLBuilder/Manager/FieldManager.php +++ b/src/HTMLBuilder/Manager/FieldManager.php @@ -30,6 +30,10 @@ class FieldManager implements ManagerInterface $query .= ' AND `id_record` = '.prepare($options['id_record']); } + if (isset($options['place']) && $options['place'] == 'add') { + $query .= ' AND `on_add` = 1'; + } + $query .= ' AND `top` = '.((isset($options['position']) && $options['position'] == 'top') ? 1 : 0).' ORDER BY `order`'; $results = $database->fetchArray($query); @@ -51,9 +55,19 @@ class FieldManager implements ManagerInterface $field['value'] = isset($field['value']) ? $field['value'] : ''; + $replace = [ + 'value' => $field['value'], + 'label' => $field['name'], + 'name' => $field['html_name'], + ]; + + foreach ($replace as $key => $value) { + $field['content'] = str_replace('|'.$key.'|', $value, $field['content']); + } + $result .= '
- '.str_replace('|value|', $field['value'], $field['content']).' + '.$field['content'].'
'; if (($key + 1) % 3 == 0) { diff --git a/update/2_4.sql b/update/2_4.sql index 1634a67e7..3d8e5d0d6 100644 --- a/update/2_4.sql +++ b/update/2_4.sql @@ -223,14 +223,18 @@ UPDATE `zz_widgets` SET `help` = 'Fatturato IVA inclusa.' WHERE `zz_widgets`.`na CREATE TABLE IF NOT EXISTS `zz_fields` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11) NOT NULL, + `id_module` int(11), + `id_plugin` int(11), `name` varchar(255) NOT NULL, + `html_name` varchar(255) NOT NULL, `content` text NOT NULL, `options` text, `order` int(11) NOT NULL, + `on_add` boolean NOT NULL, `top` boolean NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE + FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB; --