Overview
Comment:Édition de squelette
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ca38053ee11542f409ccff87a59b683e10f69382
User & Date: bohwaz on 2012-05-21 02:43:26
Other Links: manifest | tags
Context
2012-05-21
03:22
Déplacement de la CSS par défaut check-in: a674a25aad user: bohwaz tags: trunk
02:43
Édition de squelette check-in: ca38053ee1 user: bohwaz tags: trunk
02:19
Déplacement des squelettes, CSS, etc. pour séparer contenu utilisateur du contenu admin check-in: df3ed64d14 user: bohwaz tags: trunk
Changes

Modified include/class.squelette.php from [af5ba1dbd4] to [32180e30df].

426
427
428
429
430
431
432
433

434




































































435
        if (isset($this->variables[$var]))
            return $this->variables[$var];
        elseif (isset($_REQUEST[$var]))
            return $_REQUEST[$var];
        else
            return null;
    }
}






































































?>







|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
        if (isset($this->variables[$var]))
            return $this->variables[$var];
        elseif (isset($_REQUEST[$var]))
            return $_REQUEST[$var];
        else
            return null;
    }

    static public function getSource($template)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        $path = file_exists(GARRADIN_ROOT . '/squelettes/' . $template)
            ? GARRADIN_ROOT . '/squelettes/' . $template
            : GARRADIN_ROOT . '/squelettes-dist/' . $template;

        if (!file_exists($path))
            return false;

        return file_get_contents($path);
    }

    static public function editSource($template, $content)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        $path = GARRADIN_ROOT . '/squelettes/' . $template;

        return file_put_contents($path, $content);
    }

    static public function resetSource($template)
    {
        if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template))
            return false;

        if (file_exists(GARRADIN_ROOT . '/squelettes/' . $template))
        {
            unlink(GARRADIN_ROOT . '/squelettes/' . $template);
        }

        return true;
    }

    static public function listSources()
    {
        $sources = array();

        $dir = dir(GARRADIN_ROOT . '/squelettes-dist');

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
                $sources[] = $file;
        }

        $dir->close();

        $dir = dir(GARRADIN_ROOT . '/squelettes');

        while ($file = $dir->read())
        {
            if ($file[0] != '.')
                $sources[] = $file;
        }

        $dir->close();

        $sources = array_unique($sources);
        sort($sources);

        return $sources;
    }

}

?>

Modified templates/admin/config/site.tpl from [75c475987c] to [c187de18fa].

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

21

22













23
24
25
26
27
28










29
30
{include file="admin/_head.tpl" title="Configuration" current="config"}

{if $error}
    {if $error == 'OK'}
    <p class="confirm">
        La configuration a bien été enregistrée.
    </p>
    {else}
    <p class="error">
        {$error|escape}
    </p>
    {/if}
{/if}

<ul class="actions">
    <li><a href="{$www_url}admin/config/">Général</a></li>
    <li><a href="{$www_url}admin/config/membres.php">Membres</a></li>
    <li class="current"><a href="{$www_url}admin/config/site.php">Site public</a></li>
</ul>


<form method="post" action="{$self_url|escape}">















    <p class="submit">
        {csrf_field key="config_membres"}
        <input type="submit" name="save" value="Enregistrer &rarr;" />
    </p>

</form>











{include file="admin/_foot.tpl"}


|
<
<
<
<
<



<








>
|
>

>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|

|
>
>
>
>
>
>
>
>
>
>


1
2
3





4
5
6

7
8
9
10
11
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
{include file="admin/_head.tpl" title="Configuration" current="config"}

{if $error && $error != 'OK'}





    <p class="error">
        {$error|escape}
    </p>

{/if}

<ul class="actions">
    <li><a href="{$www_url}admin/config/">Général</a></li>
    <li><a href="{$www_url}admin/config/membres.php">Membres</a></li>
    <li class="current"><a href="{$www_url}admin/config/site.php">Site public</a></li>
</ul>

{if isset($edit)}
    <form method="post" action="{$self_url|escape}">
        <h3>Éditer un squelette</h3>

        {if $error == 'OK'}
        <p class="confirm">
            Modifications enregistrées.
        </p>
        {/if}

        <fieldset class="skelEdit">
            <legend>{$edit.file|escape}</legend>
            <p>
                <textarea name="content" cols="90" rows="50">{form_field name=content data=$edit}</textarea>
            </p>
        </fieldset>

        <p class="submit">
            {csrf_field key=$csrf_key}
            <input type="submit" name="save" value="Enregistrer &rarr;" />
        </p>

    </form>
{else}
    <div class="templatesList">
        <h3>Squelettes du site</h3>
        <ul>
        {foreach from=$sources item="source"}
            <li><a href="?edit={$source|escape:'url'}">{$source|escape}</a></li>
        {/foreach}
        </ul>
    </div>
{/if}

{include file="admin/_foot.tpl"}

