Exemple #1
0
 public function getImage(XenForo_Model $model)
 {
     $attachment = $this->_getAttachment($model);
     if (!empty($attachment)) {
         return $this->_getImageForAttachment($attachment, $model);
     }
     return parent::getImageDataPath($model);
 }
Exemple #2
0
 public function getImageDataPath(XenForo_Model $model)
 {
     $video = $this->_videoDw->getMergedData();
     $videoData = $this->_getVideoData($model);
     if (!empty($videoData)) {
         $path = $model->getModelFromCache('sonnb_XenGallery_Model_VideoData')->getContentDataFile($videoData);
         if (!file_exists($path)) {
             // TODO: remove this?
             $path = $model->getModelFromCache('sonnb_XenGallery_Model_VideoData')->getContentDataLargeThumbnailFile($videoData);
         }
         return $path;
     }
     return parent::getImageDataPath($model);
 }
Exemple #3
0
 public function getImageDataPath(XenForo_Model $model)
 {
     $photo = $this->_photoDw->getMergedData();
     $photoData = $this->_getPhotoData($model);
     if (!empty($photoData)) {
         $photoDataModel = $model->getModelFromCache('sonnb_XenGallery_Model_PhotoData');
         if (method_exists($photoDataModel, 'getPhotoDataFile')) {
             // sonnb - XenGallery v1.0.0
             return $photoDataModel->getPhotoDataFile($photoData);
         } else {
             // sonnb - XenGallery v2.0.0
             return $photoDataModel->getContentDataFile($photoData);
         }
     }
     return parent::getImageDataPath($model);
 }
Exemple #4
0
 public function publish($targetId, bdSocialShare_Shareable_Abstract $shareable, $accessToken)
 {
     try {
         $link = $shareable->getLink($this);
         $imageDataPath = $shareable->getImageDataPath($this);
         $userText = $shareable->getUserText($this);
         $title = $shareable->getTitle($this);
         $description = $shareable->getDescription($this);
         $image = $shareable->getImage($this);
         $userText = strval($userText);
         $title = strval($title);
         $description = strval($description);
         $sendLinkData = (bdSocialShare_Option::get('facebookSendLinkData') or $shareable instanceof bdSocialShare_Shareable_StaffShare);
         if ($sendLinkData and !empty($imageDataPath)) {
             // upload as a new photo in the app album
             $client = XenForo_Helper_Http::getClient(sprintf('https://graph.facebook.com/v2.0/%s/photos', $targetId));
             $client->setFileUpload($imageDataPath, 'source');
             $parts = array();
             if (!empty($title)) {
                 $parts[] = $title;
             }
             if (empty($parts)) {
                 if (!empty($description)) {
                     $parts[] = $description;
                 }
             }
             if (!empty($link)) {
                 $parts[] = $link;
             }
             if (!empty($parts)) {
                 $client->setParameterPost('message', implode("\n", $parts));
             }
         }
         if (empty($client) and !empty($link)) {
             // publish as a link
             $client = XenForo_Helper_Http::getClient(sprintf('https://graph.facebook.com/v2.0/%s/feed', $targetId));
             $client->setParameterPost('link', $link);
             if ($sendLinkData and !empty($title)) {
                 // send link data
                 $client->setParameterPost('name', $title);
                 if (!empty($image)) {
                     $client->setParameterPost('picture', $image);
                 }
                 if (!empty($description)) {
                     $client->setParameterPost('description', $description);
                 }
             }
             if (!empty($userText)) {
                 $client->setParameterPost('message', $userText);
             }
         }
         if (empty($client) and !empty($userText)) {
             // publish as a status
             $client = XenForo_Helper_Http::getClient(sprintf('https://graph.facebook.com/v2.0/%s/feed', $targetId));
             if (!empty($link)) {
                 // merge user text and link
                 $client->setParameterPost('message', sprintf('%s %s', $userText, $link));
             } else {
                 $client->setParameterPost('message', $userText);
             }
         }
         if (empty($client)) {
             return false;
         }
         $client->setParameterPost('access_token', $accessToken);
         $response = $client->request('POST');
         $responseBody = $response->getBody();
         $responseArray = json_decode($responseBody, true);
         if (isset($responseArray['id'])) {
             return $responseArray;
         } else {
             throw new bdSocialShare_Exception_Interrupted($responseBody);
         }
     } catch (Zend_Http_Client_Exception $e) {
         throw new bdSocialShare_Exception_HttpClient($e->getMessage());
     }
     // MUST NOT REACH HERE!!!!
 }