Overview
Comment:Choix de page parente (à terminer)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c0e9ecb182462569b7d30bc6673ac98b5ab32350
User & Date: bohwaz on 2012-05-10 02:38:38
Other Links: manifest | tags
Context
2012-05-13
02:09
Site public à base de squelettes check-in: 1ead174df1 user: bohwaz tags: trunk
2012-05-10
02:38
Choix de page parente (à terminer) check-in: c0e9ecb182 user: bohwaz tags: trunk
01:50
Se souvenir du champ recherché check-in: 05337ec90c user: bohwaz tags: trunk
Changes

Modified include/class.wiki.php from [bee945896c] to [700c891077].

136
137
138
139
140
141
142






143
144
145
146
147
148
149
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_creation) AS date_creation,
            strftime(\'%s\', date_modification) AS date_modification
            FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);
    }







    public function editRevision($id, $revision_edition = 0, $data)
    {
        $db = Garradin_DB::getInstance();

        $revision = $db->simpleQuerySingle('SELECT revision FROM wiki_pages WHERE id = ?;', false, (int)$id);








>
>
>
>
>
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_creation) AS date_creation,
            strftime(\'%s\', date_modification) AS date_modification
            FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);
    }

    public function getTitle($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT titre FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$id);
    }

    public function editRevision($id, $revision_edition = 0, $data)
    {
        $db = Garradin_DB::getInstance();

        $revision = $db->simpleQuerySingle('SELECT revision FROM wiki_pages WHERE id = ?;', false, (int)$id);

359
360
361
362
363
364
365
366

367


























































368
    }

    public function countRecentModifications()
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM wiki_pages WHERE '.$this->_getLectureClause().';');
    }
}




























































?>







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

365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
    }

    public function countRecentModifications()
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM wiki_pages WHERE '.$this->_getLectureClause().';');
    }

    public function listBackParentTree($parent)
    {
        $db = Garradin_DB::getInstance();
        $flat = array((int)$parent);

        if ($parent != 0)
        {
            do
            {
                $parent = $db->simpleQuerySingle('SELECT parent FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$parent);
                $flat[] = (int)$parent;
            }
            while ($parent != 0);
        }

        foreach ($flat as &$id)
        {
            $id = array(
                'id'        =>  (int)$id,
                'children'  =>  $db->simpleStatementFetch('SELECT id, titre
                    FROM wiki_pages WHERE parent = ? ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE;', SQLITE3_ASSOC, (int)$id),
            );
        }

        $tree = array_reverse($flat);
        $tree = $this->_buildBackParentTree($tree);

        var_dump($tree);
        exit;

        return $tree;
    }

    protected function _buildBackParentTree(&$tree, &$parent = null)
    {
        foreach ($tree as &$elm)
        {
            if (empty($elm['id']))
            {
                $elm['titre'] = 'Racine du site';
            }
            elseif (!empty($parent['children']))
            {
                foreach ($parent['children'] as $c)
                {
                    if ($c['id'] == $elm['id'])
                        $elm['titre'] = $c['titre'];
                }
            }

            if (!empty($elm['children']))
            {
                $this->_buildBackParentTree($elm['children'], $elm);
            }
        }

        return $tree;
    }
}

?>

Modified templates/admin/_head.tpl from [d08f3a74e5] to [453e9600f2].

1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>{$title|escape}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="{$www_url}style/admin.css" media="screen,projection,handheld" />
</head>

<body>


<div class="header">
    <h1>{$title|escape}</h1>

    {if $is_logged}
    <ul class="menu">
        <li class="home{if $current == 'home'} current{/if}"><a href="{$www_url}admin/">Accueil</a></li>
        {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}











>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>{$title|escape}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="{$www_url}style/admin.css" media="screen,projection,handheld" />
</head>

<body>

{if empty($is_popup)}
<div class="header">
    <h1>{$title|escape}</h1>

    {if $is_logged}
    <ul class="menu">
        <li class="home{if $current == 'home'} current{/if}"><a href="{$www_url}admin/">Accueil</a></li>
        {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}
55
56
57
58
59
60
61

62
63
        {if count($config.champs_modifiables_membre) > 0}
            <li class="mes_infos{if $current == 'mes_infos'} current{/if}"><a href="{$www_url}admin/mes_infos.php">Mes infos</a>
        {/if}
        <li class="logout"><a href="{$www_url}admin/logout.php">Déconnexion</a></li>
    </ul>
    {/if}
</div>


<div class="page">







>


56
57
58
59
60
61
62
63
64
65
        {if count($config.champs_modifiables_membre) > 0}
            <li class="mes_infos{if $current == 'mes_infos'} current{/if}"><a href="{$www_url}admin/mes_infos.php">Mes infos</a>
        {/if}
        <li class="logout"><a href="{$www_url}admin/logout.php">Déconnexion</a></li>
    </ul>
    {/if}
</div>
{/if}

<div class="page">

Added templates/admin/wiki/_chercher_parent.tpl version [fe3751be63].

















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{include file="admin/_head.tpl" title="Choisir la page parent" current="wiki" is_popup=true}

<ul>
    {foreach from=$list item="rub"}
    <li>
        <h3><a href="?current={$rub.id|escape}">{$rub.titre|escape}</a></h3>
    </li>
    {/foreach}
</ul>

{literal}
<script type="text/javascript">
(function() {
    window.chooseParent = function(parent, title)
    {
        window.opener.changeParent(id, title);
        self.close();
        return false;
    };
}());
</script>
{/literal}

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

Modified templates/admin/wiki/editer.tpl from [897d5a5c6c] to [883271b550].

15
16
17
18
19
20
21
22
23
24

25
26



27
28
29
30
31
32
33
            <dd><input type="text" name="titre" id="f_titre" value="{form_field data=$page name=titre}" /></dd>
            <dt><label for="f_uri">Adresse unique</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd class="help">
                Chaque page doit comporter une adresse unique qui permet de l'identifier.
                Cette adresse ne peut comporter que des lettres, des chiffres, des tirets et des tirets bas.
            </dd>
            <dd><input type="text" name="uri" id="f_uri" value="{form_field data=$page name=uri}" /></dd>
            <dt><label for="f_parent">Cette page est une sous-rubrique de...</label></dt>
            <dd>
                <select name="parent" id="f_parent">

                    <option value="0">- la racine du site</option>
                </select>



            </dd>
        </dl>
    </fieldset>

    <fieldset class="wikiRights">
        <legend>Droits d'accès</legend>
        <dl>







|

|
>
|
|
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
            <dd><input type="text" name="titre" id="f_titre" value="{form_field data=$page name=titre}" /></dd>
            <dt><label for="f_uri">Adresse unique</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd class="help">
                Chaque page doit comporter une adresse unique qui permet de l'identifier.
                Cette adresse ne peut comporter que des lettres, des chiffres, des tirets et des tirets bas.
            </dd>
            <dd><input type="text" name="uri" id="f_uri" value="{form_field data=$page name=uri}" /></dd>
            <dt><label for="f_browse_parent">Cette page est une sous-rubrique de...</label></dt>
            <dd>
                <input type="hidden" name="parent" id="f_parent" value="{form_field data=$page name=parent}" />
                {if $parent == 0}
                    <samp id="current_parent_name">la racine du site</samp>
                {else}
                    <samp id="current_parent_name">{$parent|escape}</samp>
                {/if}
                <input type="button" id="f_browse_parent" onclick="browseWikiForParent();" value="Changer" />
            </dd>
        </dl>
    </fieldset>

    <fieldset class="wikiRights">
        <legend>Droits d'accès</legend>
        <dl>
105
106
107
108
109
110
111












112
113
114
115
116
        document.getElementById('f_droit_ecriture_categorie').disabled = false;
    };

    document.getElementById('f_droit_lecture_public').onchange = function() {
        document.getElementById('f_droit_ecriture_normal').disabled = false;
        document.getElementById('f_droit_ecriture_categorie').disabled = false;
    };












}());
</script>
{/literal}

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







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





