status() public static method

Obtain the integer value of the specified comment status, or false
public static status ( string | integer $name ) : integer | boolean
$name string | integer A comment status name or value
return integer | boolean The valid integer status value or false if there was no match
コード例 #1
0
ファイル: atomhandler.php プロジェクト: habari/system
 /**
  * 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;
 }
コード例 #2
0
 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 '';
 }