Overview
Comment:PSR-0 progress: move countries list in KD2fw
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 82870b9ec8308c7be718dc847c7a61792114e16b
User & Date: bohwaz on 2015-01-02 23:40:45
Other Links: manifest | tags
Context
2015-01-02
23:55
Patch fourni dans ticket [e6a2c8e0d9] : utilisation de la somme des transactions plutôt que de leur nombre pour la taille du camembert check-in: 050e4d960a user: bohwaz tags: trunk
23:40
PSR-0 progress: move countries list in KD2fw check-in: 82870b9ec8 user: bohwaz tags: trunk
2014-12-18
19:41
Passage à PSR-0 + Dépendances simplifiées avec KD2fw check-in: c39efc2c38 user: bohwaz tags: trunk
Changes

Modified src/include/lib/Garradin/Template.php from [a4347e0678] to [0b9f38d0e7].

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

namespace Garradin;

require_once ROOT . '/include/libs/template_lite/class.template.php';

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

    static public function getInstance()
    {




|







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

namespace Garradin;

require_once ROOT . '/include/lib/Template_Lite/class.template.php';

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

    static public function getInstance()
    {
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
    {
        $attributes .= 'required="required" ';
    }

    if (!empty($params['user_mode']) && empty($config['editable']))
    {
        $out = '<dt>' . htmlspecialchars($config['title'], ENT_QUOTES, 'UTF-8') . '</dt>';
        $out .= '<dd>' . htmlspecialchars((trim($value) === '' ? 'Non renseigné' : $value), ENT_QUOTES, 'UTF-8') . '</dd>';
        return $out;
    }

    if ($type == 'select')
    {
        $field .= '<select '.$attributes.'>';
        foreach ($config['options'] as $k=>$v)







|







433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
    {
        $attributes .= 'required="required" ';
    }

    if (!empty($params['user_mode']) && empty($config['editable']))
    {
        $out = '<dt>' . htmlspecialchars($config['title'], ENT_QUOTES, 'UTF-8') . '</dt>';
        $out .= '<dd>' . (trim($value) === '' ? 'Non renseigné' : tpl_display_champ_membre($value, $config)) . '</dd>';
        return $out;
    }

    if ($type == 'select')
    {
        $field .= '<select '.$attributes.'>';
        foreach ($config['options'] as $k=>$v)
531
532
533
534
535
536
537








































538
539
540
541
542
543
544
    {
        $out .= '
    <dd>' . $field . '</dd>';
    }

    return $out;
}









































$tpl->register_compiler('continue', function() { return 'continue;'; });

$tpl->register_function('csrf_field', 'Garradin\tpl_csrf_field');
$tpl->register_function('form_field', 'Garradin\tpl_form_field');
$tpl->register_function('select_compte', 'Garradin\tpl_select_compte');








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
    {
        $out .= '
    <dd>' . $field . '</dd>';
    }

    return $out;
}

function tpl_display_champ_membre ($v, $config)
{
    if ($config['type'] == 'checkbox')
    {
        return $v ? 'Oui' : 'Non';
    }
    elseif ($config['type'] == 'email')
    {
        return '<a href="mailto:' . $v . '">' . $v . '</a>';
    }
    elseif ($config['type'] == 'tel')
    {
        return '<a href="tel:' . $v . '">' . $v . '</a>';
    }
    elseif ($config['type'] == 'url')
    {
        return '<a href="' . $v . '">' . $v . '</a>';
    }
    elseif ($config['type'] == 'country') 
    {
        return Utils::getCountryName($v);
    }
    elseif ($config['type'] == 'multiple')
    {
        $out = [];

        foreach ($config['options'] as $b => $name)
        {
            if ($v & (0x01 << $b))
                $out[] = $name;
        }

        return implode(', ', $out);
    }
    else
    {
        return $v;
    }
}

$tpl->register_compiler('continue', function() { return 'continue;'; });

$tpl->register_function('csrf_field', 'Garradin\tpl_csrf_field');
$tpl->register_function('form_field', 'Garradin\tpl_form_field');
$tpl->register_function('select_compte', 'Garradin\tpl_select_compte');

555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
$tpl->register_modifier('format_tel', 'Garradin\tpl_format_tel');
$tpl->register_modifier('format_wiki', 'Garradin\tpl_format_wiki');
$tpl->register_modifier('liens_wiki', 'Garradin\tpl_liens_wiki');
$tpl->register_modifier('escape_money', 'Garradin\escape_money');
$tpl->register_modifier('html_money', 'Garradin\tpl_html_money');
$tpl->register_modifier('abs', 'abs');

$tpl->register_modifier('display_champ_membre', function ($v, $config) {
    if ($config['type'] == 'checkbox') {
        return $v ? 'Oui' : 'Non';
    } elseif ($config['type'] == 'email') {
        return '<a href="mailto:' . $v . '">' . $v . '</a>';
    } elseif ($config['type'] == 'tel') {
        return '<a href="tel:' . $v . '">' . $v . '</a>';
    } elseif ($config['type'] == 'url') {
        return '<a href="' . $v . '">' . $v . '</a>';
    } elseif ($config['type'] == 'country') {
        return Utils::getCountryName($v);
    } elseif ($config['type'] == 'multiple') {
        $out = [];

        foreach ($config['options'] as $b => $name)
        {
            if ($v & (0x01 << $b))
                $out[] = $name;
        }

        return implode(', ', $out);
    } else {
        return $v;
    }

});

$tpl->register_modifier('format_sqlite_date_to_french', ['Garradin\Utils', 'sqliteDateToFrench']);

$tpl->register_modifier('format_bytes', function ($size) {
    if ($size > (1024 * 1024))
        return round($size / 1024 / 1024, 2) . ' Mo';
    elseif ($size > 1024)







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







595
596
597
598
599
600
601
602

























603
604
605
606
607
608
609
$tpl->register_modifier('format_tel', 'Garradin\tpl_format_tel');
$tpl->register_modifier('format_wiki', 'Garradin\tpl_format_wiki');
$tpl->register_modifier('liens_wiki', 'Garradin\tpl_liens_wiki');
$tpl->register_modifier('escape_money', 'Garradin\escape_money');
$tpl->register_modifier('html_money', 'Garradin\tpl_html_money');
$tpl->register_modifier('abs', 'abs');

$tpl->register_modifier('display_champ_membre', 'Garradin\tpl_display_champ_membre');


























$tpl->register_modifier('format_sqlite_date_to_french', ['Garradin\Utils', 'sqliteDateToFrench']);

$tpl->register_modifier('format_bytes', function ($size) {
    if ($size > (1024 * 1024))
        return round($size / 1024 / 1024, 2) . ' Mo';
    elseif ($size > 1024)

Modified src/include/lib/Garradin/Utils.php from [76e15a68b6] to [5778268a49].

260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
        if (!empty($_SERVER['REMOTE_ADDR']))
            return $_SERVER['REMOTE_ADDR'];
        return '';
    }

    static public function &getCountryList()
    {
        if (is_null(self::$country_list))
        {
            require_once ROOT . '/include/libs/countries/countries_fr.php';
            self::$country_list = $countries;
        }

        return self::$country_list;
    }

    static public function getCountryName($code)
    {
        $list = self::getCountryList();

        if (!isset($list[$code]))







<
<
<
<
<
|
<







260
261
262
263
264
265
266





267

268
269
270
271
272
273
274
        if (!empty($_SERVER['REMOTE_ADDR']))
            return $_SERVER['REMOTE_ADDR'];
        return '';
    }

    static public function &getCountryList()
    {





        return \KD2\Countries_FR::$countries;

    }

    static public function getCountryName($code)
    {
        $list = self::getCountryList();

        if (!isset($list[$code]))

Modified tools/setup_dependencies.sh from [1023c19b73] to [aa98a2d421].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

# Mise en place/à jour des dépendances

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

if [ ! -d "$SCRIPTPATH/../src" ]
then
	echo "$SCRIPTPATH n'est pas le bon chemin, ou répertoire src/ manquant"
	exit 0
fi

KEYWORD="checkout"
SRCPATH="$SCRIPTPATH/../src/include/libs"

# Template Lite
svn ${KEYWORD} https://svn.kd2.org/svn/misc/libs/template_lite/ "$SRCPATH/template_lite/"

# Liste des pays
svn ${KEYWORD} https://svn.kd2.org/svn/misc/libs/i18n/countries/ "$SRCPATH/countries/"













|


|

<
<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


#!/bin/sh

# Mise en place/à jour des dépendances

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

if [ ! -d "$SCRIPTPATH/../src" ]
then
	echo "$SCRIPTPATH n'est pas le bon chemin, ou répertoire src/ manquant"
	exit 0
fi

KEYWORD="checkout"
SRCPATH="$SCRIPTPATH/../src/include/lib"

# Template Lite
svn ${KEYWORD} https://svn.kd2.org/svn/misc/libs/template_lite/ "$SRCPATH/Template_Lite/"