getComment() public static method

Get all data for a given id
public static getComment ( integer $id ) : array
$id integer The Id of the comment to fetch?
return array
示例#1
0
 /**
  * Get the data
  * If a revision-id was specified in the URL we load the revision and not the actual data.
  */
 private function getData()
 {
     // get the record
     $this->record = (array) BackendBlogModel::getComment($this->id);
     // no item found, throw an exceptions, because somebody is f*****g with our URL
     if (empty($this->record)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
示例#2
0
文件: Api.php 项目: forkcms/forkcms
 /**
  * Get a single comment
  *
  * @param int $id The id of the comment.
  *
  * @return array
  */
 public static function commentsGetById($id)
 {
     // authorize
     if (BaseAPI::isAuthorized() && BaseAPI::isValidRequestMethod('GET')) {
         // get comment
         $comment = (array) BackendBlogModel::getComment($id);
         // init var
         $return = array('comments' => null);
         // any comment found?
         if (empty($comment)) {
             return $return;
         }
         // create array
         $item['comment'] = array();
         // article meta data
         $item['comment']['article']['@attributes']['id'] = $comment['post_id'];
         $item['comment']['article']['@attributes']['lang'] = $comment['language'];
         $item['comment']['article']['title'] = $comment['post_title'];
         $item['comment']['article']['url'] = SITE_URL . BackendModel::getURLForBlock('Blog', 'Detail', $comment['language']) . '/' . $comment['post_url'];
         // set attributes
         $item['comment']['@attributes']['id'] = $comment['id'];
         $item['comment']['@attributes']['created_on'] = date('c', $comment['created_on']);
         $item['comment']['@attributes']['status'] = $comment['status'];
         // set content
         $item['comment']['text'] = $comment['text'];
         $item['comment']['url'] = $item['comment']['article']['url'] . '#comment-' . $comment['id'];
         // author data
         $item['comment']['author']['@attributes']['email'] = $comment['email'];
         $item['comment']['author']['name'] = $comment['author'];
         $item['comment']['author']['website'] = $comment['website'];
         // add
         $return['comments'][] = $item;
         return $return;
     }
 }