Beispiel #1
0
 private function changeStatus()
 {
     if ($this->status) {
         $status = new Status();
         $status->text = $this->status;
         $status->authorId = $this->user->id;
         if ($this->status_mood_id) {
             $status->moodId = $this->status_mood_id;
         }
         $status->save();
     }
 }
Beispiel #2
0
 /**
  * Method to add status field in user array.
  * This is a crutch for post processing.
  *
  * @param array &$user
  */
 public static function addStatusToUser(&$user)
 {
     $statusCriteria = new \CDbCriteria(array('order' => 't.id desc', 'limit' => 1));
     $statusCriteria->condition = 'authorId = ' . $user['id'];
     $status = Status::model()->with('moodModel')->find($statusCriteria);
     $user['status'] = null;
     if ($status) {
         Formatter::formatCommon($status);
         $user['status'] = $status->getAttributes();
         if ($status->moodModel) {
             Formatter::formatCommon($status->moodModel);
             $user['status']['moodModel'] = $status->moodModel->getAttributes();
         }
     }
 }
Beispiel #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);
 }