Пример #1
0
 public function getImage(XenForo_Model $model)
 {
     if (isset($this->_data['image'])) {
         return $this->_data['image'];
     }
     return parent::getImage($model);
 }
Пример #2
0
 public function getImage(XenForo_Model $model)
 {
     $imageUrl = bdMedal_Model_Medal::getImageUrl($this->_medal);
     if (!empty($imageUrl)) {
         return XenForo_Link::convertUriToAbsoluteUri($imageUrl, true);
     }
     return parent::getImage($model);
 }
Пример #3
0
 public function getImage(XenForo_Model $model)
 {
     $entry = $this->_entryDw->getMergedData();
     $image = $this->_getImageFromBbCodeMessage($model, $entry, 'blog_entry', $entry['entry_id']);
     if (!empty($image)) {
         return $image;
     }
     return parent::getImage($model);
 }
Пример #4
0
 public function getImage(XenForo_Model $model)
 {
     $resource = $this->_resourceDw->getMergedData();
     if (isset(XenForo_Template_Helper_Core::$helperCallbacks['resourceiconurl'])) {
         $iconUrl = XenForo_Template_Helper_Core::callHelper('resourceiconurl', array($resource));
         return XenForo_Link::convertUriToAbsoluteUri($iconUrl, true);
     }
     return parent::getImage($model);
 }
Пример #5
0
 public function getImage(XenForo_Model $model)
 {
     $post = $this->_postDw->getMergedData();
     if ($post['position'] > 0) {
         // this is a reply, use the first post image
         $firstPost = $this->_getFirstPost($model);
         $image = $this->_getImageFromPost($model, $firstPost);
     } else {
         // this is the first post, use its image
         $image = $this->_getImageFromPost($model, $post);
     }
     if (!empty($image)) {
         return $image;
     }
     return parent::getImage($model);
 }
Пример #6
0
 public function getImage(XenForo_Model $model)
 {
     $item = $this->_itemDw->getMergedData();
     if ($item['attach_count'] > 0) {
         if ($this->_image === false) {
             $item = $model->getModelFromCache('NFLJ_Showcase_Model_Item')->getAndMergeAttachmentsIntoItem($item);
             if (!empty($item['cover_image'])) {
                 $this->_image = XenForo_Link::convertUriToAbsoluteUri($item['cover_image']['thumbnailUrl'], true);
             } else {
                 $this->_image = '';
             }
         }
         if (!empty($this->_image)) {
             return $this->_image;
         }
     }
     return parent::getImage($model);
 }
Пример #7
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!!!!
 }