__('Comments Admin', __FILE__), 'version' => 103, 'summary' => __('Provides an administrative interface for working with comments', __FILE__), 'permanent' => false, 'requires' => 'FieldtypeComments', ); } public function init() { parent::init(); } protected function ___renderItem(Comment $comment, $n) { $statuses = array( Comment::statusApproved => $this->_x('Approved', 'comment-status'), Comment::statusPending => $this->_x('Pending', 'comment-status'), Comment::statusSpam => $this->_x('Spam', 'comment-status'), ); $statusName = ''; $statusOut = ""; $headLabel = $statusName; $num = $n+1; $liID = "CommentsAdminItem{$comment->id}"; if($comment->status == Comment::statusApproved) $liClass = "InputfieldStateCollapsed"; else if($comment->status == Comment::statusSpam) $liClass = "InputfieldStateCollapsed CommentsAdminItemSpam ui-state-error"; else $liClass = ''; if($comment->status == Comment::statusSpam) $note = $this->_("Spam is automatically deleted after the amount of time specified in the field configuration."); else if($comment->status == Comment::statusPending) $note = $this->_("This item is awaiting approval or deletion."); else $note = ''; if($note) $note = "\n\t\t\t

$note

"; $out = "\n\t
  • " . "\n\t\t" . "\n\t\t
    " . $note . "\n\t\t\t

    " . "\n\t\t\t

    " . "\n\t\t\t

    " . "\n\t\t\t

    " . "\n\t\t\t

    " . "\n\t\t\t" . "\n\t\t
    " . "\n\t
  • "; return $out; } public function ___render() { $out = ''; $n = 0; if(!count($this->value)) return "

    " . $this->_('There are currently no items to display.') . "

    "; $out = "\n"; return $out; } public function ___processInput(WireInputData $input) { $n = 1; $names = array( 'cite', 'email', 'website', 'status', 'delete', 'text', 'sort', ); foreach($this->value as $comment) { $data = array(); foreach($names as $name) { $inputName = $this->name . "_" . $name . "_" . $comment->id; $value = isset($input[$inputName]) ? $input[$inputName] : ''; $data[$name] = $value; } if($data['status'] && $data['status'] == "delete{$comment->id}") { $this->value->remove($comment); $this->message(sprintf($this->_('Removed comment #%d'), $n)); $this->value->trackChange('remove'); continue; } foreach($data as $key => $value) { if($key == 'text') $value = $comment->cleanCommentString($value); if(($value || $key == 'status') && $comment->$key != $value) { $comment->$key = $value; $this->message(sprintf($this->_('Updated %s for comment #%d'), $key, $n)); $this->value->trackChange('update'); } } $n++; } return $this; } }