Esempio n. 1
0
 /**
  * Convert a comment instance to the expected data format.
  *
  * @param   Comment  $comment  Comment to convert.
  * @return  array
  */
 protected function convertComment(Comment $comment)
 {
     $content = $comment->toArray();
     $defaults = array('comment_type' => 'comment', 'referrer' => visitor::referrer(), 'blog_lang' => site()->multilang() ? site()->language() : 'en', 'blog_charset' => c::get('charset', 'utf8'));
     $map = array('text' => 'comment_content', 'author_email' => 'comment_author_email', 'author_url' => 'comment_author_url', 'author_ip' => 'user_ip', 'author_agent' => 'user_agent', 'page_uri' => 'permalink');
     // Swap array keys with the keys expected by Akismet
     foreach ($content as $key => $value) {
         unset($content[$key]);
         if (isset($map[$key])) {
             $new = $map[$key];
             $content[$new] = $value;
         }
     }
     // Include the default values in the request
     $content = array_merge($defaults, $content);
     // Post-process a few of the raw values
     if (!empty($content['permalink'])) {
         $content['permalink'] = url($content['permalink']);
     }
     if (!empty($content['comment_content'])) {
         $content['comment_content'] = markdown($content['comment_content']);
     }
     return $content;
 }