예제 #1
0
 public function postPhoto()
 {
     if (isset($_FILES['photo'])) {
         $this->model = \AlbumPhoto::model()->createUserTempPhoto($_FILES['photo']);
         if (!$this->model instanceof \AlbumPhoto) {
             throw new ApiException('CreatingPhotoError', 500);
         }
         MigrateManager::movePhoto($this->model);
         $this->model->refresh();
         $this->controller->data = $this->model;
         $this->controller->setAction($this);
     } else {
         throw new ParamsMissingApiException();
     }
 }
예제 #2
0
 public function secondStep($new)
 {
     $new->templateObject->data['type'] = 'post';
     $this->owner->post->purified->clearCache();
     //we need to go deeper here
     $new->html = PhotoHelper::adaptImages($this->owner->post->purified->text);
     $new->text = $this->owner->post->text;
     $clearText = $new->fillText();
     $new->isNoindex = $new->isNoindex ? true : !UniquenessChecker::checkBeforeTest($this->owner->author_id, $clearText);
     $photo = $this->owner->post->photo;
     $new->preview = '<p>' . HStr::truncate($clearText, 200, ' <a class="ico-more" href="' . $this->owner->url . '"></a>') . '</p>';
     if ($this->owner->gallery !== null && !empty($this->owner->gallery->items)) {
         $collection = MigrateManager::syncPhotoPostCollection($this->owner);
         $helper = new PhotoTagHelper($collection, $new->authorId);
         $photoAlbumTag = $this->render('site.frontend.modules.api.modules.v2_1.behaviors.views.photo_album_tag', array('data' => $helper));
         $new->html .= $photoAlbumTag;
         $new->preview = $this->render('site.frontend.modules.posts.behaviors.converters.views.photopostPreview', array('tag' => $photoAlbumTag, 'text' => HStr::truncate(trim(preg_replace('~\\s+~', ' ', strip_tags($new->text))), 200, ' <span class="ico-more"></span>')));
         $new->socialObject->imageUrl = \Yii::app()->thumbs->getThumb($collection->cover->photo, 'socialImage')->getUrl();
     } elseif ($photo) {
         $new->preview = $this->render('site.frontend.modules.api.modules.v2_1.behaviors.views.photo_preview', array('url' => $this->owner->url, 'photo' => $photo, 'preview' => $new->preview));
         $new->socialObject->imageUrl = $photo->getPreviewUrl(200, 200);
     }
     if (empty($new->metaObject->description)) {
         $new->metaObject->description = trim(preg_replace('~\\s+~', ' ', strip_tags($this->owner->post->text)));
     }
     $success = $new->save();
     if ($success) {
         $class = \site\frontend\modules\api\APiModule::CACHE_DELETE;
         $del = new $class();
         $del->realOwner = get_class(new \site\frontend\modules\posts\models\Content());
         $del->handleCollection();
     }
     return $success;
 }