]> git.agnieray.net Git - galette.git/commitdiff
Code cleanup
authorJohan Cwiklinski <johan@x-tnd.be>
Sun, 14 Apr 2024 07:02:08 +0000 (09:02 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 14 Apr 2024 07:13:47 +0000 (09:13 +0200)
Remove useless polyfill
Drop no longer used functions
Remove dead code

.composer-require-checker.config.json
galette/includes/functions.inc.php
galette/lib/Galette/Controllers/Crud/TransactionsController.php

index 482010e7bd8deccc917f4ddc08ba6690cae64647..c22b04f7b1249a3f20a135fa5d853eb642f6834b 100644 (file)
@@ -70,9 +70,6 @@
 
     "//know but not detected Galette function,",
     "remove_remarks",
-    "custom_html_entity_decode",
-    "get_form_value",
-    "get_numeric_form_value",
     "isValidWebUrl",
     "remove_remarks",
     "split_sql_file",
index 3f69c0dae39e0d6db0e93a8852bf095e754fbb8a..2716e5cb76588ebe24979b3e2e4a45aa95c92b42 100644 (file)
@@ -23,8 +23,6 @@ if (!defined('GALETTE_ROOT')) {
     die("Sorry. You can't access directly to this file");
 }
 
-use Analog\Analog;
-
 /**
  * Check URL validity
  *
@@ -39,109 +37,3 @@ function isValidWebUrl($url)
         $url
     ));
 }
-
-/**
- * Custom HTML entitiy decode
- *
- * @param string $given_html  Original HTML
- * @param int    $quote_style Quoting style
- *
- * @return string
- */
-function custom_html_entity_decode($given_html, $quote_style = ENT_QUOTES)
-{
-    $trans_table = array_flip(
-        get_html_translation_table(
-            HTML_ENTITIES,
-            $quote_style
-        )
-    );
-    $trans_table['&#39;'] = "'";
-    return strtr($given_html, $trans_table);
-}
-
-/**
- * Get a value sent by a form, either in POST and GET arrays
- *
- * @param string $name   property name
- * @param string $defval default rollback value
- *
- * @return string value retrieved from :
- * - GET array if defined and numeric,
- * - POST array if defined and numéric
- * - $defval otherwise
- */
-function get_form_value($name, $defval)
-{
-    $val = $defval;
-    if (isset($_GET[$name])) {
-        $val = $_GET[$name];
-    } elseif (isset($_POST[$name])) {
-        $val = $_POST[$name];
-    }
-    return $val;
-}
-
-/**
- * Get a numeric value sent by a form, either in POST and GET arrays
- *
- * @param string $name   property name
- * @param string $defval default rollback value
- *
- * @return numeric value retrieved from :
- * - GET array if defined and numeric,
- * - POST array if defined and numéric
- * - $defval otherwise
- */
-function get_numeric_form_value($name, $defval)
-{
-    $val = get_form_value($name, $defval);
-    if (!is_numeric($val)) {
-        Analog::log(
-            '[get_numeric_form_value] not a numeric value! (value was: `' .
-            $val . '`)',
-            Analog::INFO
-        );
-        $val = $defval;
-    }
-    return $val;
-}
-
-/**
- * Get a post numeric value
- *
- * @param string $name   property name
- * @param string $defval default rollback value
- *
- * @return string value retrieved from :
- * - POST array if defined and numéric
- * - $defval otherwise
- */
-function get_numeric_posted_value($name, $defval)
-{
-    if (isset($_POST[$name])) {
-        $val = $_POST[$name];
-        if (is_numeric($val)) {
-            return $val;
-        }
-    }
-    return $defval;
-}
-
-if (!function_exists('str_contains')) {
-    /**
-     * PHP8 str_contains polyfill
-     *
-     * based on original work from the PHP Laravel framework
-     * see https://www.php.net/manual/fr/function.str-contains.php#125977
-     *
-     * @param string $haystack The string to search in.
-     * @param string $needle   The substring to search for in the haystack
-     *
-     * @return bool
-     */
-    function str_contains($haystack, $needle)
-    {
-        return $needle !== '' && mb_strpos($haystack, $needle) !== false;
-    }
-}
index c311c47d4106d4249cfbc160d7524f28dd642926..b664bc4e370e926c2992f6def29bc5f094a237ba 100644 (file)
@@ -92,8 +92,6 @@ class TransactionsController extends ContributionsController
      */
     public function edit(Request $request, Response $response, int $id = null, string|null $action = 'edit'): Response
     {
-        $trans = null;
-
         if ($this->session->transaction !== null) {
             $trans = $this->session->transaction;
             $this->session->transaction = null;
@@ -106,12 +104,6 @@ class TransactionsController extends ContributionsController
             $trans_id = $id;
         }
 
-        $transaction['trans_id'] = $trans_id;
-        $transaction['trans_amount'] = get_numeric_form_value("trans_amount", '');
-        $transaction['trans_date'] = get_form_value("trans_date", '');
-        $transaction['trans_desc'] = get_form_value("trans_desc", '');
-        $transaction['id_adh'] = get_numeric_form_value("id_adh", '');
-
         // flagging required fields
         $required = array(
             'trans_amount'  =>  1,
@@ -140,7 +132,6 @@ class TransactionsController extends ContributionsController
         $params = [
             'page_title'        => $title,
             'required'          => $required,
-            'data'              => $transaction, //TODO: remove
             'transaction'       => $trans
         ];