# HG changeset patch # User Franck Deroche # Date 1193408816 -7200 # Node ID 116ef98b4cb52c16711eec0ce7afdb74e76f48ce # Parent 3b7c1400f89a13265c0e92fb2c8f5189e010bf09 L'affichage d'un post unique avec commentaire utilise maintenant les templates aussi. diff -r 3b7c1400f89a -r 116ef98b4cb5 comment.php --- a/comment.php Fri Oct 26 14:36:59 2007 +0200 +++ b/comment.php Fri Oct 26 16:26:56 2007 +0200 @@ -1,11 +1,12 @@ get('Auteur'); $Adresse=$Req->get('Adresse'); $AdresseMail = $Req->get('AdresseMail'); @@ -15,8 +16,6 @@ // Prévention d'un "cassage" par ajout d'un commentaire incorrectement formaté $ip = $_SERVER['REMOTE_ADDR']; $Auteur = str_replace(array('<', '>'), array('<', '>'), $Auteur); - /*if(!DOMDocument::loadXML('' . $Comment . '')) - $Comment = '', ']]>',$Comment) . ']]>';*/ if(DOMDocument::loadXML('' . $Comment . '')) { $Data->debugQuery(" INSERT INTO Commentaires(MessId, Auteur, Adresse, AdresseMail, Comment, DateComment, ip) @@ -30,64 +29,43 @@ } } + // Ajout du post au squelette $Data->Query("SELECT * FROM Mess WHERE num_mess = {$id}"); $row = $Data->GetRow(); - $mood = ''; - $Mess=$Data->utf8_ensure(str_replace("

","

",str_replace("

","

", $row['Message']))); - $dateFormatee = strftime("%A %d %B %Y, %Hh%M", strtotime($row['DatePost'])); - $Titre = $Data->utf8_ensure($row['Titre']); - $Titre_url = str_replace(" ", "_", strip_tags($Titre)); - $Titre_url = str_replace("-", "_", $Titre_url); - include("top.php"); - if(!empty($row['Emot'])) { - $mood = "Mood : {$row["; - $row['Emot'] = " " . $row['Emot']; - } - echo(" -
-

{$Titre} | {$dateFormatee}

- {$mood} - {$Mess}
- {$infos} -
"); + $post = new Post($row); + $sk->addBlogPost($post->format()); + + // Récupération des commentaires $Data->Query("SELECT * FROM Commentaires Where MessId={$id} AND Visible=1 ORDER BY num_comm"); $defaultGravatar = urlencode("http://defr.org/Misc/NoGravatar.png"); while(0 !== ($row = $Data->GetRow())) { - $dateFormatee = strftime(" à %Hh%M le %A %d %B %Y", strtotime($row['DateComment'])); - $AdresseMail = $row['AdresseMail']; - $grav_id = md5($AdresseMail); - $Comment = nl2br($row['Comment']); - $Comment = str_replace(" & ", " & ", $Comment); - if($row['num_comm'] == 172) $Comment = str_replace("", "", $Comment); - //if(stristr($Adresse, "@")) $Adresse = "mailto:" . $Adresse; - $betterHref = (stristr($row['Adresse'], 'http://') != false)?"href='{$row['Adresse']}'":''; - echo(" -
-
- - {$row['Auteur']} {$dateFormatee} -
-
{$Comment}
-
-
"); + $commentTpl = new Template('comment.xml'); + $dateFormatee = strftime(" à %Hh%M le %A %d %B %Y", strtotime($row['DateComment'])); + $AdresseMail = $row['AdresseMail']; + $grav_id = md5($AdresseMail); + $grav_url = 'http://www.gravatar.com/avatar.php?gravatar_id=' . $grav_id . '&size=50&default=' . $defaultGravatar; + $Comment = nl2br($row['Comment']); + $Comment = str_replace(" & ", " & ", $Comment); + $commentFrag = $commentTpl->getDocumentFragment(); + $commentFrag->appendXML($Comment); + $params = array( + '#gravatar@src' => $grav_url, + '#auteur@href' => 'TODO', + '#auteur@name' => 'c' . $row['num_comm'], + '#auteur' => $row['Auteur'], + 'commentDate' => $dateFormatee, + 'comment' => $commentFrag, + ); + if(stristr($row['Adresse'], 'http://')) { + $params['#auteur@href'] = $row['Adresse']; + } + $commentTpl->setParams($params); + $sk->addBlogPost($commentTpl); } - echo(" -
- Revenir au blog -
-
-
-
- Vous souhaitez ajouter un nouveau commentaire ? Faites donc, il vous suffit de remplir - le petit formulaire ci-dessous. - - - - - -
-
-
- "); - include("foot.php"); + + // Ajout du formulaire d'ajout de commentaires + $commentForm = new Template('commentForm.xml'); + $sk->addBlogPost($commentForm); + + echo $sk; ?> diff -r 3b7c1400f89a -r 116ef98b4cb5 templates/comment.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/comment.xml Fri Oct 26 16:26:56 2007 +0200 @@ -0,0 +1,11 @@ + +
+
+ + +
+
+
+
diff -r 3b7c1400f89a -r 116ef98b4cb5 templates/commentForm.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/commentForm.xml Fri Oct 26 16:26:56 2007 +0200 @@ -0,0 +1,21 @@ + + +
+ Revenir au blog +
+
+
+
+ Vous souhaitez ajouter un nouveau commentaire ? Faites donc, il vous suffit de remplir + le petit formulaire ci-dessous. + + + + + +
+
+
+