Exemple #1
0
 public function postProcessing(&$data)
 {
     include_once \Yii::getPathOfAlias('site.frontend.vendor.simplehtmldom_1_5') . DIRECTORY_SEPARATOR . 'simple_html_dom.php';
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['purifiedHtml'] = Comment::model()->findByPk($data[$i]['id'])->purified->text;
         $data[$i]['text'] = HtmlParser::handleHtml($data[$i]['text'], $data[$i])->outertext;
         $data[$i]['purifiedHtml'] = HtmlParser::handleHtml($data[$i]['purifiedHtml'], $data[$i])->outertext;
         if (in_array('answers', $this->controller->getWithParameters(Comment::model(), true))) {
             $answers = Comment::model()->findAll(array('condition' => 'root_id = ' . $data[$i]['id'] . ' and id != ' . $data[$i]['id']));
             if ($answers) {
                 $data[$i]['answers'] = array();
                 foreach ($answers as $answer) {
                     Formatter::format($answer);
                     $temp = $answer->getAttributes();
                     $temp['text'] = HtmlParser::handleHtml($temp['text'], $temp)->outertext;
                     Formatter::formatUser($answer->author);
                     Formatter::formatCommon($answer->author);
                     $temp['author'] = $answer->author->getAttributes(Filter::getFilter($answer->author->getAttributes(), get_class($answer->author)));
                     //Formatter::format($temp);
                     $data[$i]['answers'][] = $temp;
                 }
             }
         }
     }
 }
Exemple #2
0
 private function handleContacts(&$contacts)
 {
     for ($i = 0; $i < count($contacts); $i++) {
         /**
          * @var \User $user
          */
         $user = \User::model()->findByPk($contacts[$i]['id']);
         if (!$user) {
             throw new NotFoundApiException('InvalidContact:UserNotFound');
         }
         Formatter::formatUser($user);
         $contacts[$i]['avatar'] = $user->getAttributes()['avatarInfo'];
         $message = \MessagingMessage::model()->between($this->controller->identity->getId(), $user->id)->find(array('order' => \MessagingMessage::model()->getTableAlias() . ".created desc"));
         Formatter::formatCommon($message);
         $contacts[$i]['message'] = $message->getAttributes();
     }
 }