Skip to content

Commit

Permalink
Merge pull request #9 from pixelant/development
Browse files Browse the repository at this point in the history
Bug fixes. Small code changes.
  • Loading branch information
anjeylink authored Aug 3, 2017
2 parents 053e1ba + 4209d44 commit 342b924
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 27 deletions.
14 changes: 2 additions & 12 deletions Classes/Controller/SocialFeedAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ class SocialFeedAjaxController
*/
const URL = 'https://api.instagram.com/v1/users/search?q=%s&access_token=%s';

/**
* post data
*
* @var array
*/
protected $postData = [];

/**
* configurationRepository
*
Expand All @@ -67,8 +60,6 @@ public function __construct()
$this->configurationRepository = GeneralUtility::makeInstance(
ObjectManager::class
)->get(ConfigurationRepository::class);

$this->postData['configuration'] = (int)GeneralUtility::_POST('configuration');
}

/**
Expand All @@ -82,10 +73,9 @@ public function __construct()
*/
public function loadInstUserId(ServerRequestInterface $request, ResponseInterface $response)
{

if ($this->postData['configuration']) {
if ($configurationUid = (int)$request->getParsedBody()['configuration']) {
/** @var Configuration $configuration */
$configuration = $this->configurationRepository->findByUid($this->postData['configuration']);
$configuration = $this->configurationRepository->findByUid($configurationUid);

if ($configuration !== null
&& $configuration->getToken()->getCredential('accessToken')
Expand Down
15 changes: 15 additions & 0 deletions Classes/Domain/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ public function getMessage()
return $this->message;
}

/**
* Returns the message decoded
*
* @return string $message
*/
public function getDecodedMessage()
{
return json_decode(
sprintf(
'"%s"',
$this->message
)
);
}

/**
* Sets the message
*
Expand Down
5 changes: 3 additions & 2 deletions Classes/Utility/Task/CleanUpTaskUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ private function isFeedDeleted($externalIdentifier, Configuration $configuration

$data = json_decode(GeneralUtility::getUrl($url), true);

return !(isset($data['id']) && $data['id'] == $externalIdentifier);

return (!isset($data['id']) || $data['id'] !== $externalIdentifier);
break;
case Token::INSTAGRAM_OAUTH2:
$url = sprintf(
Expand All @@ -252,7 +253,7 @@ private function isFeedDeleted($externalIdentifier, Configuration $configuration

$data = json_decode(GeneralUtility::getUrl($url), true);

return !(isset($data['data']['id']) && $data['data']['id'] == $externalIdentifier);
return (!isset($data['data']['id']) || $data['data']['id'] !== $externalIdentifier);
break;
default:
throw new \UnexpectedValueException('Such social type is not valid', 1466690851);
Expand Down
15 changes: 14 additions & 1 deletion Classes/Utility/Task/ImportTaskUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ private function updateFacebookFeed($data, Configuration $configuration)
private function setFacebookData(Feed $feed, $rawData)
{
if (isset($rawData['message'])) {
$feed->setMessage($rawData['message']);

$feed->setMessage($this->encodeMessage($rawData['message']));
}

if (isset($rawData['attachments']['data'][0]['media']['image']['src'])) {
Expand All @@ -355,4 +356,16 @@ private function setFacebookData(Feed $feed, $rawData)
$feed->setTitle($rawData['attachments']['data'][0]['title']);
}
}

/**
* Use json_encode to get emoji character convert to unicode
* @TODO is there better way to do this ?
*
* @param $message
* @return bool|string
*/
private function encodeMessage($message)
{
return substr(json_encode($message), 1, -1);
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Access tokens types:
In configuration there are next fields:

* Configuration name - *just a custom name*
* Social ID - *ID of account where to fetch feed (for example, "pixelant.net" - Pixelant ID on a facebook)*
* Social ID - *ID of account where to fetch feed (for example, "pixelant.net" - Pixelant ID on a facebook) or Instagram hashtag (with starting #)*
* Limit - *minimum number of records to keep and fetch from feed at once*
* Storage - *specify folder where to save feed items*
* Token - *choose access token*
Expand Down
5 changes: 4 additions & 1 deletion Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@
<source>Configuration name</source>
</trans-unit>
<trans-unit id="pxasocialfeed_module.labels.form.social_id">
<source>Social ID/Instagram hashtag (with starting #)</source>
<source>Social ID</source>
</trans-unit>
<trans-unit id="pxasocialfeed_module.labels.form.social_id_tooltip">
<source>Either Facebook / Twitter / Instagram ID or Instagram hashtag (with starting #)</source>
</trans-unit>
<trans-unit id="pxasocialfeed_module.labels.form.amount_of_feeds">
<source>Limit</source>
Expand Down
15 changes: 10 additions & 5 deletions Resources/Private/Partials/Frontend/FeedsItems.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ <h3 class="social-feed-title">{feed.title}</h3>
<span class="social-feed-date">{feed.postDate -> f:format.date(format: settings.dateFormat)}</span>
</div>
<f:if condition="{settings.loadLikesCount}">
<span class="social-feed-like-count">
<f:image src="EXT:pxa_social_feed/Resources/Public/Icons/like.svg" class="like-icon" alt="like" width="17"/>
<span class="social-feed-like-like-count-element">{feed.likes}</span>
</span>
<span class="social-feed-like-count">
<f:image src="EXT:pxa_social_feed/Resources/Public/Icons/like.svg" class="like-icon" alt="like" width="17"/>
<span class="social-feed-like-like-count-element">{feed.likes}</span>
</span>
</f:if>
</div>

<p class="social-feed-message">{feed.message -> f:format.raw()}</p>
<p class="social-feed-message">
<f:if condition="{feed.configuration.token.socialType} == 1">
<f:then>{feed.decodedMessage -> f:format.raw()}</f:then>
<f:else>{feed.message -> f:format.raw()}</f:else>
</f:if>
</p>
</a>
</li>
</f:for>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ <h4><f:translate key="pxasocialfeed_module.labels.{f:if(then: 'editConfig', else
</tr>
<tr>
<td><f:translate key="pxasocialfeed_module.labels.form.social_id"/></td>
<td><f:form.textfield property="socialId" class="form-control"/></td>
<td><f:form.textfield
property="socialId"
title="{f:translate(key: 'pxasocialfeed_module.labels.form.social_id_tooltip')}"
class="form-control tooltip-hold"
data="{placement: 'left'}"/></td>
</tr>
<tr>
<td><f:translate key="pxasocialfeed_module.labels.form.amount_of_feeds"/></td>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/Backend/SocialFeedModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ define(['jquery',
}

/**
* Instagram toket get button
* Instagram token get button
* @private
*/
function _getInstagramToketClick() {
Expand Down
9 changes: 7 additions & 2 deletions Resources/Public/JavaScript/owl.carousel.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'uploadfolder' => '0',
'createDirs' => '',
'clearCacheOnLoad' => 0,
'version' => '1.5.0',
'version' => '1.5.1',
'constraints' => [
'depends' => [
'typo3' => '7.6.0-8.9.99',
Expand Down

0 comments on commit 342b924

Please sign in to comment.