Differences From Artifact [8a63c595f0]:

To Artifact [2a741f1d56]:


1


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



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

class Garradin_TPL extends Template_Lite
{
    static protected $_instance = null;

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new Garradin_TPL;
    }

    private function __clone()
    {
    }

    public function __construct()

>
>



|





|







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

namespace Garradin;

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

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

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new Template;
    }

    private function __clone()
    {
    }

    public function __construct()
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
        $this->assign('www_url', WWW_URL);
        $this->assign('self_url', utils::getSelfUrl());

        $this->assign('is_logged', false);
    }
}

$tpl = Garradin_TPL::getInstance();

if (class_exists('Garradin_Config'))
{
    $tpl->assign('config', Garradin_Config::getInstance()->getConfig());
}
else
{
    $tpl->assign('config', false);
}

function tpl_csrf_field($params)
{
    $name = utils::CSRF_field_name($params['key']);
    $value = utils::CSRF_create($params['key']);

    return '<input type="hidden" name="'.$name.'" value="'.$value.'" />';







|

<
<
<
<
<
<
|
<







33
34
35
36
37
38
39
40
41






42

43
44
45
46
47
48
49
        $this->assign('www_url', WWW_URL);
        $this->assign('self_url', utils::getSelfUrl());

        $this->assign('is_logged', false);
    }
}

$tpl = Template::getInstance();







$tpl->assign('config', Config::getInstance()->getConfig());


