[ Index ]
 

Code source de Dotclear 1.2.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/inc/classes/ -> class.blogpost.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2004 Olivier Meunier and contributors. All rights
   5  # reserved.
   6  #
   7  # DotClear is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation; either version 2 of the License, or
  10  # (at your option) any later version.
  11  # 
  12  # DotClear is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  # 
  17  # You should have received a copy of the GNU General Public License
  18  # along with DotClear; if not, write to the Free Software
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  #
  21  # ***** END LICENSE BLOCK *****
  22  
  23  /**
  24  @class blogpost
  25  
  26  Cette classe définit un objet de type recordset en l'étendant de nouvelles
  27  fonctions. Elle dispose donc de toutes les fonctions d'un recordset en sus
  28  des fonctions suivantes.
  29  
  30  Cette classe doit être initialisée avec la définition d'un objet de type
  31  blog (à l'aide de la méthode ''setBlog'').
  32  
  33  @param    blog        blog            Objet de type blog
  34  */
  35  class blogpost extends recordset
  36  {
  37      var $blog;
  38      
  39      /** @doc
  40      === Méthodes === */
  41      
  42      /**
  43      @function setBlog
  44      
  45      Défini l'objet de type blog qui sera passé à la classe après qu'il a été
  46      instancié.
  47      
  48      @param    blog        blog            Objet de type blog
  49      */
  50  	function setBlog(&$blog)
  51      {
  52          $this->blog = $blog;
  53      }
  54      
  55      /**
  56      @function getFormat
  57      
  58      Renvoie le format du billet (''wiki'' ou ''html'')
  59      
  60      @return    string
  61      */
  62  	function getFormat()
  63      {
  64          return ($this->f('post_content_wiki') != '') ? 'wiki' : 'html';
  65      }
  66      
  67      /**
  68      @function getNbComments
  69      
  70      Renvoie le nombre de commentaires d'un billet.
  71      
  72      @return    integer
  73      */
  74  	function getNbComments()
  75      {
  76          return (integer) $this->blog->getNbComments($this->f('post_id'));
  77      }
  78      
  79      /**
  80      @function getNbTrackbacks
  81      
  82      Renvoie le nombre de trackback d'un billet.
  83      
  84      @return    integer
  85      */
  86  	function getNbTrackbacks()
  87      {
  88          return (integer) $this->blog->getNbTrackbacks($this->f('post_id'));
  89      }
  90      
  91      /**
  92      @function getTS
  93      
  94      Renvoie le timestamp UNIX du billet.
  95      
  96      @return    string
  97      */
  98  	function getTS()
  99      {
 100          return strtotime($this->f('post_dt'));
 101      }
 102      
 103      /**
 104      @function getLDate()
 105      
 106      Renvoie la date du billet au format définit par la propriété
 107      ''date_format'' de l'objet $blog définit pour l'objet courant.
 108      
 109      @return    string
 110      */
 111  	function getLDate()
 112      {
 113          return dt::str($this->blog->date_format,$this->getTS());
 114      }
 115      
 116      /**
 117      @function getLTime()
 118      
 119      Renvoie l'heure du billet au format définit par la propriété
 120      ''time_format'' de l'objet $blog définit pour l'objet courant.
 121      
 122      @return    string
 123      */
 124  	function getLTime()
 125      {
 126          return dt::str($this->blog->time_format,$this->getTS());
 127      }
 128      
 129      /**
 130      @function getIsoDate
 131      
 132      Renvoie la date du billet au format ISO.
 133      
 134      @return string
 135      */
 136  	function getIsoDate()
 137      {
 138          return dt::iso8601($this->getTS());
 139      }
 140      
 141      /**
 142      @function getUserCN
 143      
 144      Renvoie le ''common name'' de l'auteur du billet. Si ce dernier a un
 145      pseudo, alors le pseudo sera utilisé, sinon, le prénom suivit du nom.
 146      
 147      @return    string
 148      */
 149  	function getUserCN()
 150      {
 151          if($this->f('user_pseudo') != '') {
 152              return $this->f('user_pseudo');
 153          } else {
 154              return trim($this->f('user_prenom').' '.$this->f('user_nom'));
 155          }
 156      }
 157      
 158      /**
 159      @function getPermURL
 160      
 161      Renvoie l'URL permanente du billet.
 162      
 163      @return    string
 164      */
 165  	function getPermURL()
 166      {
 167          return sprintf($this->blog->front_url['post'],$this->f('postyear'),
 168                      $this->f('postmonth'),$this->f('postday'),
 169                      $this->f('post_id'),$this->f('post_titre_url'));
 170      }
 171      
 172      /**
 173      @function getCatURL
 174      
 175      Renvoir l'URL vers la catégorie du billet.
 176      
 177      @return    string
 178      */
 179  	function getCatURL()
 180      {
 181          return sprintf($this->blog->front_url['cat'],$this->f('cat_libelle_url'));
 182      }
 183      
 184      /**
 185      @function getIDs
 186      
 187      Cette méthode crée une liste des ID de chaque billet du recordset. Chaque
 188      entrée peut être précédée d'une éventuelle chaîne définie par $str.
 189      
 190      @param    string    str            Chaîne précédant chaque ID
 191      @return    array
 192      */
 193  	function getIDs($str='')
 194      {
 195          $res = array();
 196          
 197          $index = $this->int_index;
 198          $this->moveStart();
 199          
 200          while (!$this->EOF())
 201          {
 202              $res[] = $str.$this->f('post_id');
 203              $this->moveNext();
 204          }
 205          $this->move($index);
 206          return $res;
 207      }
 208  }
 209  ?>


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7