From 140a44ee91657e9d042b5cf7b2514c03306c7cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Fri, 27 Aug 2010 05:42:26 +0200 Subject: [PATCH] Articles. --- .../modules/articles/articles-article.php | 60 +++++++++++++ .../modules/articles/articles-article.php~ | 53 +++++++++++ .../code/modules/articles/articles-index.php | 87 +++++++++++++++++++ .../code/modules/articles/articles-index.php~ | 83 ++++++++++++++++++ __cms__/code/modules/articles/include.php | 4 + __cms__/code/modules/articles/include.php~ | 5 ++ __cms__/code/modules/forum/forum-index.php | 2 +- __cms__/code/modules/include.php | 1 + __cms__/code/site/squelette.php | 1 + __cms__/code/texte-enrichi/texte-enrichi.php | 4 + .../articles/Nouvel article/__prop__contenu | 1 + .../Nouvel article/__prop__proprietaire | 1 + .../articles/Nouvel article/__prop__titre | 1 + .../articles/Nouvel article/__prop__type | 1 + __cms__/donnees/articles/__prop__description | 2 + __cms__/donnees/articles/__prop__description~ | 1 + __cms__/donnees/articles/__prop__titre | 1 + __cms__/donnees/articles/__prop__titre~ | 1 + __cms__/donnees/articles/__prop__type | 1 + __cms__/donnees/articles/__prop__type~ | 1 + articles/Nouvel article/index.php | 7 ++ articles/index.php | 7 ++ permissions.sh | 2 +- 23 files changed, 325 insertions(+), 2 deletions(-) create mode 100644 __cms__/code/modules/articles/articles-article.php create mode 100644 __cms__/code/modules/articles/articles-article.php~ create mode 100644 __cms__/code/modules/articles/articles-index.php create mode 100644 __cms__/code/modules/articles/articles-index.php~ create mode 100644 __cms__/code/modules/articles/include.php create mode 100644 __cms__/code/modules/articles/include.php~ create mode 100644 __cms__/donnees/articles/Nouvel article/__prop__contenu create mode 100644 __cms__/donnees/articles/Nouvel article/__prop__proprietaire create mode 100644 __cms__/donnees/articles/Nouvel article/__prop__titre create mode 100644 __cms__/donnees/articles/Nouvel article/__prop__type create mode 100644 __cms__/donnees/articles/__prop__description create mode 100644 __cms__/donnees/articles/__prop__description~ create mode 100644 __cms__/donnees/articles/__prop__titre create mode 100644 __cms__/donnees/articles/__prop__titre~ create mode 100644 __cms__/donnees/articles/__prop__type create mode 100644 __cms__/donnees/articles/__prop__type~ create mode 100644 articles/Nouvel article/index.php create mode 100644 articles/index.php diff --git a/__cms__/code/modules/articles/articles-article.php b/__cms__/code/modules/articles/articles-article.php new file mode 100644 index 0000000..d83a2de --- /dev/null +++ b/__cms__/code/modules/articles/articles-article.php @@ -0,0 +1,60 @@ +parent(), '', "redirect"); + } else { + if (isset($paramètres["contenu"])) { + Stockage::set_prop($chemin, "contenu", $paramètres["contenu"]); + } + + // titre après les autres paramètres car il peut générer un redirect. + if (isset($paramètres["titre"]) && Stockage::prop_diff($chemin, "titre", $paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + Stockage::renomer($chemin, $paramètres["titre"]); + $chemin = $chemin->renomer($paramètres["titre"]); + // TODO : transmettre le paramètre "vue" + return new Page($chemin, '', "redirect"); + } + + if (isset($paramètres["vue"])) { + return self::vue($chemin, $paramètres["vue"]); + } else { + return self::vue($chemin); + } + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '
'; + $ret .= '

'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "contenu"), "contenu"); + $ret .= '

'; + $ret .= '
'; + } else { + $ret .= '

' . Stockage::get_prop($chemin, "titre") . '

'; + $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "contenu")); + } + if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) { + // TODO : afficher le bouton "Supprimer". + } + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } elseif ($vue == "miniature") { + $ret = miniature_texte_enrichi(Stockage::get_prop($chemin, "contenu")); + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ArticlesArticle", "articles-article", "vue", "titre contenu"); + +?> \ No newline at end of file diff --git a/__cms__/code/modules/articles/articles-article.php~ b/__cms__/code/modules/articles/articles-article.php~ new file mode 100644 index 0000000..765b3ff --- /dev/null +++ b/__cms__/code/modules/articles/articles-article.php~ @@ -0,0 +1,53 @@ +parent(), '', "redirect"); + } else { + if (isset($paramètres["contenu"])) { + Stockage::set_prop($chemin, "contenu", $paramètres["contenu"]); + } + + // titre après les autres paramètres car il peut générer un redirect. + if (isset($paramètres["titre"]) && Stockage::prop_diff($chemin, "titre", $paramètres["titre"])) { + Stockage::set_prop($chemin, "titre", $paramètres["titre"]); + Stockage::renomer($chemin, $paramètres["titre"]); + $chemin = $chemin->renomer($paramètres["titre"]); + // TODO : transmettre le paramètre "vue" + return new Page($chemin, '', "redirect"); + } + + return new Page($chemin->parent(), '', "redirect"); + } + } + + public static function vue($chemin, $vue = "normal") { + if ($vue == "normal") { + $ret = ''; + + if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) { + $ret .= '
'; + $ret .= '

'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "contenu"), "contenu"); + $ret .= '

'; + $ret .= '
'; + } else { + $ret .= '

' . Stockage::get_prop($chemin, "titre") . '

'; + $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "contenu")); + } + if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) { + // TODO : afficher le bouton "Supprimer". + } + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ArticlesArticle", "articles-article", "vue", "titre contenu"); + +?> \ No newline at end of file diff --git a/__cms__/code/modules/articles/articles-index.php b/__cms__/code/modules/articles/articles-index.php new file mode 100644 index 0000000..7812874 --- /dev/null +++ b/__cms__/code/modules/articles/articles-index.php @@ -0,0 +1,87 @@ +get_url() . '">'; + $ret .= '

'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description"); + $ret .= '

'; + $ret .= ''; + } else { + $ret .= '

' . Stockage::get_prop($chemin, "titre") . '

'; + $ret .= '

' . Stockage::get_prop($chemin, "description") . '

'; + } + + $ret .= '
'; + $ret .= ''; + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ArticlesIndex", "articles-index", "vue", "titre description"); + +?> diff --git a/__cms__/code/modules/articles/articles-index.php~ b/__cms__/code/modules/articles/articles-index.php~ new file mode 100644 index 0000000..dac0b3b --- /dev/null +++ b/__cms__/code/modules/articles/articles-index.php~ @@ -0,0 +1,83 @@ +get_url() . '">'; + $ret .= '

'; + $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description"); + $ret .= '

'; + $ret .= ''; + } else { + $ret .= '

' . Stockage::get_prop($chemin, "titre") . '

'; + $ret .= '

' . Stockage::get_prop($chemin, "description") . '

'; + } + + $ret .= '
'; + $ret .= '
    '; + + if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) { + $ret .= '
  • '; + $ret .= '
    '; + + $ret .= '
    '; + $ret .= '

    '; + $ret .= ''; + $ret .= ''; + $ret .= '

    '; + $ret .= '
    '; + + $ret .= '
    '; + $ret .= '
  • '; + } + + foreach (Stockage::liste_enfants($chemin) as $k) { // TODO : trier par numéro ! + $mini = Modules::vue($k, 'miniature'); + $ret .= '
  • '; + // TODO : mettre une ancre "#message" + $ret .= ''; // TODO : escape l'url ! + $ret .= ''; + $ret .= $mini->titre; + $ret .= ''; + $ret .= ''; + $ret .= '
  • '; + } + + $ret .= '
'; + + return new Page($ret, Stockage::get_prop($chemin, "titre")); + } + } +} + +Modules::enregister_module("ArticlesIndex", "articles-index", "vue", "titre description"); + +?> diff --git a/__cms__/code/modules/articles/include.php b/__cms__/code/modules/articles/include.php new file mode 100644 index 0000000..00e338f --- /dev/null +++ b/__cms__/code/modules/articles/include.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/__cms__/code/modules/articles/include.php~ b/__cms__/code/modules/articles/include.php~ new file mode 100644 index 0000000..eef384d --- /dev/null +++ b/__cms__/code/modules/articles/include.php~ @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/__cms__/code/modules/forum/forum-index.php b/__cms__/code/modules/forum/forum-index.php index 1fa2513..2b319ee 100644 --- a/__cms__/code/modules/forum/forum-index.php +++ b/__cms__/code/modules/forum/forum-index.php @@ -49,7 +49,7 @@ class ForumIndex { $ret .= '
  • '; $ret .= '
    '; - $ret .= '
    '; + $ret .= ''; $ret .= '

    '; $ret .= ''; $ret .= ''; diff --git a/__cms__/code/modules/include.php b/__cms__/code/modules/include.php index ead5360..26f906a 100644 --- a/__cms__/code/modules/include.php +++ b/__cms__/code/modules/include.php @@ -6,5 +6,6 @@ require_once(dirname(__FILE__) . "/site/include.php"); require_once(dirname(__FILE__) . "/admin/include.php"); require_once(dirname(__FILE__) . "/forum/include.php"); require_once(dirname(__FILE__) . "/galerie/include.php"); +require_once(dirname(__FILE__) . "/articles/include.php"); ?> \ No newline at end of file diff --git a/__cms__/code/site/squelette.php b/__cms__/code/site/squelette.php index b14259c..0f76df7 100644 --- a/__cms__/code/site/squelette.php +++ b/__cms__/code/site/squelette.php @@ -40,6 +40,7 @@ class Squelette { $ret .= '

  • Accueil
  • ' . $nl; $ret .= '
  • get_url() . '">Galerie
  • ' . $nl; $ret .= '
  • get_url() . '">Forum
  • ' . $nl; + $ret .= '
  • get_url() . '">Articles
  • ' . $nl; if (Permissions::vérifier_permission($racine->enfant("admin"), "set_prop", Authentification::get_utilisateur())) { $ret .= '
  • get_url() . '">Administration
  • ' . $nl; } diff --git a/__cms__/code/texte-enrichi/texte-enrichi.php b/__cms__/code/texte-enrichi/texte-enrichi.php index fe646da..6d67216 100644 --- a/__cms__/code/texte-enrichi/texte-enrichi.php +++ b/__cms__/code/texte-enrichi/texte-enrichi.php @@ -24,4 +24,8 @@ function affichage_texte_enrichi($données) { return "

    " . $données . "

    "; // escape html chars & co. } +function miniature_texte_enrichi($données) { + return substr($données, 0, 50) . "..."; // escape html chars & co. +} + ?> \ No newline at end of file diff --git a/__cms__/donnees/articles/Nouvel article/__prop__contenu b/__cms__/donnees/articles/Nouvel article/__prop__contenu new file mode 100644 index 0000000..f5950f3 --- /dev/null +++ b/__cms__/donnees/articles/Nouvel article/__prop__contenu @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. \ No newline at end of file diff --git a/__cms__/donnees/articles/Nouvel article/__prop__proprietaire b/__cms__/donnees/articles/Nouvel article/__prop__proprietaire new file mode 100644 index 0000000..f77b004 --- /dev/null +++ b/__cms__/donnees/articles/Nouvel article/__prop__proprietaire @@ -0,0 +1 @@ +admin \ No newline at end of file diff --git a/__cms__/donnees/articles/Nouvel article/__prop__titre b/__cms__/donnees/articles/Nouvel article/__prop__titre new file mode 100644 index 0000000..3a75289 --- /dev/null +++ b/__cms__/donnees/articles/Nouvel article/__prop__titre @@ -0,0 +1 @@ +Nouvel article \ No newline at end of file diff --git a/__cms__/donnees/articles/Nouvel article/__prop__type b/__cms__/donnees/articles/Nouvel article/__prop__type new file mode 100644 index 0000000..886d9f1 --- /dev/null +++ b/__cms__/donnees/articles/Nouvel article/__prop__type @@ -0,0 +1 @@ +articles-article \ No newline at end of file diff --git a/__cms__/donnees/articles/__prop__description b/__cms__/donnees/articles/__prop__description new file mode 100644 index 0000000..c5c19a6 --- /dev/null +++ b/__cms__/donnees/articles/__prop__description @@ -0,0 +1,2 @@ +Description des articles. +FooBar \ No newline at end of file diff --git a/__cms__/donnees/articles/__prop__description~ b/__cms__/donnees/articles/__prop__description~ new file mode 100644 index 0000000..cda64c6 --- /dev/null +++ b/__cms__/donnees/articles/__prop__description~ @@ -0,0 +1 @@ +Description des articles. diff --git a/__cms__/donnees/articles/__prop__titre b/__cms__/donnees/articles/__prop__titre new file mode 100644 index 0000000..4b6c5c9 --- /dev/null +++ b/__cms__/donnees/articles/__prop__titre @@ -0,0 +1 @@ +Articles test \ No newline at end of file diff --git a/__cms__/donnees/articles/__prop__titre~ b/__cms__/donnees/articles/__prop__titre~ new file mode 100644 index 0000000..27c6bd8 --- /dev/null +++ b/__cms__/donnees/articles/__prop__titre~ @@ -0,0 +1 @@ +Articles diff --git a/__cms__/donnees/articles/__prop__type b/__cms__/donnees/articles/__prop__type new file mode 100644 index 0000000..0fa672b --- /dev/null +++ b/__cms__/donnees/articles/__prop__type @@ -0,0 +1 @@ +articles-index \ No newline at end of file diff --git a/__cms__/donnees/articles/__prop__type~ b/__cms__/donnees/articles/__prop__type~ new file mode 100644 index 0000000..15e8b05 --- /dev/null +++ b/__cms__/donnees/articles/__prop__type~ @@ -0,0 +1 @@ +articles-index diff --git a/articles/Nouvel article/index.php b/articles/Nouvel article/index.php new file mode 100644 index 0000000..606e099 --- /dev/null +++ b/articles/Nouvel article/index.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/articles/index.php b/articles/index.php new file mode 100644 index 0000000..4ccf746 --- /dev/null +++ b/articles/index.php @@ -0,0 +1,7 @@ + diff --git a/permissions.sh b/permissions.sh index 9d9ef23..ac73618 100644 --- a/permissions.sh +++ b/permissions.sh @@ -1,6 +1,6 @@ #!/bin/sh -fichiers="index.php galerie forum admin __cms__/donnees" +fichiers="index.php galerie forum articles admin __cms__/donnees" chgrp -R www-data $fichiers chmod -R 664 $fichiers