Modified www/admin/config/site.php from [9db92f2caf] to [6f62adaff8].

1
2
3
4
5
6
7
8
9


10
11
12
13
14
15
16
<?php

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$error = false;

if (isset($_GET['ok']))
{
    $error = 'OK';
}










>
>







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

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.squelette.php';

$error = false;

if (isset($_GET['ok']))
{
    $error = 'OK';
}

32
33
34
35
36
37
38






































39
40
41
42
43
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}







































$tpl->assign('error', $error);
$tpl->display('admin/config/site.tpl');

?>







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





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
74
75
76
77
78
79
80
81
82
83
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

if (utils::get('edit'))
{
    $source = Squelette::getSource(utils::get('edit'));

    if (!$source)
    {
        throw new UserException("Ce squelette n'existe pas.");
    }

    $csrf_key = 'edit_skel_'.md5(utils::get('edit'));

    if (utils::post('save'))
    {
        if (!utils::CSRF_check($csrf_key))
        {
            $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
        }
        else
        {
            if (Squelette::editSource(utils::get('edit'), utils::post('content')))
            {
                utils::redirect('/admin/config/site.php?edit='.rawurlencode(utils::get('edit')).'&ok');
            }
            else
            {
                $error = "Impossible d'enregistrer le squelette.";
            }
        }
    }

    $tpl->assign('edit', array('file' => trim(utils::get('edit')), 'content' => $source));
    $tpl->assign('csrf_key', $csrf_key);
}
else
{
    $tpl->assign('sources', Squelette::listSources());
}

$tpl->assign('error', $error);
$tpl->display('admin/config/site.tpl');

?>

Modified www/admin/membres/ajouter.php from [1238931550] to [76e0ebba8d].

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

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/lib.passphrase.french.php';
require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;

$error = false;

if (!empty($_POST['save']))









|







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

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/libs/passphrase/lib.passphrase.french.php';
require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;

$error = false;

if (!empty($_POST['save']))

Modified www/admin/static/admin.css from [7170cde6ae] to [361961b29f].

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
}

/* Formulaires */
fieldset {
    border: 1px solid #ccc;
    padding: 0.8em 1em 0 1em;
    margin-bottom: 1em;

}

fieldset legend {
    padding: 0 0.5em;
    font-weight: bold;
}

label:hover {
    cursor: pointer;
    border-bottom: 1px dotted #900;
}

dl dt label {
    font-weight: bold;
}

fieldset dl {
    margin-bottom: 0.8em;
}

fieldset dl dt b {
    color: #900;
    font-size: 0.7em;
    font-weight: normal;
    vertical-align: super;
}








>
















<
<
<
<







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
}

/* Formulaires */
fieldset {
    border: 1px solid #ccc;
    padding: 0.8em 1em 0 1em;
    margin-bottom: 1em;
    padding: 0.5em;
}

fieldset legend {
    padding: 0 0.5em;
    font-weight: bold;
}

label:hover {
    cursor: pointer;
    border-bottom: 1px dotted #900;
}

dl dt label {
    font-weight: bold;
}





fieldset dl dt b {
    color: #900;
    font-size: 0.7em;
    font-weight: normal;
    vertical-align: super;
}

371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

fieldset.wikiText {
    clear: both;
    border: none;
    padding: 0.5em;
}

fieldset.wikiText textarea {
    width: 100%;
}

fieldset.wikiMain {
    float: left;
    width: 47%;
    margin-right: 2%;







|







368
369
370
371
372
373
374
375
376
377
378
379
380
381
382

fieldset.wikiText {
    clear: both;
    border: none;
    padding: 0.5em;
}

fieldset.wikiText textarea, fieldset.skelEdit textarea {
    width: 100%;
}

fieldset.wikiMain {
    float: left;
    width: 47%;
    margin-right: 2%;
571
572
573
574
575
576
577




.diff .line { width: 2%; padding: 0.2em; text-align: right; }
.diff .leftChange, .diff .rightChange { padding: 0.2em; text-align: center; }
.diff ins { background: #9f9; }
.diff del { background: #f99; }
.diff hr { background: none; border: none; border-top: 2px dotted #000; color: #fff; }
.diff { border-collapse: collapse; width: 100%; font-size: 0.9em; }
.diff tr { border: 1px solid #ccc; vertical-align: top; }











>
>
>
>
568
569
570
571
572
573
574
575
576
577
578
.diff .line { width: 2%; padding: 0.2em; text-align: right; }
.diff .leftChange, .diff .rightChange { padding: 0.2em; text-align: center; }
.diff ins { background: #9f9; }
.diff del { background: #f99; }
.diff hr { background: none; border: none; border-top: 2px dotted #000; color: #fff; }
.diff { border-collapse: collapse; width: 100%; font-size: 0.9em; }
.diff tr { border: 1px solid #ccc; vertical-align: top; }

.templatesList ul {
    margin: 1em 2em;
}