[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/dao/ -> trackbacks.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/dao/commentscommon.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/dao/trackback.class.php" );
   5  
   6      define( 'NO_TRACKBACKS', 'no trackbacks available' );
   7  
   8      /**
   9       * Implementation of a trackback feature.
  10       * The technical specifications of the trackback protocol can be found
  11       * here: http://www.movabletype.org/docs/mttrackback.html.
  12       *
  13       * \ingroup DAO
  14       *
  15       * @see CommentsCommon
  16       */
  17      class Trackbacks extends CommentsCommon 
  18      {
  19  
  20          /**
  21           * Initializes the connection to the database
  22           */
  23      	function Trackbacks()
  24          {
  25              $this->CommentsCommon();
  26          }
  27  
  28          /**
  29           * Adds a trackback to the database.
  30           *
  31           * @param A Trackback object
  32           * @return Returns true if successful or false otherwise. Also in case it is successful, it will modify
  33           * the original object to include the id of the trackback that was added.
  34           */
  35  		function addTrackback( &$trackback )
  36          {
  37              return( CommentsCommon::addComment( $trackback ));
  38          }
  39  
  40          /**
  41           * Returns the trackback items for a given article.
  42           *
  43           * @param artId The article identifier.
  44           * @param status One of these:
  45           * - COMMENT_STATUS_ALL
  46           * - COMMENT_STATUS_SPAM
  47           * - COMMENT_STATUS_NONSPAM
  48           * @param page
  49           * @param itemsPerPage
  50           * @return An array of TrackbackItem objects with the information, or false otherwise.
  51           */
  52          function getArticleTrackBacks( $artId, $status = COMMENT_STATUS_ALL, $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
  53          {
  54              $tbs = CommentsCommon::getPostComments( $artId,  // article id
  55                                                      COMMENT_ORDER_NEWEST_FIRST,   // no choice of order for trackbacks
  56                                                      $status,  // spam or not
  57                                                      COMMENT_TYPE_TRACKBACK,   // we're loading trackbacks
  58                                                      $page,
  59                                                      $itemsPerPage );
  60              return( $tbs );
  61          }
  62          
  63          /**
  64           * returns the 'x' most recent trackbacks from a blog
  65           *
  66           * @param blogId the blog id
  67           * @param amount the maximum numer of trackbacks to return. By default, it will return all trackbacks.
  68           * @return an array of Trackback objects
  69           */
  70  		function getBlogTrackbacks( $blogId, $status = COMMENT_STATUS_ALL, $searchTerms = "", $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
  71          {
  72              return( CommentsCommon::getBlogComments( $blogId, 
  73                                                       COMMENT_ORDER_NEWEST_FIRST,
  74                                                       $status, 
  75                                                       COMMENT_TYPE_TRACKBACK,
  76                                                       $searchTerms,
  77                                                       $page,
  78                                                       $itemsPerPage ));
  79          }
  80          
  81          /**
  82           * returns a list of trackbacks given an array with article ids
  83           *
  84           * @param artIds An array of article ids
  85           * @return An array of Trackback objects
  86           * @see getArticleTrackback
  87           */
  88          function getArticleTrackBacksByIds( $artIds )
  89          {
  90              return( CommentsCommon::getArticleTrackBacksByIds( $artIds, COMMENT_TYPE_TRACKBACK ));
  91          }
  92          
  93          /**
  94           * returns a single trackback, identified by its... identifier :)
  95           */
  96  		function getTrackBack( $id )
  97          {
  98              return( CommentsCommon::getComment( $id, COMMENT_TYPE_TRACKBACK ));
  99          }
 100  
 101          /**
 102           * function factored out from the above
 103           *
 104           * @private
 105           * @param row The row with the information
 106           */
 107          function _fillCommentInformation( $row )
 108          {
 109              // ---
 110              // there we go again doing dirty things to the poor trackbacks...
 111              // ---
 112              $prefix = $this->getPrefix();
 113              $date = $row["date"];
 114              $articleId = $row["article_id"];
 115  
 116              $blogId = $row["blog_id"];            
 117              $blogs =  new Blogs();
 118              $blogInfo = $blogs->getBlogInfo( $blogId );
 119              $blogSettings = $blogInfo->getSettings();
 120              $timeDiff = $blogSettings->getValue( "time_offset" );
 121              // now that we've got the time difference, we can
 122              // calculate what would the "real" date...
 123              $date = Timestamp::getDateWithOffset( $date, $timeDiff );
 124  
 125              $trackback = new TrackBack( $row["user_url"],
 126                                    $row["topic"],
 127                                    $row["article_id"],
 128                                    $row["text"],
 129                                    $row["user_name"],
 130                                    $date,
 131                                    $row["client_ip"],
 132                                    $row["spam_rate"],
 133                                    $row["status"],
 134                                    $row["id"] );                            
 135                                    
 136              return( $trackback );
 137          }
 138  
 139          /**
 140           * Returns how many trackbacks have been received for the given article
 141           *
 142           * @param artId The article identifier.
 143           * @status
 144           * @return The number of trackbacks received pointing to that article,
 145           */
 146          function getNumTrackbacksArticle( $artId, $status = COMMENT_STATUS_ALL )
 147          {
 148              return( CommentsCommon::getNumPostComments( $artId, $status, COMMENT_TYPE_TRACKBACK ));
 149          }
 150          
 151          /**
 152           * removes a trackback from the database
 153           *
 154           * @param trackbackId
 155           * @param articleId
 156           * @return True if successful or false otherwise
 157           */
 158  		function deleteTrackback( $trackbackId )
 159          {
 160              return( CommentsCommon::deleteComment( $trackbackId, COMMENT_TYPE_TRACKBACK ));
 161          }
 162          
 163          /**
 164           * @private
 165           * @return Returns true if this trackback already exists in the db
 166           */
 167          function getIdenticalTrackback( $trackback )
 168          {
 169              // :TODO:
 170              //
 171              // implement this
 172              /*return( CommentsCommon::getIdenticalComment( $trackback->getTopic(), 
 173                                                           $trackback->getText(), 
 174                                                           $trackback->getArticleId(),
 175                                                           $trackback->getParentId(),
 176                                                           $trackback->getUserName(), 
 177                                                           $trackback->getUserEmail(),
 178                                                           $trackback->getUserUrl(), 
 179                                                           $trackback->getClientIp(), 
 180                                                           COMMENT_TYPE_TRACKBACK ));*/
 181          }
 182      }
 183  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics