From 31c2aa5c6380bb27b69014ab545034a808dd6573 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 19:54:58 +0100 Subject: [PATCH 1/3] Fix js syntax error --- htdocs/core/class/html.formmail.class.php | 71 ++++++++++++----------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 21f064ba8ca..114c01ec5e1 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1579,49 +1579,50 @@ class FormMail extends Form CKEDITOR.instances.".$htmlContent.".setReadOnly(1); } - $.ajax({ - url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."', - type: 'POST', - contentType: 'application/json', - data: JSON.stringify({ - 'format': '".dol_escape_js($format)."', /* the format for output */ - 'function': '".dol_escape_js($function)."', /* the AI feature to call */ - 'instructions': instructions, /* the prompt string */ - }), - success: function(response) { - console.log('Add response into field \'#".$htmlContent."\': '+response); + $.ajax({ + url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify({ + 'format': '".dol_escape_js($format)."', /* the format for output */ + 'function': '".dol_escape_js($function)."', /* the AI feature to call */ + 'instructions': instructions, /* the prompt string */ + }), + success: function(response) { + console.log('Add response into field \'#".$htmlContent."\': '+response); - jQuery('#".$htmlContent."').val(response); // If #htmlcontent is a input name or textarea - jQuery('#".$htmlContent."').html(response); // If #htmlContent is a div - //jQuery('#".$htmlContent."preview').val(response); + jQuery('#".$htmlContent."').val(response); // If #htmlcontent is a input name or textarea + jQuery('#".$htmlContent."').html(response); // If #htmlContent is a div + //jQuery('#".$htmlContent."preview').val(response); - if (CKEDITOR.instances) { - var editorInstance = CKEDITOR.instances.".$htmlContent."; - if (editorInstance) { - editorInstance.setReadOnly(0); - editorInstance.setData(response); + if (CKEDITOR.instances) { + var editorInstance = CKEDITOR.instances.".$htmlContent."; + if (editorInstance) { + editorInstance.setReadOnly(0); + editorInstance.setData(response); + } + //var editorInstancepreview = CKEDITOR.instances.".$htmlContent."preview; + //if (editorInstancepreview) { + // editorInstancepreview.setData(response); + //} } - //var editorInstancepreview = CKEDITOR.instances.".$htmlContent."preview; - //if (editorInstancepreview) { - // editorInstancepreview.setData(response); - //} - } - // remove readonly - $('#ai_instructions".$htmlContent."').val(''); + // remove readonly + $('#ai_instructions".$htmlContent."').val(''); - apicallfinished = 1; - if (timeoutfinished) { + apicallfinished = 1; + if (timeoutfinished) { + $('#ai_status_message".$htmlContent."').hide(); + } + }, + error: function(xhr, status, error) { + alert(error); + console.error('error ajax', status, error); $('#ai_status_message".$htmlContent."').hide(); } - }, - error: function(xhr, status, error) { - alert(error); - console.error('error ajax', status, error); - $('#ai_status_message".$htmlContent."').hide(); - } - }); + }); + } }); }); From 824f4e06b5441469304858392e1c6385a5c565de Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 02:27:36 +0100 Subject: [PATCH 2/3] Debug v21 smartphone --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index baec057484e..0a83062a908 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3353,7 +3353,7 @@ if (!GETPOST('hide_websitemenu')) { print ''; - print ''; + print ''; // Print nav arrows $pagepreviousid = 0; From 99e8842f0a1b808b853b440043d567c87a294daa Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 03:49:11 +0100 Subject: [PATCH 3/3] Fix phpstan --- htdocs/ai/class/ai.class.php | 4 ++-- htdocs/ai/lib/ai.lib.php | 2 +- htdocs/core/lib/geturl.lib.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index e581fea16fa..8eb4ae4d642 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -233,8 +233,8 @@ class Ai ); // Add a system message - $addDateTimeContext = 0; - if ($addDateTimeContext) { + $addDateTimeContext = false; + if ($addDateTimeContext) { // @phpstan-ignore-line $prePrompt = ($prePrompt ? $prePrompt.(preg_match('/[\.\!\?]$/', $prePrompt) ? '' : '.').' ' : '').'Today we are '.dol_print_date(dol_now(), 'dayhourtext'); } if ($prePrompt) { diff --git a/htdocs/ai/lib/ai.lib.php b/htdocs/ai/lib/ai.lib.php index 25aa3482626..8705f1e961f 100644 --- a/htdocs/ai/lib/ai.lib.php +++ b/htdocs/ai/lib/ai.lib.php @@ -27,7 +27,7 @@ /** * Prepare admin pages header * - * @return array>}> + * @return array> */ function getLitOfAIFeatures() { diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index d3c9c2e3e13..20d22d47b7c 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -52,7 +52,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent postorget=".$postorget." URL=".$url." param=".$param); if (!function_exists('curl_init')) { - return array('http_code' => 500, 'content' => '', 'curl_error_no' => 'PHP curl lib not available', 'curl_error_msg' => 'PHP curl library must be installed'); + return array('http_code' => 500, 'content' => '', 'curl_error_no' => 1, 'curl_error_msg' => 'PHP curl library must be installed'); } //setting the curl parameters.