function tpl_csrf_field($params)
{
    $name = utils::CSRF_field_name($params['key']);
    $value = utils::CSRF_create($params['key']);

    return '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
function tpl_format_droits($params)
{
    $droits = $params['droits'];

    $out = array('connexion' => '', 'inscription' => '', 'membres' => '', 'compta' => '',
        'wiki' => '', 'config' => '');
    $classes = array(
        Garradin_Membres::DROIT_AUCUN   =>  'aucun',
        Garradin_Membres::DROIT_ACCES   =>  'acces',
        Garradin_Membres::DROIT_ECRITURE=>  'ecriture',
        Garradin_Membres::DROIT_ADMIN   =>  'admin',
    );

    foreach ($droits as $cle=>$droit)
    {
        $cle = str_replace('droit_', '', $cle);

        if (array_key_exists($cle, $out))
        {

            $class = $classes[$droit];
            $desc = false;
            $s = false;

            if ($cle == 'connexion')
            {
                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de se connecter';
                else
                    $desc = 'A le droit de se connecter';
            }
            elseif ($cle == 'inscription')
            {
                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de s\'inscrire seul';
                else
                    $desc = 'A le droit de s\'inscrire seul';
            }
            elseif ($cle == 'config')
            {
                $s = '&#x2611;';

                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc = 'Ne peut modifier la configuration';
                else
                    $desc = 'Peut modifier la configuration';
            }
            elseif ($cle == 'compta')
            {
                $s = '&euro;';
            }

            if (!$s)
                $s = strtoupper($cle[0]);

            if (!$desc)
            {
                $desc = ucfirst($cle). ' : ';

                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc .= 'Pas accès';
                elseif ($droit == Garradin_Membres::DROIT_ACCES)
                    $desc .= 'Lecture uniquement';
                elseif ($droit == Garradin_Membres::DROIT_ECRITURE)
                    $desc .= 'Lecture & écriture';
                else
                    $desc .= 'Administration';
            }

            $out[$cle] = '<b class="'.$class.' '.$cle.'" title="'
                .htmlspecialchars($desc, ENT_QUOTES, 'UTF-8').'">'.$s.'</b>';







|
|
|
|















|






|








|
















|

|

|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
function tpl_format_droits($params)
{
    $droits = $params['droits'];

    $out = array('connexion' => '', 'inscription' => '', 'membres' => '', 'compta' => '',
        'wiki' => '', 'config' => '');
    $classes = array(
        Membres::DROIT_AUCUN   =>  'aucun',
        Membres::DROIT_ACCES   =>  'acces',
        Membres::DROIT_ECRITURE=>  'ecriture',
        Membres::DROIT_ADMIN   =>  'admin',
    );

    foreach ($droits as $cle=>$droit)
    {
        $cle = str_replace('droit_', '', $cle);

        if (array_key_exists($cle, $out))
        {

            $class = $classes[$droit];
            $desc = false;
            $s = false;

            if ($cle == 'connexion')
            {
                if ($droit == Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de se connecter';
                else
                    $desc = 'A le droit de se connecter';
            }
            elseif ($cle == 'inscription')
            {
                if ($droit == Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de s\'inscrire seul';
                else
                    $desc = 'A le droit de s\'inscrire seul';
            }
            elseif ($cle == 'config')
            {
                $s = '&#x2611;';

                if ($droit == Membres::DROIT_AUCUN)
                    $desc = 'Ne peut modifier la configuration';
                else
                    $desc = 'Peut modifier la configuration';
            }
            elseif ($cle == 'compta')
            {
                $s = '&euro;';
            }

            if (!$s)
                $s = strtoupper($cle[0]);

            if (!$desc)
            {
                $desc = ucfirst($cle). ' : ';

                if ($droit == Membres::DROIT_AUCUN)
                    $desc .= 'Pas accès';
                elseif ($droit == Membres::DROIT_ACCES)
                    $desc .= 'Lecture uniquement';
                elseif ($droit == Membres::DROIT_ECRITURE)
                    $desc .= 'Lecture & écriture';
                else
                    $desc .= 'Administration';
            }

            $out[$cle] = '<b class="'.$class.' '.$cle.'" title="'
                .htmlspecialchars($desc, ENT_QUOTES, 'UTF-8').'">'.$s.'</b>';
178
179
180
181
182
183
184

185

186
187
188
189
190
191
192
    $str = utils::htmlSpip($str);
    $str = utils::htmlGarbage2xhtml($str);
    return $str;
}

function tpl_liens_wiki($str, $prefix)
{

    return preg_replace('!<a href="([^/.]+)">!ie', '"<a href=\"".$prefix.Garradin_Wiki::transformTitleToURI("$1")."\">"', $str);

}

function tpl_pagination($params)
{
    if (!isset($params['url']) || !isset($params['page']) || !isset($params['bypage']) || !isset($params['total']))
        throw new BadFunctionCallException("Paramètre manquant pour pagination");








>
|
>







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
    $str = utils::htmlSpip($str);
    $str = utils::htmlGarbage2xhtml($str);
    return $str;
}

function tpl_liens_wiki($str, $prefix)
{
    return preg_replace_callback('!<a href="([^/.]+)">!i', function ($matches) use ($prefix) {
        return '<a href="' . $prefix . Wiki::transformTitleToURI($matches[1]) . '">';
    }, $str);
}

function tpl_pagination($params)
{
    if (!isset($params['url']) || !isset($params['page']) || !isset($params['bypage']) || !isset($params['total']))
        throw new BadFunctionCallException("Paramètre manquant pour pagination");

352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
}

function escape_money($number)
{
    return number_format((float)$number, 2, ',', ' ');
}

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

$tpl->register_function('format_droits', 'tpl_format_droits');

$tpl->register_function('pagination', 'tpl_pagination');

$tpl->register_function('diff', 'tpl_diff');

$tpl->register_modifier('get_country_name', array('utils', 'getCountryName'));
$tpl->register_modifier('format_tel', 'tpl_format_tel');
$tpl->register_modifier('format_wiki', 'tpl_format_wiki');
$tpl->register_modifier('liens_wiki', 'tpl_liens_wiki');
$tpl->register_modifier('escape_money', 'escape_money');
$tpl->register_modifier('abs', 'abs');

//$tpl->register_modifier('retard_cotisation', array('Garradin_Membres', 'checkCotisation'));

$tpl->register_modifier('strftime_fr', 'tpl_strftime_fr');
$tpl->register_modifier('date_fr', 'tpl_date_fr');

?>







|
|
|

|

|

|

|
|
|
|
|


|

|
|


349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
}

function escape_money($number)
{
    return number_format((float)$number, 2, ',', ' ');
}

$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');

$tpl->register_function('format_droits', 'Garradin\tpl_format_droits');

$tpl->register_function('pagination', 'Garradin\tpl_pagination');

$tpl->register_function('diff', 'Garradin\tpl_diff');

$tpl->register_modifier('get_country_name', array('Garradin\utils', 'getCountryName'));
$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('abs', 'abs');

//$tpl->register_modifier('retard_cotisation', array('Membres', 'checkCotisation'));

$tpl->register_modifier('strftime_fr', 'Garradin\tpl_strftime_fr');
$tpl->register_modifier('date_fr', 'Garradin\tpl_date_fr');

?>