public function getDescription(XenForo_Model $model) { $post = $this->_postDw->getMergedData(); $thread = $this->_postDw->getDiscussionData(); $params = false; if ($post['position'] > 0) { // this is a reply, use the first post body $firstPost = $this->_getFirstPost($model); if (!empty($firstPost)) { $params = array('firstPost' => $firstPost, 'snippet' => $this->_getSnippetFromBbCodeMessage($model, $firstPost['message'])); } } else { // this is the first post, use its body as the description $params = array('fistPost' => $post, 'snippet' => $this->_getSnippetFromBbCodeMessage($model, $post['message'])); } if (!empty($params)) { $params['post'] = $post; $params['thread'] = $thread; if ($post['user_id'] == $this->getViewingUserId()) { return $this->_getSimulationTemplate('bdsocialshare_description_post', $params); } else { return $this->_getSimulationTemplate('bdsocialshare_description_post_auto', $params); } } else { return parent::getDescription($model); } }
public function getDescription(XenForo_Model $model) { if (isset($this->_data['description'])) { return $this->_data['description']; } return parent::getDescription($model); }
public function publish($targetId, bdSocialShare_Shareable_Abstract $shareable, $token) { $statusText = false; $userText = $shareable->getUserText($this); $title = $shareable->getTitle($this); $description = $shareable->getDescription($this); $userText = strval($userText); $title = strval($title); $description = strval($description); if (!empty($userText)) { $statusText = $userText; } if ($statusText === false) { if (!empty($title)) { $statusText = $title; } if (!empty($description)) { if (!empty($statusText)) { $statusText .= ': ' . $description; } else { $statusText = $description; } } } $link = $shareable->getLink($this); if (!empty($link)) { // minus short url length // minus one for the ellipsis character // minus another one for the space character $status = XenForo_Helper_String::wholeWordTrim($statusText, 140 - $this->getShortUrlLengthHttps($token) - 2, 0, '…') . ' ' . $link; } else { // minus one for the ellipsis character $status = XenForo_Helper_String::wholeWordTrim($statusText, 140 - 1, 0, '…'); } $response = bdSocialShare_Helper_Twitter::statusesUpdate($token['oauth_token'], $token['oauth_token_secret'], $status); if (isset($response['id_str'])) { return $response; } else { throw new bdSocialShare_Exception_Interrupted(serialize(array($status, $response))); } }
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!!!! }