Differences From Artifact [a4347e0678]:

To Artifact [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)