[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 27/38: Nouvelle fonction pour ajouter des att
From: |
dwm |
Subject: |
[Noalyss-commit] [noalyss] 27/38: Nouvelle fonction pour ajouter des attributs à un élément DOM |
Date: |
Sun, 18 Feb 2024 07:30:46 -0500 (EST) |
sparkyx pushed a commit to branch devel
in repository noalyss.
commit 09ad1d762d0b71a6c95b041c0172cc1c9867aa38
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Wed Feb 14 18:23:18 2024 +0100
Nouvelle fonction pour ajouter des attributs à un élément DOM
---
include/lib/function_javascript.php | 18 ++++++++++++++++++
include/lib/html_input.class.php | 34 +++++++++++++++++++++++++++-------
2 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/include/lib/function_javascript.php
b/include/lib/function_javascript.php
index cc6895ca6..55f88dfe0 100644
--- a/include/lib/function_javascript.php
+++ b/include/lib/function_javascript.php
@@ -2798,4 +2798,22 @@ function json_response($p_answer)
JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
}
+/**
+ * @brief build a string with the attribute that javascript can use , that
string must be included in a DOM element.
+ * @note IMPORTANT : special chars will be translated(see htmlspecialchars
function) : quote, double-quote , ampersand...
+ * @param $pa_attribute array of pair key => value
+ * @see htmlspecialchars()
+ * @return HTML string
+ */
+function build_javascript_attribute($pa_attribute)
+{
+ $str_javascript_attr="";
+ if (! empty ($pa_attribute)) {
+ foreach ($pa_attribute as $key=>$value) {
+ $str_javascript_attr.=sprintf(' "%s"="%s" ',h($key),h($value));
+ }
+ }
+ return $str_javascript_attr;
+}
+
?>
diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php
index de151e6d6..a18b85a68 100755
--- a/include/lib/html_input.class.php
+++ b/include/lib/html_input.class.php
@@ -133,7 +133,8 @@ class HtmlInput
/**
* @brief you can add attribute to this in javascript
* this function is a wrapper and create a script (in js) to modify
- * "this" (in javascript) with the value of obj->attribute from PHP
+ * "this" (in javascript) with the value of obj->attribute from PHP.
+ * @see build_javascript_attribute() include the string in the DOM Element
instead of in a piece of code
* @return string : return string with the javascript code
*/
public function get_js_attr()
@@ -355,6 +356,22 @@ class HtmlInput
$view_history=HtmlInput::button("hcb".$e, $p_mesg, $js);
return $view_history;
}
+ /**
+ *@brief display a div with the history of the card
+ * @param int $f_id fiche.f_id
+ * @param string $p_mesg string to display
+ * @param int $p_exercice exercice of the history
+ */
+ static function followup_card_button($f_id, $p_mesg)
+ {
+ global $g_user;
+ $js=sprintf('onclick="view_followup_card(\'%s\',\'%s\')"', $f_id,
+ dossier::id());
+ $view_followup=HtmlInput::button(uniqid("fu"), $p_mesg, $js);
+ return $view_followup;
+ }
+
+
/**
* @brief display a div with the history of the account
@@ -581,13 +598,14 @@ class HtmlInput
* @brief show the detail of a card
*/
static function card_detail($p_qcode, $pname='', $p_style="",
- $p_nohistory=false)
+ $p_nohistory=false,$nofollowup=false)
{
if ($pname !=='') {$pname='<span class="v-large">('.$pname.')</span>';}
$r="";
$histo=($p_nohistory==true)?' ,nohistory:1':"";
- $r.=sprintf('<a href="javascript:void(0)" %s class="detail"
onclick="fill_ipopcard({qcode:\'%s\' %s})">%s %s</a>',
- $p_style, $p_qcode, $histo, $p_qcode,$pname);
+ $followup=($nofollowup==true)?' ,nofollowup:1':"";
+ $r.=sprintf('<a href="javascript:void(0)" %s class="detail"
onclick="fill_ipopcard({qcode:\'%s\' %s %s})">%s %s</a>',
+ $p_style, $p_qcode, $histo,$followup,$p_qcode,$pname);
return $r;
}
@@ -929,9 +947,11 @@ class HtmlInput
* @param string $p_js javascript
* @param string $p_style is the visuable effect (class, style...)
* @param string $p_title Title
+ * @param array $p_attribute javascript attribute to add to the anchor,
CAUTION special chars will be translated(see htmlspecialchars function)
+ * @see h()
*/
static function anchor($p_text, $p_url="", $p_js="",
- $p_style=' class="line" ',$p_title="click")
+ $p_style=' class="line" ', $p_title="click", array
$p_attribute=[])
{
if ($p_js!="")
{
@@ -939,8 +959,8 @@ class HtmlInput
} else {
$p_url=sprintf('href="%s"',$p_url);
}
-
- $str=sprintf('<a %s %s %s title="%s">%s</a>', $p_style, $p_url, $p_js,
$p_title,$p_text);
+ $str_javascript_attr=build_javascript_attribute($p_attribute);
+ $str=sprintf('<a %s %s %s %s title="%s">%s</a>',
$str_javascript_attr,$p_style, $p_url, $p_js, $p_title,$p_text);
return $str;
}
- [Noalyss-commit] [noalyss] 26/38: Task #2321: erreur de numérotation, (continued)
- [Noalyss-commit] [noalyss] 26/38: Task #2321: erreur de numérotation, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 29/38: cosmetic, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 10/38: Filtre ne fonctionne pas tva_search_id est vide, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 11/38: Sécurité : bloquer le changement de date des opérations, Renforce mode strict : change de date impossible, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 17/38: FOLLOWUP : nom contact pas affiché, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 23/38: Merge branch 'devel', dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 13/38: FOLLOWUP : Cosmetic nombre pièces, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 22/38: Fix : auto numbering receipt, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 32/38: cosmetic, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 36/38: Fix : Bug cannot filter a list of element, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 27/38: Nouvelle fonction pour ajouter des attributs à un élément DOM,
dwm <=
- [Noalyss-commit] [noalyss] 31/38: DB protect against JS Injection, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 24/38: Nouveau #00022980002298: detail fiche , historique du suivi, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 35/38: Merge devel, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 09/38: Task #2321: Sécurité : empêcher changement de numéro de pièce, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 16/38: Follow-Up : bug ne peut pas ajouter fichier sur nouvel événement, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 18/38: Fix cosmetic bug : duplicate operation with autoreverse VAT has an VAT amount, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 20/38: Fix : auto numbering receipt, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 21/38: Merge branch 'devel', dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 25/38: cosmetic, dwm, 2024/02/18
- [Noalyss-commit] [noalyss] 37/38: Cosmetic, dwm, 2024/02/18