Ejemplo n.º 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;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 function postProcessing(&$data)
 {
     if (\Yii::app()->request->requestType == 'GET') {
         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]['isReadByInterlocutor'] = \MessagingMessage::model()->findByPk($data[$i]['id'])->getIsReadByInterlocutor();
             $data[$i]['text'] = HtmlParser::handleHtml($data[$i]['text'])->outertext;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * HTML Format, Views Counter Increment
  *
  * @param $data
  */
 public function postProcessing(&$data)
 {
     //\Yii::import('ext.SimpleHTMLDOM.SimpleHTMLDOM');
     include_once \Yii::getPathOfAlias('site.frontend.vendor.simplehtmldom_1_5') . DIRECTORY_SEPARATOR . 'simple_html_dom.php';
     $lastText = '';
     $indexes = array();
     //В форматер и отрефакторить.
     for ($i = 0; $i < count($data); $i++) {
         if ($data[$i]['originService'] == 'oldCommunity') {
             $data[$i]['subscribers'] = \UserClubSubscription::model()->getSubscribersCount(Content::model()->findByPk($data[$i]['id'])->club->id);
         } else {
             if ($data[$i]['originService'] == 'oldBlog') {
                 $data[$i]['subscribers'] = (int) \UserBlogSubscription::model()->subscribersCount($data[$i]['authorId']);
             } else {
                 $data[$i]['subscribers'] = 0;
             }
         }
         $temp = $data[$i]['html'];
         if ($i != 0) {
             //ApiLog::i($lastText . ' -------- ' . $temp);
             if ($lastText == $temp) {
                 //ApiLog::i('DELETED');
                 //$data[$i] = null;
                 $indexes[] = $i;
                 continue;
             }
         }
         if (!$this->isOriginHtml) {
             $data[$i]['html'] = HtmlParser::handleHtml($data[$i]['html'], $data[$i])->outertext;
             if ($data[$i]['preview'] != '') {
                 $data[$i]['preview'] = HtmlParser::handleHtml($data[$i]['preview'])->outertext;
             }
             $url = preg_replace("/http:\\/\\/www.*\\.ru/", "", $data[$i]['url']);
             $pageView = PageView::getModel($url);
             $data[$i]['views'] = $pageView->visits;
             if (isset($data[$i]['photoCollection'])) {
                 $array = \CJSON::decode($data[$i]['photoCollection']);
                 $collection = PhotoCollection::model()->findByPk($array['id']);
                 if ($collection) {
                     $data[$i]['photoCollection'] = $collection->getAttributes();
                     $attaches = PhotoAttach::model()->findAll(array('condition' => 'collection_id=' . $data[$i]['photoCollection']['id'], 'with' => array('photo')));
                     foreach ($attaches as $attach) {
                         $temp = $attach->getAttributes();
                         $temp['photo'] = $attach->photo->getAttributes();
                         $temp['photo']['originalUrl'] = \Yii::app()->fs->getUrl($attach->photo->getFile()->getKey());
                         $data[$i]['photoCollection']['attaches'][] = $temp;
                     }
                 }
             }
         }
         //crutch for adding status info for.
         if ($data[$i]['originService'] == 'status') {
             $status = Status::model()->with('moodModel')->findByPk($data[$i]['originEntityId']);
             Formatter::formatCommon($status);
             $data[$i]['status'] = $status->getAttributes();
             if ($status->moodModel) {
                 Formatter::formatCommon($status->moodModel);
                 $data[$i]['status']['moodModel'] = $status->moodModel->getAttributes();
             }
         }
         $lastText = $temp;
     }
     for ($i = 0; $i < count($indexes); $i++) {
         unset($data[$indexes[$i]]);
     }
     $data = array_values($data);
 }