Overview
Comment:Refactor date modifiers, remove format_sqlite_date_to_french modifier
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 6f8a05aa31f3d7fa1c5d2cf17b3838aa9d23b0ee
User & Date: bohwaz on 2020-11-25 15:24:04
Other Links: branch diff | manifest | tags
Context
2020-11-25
15:35
Refactor old date_fr modifiers check-in: 6dd8cf19c9 user: bohwaz tags: dev
15:24
Refactor date modifiers, remove format_sqlite_date_to_french modifier check-in: 6f8a05aa31 user: bohwaz tags: dev
12:51
Don't allow to restore an old upgrade as it would mean you are logged out check-in: 3d65b650cd user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Accounting/Graph.php from [b9b5c0b6e9] to [a1b33675d1].

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		if (count($data))
		{
			$labels = [];

			foreach ($data[0]->get() as $k=>$v)
			{
				$date = new \DateTime('@' . ($k * $interval));
				$labels[] = Utils::date_fr('M y', $date);
			}

			$plot->setLabels($labels);

			$i = 0;
			$colors = self::getColors();








|







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		if (count($data))
		{
			$labels = [];

			foreach ($data[0]->get() as $k=>$v)
			{
				$date = new \DateTime('@' . ($k * $interval));
				$labels[] = Utils::date_fr($date, 'M y');
			}

			$plot->setLabels($labels);

			$i = 0;
			$colors = self::getColors();

Modified src/include/lib/Garradin/Template.php from [8e6516db48] to [9daeb04963].

1
2
3
4
5
6

7
8
9
10
11
12
13
<?php

namespace Garradin;

use KD2\Form;
use KD2\HTTP;

use Garradin\Membres\Session;
use Garradin\Entities\Accounting\Account;

class Template extends \KD2\Smartyer
{
	static protected $_instance = null;







>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

namespace Garradin;

use KD2\Form;
use KD2\HTTP;
use KD2\Translate;
use Garradin\Membres\Session;
use Garradin\Entities\Accounting\Account;

class Template extends \KD2\Smartyer
{
	static protected $_instance = null;

76
77
78
79
80
81
82
83
84
85
86
87
88


89
90
91
92
93
94
95
96
97
98
99
100
101
		$this->register_function('icon', [$this, 'widgetIcon']);
		$this->register_function('button', [$this, 'widgetButton']);
		$this->register_function('linkbutton', [$this, 'widgetLinkButton']);

		$this->register_modifier('strlen', 'strlen');
		$this->register_modifier('dump', ['KD2\ErrorManager', 'dump']);
		$this->register_modifier('get_country_name', ['Garradin\Utils', 'getCountryName']);
		$this->register_modifier('format_sqlite_date_to_french', ['Garradin\Utils', 'sqliteDateToFrench']);
		$this->register_modifier('format_bytes', ['Garradin\Utils', 'format_bytes']);
		$this->register_modifier('format_tel', [$this, 'formatPhoneNumber']);
		$this->register_modifier('abs', 'abs');
		$this->register_modifier('display_champ_membre', [$this, 'displayChampMembre']);



		$this->register_modifier('date_fr', function ($ts, $format = 'd/m/Y H:i:s') {
			return Utils::date_fr($format, $ts);
		});

		$this->register_modifier('date_short', function ($dt) {
			return Utils::date_fr('d/m/Y', $dt);
		});

		$this->register_modifier('html_money', [$this, 'htmlMoney']);
		$this->register_modifier('money_currency', [$this, 'htmlMoneyCurrency']);

		$this->register_modifier('format_wiki', function ($str) {
			$str = Utils::SkrivToHTML($str);







<
<




>
>
|
<
<


|







77
78
79
80
81
82
83


84
85
86
87
88
89
90


91
92
93
94
95
96
97
98
99
100
		$this->register_function('icon', [$this, 'widgetIcon']);
		$this->register_function('button', [$this, 'widgetButton']);
		$this->register_function('linkbutton', [$this, 'widgetLinkButton']);

		$this->register_modifier('strlen', 'strlen');
		$this->register_modifier('dump', ['KD2\ErrorManager', 'dump']);
		$this->register_modifier('get_country_name', ['Garradin\Utils', 'getCountryName']);


		$this->register_modifier('format_tel', [$this, 'formatPhoneNumber']);
		$this->register_modifier('abs', 'abs');
		$this->register_modifier('display_champ_membre', [$this, 'displayChampMembre']);

		$this->register_modifier('format_bytes', ['Garradin\Utils', 'format_bytes']);
		$this->register_modifier('strftime_fr', [Utils::class, 'strftime_fr']);
		$this->register_modifier('date_fr', [Utils::class, 'date_fr']);



		$this->register_modifier('date_short', function ($dt) {
			return Utils::date_fr($dt, 'd/m/Y');
		});

		$this->register_modifier('html_money', [$this, 'htmlMoney']);
		$this->register_modifier('money_currency', [$this, 'htmlMoneyCurrency']);

		$this->register_modifier('format_wiki', function ($str) {
			$str = Utils::SkrivToHTML($str);
245
246
247
248
249
250
251





252
253
254
255
256
257
258
		}
		elseif (isset($default)) {
			$current_value = $default;
		}

		if ($type == 'date' && is_object($current_value) && $current_value instanceof \DateTimeInterface) {
			$current_value = $current_value->format('d/m/Y');





		}

		$attributes['id'] = 'f_' . $name;
		$attributes['name'] = $name;

		if ($type == 'radio' || $type == 'checkbox') {
			$attributes['id'] .= '_' . $value;







>
>
>
>
>







244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
		}
		elseif (isset($default)) {
			$current_value = $default;
		}

		if ($type == 'date' && is_object($current_value) && $current_value instanceof \DateTimeInterface) {
			$current_value = $current_value->format('d/m/Y');
		}
		elseif ($type == 'date' && is_string($current_value)) {
			if ($v = \DateTime::createFromFormat('!Y-m-d', $current_value)) {
				$current_value = $v->format('d/m/Y');
			}
		}

		$attributes['id'] = 'f_' . $name;
		$attributes['name'] = $name;

		if ($type == 'radio' || $type == 'checkbox') {
			$attributes['id'] .= '_' . $value;

Modified src/include/lib/Garradin/Utils.php from [9de2c1822f] to [2f36c3168c].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28



29












30
31
32
33

34

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
    const EMAIL_CONTEXT_BULK = 'bulk';
    const EMAIL_CONTEXT_PRIVATE = 'private';
    const EMAIL_CONTEXT_SYSTEM = 'system';

    static protected $skriv = null;

    static private $french_date_names = [
        'January'=>'Janvier', 'February'=>'Février', 'March'=>'Mars', 'April'=>'Avril', 'May'=>'Mai',
        'June'=>'Juin', 'July'=>'Juillet', 'August'=>'Août', 'September'=>'Septembre', 'October'=>'Octobre',
        'November'=>'Novembre', 'December'=>'Décembre', 'Monday'=>'Lundi', 'Tuesday'=>'Mardi', 'Wednesday'=>'Mercredi',
        'Thursday'=>'Jeudi','Friday'=>'Vendredi','Saturday'=>'Samedi','Sunday'=>'Dimanche',
        'Feb'=>'Fév','Apr'=>'Avr','Jun'=>'Juin', 'Jul'=>'Juil','Aug'=>'Aout','Dec'=>'Déc',
        'Mon'=>'Lun','Tue'=>'Mar','Wed'=>'Mer','Thu'=>'Jeu','Fri'=>'Ven','Sat'=>'Sam','Sun'=>'Dim'];

    static public function strftime_fr($format=null, $ts=null)
    {



        if (is_null($format))












        {
            $format = '%d/%m/%Y à %H:%M';
        }


        $date = strftime($format, $ts);

        $date = strtr($date, self::$french_date_names);
        $date = strtolower($date);
        return $date;
    }

    static public function date_fr($format=null, $ts=null)
    {
        if (is_null($format))
        {
            $format = 'd/m/Y à H:i';
        }

        if (is_object($ts)) {
            $date = $ts->format($format);
        }
        elseif (is_numeric($ts)) {
            $date = date($format, $ts);
        }
        elseif (strlen($ts) == 10) {
            $ts = \DateTime::createFromFormat('!Y-m-d', $ts);
            $date = $ts->format($format);
        }
        elseif (strlen($ts) == 19) {
            $ts = \DateTime::createFromFormat('Y-m-d H:i:s', $ts);
            $date = $ts->format($format);
        }
        else {
            return null;
        }

        $date = strtr($date, self::$french_date_names);
        $date = strtolower($date);
        return $date;
    }

    static public function sqliteDateToFrench($d, $short = false)
    {
        if (strlen($d) == 10 || $short)







|







|

>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
|
<
|
>
|
>
|




|






<
<
<
<
|
<
<
<
|
|
<
<
<
<
<
<
<
<
|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62




63



64
65








66
67
68
69
70
71
72
73
{
    const EMAIL_CONTEXT_BULK = 'bulk';
    const EMAIL_CONTEXT_PRIVATE = 'private';
    const EMAIL_CONTEXT_SYSTEM = 'system';

    static protected $skriv = null;

    const FRENCH_DATE_NAMES = [
        'January'=>'Janvier', 'February'=>'Février', 'March'=>'Mars', 'April'=>'Avril', 'May'=>'Mai',
        'June'=>'Juin', 'July'=>'Juillet', 'August'=>'Août', 'September'=>'Septembre', 'October'=>'Octobre',
        'November'=>'Novembre', 'December'=>'Décembre', 'Monday'=>'Lundi', 'Tuesday'=>'Mardi', 'Wednesday'=>'Mercredi',
        'Thursday'=>'Jeudi','Friday'=>'Vendredi','Saturday'=>'Samedi','Sunday'=>'Dimanche',
        'Feb'=>'Fév','Apr'=>'Avr','Jun'=>'Juin', 'Jul'=>'Juil','Aug'=>'Aout','Dec'=>'Déc',
        'Mon'=>'Lun','Tue'=>'Mar','Wed'=>'Mer','Thu'=>'Jeu','Fri'=>'Ven','Sat'=>'Sam','Sun'=>'Dim'];

    static public function get_datetime($ts)
    {
        if (is_object($ts) && $ts instanceof \DateTimeInterface) {
            return $ts;
        }
        elseif (is_numeric($ts)) {
            return new \DateTime('@' . $ts);
        }
        elseif (strlen($ts) == 10) {
            return \DateTime::createFromFormat('!Y-m-d', $ts);
        }
        elseif (strlen($ts) == 19) {
            return \DateTime::createFromFormat('Y-m-d H:i:s', $ts);
        }
        else {
            return null;
        }
    }

    static public function strftime_fr($ts, $format)

    {
        $ts = self::get_datetime($ts);
        $date = strftime($format, $ts->getTimestamp());

        $date = strtr($date, self::FRENCH_DATE_NAMES);
        $date = strtolower($date);
        return $date;
    }

    static public function date_fr($ts, $format = null)
    {
        if (is_null($format))
        {
            $format = 'd/m/Y à H:i';
        }





        $date = self::get_datetime($ts);



        $date = $date->format($format);









        $date = strtr($date, self::FRENCH_DATE_NAMES);
        $date = strtolower($date);
        return $date;
    }

    static public function sqliteDateToFrench($d, $short = false)
    {
        if (strlen($d) == 10 || $short)

Modified src/www/admin/static/styles/03-forms.css from [eda1102a12] to [346b6469db].

225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

input[readonly], input.disabled {
    color: #666;
    background-color: #eee;
    border-color: #999;
}

select, input[size], input[type=color], button, input[type=button], input[type=submit] {
    min-width: 0;
}

/* Radio button lists (eg. new transaction) */
form .radio-btn {
    display: table;
    width: 100%;







|







225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

input[readonly], input.disabled {
    color: #666;
    background-color: #eee;
    border-color: #999;
}

select, input[size], input[type=color], button, input[type=button], input[type=submit], input[type=number] {
    min-width: 0;
}

/* Radio button lists (eg. new transaction) */
form .radio-btn {
    display: table;
    width: 100%;