109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
        document.getElementById('f_droit_ecriture_categorie').disabled = false;
    };

    document.getElementById('f_droit_lecture_public').onchange = function() {
        document.getElementById('f_droit_ecriture_normal').disabled = false;
        document.getElementById('f_droit_ecriture_categorie').disabled = false;
    };

    window.changeParent = function(parent, title)
    {
        document.getElementById('f_parent').value = parent;
        document.getElementById('current_parent_name').innerHTML = title;
        return true;
    };

    window.browseWikiForParent = function()
    {
        window.open('_chercher_parent.php?current=' + document.getElementById('f_parent').value);
    };
}());
</script>
{/literal}

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

Added www/admin/wiki/_chercher_parent.php version [6e4796bdd5].



































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

require_once __DIR__ . '/_inc.php';

if (utils::get('current') && !is_numeric(utils::get('current')))
{
    throw new UserException('Numéro de page parent invalide.');
}

$current = (int) utils::get('current');

$tpl->assign('current', $current);
$tpl->assign('list', $wiki->listBackParentTree($current));

$tpl->display('admin/wiki/_chercher_parent.tpl');

?>

Modified www/admin/wiki/editer.php from [1f2eae6d66] to [19d814269b].

54
55
56
57
58
59
60



61
62
63
64
65
66
67
68
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}




$tpl->assign('error', $error);
$tpl->assign('page', $page);

$tpl->assign('time', time());

$tpl->display('admin/wiki/editer.tpl');

?>







>
>
>








54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

$parent = (int) utils::get('parent') ?: (int) $page['parent'];
$tpl->assign('parent', $parent ? $wiki->getTitle($parent) : 0);

$tpl->assign('error', $error);
$tpl->assign('page', $page);

$tpl->assign('time', time());

$tpl->display('admin/wiki/editer.tpl');

?>

Modified www/style/admin.css from [db7f55eaf7] to [aaea58089c].

389
390
391
392
393
394
395





}

.wikiFooter {
    font-size: 0.8em;
    color: #666;
    border-top: 0.1em solid #ccc;
}












>
>
>
>
>
389
390
391
392
393
394
395
396
397
398
399
400
}

.wikiFooter {
    font-size: 0.8em;
    color: #666;
    border-top: 0.1em solid #ccc;
}

.wikiMain samp {
    background: #eee;
    padding: 0.2em 0.3em;
}