Includes an instance of the CommentInfo class; for holding inforecords about the comment If the Comment object describes an existing user; use the internal info object to get, set, unset and test for existence (isset) of info records $this->info = new CommentInfo ( 1 ); // Info records of comment with id = 1 $this->info->browser_ua= "Netscape 2.0"; // set info record with name "browser_ua" to value "Netscape 2.0" $info_value= $this->info->browser_ua; // get value of info record with name "browser_ua" into variable $info_value if ( isset ($this->info->browser_ua) ) // test for existence of "browser_ua" unset ( $this->info->browser_ua ); // delete "browser_ua" info record
Inheritance: extends QueryRecord, implements IsContent
Example #1
0
 /**
  * Output an Atom collection of comments based on the supplied parameters.
  *
  * @param array $params An array of parameters passed to Comments::get() to retrieve comments
  */
 function get_comments($params = array())
 {
     $comments = null;
     $comments_count = null;
     // Assign self link.
     $self = '';
     // Assign alternate link.
     $alternate = '';
     $updated = DateTime::create();
     // Check if this is a feed for a single post
     if (isset($params['slug']) || isset($params['id'])) {
         if (isset($params['slug'])) {
             $post = Post::get(array('slug' => $params['slug']));
         } elseif (isset($params['id'])) {
             $post = Post::get(array('id' => $params['id']));
         }
         // If the post doesn't exist, send a 404
         if (!$post instanceof Post) {
             header('HTTP/1.1 404 Not Found', true, 404);
             die('The post could not be found');
         }
         $comments = $post->comments->approved;
         $comments_count = count($comments);
         $content_type = Post::type_name($post->content_type);
         $self = URL::get("atom_feed_{$content_type}_comments", $post, false);
         $alternate = URL::get("display_{$content_type}", $post, false);
         if ($comments_count) {
             $updated = $comments[$comments_count - 1]->date;
         }
     } else {
         $self = URL::get('atom_feed_comments');
         $alternate = URL::get('display_home');
         $params['status'] = 'approved';
         $comments = Comments::get($params);
         $comments_count = Comments::count_total(Comment::status('approved'));
         if ($comments_count) {
             $updated = $comments[0]->date;
         }
     }
     $id = isset($params['slug']) ? $params['slug'] : 'atom_comments';
     $xml = $this->create_atom_wrapper($alternate, $self, $id, $updated);
     $xml = $this->add_pagination_links($xml, $comments_count);
     $xml = $this->add_comments($xml, $comments);
     Plugins::act('atom_get_comments', $xml, $params, $this->handler_vars);
     $xml = $xml->asXML();
     ob_clean();
     header('Content-Type: application/atom+xml');
     print $xml;
 }
 public static function get_spaminess_style(Comment $comment)
 {
     if (isset($comment->info->defensio_spaminess) && $comment->status == Comment::status('spam')) {
         $grad_hex = create_function('$s,$e,$i', 'return (($e-$s)*$i)+$s;');
         $start_hex = '#FFD6D7';
         $end_hex = '#F8595D';
         $border = ColorUtils::rgb_hex(array_combine(array('r', 'g', 'b'), array_map($grad_hex, ColorUtils::hex_rgb($start_hex), ColorUtils::hex_rgb($end_hex), array_pad(array(), 3, $comment->info->defensio_spaminess))));
         return "border-left-color:#{$border}; border-right-color:#{$border};";
     } elseif ($comment->status == self::COMMENT_STATUS_QUEUED) {
         return 'border-left: 3px solid #BCCFFF; border-right: 3px solid #BCCFFF;';
     }
     return '';
 }