changeset 61:25c6e59f019e

Suppression des urls en dur présentes dans le code. Le code ne présuppose plus qu'il est hébergé directement sur http://defr.org/blog. Ce n'est par contre pas vrai pour les différents templates pour le moment, et les fichiers CSS pensent toujours qu'on est hébergé dans le repertoire /blog, mais ca reste des présupposés à mon avis moins ennuyeux. Accessoirement, le code suppose que les trois constantes supplémentaires suivantes ait été définie dans le fichier config.php: BLOG_URL, l'adresse du blog, sans / à la fin BLOG_DEFAULT_GRAVATAR, l'image par défaut pour les personnes laissant des commentaires ADMIN_MAIl, l'adresse mail ou sont envoyé les informations sur les commentaires autorisés.
author Franck Deroche <webmaster@defr.org>
date Tue, 11 Mar 2008 15:53:15 +0100
parents 46be148257ae
children 96b3c34d3705
files admin.php comment.php includes/class.post.php includes/class.skeleton.php
diffstat 4 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/admin.php	Tue Mar 11 14:55:20 2008 +0100
+++ b/admin.php	Tue Mar 11 15:53:15 2008 +0100
@@ -88,7 +88,7 @@
 			
 			$fp = fsockopen($ar_tbAddress['host'], 80, $errno, $errstr, 15);
 			$argToSend = "title=" . htmlentities(urlencode($row['Titre'])) . "&blog_name=Dual+Blog";
-			$argToSend .= "&url=http://defr.org/blog/posts/{$row['num_mess']}&excerpt=" 
+			$argToSend .= "&url=" . BLOG_URL . "/posts/{$row['num_mess']}&excerpt=" 
 								. htmlentities(urlencode(substr(strip_tags($row['Message']), 0, 255) . "..."));
 
 			$toSend = $genToSend . "Content-Length: " . strlen($argToSend) . "\n\n";
--- a/comment.php	Tue Mar 11 14:55:20 2008 +0100
+++ b/comment.php	Tue Mar 11 15:53:15 2008 +0100
@@ -27,7 +27,7 @@
 		VALUES({$id}, '{$Auteur}', '{$Adresse}', '{$AdresseMail}', '{$Comment}', '{$DateComment}', '{$ip}')
 	");
 	$Data->Query("UPDATE Mess SET NbCommentaires=NbCommentaires+1 WHERE num_mess={$id}");
