[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 74/107: New : manage_table_sql has new functi
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 74/107: New : manage_table_sql has new function (input_custom and display_row_custom) for handling special data |
Date: |
Mon, 26 Aug 2019 10:32:04 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit b21b3bd922a0aa49c27e7ed13f562a38536e374e
Author: Dany De Bontridder <address@hidden>
Date: Thu Aug 8 01:26:26 2019 +0200
New : manage_table_sql has new function (input_custom and
display_row_custom)
for handling special data
---
include/lib/manage_table_sql.class.php | 54 ++++++++++++++++++++++++++++++----
1 file changed, 49 insertions(+), 5 deletions(-)
diff --git a/include/lib/manage_table_sql.class.php
b/include/lib/manage_table_sql.class.php
index 51aef22..3488a20 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -262,8 +262,11 @@ function check()
* select must supply an array of possible values [val=> , label=>] with
* the variable $this->key_name->a_value
* @param $p_key col name
- * @param $p_type is SELECT NUMERIC TEXT or DATE
+ * @param $p_type is SELECT NUMERIC TEXT , DATE or custom
* @param $p_array if type is SELECT an array is expected
+ * @note if $p_type is custom then a function named
input_custom($p_key,$p_value) must be implemented
+ * in the class
+ * @see Manage_Table_SQL:input_custom
*/
function set_col_type($p_key, $p_value, $p_array=NULL)
{
@@ -271,7 +274,7 @@ function check()
throw new Exception("invalid key $p_key");
if (!in_array($p_value,
- array("text", "numeric", "date", "select",
"timestamp")))
+ array("text", "numeric", "date", "select",
"timestamp","custom")))
throw new Exception("invalid type $p_value");
$this->a_type[$p_key]=$p_value;
@@ -770,7 +773,11 @@ function check()
/**
* @brief display a data row in the table, with the order defined
* in a_order and depending of the visibility of the column
+ * @param array $p_row contains a row from the database
+ * @see set_col_type
+ * @see input_custom
* @see display_table
+ * @see display_row_custom
*/
function display_row($p_row)
{
@@ -830,7 +837,11 @@ function check()
}
- }else {
+ } elseif ($this->get_col_type($v)=="custom") {
+ // For custom col
+ echo td($this->display_row_custom($v,$p_row[$v]));
+ }
+ else {
echo td($p_row[$v]);
}
}
@@ -844,7 +855,18 @@ function check()
echo '</tr>';
}
-
+ /**
+ * For the type custom , we can call a function to display properly the
value
+ * @param $p_key string key name
+ * @param $p_value string value
+ * @see input_custom
+ * @see set_type
+ * @note must return a string which will be in surrounded by td in the
function display_row
+ * @return string
+ */
+ function display_row_custom($p_key,$p_value) {
+ return $p_value;
+ }
/**
* @brief display into a dialog box the datarow in order
* to be appended or modified. Can be override if you need
@@ -905,6 +927,9 @@ function check()
$min_size=10;
$text->size=$min_size;
echo $text->input();
+ } elseif ($this->a_type[$key]=="custom")
+ {
+ $this->input_custom($key,$value);
}
echo "</td>";
}
@@ -919,7 +944,26 @@ function check()
}
echo "</table>";
}
-
+ /**
+ * @brief this function let you create your own input , for example for a
ITEXT , a IRADIO , ...
+ * it must be override , there is not default
+ * @code
+ * function input_custom($p_key,$p_value) {
+ * switch ($p_key) {
+ * case 'name':
+ * $w=new ICard($p_key,$p_value);
+ * $w->input();
+ * break;
+ * }
+ * }
+ * @endcode
+ * @parameter string $p_key name of the column
+ * @parameter string $p_value current value
+ * @return nothing
+ */
+ function input_custom($p_key,$p_value) {
+ throw new Exception(__FILE__.":".__LINE__."-"._("non implémenté"));
+ }
/**
* @brief Save the record from Request into the DB and returns an XML
* to update the Html Element
- [Noalyss-commit] [noalyss] 25/107: correct js for error, (continued)
- [Noalyss-commit] [noalyss] 25/107: correct js for error, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 29/107: Bug in exception : gettext cannot accept 2 args, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 33/107: Small bug use the date instead of now for table version, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 40/107: PHPUnit : adapt to new version, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 61/107: Documentation, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 62/107: #1316: Notes tableau de bord - pas de limite ou choix., Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 69/107: Fix test, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 50/107: Documentation : automatic format breaks doxygen tag, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 43/107: fixup! Code cleaning : split database into database (for noalyss) and databasecore , with the functions, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 65/107: Code cleaning : remove obsolete, and direct access to, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 74/107: New : manage_table_sql has new function (input_custom and display_row_custom) for handling special data,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 73/107: Cosmetic & bug fix for SELECT_BOX, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 28/107: Debug : add function tracedebug, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 32/107: Cosmetic : font new symbol Cosmetic : CSS padding for div.menu2 a.mtitle, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 58/107: javascript Add new function json_response, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 52/107: Adapt Unit Test, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 76/107: fixup! Improve message progress bar + translation, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 78/107: Purpose is to contain all the prepared query called from different locations, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 83/107: Task#1734 New : Add PRINTTVA to have a summary of VAT by ledger, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 93/107: Documentation, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 92/107: Code : remove direct use of $_GET, Dany De Bontridder, 2019/08/26