-	mail('webmaster+blogcomment@defr.org', 'Nouveau commentaire sur de ' . $Auteur, $Auteur . " vient de mettre en ligne le commentaire suivant:  \n" . wordwrap($Comment, 70));
+	mail(ADMIN_MAIL, 'Nouveau commentaire de ' . $Auteur, $Auteur . " vient de mettre en ligne le commentaire suivant:  \n" . wordwrap($Comment, 70));
 	}
 	else {
 		$infos = 'Votre commentaire doit etre fait de XML valide pour apparaitre.';
@@ -46,7 +46,7 @@
 
      // 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");
+      $defaultGravatar = urlencode(BLOG_DEFAULT_GRAVATAR);
       while(0 !== ($row = $Data->GetRow())) {
 	    $commentTpl = new Template(Skeleton::getTemplateFile('comment'));
         $dateFormatee = strftime(" à %Hh%M, le %A %d %B %Y", strtotime($row['DateComment']));
--- a/includes/class.post.php	Tue Mar 11 14:55:20 2008 +0100
+++ b/includes/class.post.php	Tue Mar 11 15:53:15 2008 +0100
@@ -30,7 +30,7 @@
     
     // On détermine l'url de ce post
     $strippedTitle = TextUtils::StripTitle($infos['Titre']);
-    $this->url = '/blog/posts/' . $infos['num_mess'] . '-' . $strippedTitle;
+    $this->url = '/posts/' . $infos['num_mess'] . '-' . $strippedTitle;
 
    // On détermine le label du lien vers les commentaires
    $this->commentLabel = "Un p'tit commentaire ?";
@@ -39,7 +39,7 @@
 
    // On s'occupe de l'indicateur d'humeur
    if(!empty($infos['Emot'])) {
-        $mood = array('src' => "/blog/mood/{$infos['Emot']}.png",
+        $mood = array('src' => BLOG_URL . "/mood/{$infos['Emot']}.png",
                       'alt' => 'Mood: ' . $infos['Emot']);
         $this->mood = (object)$mood;
    }
@@ -58,7 +58,7 @@
 	    while(0 !== ($tag = $db->GetRow(2)))
 	    {
 		$tags .= sprintf("<a href='%s'>%s</a> |",
-		                '/blog/tags/' . urlencode($tag['Tag']),
+		                BLOG_URL . '/tags/' . urlencode($tag['Tag']),
 				$tag['Tag']);
 	    }
 	    $tags = substr($tags, 0, -1);
@@ -84,8 +84,8 @@
         'postContent' => $this->mess,
         'postNumber' => $this->infos->num_mess,
         'postComments' => $this->commentLabel,
-        '#linkPostNumber@href' => $this->url,
-        '#linkPostComments@href' => $this->url,
+        '#linkPostNumber@href' => $this->getURL(true),
+        '#linkPostComments@href' => $this->getURL(true),
         'postTags' => $this->tags
      );
      if(!empty($this->mood->src)) {
@@ -97,7 +97,7 @@
   }
 
   public function getURL() {
-     return $this->url;
+     return BLOG_URL . $this->url;
   }
 }
 ?>
--- a/includes/class.skeleton.php	Tue Mar 11 14:55:20 2008 +0100
+++ b/includes/class.skeleton.php	Tue Mar 11 15:53:15 2008 +0100
@@ -53,7 +53,7 @@
             $monthName = TextUtils::getMonthName($row['Month']);
             $curArchiveTpl->setParams(array(
                 'a' =>  $monthName . ' ' . $row['Year'],
-                'a@href' => "http://defr.org/blog/posts/{$row['Year']}/{$row['Month']}",
+                'a@href' => BLOG_URL . "/posts/{$row['Year']}/{$row['Month']}",
                 'postCount' => '(' . $row['Nb'] . ')'
             ));
             $archives[] = array('li' => $curArchiveTpl);
@@ -71,14 +71,14 @@
         // On récupère une version filtrée du titre du post ...
         $tf = TextUtils::StripTitle($row['Titre']);
         // ... Qui nous permet d'obtenir l'adresse du commentaire sur le post
-        $c_url = "/blog/posts/{$row['MessId']}-$tf#c{$row['num_comm']}";
+        $c_url = BLOG_URL . "/posts/{$row['MessId']}-$tf#c{$row['num_comm']}";
         // Si jamais on a une adresse mail, on rajoute un mailto:
         if(strpos($row['Adresse'], '@') !== false) 
             $row['Adresse'] = 'mailto:' . $row['Adresse'];
         // On commence par définir les paramètres généraux
         $params = array(                
                 '#CommentAuthor' => $row['Auteur'],
-                '#CommentAuthor@href' => urlencode($row['Adresse']),
+                '#CommentAuthor@href' => $row['Adresse'],
                 '#Post' => $row['Titre'],
                 '#Post@href' => $c_url
         );
@@ -128,9 +128,9 @@
        $retVal = new Template('calendar.xml');
        $retVal->setParams(array(
          '#calPrev' => TextUtils::getMonthName($prevMonth) . ' ' . $prevYear,
-         '#calPrev@href' => '/blog/posts/' . $prevYear . '/' . $prevMonth,
+         '#calPrev@href' => BLOG_URL . '/posts/' . $prevYear . '/' . $prevMonth,
          '#calNext' => TextUtils::getMonthName($nextMonth) . ' ' . $nextYear,
-         '#calNext@href' => '/blog/posts/' . $nextYear . '/' . $nextMonth,
+         '#calNext@href' => BLOG_URL . '/posts/' . $nextYear . '/' . $nextMonth,
          'currentMonth' => TextUtils::getMonthName($cMonth) . ' ' . $cYear
        ));
     } else {
@@ -201,7 +201,7 @@
         $type = ($styleSheet->enabled) ? "" : "Alternate ";
         $type .= "StyleSheet";
         $params['possibleStyleSheets'][] = array(
-            'link@href'  => '/blog/css/' . $styleSheet->CSSFile,
+            'link@href'  => BLOG_URL . '/css/' . $styleSheet->CSSFile,
             'link@rel'   => $type,
             'link@title' => $styleSheet->name
         );