From 0b6a93974fa867ba3760fd773a0443409da109ae Mon Sep 17 00:00:00 2001 From: Mathias Date: Fri, 19 Nov 2021 15:32:09 +0100 Subject: [PATCH] run ecs check and fix --- .gitignore | 14 +- .gitlab-ci.yml | 29 + CHANGELOG.md | 2 +- composer.json | 5 +- ecs.php | 40 ++ src/ContaoManager/Plugin.php | 43 +- src/Controller/FacebookController.php | 26 +- src/Controller/InstagramController.php | 27 +- src/Controller/LinkedinController.php | 65 +- src/Controller/ModerateController.php | 74 ++- src/Dca/tl_social_feed.php | 51 +- src/DependencyInjection/Configuration.php | 23 +- .../PdirSocialFeedExtension.php | 20 +- src/EventListener/CronListener.php | 611 ++++++++++-------- src/EventListener/SocialFeedListener.php | 41 +- src/Importer/Importer.php | 64 +- src/Importer/InstagramClient.php | 41 +- src/Importer/InstagramRequestCache.php | 26 +- src/Importer/NewsImporter.php | 97 +-- src/Model/SocialFeedModel.php | 20 +- src/Module/ModuleCustomNewslist.php | 30 +- src/PdirSocialFeedBundle.php | 24 +- src/Resources/contao/config/config.php | 52 +- src/Resources/contao/config/runonce.php | 28 +- src/Resources/contao/dca/tl_module.php | 61 +- src/Resources/contao/dca/tl_news.php | 112 ++-- src/Resources/contao/dca/tl_social_feed.php | 216 ++++--- src/Resources/contao/languages/de/default.php | 18 + src/Resources/contao/languages/de/modules.php | 33 +- .../contao/languages/de/tl_module.php | 31 +- src/Resources/contao/languages/de/tl_news.php | 18 + .../contao/languages/de/tl_social_feed.php | 104 +-- src/Resources/contao/languages/en/default.php | 18 + src/Resources/contao/languages/en/modules.php | 33 +- .../contao/languages/en/tl_module.php | 31 +- src/Resources/contao/languages/en/tl_news.php | 26 +- .../contao/languages/en/tl_social_feed.php | 92 +-- src/Resources/contao/languages/it/default.php | 18 + src/Resources/contao/languages/it/modules.php | 33 +- .../contao/languages/it/tl_module.php | 31 +- src/Resources/contao/languages/it/tl_news.php | 26 +- .../contao/languages/it/tl_social_feed.php | 107 +-- src/SocialFeed/SocialFeedNewsClass.php | 76 ++- 43 files changed, 1613 insertions(+), 924 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 ecs.php diff --git a/.gitignore b/.gitignore index 17c41f3..c1a5994 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,12 @@ -.git/ -.idea/ \ No newline at end of file +# Composer +/composer.lock +/vendor/ + +# cypress & node +cypress.json +/node_modules/ + +# PhpUnit +/.idea +/.phpunit.result.cache +/phpunit.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6424a1c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,29 @@ +cache: + paths: + - vendor/ + +before_script: +# - cp ci/php.ini /usr/local/etc/php/conf.d/test.ini + - COMPOSER_MEMORY_LIMIT=-1 composer install -n --prefer-dist --no-progress --ignore-platform-reqs + +php:7.4: + # This docker image comes with composer and ant. + image: jorge07/alpine-php:7.4-dev + script: + - vendor/bin/phpunit --configuration phpunit.xml --coverage-text --log-junit report.xml + - vendor/bin/ecs check src tests + artifacts: + when: always + reports: + junit: report.xml + +php:8.0: + # This docker image comes with composer and ant. + image: jorge07/alpine-php:8.0-dev + script: + - vendor/bin/phpunit --configuration phpunit.xml --coverage-text --log-junit report.xml + - vendor/bin/ecs check src tests + artifacts: + when: always + reports: + junit: report.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f672e3..2726d3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [2.10.0](https://github.com/pdir/social-feed-bundle/tree/2.10.0) – 2021-xx-xx +## [2.10.0](https://github.com/pdir/social-feed-bundle/tree/2.10.0) – 2021-11-19 - [feature] linkedin import diff --git a/composer.json b/composer.json index 19f1778..1f1ffd3 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,10 @@ "zoonman/linkedin-api-php-client": "dev-master" }, "require-dev": { - "contao/manager-plugin": "^2.0" + "contao/manager-plugin": "^2.0", + "contao/easy-coding-standard": "^3.0", + "phpunit/phpunit": "^8.4 || ^9.5", + "symfony/phpunit-bridge": "^4.4 || ^5.1" }, "conflict": { "contao/manager-plugin": "<2.0 || >=3.0" diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..b8273f3 --- /dev/null +++ b/ecs.php @@ -0,0 +1,40 @@ + +@author Philipp Seibt +@author pdir GmbH + +For the full copyright and license information, please view the LICENSE +file that was distributed with this source code. +EOF; + +return static function (ContainerConfigurator $containerConfigurator): void { + $containerConfigurator->import(__DIR__.'/vendor/contao/easy-coding-standard/config/set/contao.php'); + + $parameters = $containerConfigurator->parameters(); + $parameters->set(Option::LINE_ENDING, "\n"); + + $services = $containerConfigurator->services(); + $services + ->set(HeaderCommentFixer::class) + ->call('configure', [[ + 'header' => $GLOBALS['ecsHeader'], + ]]) + ; +}; diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 883b00d..1cfa913 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -1,12 +1,21 @@ - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @package social-feed-bundle + * @link https://github.com/pdir/social-feed-bundle + * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @author Mathias Arzberger + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace Pdir\SocialFeedBundle\ContaoManager; @@ -22,17 +31,17 @@ class Plugin implements BundlePluginInterface, RoutingPluginInterface { - /** - * {@inheritdoc} - */ - public function getBundles(ParserInterface $parser) - { - return [ - BundleConfig::create(PdirSocialFeedBundle::class) - ->setLoadAfter([ContaoCoreBundle::class]) - ->setReplace(['socialfeedbundle']), - ]; - } + /** + * {@inheritdoc} + */ + public function getBundles(ParserInterface $parser) + { + return [ + BundleConfig::create(PdirSocialFeedBundle::class) + ->setLoadAfter([ContaoCoreBundle::class]) + ->setReplace(['socialfeedbundle']), + ]; + } /** * {@inheritdoc} diff --git a/src/Controller/FacebookController.php b/src/Controller/FacebookController.php index 9b1b50c..211f5f5 100644 --- a/src/Controller/FacebookController.php +++ b/src/Controller/FacebookController.php @@ -1,31 +1,33 @@ - * @author Kamil Kuzminski - * @license MIT + * Copyright (c) 2021 pdir / digital agentur // pdir GmbH * - * https://github.com/codefog/contao-instagram + * @package social-feed-bundle + * @link https://github.com/pdir/social-feed-bundle + * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @author Mathias Arzberger + * @author Philipp Seibt + * @author pdir GmbH * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace Pdir\SocialFeedBundle\Controller; -use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; use Doctrine\DBAL\Connection; +use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Facebook\Facebook; -use Contao\CoreBundle\Exception\RedirectResponseException; /** * @Route("/_facebook", defaults={"_scope" = "backend", "_token_check" = false}) @@ -68,7 +70,7 @@ public function authAction(Request $request): Response 'client_id' => $sessionData['clientId'], 'client_secret' => $sessionData['clientSecret'], 'redirect_uri' => $this->router->generate('facebook_auth', [], RouterInterface::ABSOLUTE_URL), - 'code' => $request->query->get('code') + 'code' => $request->query->get('code'), ]; $json = file_get_contents('https://graph.facebook.com/v11.0/oauth/access_token?'.http_build_query($data)); diff --git a/src/Controller/InstagramController.php b/src/Controller/InstagramController.php index 4f7e2f2..5dd9617 100644 --- a/src/Controller/InstagramController.php +++ b/src/Controller/InstagramController.php @@ -1,24 +1,29 @@ - * @author Kamil Kuzminski - * @license MIT + * Copyright (c) 2021 pdir / digital agentur // pdir GmbH * - * https://github.com/codefog/contao-instagram + * @package social-feed-bundle + * @link https://github.com/pdir/social-feed-bundle + * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @author Mathias Arzberger + * @author Philipp Seibt + * @author pdir GmbH * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace Pdir\SocialFeedBundle\Controller; -use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; -use Pdir\SocialFeedBundle\Importer\InstagramClient; use Contao\BackendUser; use Doctrine\DBAL\Connection; +use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; +use Pdir\SocialFeedBundle\Importer\InstagramClient; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -80,7 +85,7 @@ public function authAction(Request $request): Response } // User not logged in - if (null === ($user = $this->getBackendUser())) { + if (null === $this->getBackendUser()) { return new Response(Response::$statusTexts[Response::HTTP_UNAUTHORIZED], Response::HTTP_UNAUTHORIZED); } @@ -109,7 +114,7 @@ public function authAction(Request $request): Response // Get the user and media data $this->client->getUserData($accessToken, (int) $module['id'], false); - $mediaData = $this->client->getMediaData($accessToken, (int) $module['id'], false); + // $mediaData = $this->client->getMediaData($accessToken, (int) $module['id'], false); // Store the access token and remove temporary session key $this->db->update('tl_social_feed', ['psf_instagramAccessToken' => $accessToken], ['id' => $sessionData['socialFeedId']]); diff --git a/src/Controller/LinkedinController.php b/src/Controller/LinkedinController.php index e4fc7e7..28a9db2 100644 --- a/src/Controller/LinkedinController.php +++ b/src/Controller/LinkedinController.php @@ -1,17 +1,40 @@ + * @author Kamil Kuzminski + * @license MIT + * + * Copyright (c) 2021 pdir / digital agentur // pdir GmbH + * + * @package social-feed-bundle + * @link https://github.com/pdir/social-feed-bundle + * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @author Mathias Arzberger + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\Controller; -use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; use Doctrine\DBAL\Connection; +use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use LinkedIn\Client; /** * @Route("/auth", defaults={"_scope" = "backend", "_token_check" = false}) @@ -51,28 +74,26 @@ public function authAction(Request $request): Response $sessionData = $this->session->get(SocialFeedListener::SESSION_KEY); // Missing code query parameter - if (!($code = $request->query->get('code'))) { + if (!$request->query->get('code')) { return new Response(Response::$statusTexts[Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST); - } else { - //get refresh token - $data = [ - 'grant_type' => 'authorization_code', - 'code' => $request->query->get('code'), - 'client_id' => $sessionData['clientId'], - 'client_secret' => $sessionData['clientSecret'], - 'redirect_uri' => $this->router->generate('auth_linkedin', [], RouterInterface::ABSOLUTE_URL) - ]; - - try { - $token = json_decode(file_get_contents('https://www.linkedin.com/oauth/v2/accessToken?'.http_build_query($data))); + } + //get refresh token + $data = [ + 'grant_type' => 'authorization_code', + 'code' => $request->query->get('code'), + 'client_id' => $sessionData['clientId'], + 'client_secret' => $sessionData['clientSecret'], + 'redirect_uri' => $this->router->generate('auth_linkedin', [], RouterInterface::ABSOLUTE_URL), + ]; - // Store the access token and remove temporary session key - $this->db->update('tl_social_feed', ['linkedin_access_token' => $token->access_token, 'access_token_expires' => time() + $token->expires_in, 'linkedin_refresh_token' => $token->refresh_token, 'linkedin_refresh_token_expires' => time() + $token->refresh_token_expires_in], ['id' => $sessionData['socialFeedId']]); - $this->session->remove(SocialFeedListener::SESSION_KEY); - } catch(Exception $e) { - \System::log($e->getMessage(), __METHOD__, TL_GENERAL); - } + try { + $token = json_decode(file_get_contents('https://www.linkedin.com/oauth/v2/accessToken?'.http_build_query($data))); + // Store the access token and remove temporary session key + $this->db->update('tl_social_feed', ['linkedin_access_token' => $token->access_token, 'access_token_expires' => time() + $token->expires_in, 'linkedin_refresh_token' => $token->refresh_token, 'linkedin_refresh_token_expires' => time() + $token->refresh_token_expires_in], ['id' => $sessionData['socialFeedId']]); + $this->session->remove(SocialFeedListener::SESSION_KEY); + } catch (Exception $e) { + System::log($e->getMessage(), __METHOD__, TL_GENERAL); } return new RedirectResponse($sessionData['backUrl']); diff --git a/src/Controller/ModerateController.php b/src/Controller/ModerateController.php index 09da235..ddf14e3 100644 --- a/src/Controller/ModerateController.php +++ b/src/Controller/ModerateController.php @@ -1,13 +1,31 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\Controller; use Contao\BackendTemplate; use Contao\CoreBundle\Framework\ContaoFramework; use Contao\Environment; +use Contao\Input; use Contao\Message; use Contao\System; -use Contao\Input; use Pdir\SocialFeedBundle\Importer\Importer; use Pdir\SocialFeedBundle\Importer\NewsImporter; use Pdir\SocialFeedBundle\Model\SocialFeedModel; @@ -38,14 +56,8 @@ class ModerateController /** * ExportController constructor. - * - * @param ContaoFramework $framework - * @param RequestStack $requestStack */ - public function __construct( - ContaoFramework $framework, - RequestStack $requestStack - ) + public function __construct(ContaoFramework $framework, RequestStack $requestStack) { $this->framework = $framework; $this->requestStack = $requestStack; @@ -75,11 +87,9 @@ public function run() /** * Process the form. * - * @param Request $request - * * @codeCoverageIgnore */ - protected function processForm(Request $request) + protected function processForm(Request $request): void { if (!$request->request->get('account')) { return; @@ -96,11 +106,9 @@ protected function processForm(Request $request) // import selected items $importItems = $request->request->get('importItems'); - if($importItems && count($importItems) > 0) - { - foreach($items as $item) - { - if(in_array($item['id'], $importItems)) { + if ($importItems && \count($importItems) > 0) { + foreach ($items as $item) { + if (\in_array($item['id'], $importItems, true)) { $importer = new NewsImporter($item); $importer->accountImage = $objImporter->getAccountImage(); $importer->execute($newsArchiveId, $objSocialFeedModel->socialFeedType, $objSocialFeedModel->id); @@ -109,13 +117,14 @@ protected function processForm(Request $request) } // set import message - if(is_array($items) && isset($importItems) && count($importItems) > 0) { - $this->message = sprintf($GLOBALS['TL_LANG']['BE_MOD']['socialFeedModerate']['importMessage'], count($importItems)); + if (\is_array($items) && isset($importItems) && \count($importItems) > 0) { + $this->message = sprintf($GLOBALS['TL_LANG']['BE_MOD']['socialFeedModerate']['importMessage'], \count($importItems)); } // get items for moderation list $moderationItems = $objImporter->moderation($items); - if(count($moderationItems) > 0) { + + if (\count($moderationItems) > 0) { $template = new BackendTemplate('be_sf_moderation_list'); $template->arr = $moderationItems; $html = $template->parse(); @@ -139,15 +148,14 @@ protected function getTemplate($formId) { /** * @var Environment - * @var Message $message - * @var System $system + * @var Message $message + * @var System $system */ $environment = $this->framework->getAdapter(Environment::class); $message = $this->framework->getAdapter(Message::class); $system = $this->framework->getAdapter(System::class); - if($this->message) - { + if ($this->message) { $message->addInfo($this->message); } @@ -156,7 +164,7 @@ protected function getTemplate($formId) $this->template->formId = $formId; $this->template->message = $message->generate(); $this->template->options = $this->generateOptions(); - $this->template->headline = 'Nachrichten › Social Feed › Moderate › Achiv ' . Input::get('id'); + $this->template->headline = 'Nachrichten › Social Feed › Moderate › Achiv '.Input::get('id'); return $this->template; } @@ -175,21 +183,19 @@ protected function generateOptions() $objFeedModel = SocialFeedModel::findAll(); foreach ($objFeedModel as $feed) { - if($feed->socialFeedType == 'Facebook') - { - $options[$feed->id] = $feed->socialFeedType . ' ' . $feed->pdir_sf_fb_account; + if ('Facebook' === $feed->socialFeedType) { + $options[$feed->id] = $feed->socialFeedType.' '.$feed->pdir_sf_fb_account; } - if($feed->socialFeedType == 'Instagram') - { - $options[$feed->id] = $feed->socialFeedType . ' ' . $feed->instagram_account; + + if ('Instagram' === $feed->socialFeedType) { + $options[$feed->id] = $feed->socialFeedType.' '.$feed->instagram_account; } - if($feed->socialFeedType == 'Twitter') - { - $options[$feed->id] = $feed->socialFeedType . ' ' . $feed->twitter_account; + + if ('Twitter' === $feed->socialFeedType) { + $options[$feed->id] = $feed->socialFeedType.' '.$feed->twitter_account; } } return $options; } - } diff --git a/src/Dca/tl_social_feed.php b/src/Dca/tl_social_feed.php index 65f4f11..8dd76f1 100644 --- a/src/Dca/tl_social_feed.php +++ b/src/Dca/tl_social_feed.php @@ -1,50 +1,65 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\Dca; use Contao\BackendTemplate; -use Contao\CoreBundle\Framework\ContaoFramework; use Contao\DataContainer; class tl_social_feed { /** - * social-feed-bundle version + * social-feed-bundle version. */ - const VERSION = '2.10.0'; + public const VERSION = '2.10.0'; /** - * Template + * Template. + * * @var string */ protected $strTemplate = 'be_socialfeed_setup'; + /** * On generate the label. - * - * @param array $row - * - * @return string */ public function onGenerateLabel(array $row): string { - if($row['pdir_sf_fb_account'] != "") { + if ('' !== $row['pdir_sf_fb_account']) { $account = $row['pdir_sf_fb_account']; - } else if($row['instagram_account'] != "") { + } elseif ('' !== $row['instagram_account']) { $account = $row['instagram_account']; - } else if($row['twitter_account'] != "") { + } elseif ('' !== $row['twitter_account']) { $account = $row['twitter_account']; - } else if($row['linkedin_company_id'] != "") { + } elseif ('' !== $row['linkedin_company_id']) { $account = $row['linkedin_company_id']; - } else if($row['search'] != "") { + } elseif ('' !== $row['search']) { $account = $row['search']; } else { - $account = "Kein Account/Suchbegriff angegeben"; + $account = 'Kein Account/Suchbegriff angegeben'; } - if($row['socialFeedType'] != "") { + if ('' !== $row['socialFeedType']) { $type = $row['socialFeedType']; } else { - $type = "Kein Typ angegeben"; + $type = 'Kein Typ angegeben'; } return sprintf( @@ -54,7 +69,6 @@ public function onGenerateLabel(array $row): string ); } - public function renderFooter(DataContainer $dc) { // add setupExplanation @@ -62,7 +76,7 @@ public function renderFooter(DataContainer $dc) } /** - * Gets the setup explanation + * Gets the setup explanation. * * @param Contao\DataContainer $dc * @@ -72,6 +86,7 @@ public function setupExplanation(DataContainer $dc) { $template = new BackendTemplate($this->strTemplate); $template->version = self::VERSION; + return $template->parse(); } } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index eb1717f..d5bd602 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -1,5 +1,23 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; @@ -14,7 +32,7 @@ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('pdir_socialfeed'); - if (\method_exists($treeBuilder, 'getRootNode')) { + if (method_exists($treeBuilder, 'getRootNode')) { $rootNode = $treeBuilder->getRootNode(); } else { // Backwards compatibility @@ -24,7 +42,8 @@ public function getConfigTreeBuilder() $rootNode ->children() ->integerNode('cache_ttl')->defaultValue(3600)->end() - ->end(); + ->end() + ; return $treeBuilder; } diff --git a/src/DependencyInjection/PdirSocialFeedExtension.php b/src/DependencyInjection/PdirSocialFeedExtension.php index 84beed7..26a9fc0 100644 --- a/src/DependencyInjection/PdirSocialFeedExtension.php +++ b/src/DependencyInjection/PdirSocialFeedExtension.php @@ -1,5 +1,23 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\DependencyInjection; use Pdir\SocialFeedBundle\Importer\InstagramRequestCache; @@ -13,7 +31,7 @@ class PdirSocialFeedExtension extends ConfigurableExtension /** * {@inheritdoc} */ - protected function loadInternal(array $mergedConfig, ContainerBuilder $container) + protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void { $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); diff --git a/src/EventListener/CronListener.php b/src/EventListener/CronListener.php index 52a41a5..25ff46b 100644 --- a/src/EventListener/CronListener.php +++ b/src/EventListener/CronListener.php @@ -1,49 +1,82 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\EventListener; -use Pdir\SocialFeedBundle\Importer\Importer; -use Pdir\SocialFeedBundle\Model\SocialFeedModel as SocialFeedModel; use Abraham\TwitterOAuth\TwitterOAuth; +use Contao\Database; +use Contao\Dbafs; +use Contao\Email; +use Contao\File; +use Contao\Folder; +use Contao\NewsModel; +use Contao\System; +use Facebook\Exceptions\FacebookResponseException; +use Facebook\Exceptions\FacebookSDKException; +use Facebook\Facebook; use LinkedIn\Client; -use LinkedIn\AccessToken; -use LinkedIn\Scope; +use Pdir\SocialFeedBundle\Importer\Importer; +use Pdir\SocialFeedBundle\Model\SocialFeedModel; -class CronListener extends \System +class CronListener extends System { - public function createImageFolder($account) { + /** + * @throws \Exception + */ + public function createImageFolder($account) + { // Create Public Image Folder - $imgPath = "files/social-feed/".$account."/"; - if( !file_exists($imgPath) ) { - new \Folder($imgPath); - $file = new \File("files/social-feed/.public"); - $file->write(""); + $imgPath = 'files/social-feed/'.$account.'/'; + + if (!file_exists($imgPath)) { + new Folder($imgPath); + $file = new File('files/social-feed/.public'); + $file->write(''); $file->close(); } + return $imgPath; } - public function getInstagramPosts() { + public function getInstagramPosts(): void + { $objSocialFeed = SocialFeedModel::findBy('socialFeedType', 'Instagram'); - if(NULL === $objSocialFeed) - { + if (null === $objSocialFeed) { return; } foreach ($objSocialFeed as $obj) { - $cron = $obj->pdir_sf_fb_news_cronjob; $lastImport = $obj->pdir_sf_fb_news_last_import_date; $tstamp = time(); - if ($lastImport == "") $lastImport = 0; + + if ('' === $lastImport) { + $lastImport = 0; + } $interval = $tstamp - $lastImport; // set account name for log an import $accountName = $obj->instagram_account; - if (($interval >= $cron && $cron != "no_cronjob") || ($lastImport == 0 && $cron != "no_cronjob")) { - + if (($interval >= $cron && 'no_cronjob' !== $cron) || (0 === $lastImport && 'no_cronjob' !== $cron)) { $this->setLastImportDate($id = $obj->id); $objImporter = new Importer(); @@ -54,75 +87,78 @@ public function getInstagramPosts() { // get instagram posts for account $medias = $objImporter->getInstagramPosts($obj->psf_instagramAccessToken, $obj->id, $obj->number_posts); - if (!is_array($medias)) + if (!\is_array($medias)) { continue; + } $counter = 1; - foreach ($medias as $media) { - if($counter++ > $obj->number_posts) - { + foreach ($medias as $media) { + if ($counter++ > $obj->number_posts) { continue; } - $objNews = new \NewsModel(); + $objNews = new NewsModel(); - if (null !== $objNews->findBy("social_feed_id", $media['id'])) { + if (null !== $objNews->findBy('social_feed_id', $media['id'])) { continue; } $imgPath = $this->createImageFolder($obj->id); // save pictures - $picturePath = $imgPath . $media['id'] . '.jpg'; + $picturePath = $imgPath.$media['id'].'.jpg'; $this->savePostPictures($picturePath, $media); // Write in Database $message = $this->getPostMessage($media['caption']); // add/fetch file from DBAFS - $objFile = \Dbafs::addResource($imgPath . $media['id'] . '.jpg'); + $objFile = Dbafs::addResource($imgPath.$media['id'].'.jpg'); $this->saveInstagramNews($objNews, $obj, $objFile, $message, $media); //, $account, $accountPicture); } - \System::log('Social Feed: Instagram Import Account ' . $accountName, __METHOD__, TL_GENERAL); + System::log('Social Feed: Instagram Import Account '.$accountName, __METHOD__, TL_GENERAL); $this->import('Automator'); $this->Automator->generateSymlinks(); } } } - public function getFbPosts() + public function getFbPosts(): void { $objSocialFeed = SocialFeedModel::findAll(); - if(NULL == $objSocialFeed) - { + if (null === $objSocialFeed) { return; } - foreach($objSocialFeed as $obj) { - if($obj->socialFeedType == "" || $obj->socialFeedType == "Facebook") { + foreach ($objSocialFeed as $obj) { + if ('' === $obj->socialFeedType || 'Facebook' === $obj->socialFeedType) { // Get Facebook Feed $cron = $obj->pdir_sf_fb_news_cronjob; $lastImport = $obj->pdir_sf_fb_news_last_import_date; $tstamp = time(); - if($lastImport == "") $lastImport = 0; + + if ('' === $lastImport) { + $lastImport = 0; + } $interval = $tstamp - $lastImport; - if( ($interval >= $cron && $cron != "no_cronjob") || ($lastImport == 0 && $cron != "no_cronjob") ) { + if (($interval >= $cron && 'no_cronjob' !== $cron) || (0 === $lastImport && 'no_cronjob' !== $cron)) { $this->setLastImportDate($id = $obj->id); $appId = $obj->pdir_sf_fb_app_id; $appSecret = $obj->pdir_sf_fb_app_secret; $accessToken = $obj->pdir_sf_fb_access_token; $account = $obj->pdir_sf_fb_account; - $fb = new \Facebook\Facebook([ + $fb = new Facebook([ 'app_id' => $appId, 'app_secret' => $appSecret, 'default_graph_version' => 'v2.10', ]); - if($obj->pdir_sf_fb_posts == 1) { + + if (1 === $obj->pdir_sf_fb_posts) { $response = $this->getFbPostList($fb, $accessToken, $account); } else { $response = $this->getFbFeed($fb, $accessToken, $account); @@ -135,53 +171,57 @@ public function getFbPosts() $accountId = $responsePage->getDecodedBody()['id']; $imageSrc = $responsePage->getDecodedBody()['picture']['data']['url']; $strImage = file_get_contents($imageSrc); - $file = new \File($imgPath . $accountId . '.jpg'); + $file = new File($imgPath.$accountId.'.jpg'); $file->write($strImage); $file->close(); // Write in Database - foreach($response->getDecodedBody()['data'] as $post) { + foreach ($response->getDecodedBody()['data'] as $post) { $objNews = new \NewsModel(); - if (null !== $objNews->findBy("social_feed_id", $post['id']) ) { + + if (null !== $objNews->findBy('social_feed_id', $post['id'])) { continue; } - if($post['from']['name'] != "") { + + if ('' !== $post['from']['name']) { $image = $this->getFbAttachments($fb, $id = $post['id'], $accessToken, $imgPath); $imageSrc = $image['src']; $imageTitle = $image['title']; // set variables - if(strpos($post['message'],"\n")) { - $title = mb_substr($post['message'],0,strpos($post['message'],"\n")); - } else if($post['message'] == "") { - $title = "Kein Titel"; + if (strpos($post['message'], "\n")) { + $title = mb_substr($post['message'], 0, strpos($post['message'], "\n")); + } elseif ('' === $post['message']) { + $title = 'Kein Titel'; } else { - $title = mb_substr($post['message'],0); + $title = mb_substr($post['message'], 0); } $message = $this->getPostMessage($messageText = $post['message']); - $message = str_replace("\n","
",$message); + $message = str_replace("\n", '
', $message); $timestamp = strtotime($post['created_time']); - if($imageSrc != "") { - $img = $imgPath . $post['id'] . ".jpg"; + + if ('' !== $imageSrc) { + $img = $imgPath.$post['id'].'.jpg'; } - $accountImg = $imgPath . $accountId . ".jpg"; + $accountImg = $imgPath.$accountId.'.jpg'; // add/fetch file from DBAFS - if( !is_null($img) ) { - $objFile = \Dbafs::addResource($img); - $objFileAccount = \Dbafs::addResource($accountImg); + if (null !== $img) { + $objFile = Dbafs::addResource($img); + $objFileAccount = Dbafs::addResource($accountImg); } // create new news $objNews = new \NewsModel(); // set data $objNews->pid = $obj->pdir_sf_fb_news_archive; - if($imageSrc != "") { + + if ('' !== $imageSrc) { $objNews->singleSRC = $objFile->uuid; $objNews->addImage = 1; } $objNews->tstamp = time(); - $objNews->headline = mb_substr($title,0,255); + $objNews->headline = mb_substr($title, 0, 255); - if($message == "" && $imageTitle != "") { + if ('' === $message && '' !== $imageTitle) { $objNews->teaser = $imageTitle; } else { $objNews->teaser = $message; @@ -200,7 +240,7 @@ public function getFbPosts() $objNews->save(); } } - \System::log('Social Feed: Facebook Import Account '.$account, __METHOD__, TL_GENERAL); + System::log('Social Feed: Facebook Import Account '.$account, __METHOD__, TL_GENERAL); $this->import('Automator'); $this->Automator->generateSymlinks(); } @@ -208,98 +248,26 @@ public function getFbPosts() } } - private function getFbPostList($fb, $accessToken, $account) { - try { - $response = $fb->get( - $account.'/posts?access_token='.$accessToken.'&fields=id,from,created_time,message,permalink_url' - ); - return $response; - } catch(Facebook\Exceptions\FacebookResponseException $e) { - echo 'Graph returned an error: ' . $e->getMessage(); - exit; - } catch(Facebook\Exceptions\FacebookSDKException $e) { - echo 'Facebook SDK returned an error: ' . $e->getMessage(); - exit; - } - } - - private function getFbFeed($fb, $accessToken, $account) { - try { - $response = $fb->get( - $account.'/feed?access_token='.$accessToken.'&fields=id,from,created_time,message,permalink_url' - ); - return $response; - } catch(Facebook\Exceptions\FacebookResponseException $e) { - echo 'Graph returned an error: ' . $e->getMessage(); - exit; - } catch(Facebook\Exceptions\FacebookSDKException $e) { - echo 'Facebook SDK returned an error: ' . $e->getMessage(); - exit; - } - } - - private function getFbAttachments($fb,$id,$accessToken, $imgPath) { - try { - $resMedia = $fb->get('/'. $id .'/attachments', $accessToken); - $imageSrc = ""; - if($resMedia->getDecodedBody()['data']['0']['subattachments']['data']['0']['media']) { - $arrMedia = $resMedia->getDecodedBody()['data']['0']['subattachments']['data']['0']; - } else if($resMedia->getDecodedBody()['data']['0']['media']) { - $arrMedia = $resMedia->getDecodedBody()['data']['0']; - } - if(is_array($arrMedia)) { - $imageSrc = $arrMedia['media']['image']['src']; - $strImage = file_get_contents($imageSrc); - $file = new \File($imgPath . $id . '.jpg'); - $file->write($strImage); - $file->close(); - } - $image = [ - 'src' => $arrMedia['media']['image']['src'], - 'title' => $arrMedia['title'] - ]; - return $image; - } catch(Facebook\Exceptions\FacebookResponseException $e) { - echo 'Graph returned an error: ' . $e->getMessage(); - exit; - } catch(Facebook\Exceptions\FacebookSDKException $e) { - echo 'Facebook SDK returned an error: ' . $e->getMessage(); - exit; - } - } - - private function getFbAccountPicture($fb, $accessToken, $account) { - try { - $responsePage = $fb->get( - $account.'?access_token='.$accessToken.'&fields=picture' - ); - return $responsePage; - } catch(Facebook\Exceptions\FacebookResponseException $e) { - echo 'Graph returned an error: ' . $e->getMessage(); - exit; - } catch(Facebook\Exceptions\FacebookSDKException $e) { - echo 'Facebook SDK returned an error: ' . $e->getMessage(); - exit; - } - } - - public function getLinkedinPosts() { + public function getLinkedinPosts(): void + { $objSocialFeed = SocialFeedModel::findAll(); - if(NULL === $objSocialFeed) - { + if (null === $objSocialFeed) { return; } - foreach($objSocialFeed as $obj) { - if($obj->socialFeedType == "LinkedIn") { + foreach ($objSocialFeed as $obj) { + if ('LinkedIn' === $obj->socialFeedType) { $cron = $obj->pdir_sf_fb_news_cronjob; $lastImport = $obj->pdir_sf_fb_news_last_import_date; $tstamp = time(); - if($lastImport == "") $lastImport = 0; + + if ('' === $lastImport) { + $lastImport = 0; + } $interval = $tstamp - $lastImport; - if( ($interval >= $cron && $cron != "no_cronjob") || ($lastImport == 0 && $cron != "no_cronjob") ) { + if (($interval >= $cron && 'no_cronjob' !== $cron) || (0 === $lastImport && 'no_cronjob' !== $cron)) { $this->setLastImportDate($id = $obj->id); $client = new Client( @@ -307,38 +275,38 @@ public function getLinkedinPosts() { $obj->linkedin_client_secret ); - $client->setAccessToken( $obj->linkedin_access_token); + $client->setAccessToken($obj->linkedin_access_token); $posts = $client->get( 'shares?q=owners&owners=urn:li:organization:'.$obj->linkedin_company_id.'&sharesPerOwner='.$obj->number_posts ); $organization = $client->get( - 'organizations/' . $obj->linkedin_company_id + 'organizations/'.$obj->linkedin_company_id ); - if (!is_array($posts['elements'])) + if (!\is_array($posts['elements'])) { continue; + } $counter = 1; - foreach ($posts['elements'] as $element) { - if($counter++ > $obj->number_posts) - { + foreach ($posts['elements'] as $element) { + if ($counter++ > $obj->number_posts) { continue; } - $objNews = new \NewsModel(); + $objNews = new NewsModel(); - if (null !== $objNews->findBy("social_feed_id", $element['id'])) { + if (null !== $objNews->findBy('social_feed_id', $element['id'])) { continue; } $imgPath = $this->createImageFolder($obj->linkedin_company_id); - $picturePath = $imgPath . $element['id'] . '.jpg'; + $picturePath = $imgPath.$element['id'].'.jpg'; if (!file_exists($picturePath)) { - $file = new \File($picturePath); + $file = new File($picturePath); $file->write(file_get_contents($element['content']['contentEntities'][0]['thumbnails'][0]['resolvedUrl'])); $file->close(); } @@ -346,40 +314,42 @@ public function getLinkedinPosts() { $message = $this->getPostMessage($element['text']['text']); // add/fetch file from DBAFS - $objFile = \Dbafs::addResource($imgPath . $element['id'] . '.jpg'); + $objFile = Dbafs::addResource($imgPath.$element['id'].'.jpg'); $this->saveLinkedInNews($objNews, $obj, $objFile, $message, $element, $organization); } - \System::log('Social Feed: LinkedIn Import Account ', __METHOD__, TL_GENERAL); + System::log('Social Feed: LinkedIn Import Account ', __METHOD__, TL_GENERAL); $this->import('Automator'); $this->Automator->generateSymlinks(); } - \System::log('Social Feed: LinkedIn Import ', __METHOD__, TL_GENERAL); + System::log('Social Feed: LinkedIn Import ', __METHOD__, TL_GENERAL); $this->import('Automator'); $this->Automator->generateSymlinks(); } } } - public function getTwitterPosts() { + public function getTwitterPosts(): void + { $objSocialFeed = SocialFeedModel::findAll(); - if(NULL === $objSocialFeed) - { + if (null === $objSocialFeed) { return; } - foreach($objSocialFeed as $obj) { - - if($obj->socialFeedType == "Twitter") { + foreach ($objSocialFeed as $obj) { + if ('Twitter' === $obj->socialFeedType) { $cron = $obj->pdir_sf_fb_news_cronjob; $lastImport = $obj->pdir_sf_fb_news_last_import_date; $tstamp = time(); - if($lastImport == "") $lastImport = 0; + + if ('' === $lastImport) { + $lastImport = 0; + } $interval = $tstamp - $lastImport; - if( ($interval >= $cron && $cron != "no_cronjob") || ($lastImport == 0 && $cron != "no_cronjob") ) { + if (($interval >= $cron && 'no_cronjob' !== $cron) || (0 === $lastImport && 'no_cronjob' !== $cron)) { $this->setLastImportDate($id = $obj->id); $api_key = $obj->twitter_api_key; @@ -393,64 +363,66 @@ public function getTwitterPosts() { $posts = []; - if($accountName != "" && $search == "") { + if ('' !== $accountName && '' === $search) { $posts = $connection->get('statuses/user_timeline', ['screen_name' => $accountName, 'tweet_mode' => 'extended', 'count' => $obj->number_posts]); - } else if($search != "" && $accountName != "") { - $posts = $connection->get("search/tweets", ["q" => $accountName, 'tweet_mode' => 'extended', 'count' => $obj->number_posts])->statuses; - } else if($search != "") { - $posts = $connection->get("search/tweets", ["q" => $search, 'tweet_mode' => 'extended', 'count' => $obj->number_posts])->statuses; + } elseif ('' !== $search && '' !== $accountName) { + $posts = $connection->get('search/tweets', ['q' => $accountName, 'tweet_mode' => 'extended', 'count' => $obj->number_posts])->statuses; + } elseif ('' !== $search) { + $posts = $connection->get('search/tweets', ['q' => $search, 'tweet_mode' => 'extended', 'count' => $obj->number_posts])->statuses; } - foreach($posts as $post) { - - if(!$post) { + foreach ($posts as $post) { + if (!$post) { continue; } - if($search != "" && $accountName != "" && strpos($post->full_text, $search)===false) { // remove unwanted tweets + if ('' !== $search && '' !== $accountName && false === strpos($post->full_text, $search)) { // remove unwanted tweets continue; } - if($post->retweeted_status && $obj->show_retweets != 1) { + if ($post->retweeted_status && 1 !== $obj->show_retweets) { continue; } - echo $post->in_reply_to_status_id."
"; - if($post->in_reply_to_status_id != "" && $obj->show_reply != 1) { + echo $post->in_reply_to_status_id.'
'; + + if ('' !== $post->in_reply_to_status_id && 1 !== $obj->show_reply) { continue; } - if($post->retweeted_status && $obj->show_retweets == 1) { - $post->full_text = "RT @".$post->entities->user_mentions[0]->screen_name.": ".$post->retweeted_status->full_text; + if ($post->retweeted_status && 1 === $obj->show_retweets) { + $post->full_text = 'RT @'.$post->entities->user_mentions[0]->screen_name.': '.$post->retweeted_status->full_text; } - $objNews = new \NewsModel(); + $objNews = new NewsModel(); - if (null !== $objNews->findBy("social_feed_id", $post->id)) { + if (null !== $objNews->findBy('social_feed_id', $post->id)) { continue; } $imgPath = $this->createImageFolder($accountName); // save account picture - $accountPicture = $imgPath . $post->user->id . '.jpg'; + $accountPicture = $imgPath.$post->user->id.'.jpg'; + if (!file_exists($accountPicture)) { $strImage = file_get_contents($post->user->profile_image_url_https); - $file = new \File($accountPicture); + $file = new File($accountPicture); $file->write($strImage); $file->close(); } // save post picture - if($post->entities->media[0]->media_url_https) { - $picturePath = $imgPath . $post->id . '.jpg'; + if ($post->entities->media[0]->media_url_https) { + $picturePath = $imgPath.$post->id.'.jpg'; + if (!file_exists($picturePath)) { $strImage = file_get_contents($post->entities->media[0]->media_url_https); - $file = new \File($picturePath); + $file = new File($picturePath); $file->write($strImage); $file->close(); } - $objFile = \Dbafs::addResource($imgPath . $post->id . '.jpg'); + $objFile = Dbafs::addResource($imgPath.$post->id.'.jpg'); $objNews->singleSRC = $objFile->uuid; $objNews->addImage = 1; } @@ -458,12 +430,16 @@ public function getTwitterPosts() { // write in database $objNews->pid = $obj->pdir_sf_fb_news_archive; $objNews->tstamp = time(); - if (strlen($post->full_text) > 50) $more = " ..."; - else $more = ""; - $objNews->headline = mb_substr($post->full_text, 0, 50) . $more; - if($obj->hashtags_link == 1) { - if($post->retweeted_status && $obj->show_retweets == 1) { + if (\strlen($post->full_text) > 50) { + $more = ' ...'; + } else { + $more = ''; + } + $objNews->headline = mb_substr($post->full_text, 0, 50).$more; + + if (1 === $obj->hashtags_link) { + if ($post->retweeted_status && 1 === $obj->show_retweets) { $post->entities->hashtags = $post->retweeted_status->entities->hashtags; $post->entities->user_mentions = $post->retweeted_status->entities->user_mentions; } @@ -478,24 +454,24 @@ public function getTwitterPosts() { $post->full_text = $this->replaceMentions($post->full_text); } - $objNews->teaser = str_replace("\n", "
", $post->full_text); + $objNews->teaser = str_replace("\n", '
', $post->full_text); $objNews->date = strtotime($post->created_at); $objNews->time = strtotime($post->created_at); $objNews->published = 1; $objNews->social_feed_type = $obj->socialFeedType; $objNews->social_feed_id = $post->id; $objNews->social_feed_account = $post->user->name; - $objNews->social_feed_account_picture = \Dbafs::addResource($accountPicture)->uuid; + $objNews->social_feed_account_picture = Dbafs::addResource($accountPicture)->uuid; $objNews->source = 'external'; - $url = "https://twitter.com/".$post->user->screen_name."/status/".$post->id; + $url = 'https://twitter.com/'.$post->user->screen_name.'/status/'.$post->id; $objNews->url = $url; $objNews->target = 1; $objNews->save(); } - \System::log('Social Feed: Twitter Import Account '.$accountName, __METHOD__, TL_GENERAL); + System::log('Social Feed: Twitter Import Account '.$accountName, __METHOD__, TL_GENERAL); $this->import('Automator'); $this->Automator->generateSymlinks(); } @@ -503,51 +479,184 @@ public function getTwitterPosts() { } } - private function getPostMessage($messageText) { + public function refreshLinkedInAccessToken(): void + { + $objSocialFeed = SocialFeedModel::findAll(); + + if (null === $objSocialFeed) { + return; + } + + foreach ($objSocialFeed as $obj) { + if ('LinkedIn' === $obj->socialFeedType && '' !== $obj->linkedin_access_token && '' !== $obj->linkedin_refresh_token) { + if ($obj->linkedin_refresh_token_expires <= strtotime('+1 week', time())) { + $objMail = new Email(); + $objMail->subject = 'LinkedIn Access Token Erinnerung'; + $objMail->html = 'Hallo Admin,

Der LinkedIn Access Token auf der Webseite '.$this->Environment->httpHost.' für den Account '.$obj->linkedin_company_id.' muss neu generiert werden. Melde dich dafür im Contao Backend an, rufe die Einstellungen des Social Feed Accounts auf, wähle die Checkbox "Generiere Access Token" aus und speichere. Anschließend musst du nur noch der App den Zugriff erlauben und der Access Token wird neu generiert. Dieser Vorgang muss jedes Jahr wiederholt werden.'; + $objMail->from = $GLOBALS['TL_CONFIG']['adminEmail']; + $objMail->fromName = $this->Environment->httpHost; + $objMail->sendTo($GLOBALS['TL_CONFIG']['adminEmail']); + } + + if ($obj->access_token_expires <= strtotime('+1 week', time())) { + $data = [ + 'grant_type' => 'refresh_token', + 'refresh_token' => $obj->linkedin_refresh_token, + 'client_id' => $obj->linkedin_client_id, + 'client_secret' => $obj->linkedin_client_secret, + ]; + + try { + $token = json_decode(file_get_contents('https://www.linkedin.com/oauth/v2/accessToken?'.http_build_query($data))); + + // Store the access token + $db = Database::getInstance(); + $set = ['linkedin_access_token' => $token->access_token, 'access_token_expires' => time() + $token->expires_in, 'linkedin_refresh_token' => $token->refresh_token, 'linkedin_refresh_token_expires' => time() + $token->refresh_token_expires_in]; + $db->prepare('UPDATE tl_social_feed %s WHERE id = ?')->set($set)->execute($obj->id); + } catch (Exception $e) { + System::log($e->getMessage(), __METHOD__, TL_GENERAL); + } + } + } + } + } + + private function getFbPostList($fb, $accessToken, $account) + { + try { + return $fb->get( + $account.'/posts?access_token='.$accessToken.'&fields=id,from,created_time,message,permalink_url' + ); + } catch (FacebookResponseException $e) { + echo 'Graph returned an error: '.$e->getMessage(); + exit; + } catch (FacebookSDKException $e) { + echo 'Facebook SDK returned an error: '.$e->getMessage(); + exit; + } + } + + private function getFbFeed($fb, $accessToken, $account) + { + try { + return $fb->get( + $account.'/feed?access_token='.$accessToken.'&fields=id,from,created_time,message,permalink_url' + ); + } catch (FacebookResponseException $e) { + echo 'Graph returned an error: '.$e->getMessage(); + exit; + } catch (FacebookSDKException $e) { + echo 'Facebook SDK returned an error: '.$e->getMessage(); + exit; + } + } + + private function getFbAttachments($fb, $id, $accessToken, $imgPath) + { + try { + $resMedia = $fb->get('/'.$id.'/attachments', $accessToken); + $imageSrc = ''; + + if ($resMedia->getDecodedBody()['data']['0']['subattachments']['data']['0']['media']) { + $arrMedia = $resMedia->getDecodedBody()['data']['0']['subattachments']['data']['0']; + } elseif ($resMedia->getDecodedBody()['data']['0']['media']) { + $arrMedia = $resMedia->getDecodedBody()['data']['0']; + } + + if (\is_array($arrMedia)) { + $imageSrc = $arrMedia['media']['image']['src']; + $strImage = file_get_contents($imageSrc); + $file = new File($imgPath.$id.'.jpg'); + $file->write($strImage); + $file->close(); + } + + return [ + 'src' => $arrMedia['media']['image']['src'], + 'title' => $arrMedia['title'], + ]; + } catch (FacebookResponseException $e) { + echo 'Graph returned an error: '.$e->getMessage(); + exit; + } catch (FacebookSDKException $e) { + echo 'Facebook SDK returned an error: '.$e->getMessage(); + exit; + } + } + + private function getFbAccountPicture($fb, $accessToken, $account) + { + try { + return $fb->get( + $account.'?access_token='.$accessToken.'&fields=picture' + ); + } catch (FacebookResponseException $e) { + echo 'Graph returned an error: '.$e->getMessage(); + exit; + } catch (FacebookSDKException $e) { + echo 'Facebook SDK returned an error: '.$e->getMessage(); + exit; + } + } + + private function getPostMessage($messageText) + { if (version_compare(VERSION, '4.5', '<')) { //reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ? - $message = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' . - '|[\x00-\x7F][\x80-\xBF]+' . - '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' . - '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' . + $message = preg_replace( + '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. + '|[\x00-\x7F][\x80-\xBF]+'. + '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. + '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', - '', $messageText); + '', + $messageText + ); } else { $message = $messageText; } + return $message; } - private function setLastImportDate($id) { + private function setLastImportDate($id): void + { $this->import('Database'); - $this->Database->prepare("UPDATE tl_social_feed SET pdir_sf_fb_news_last_import_date = ".time().", pdir_sf_fb_news_last_import_time = ".time()." WHERE id=?")->execute($id); + $this->Database->prepare('UPDATE tl_social_feed SET pdir_sf_fb_news_last_import_date = '.time().', pdir_sf_fb_news_last_import_time = '.time().' WHERE id=?')->execute($id); } - private function saveAccountPicture($accountPicture, $account) { + /** + * @throws \Exception + */ + private function saveAccountPicture($accountPicture, $account): void + { if (!file_exists($accountPicture)) { $strImage = file_get_contents($account->getProfilePicUrl()); - $file = new \File($accountPicture); + $file = new File($accountPicture); $file->write($strImage); $file->close(); } } - private function saveInstagramNews($objNews, $obj, $objFile, $message, $media, $account = '', $accountPicture = '') { + private function saveInstagramNews($objNews, $obj, $objFile, $message, $media, $account = '', $accountPicture = ''): void + { $objNews->pid = $obj->pdir_sf_fb_news_archive; $objNews->singleSRC = $objFile->uuid; $objNews->addImage = 1; $objNews->tstamp = time(); - if('' == $message) - { + if ('' === $message) { $message = $media['id']; } - if (strlen($message) > 50) $more = " ..."; - else $more = ""; - $objNews->headline = mb_substr($message, 0, 50) . $more; + if (\strlen($message) > 50) { + $more = ' ...'; + } else { + $more = ''; + } + $objNews->headline = mb_substr($message, 0, 50).$more; - $message = str_replace("\n", "
", $message); + $message = str_replace("\n", '
', $message); $objNews->teaser = $message; $objNews->date = strtotime($media['timestamp']); $objNews->time = strtotime($media['timestamp']); @@ -555,25 +664,29 @@ private function saveInstagramNews($objNews, $obj, $objFile, $message, $media, $ $objNews->social_feed_type = $obj->socialFeedType; $objNews->social_feed_id = $media['id']; $objNews->social_feed_config = $obj->id; - #$objNews->social_feed_account = $account; - #$objNews->social_feed_account_picture = \Dbafs::addResource($accountPicture)->uuid; + //$objNews->social_feed_account = $account; + //$objNews->social_feed_account_picture = Dbafs::addResource($accountPicture)->uuid; $objNews->source = 'external'; $objNews->url = $media['permalink']; $objNews->target = 1; $objNews->save(); } - private function saveLinkedInNews($objNews, $obj, $objFile, $message, $element, $organization) { + private function saveLinkedInNews($objNews, $obj, $objFile, $message, $element, $organization): void + { $objNews->pid = $obj->pdir_sf_fb_news_archive; $objNews->singleSRC = $objFile->uuid; $objNews->addImage = 1; $objNews->tstamp = time(); - if (strlen($message) > 50) $more = " ..."; - else $more = ""; - $objNews->headline = mb_substr($message, 0, 50) . $more; + if (\strlen($message) > 50) { + $more = ' ...'; + } else { + $more = ''; + } + $objNews->headline = mb_substr($message, 0, 50).$more; - $message = str_replace("\n", "
", $message); + $message = str_replace("\n", '
', $message); $objNews->teaser = $message; $objNews->date = $element['created']['time'] / 1000; $objNews->time = $element['created']['time'] / 1000; @@ -582,23 +695,28 @@ private function saveLinkedInNews($objNews, $obj, $objFile, $message, $element, $objNews->social_feed_id = $element['id']; $objNews->social_feed_config = $obj->id; $objNews->social_feed_account = $organization['localizedName']; - #$objNews->social_feed_account_picture = \Dbafs::addResource($accountPicture)->uuid; + //$objNews->social_feed_account_picture = Dbafs::addResource($accountPicture)->uuid; $objNews->source = 'external'; $objNews->url = 'https://www.linkedin.com/feed/update/'.$element['activity']; $objNews->target = 1; $objNews->save(); } - private function savePostPictures($picturePath, $media) { + /** + * @throws \Exception + */ + private function savePostPictures($picturePath, $media): void + { if (!file_exists($picturePath)) { - $strImage = file_get_contents(strpos($media['media_url'],"jpg")!==false ? $media['media_url'] : $media['thumbnail_url']); - $file = new \File($picturePath); + $strImage = file_get_contents(false !== strpos($media['media_url'], 'jpg') ? $media['media_url'] : $media['thumbnail_url']); + $file = new File($picturePath); $file->write($strImage); $file->close(); } } - private function replaceHashTags($str) { + private function replaceHashTags($str) + { return preg_replace( '/(\#)([^\s]+)/', '#$2', @@ -606,57 +724,17 @@ private function replaceHashTags($str) { ); } - public function refreshLinkedInAccessToken() { - $objSocialFeed = SocialFeedModel::findAll(); - - if(NULL === $objSocialFeed) - { - return; - } - - foreach($objSocialFeed as $obj) { - - if ($obj->socialFeedType == "LinkedIn" && $obj->linkedin_access_token != "" && $obj->linkedin_refresh_token != "") { - if($obj->linkedin_refresh_token_expires <= strtotime("+1 week", time())) { - $objMail = new \Email(); - $objMail->subject = 'LinkedIn Access Token Erinnerung'; - $objMail->html = 'Hallo Admin,

Der LinkedIn Access Token auf der Webseite '.$this->Environment->httpHost.' für den Account '.$obj->linkedin_company_id.' muss neu generiert werden. Melde dich dafür im Contao Backend an, rufe die Einstellungen des Social Feed Accounts auf, wähle die Checkbox "Generiere Access Token" aus und speichere. Anschließend musst du nur noch der App den Zugriff erlauben und der Access Token wird neu generiert. Dieser Vorgang muss jedes Jahr wiederholt werden.'; - $objMail->from = $GLOBALS['TL_CONFIG']['adminEmail']; - $objMail->fromName = $this->Environment->httpHost; - $objMail->sendTo($GLOBALS['TL_CONFIG']['adminEmail']); - } - - if($obj->access_token_expires <= strtotime("+1 week", time())) { - $data = [ - 'grant_type' => 'refresh_token', - 'refresh_token' => $obj->linkedin_refresh_token, - 'client_id' => $obj->linkedin_client_id, - 'client_secret' => $obj->linkedin_client_secret - ]; - - try { - $token = json_decode(file_get_contents('https://www.linkedin.com/oauth/v2/accessToken?'.http_build_query($data))); - - // Store the access token - $db = \Contao\Database::getInstance(); - $set = ['linkedin_access_token' => $token->access_token, 'access_token_expires' => time() + $token->expires_in, 'linkedin_refresh_token' => $token->refresh_token, 'linkedin_refresh_token_expires' => time() + $token->refresh_token_expires_in]; - $db->prepare('UPDATE tl_social_feed %s WHERE id = ?')->set($set)->execute($obj->id); - } catch(Exception $e) { - \System::log($e->getMessage(), __METHOD__, TL_GENERAL); - } - } - } - } - } - - private function removeTwitterLinks($str) { - return preg_replace('/\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', + private function removeTwitterLinks($str) + { + return preg_replace( + '/\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $str ); } - private function replaceLinks($str) { + private function replaceLinks($str) + { return preg_replace( '/(^|[\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is', '$3', @@ -664,7 +742,8 @@ private function replaceLinks($str) { ); } - private function replaceMentions($str) { + private function replaceMentions($str) + { return preg_replace( '/@(\w+)/', '@$1', diff --git a/src/EventListener/SocialFeedListener.php b/src/EventListener/SocialFeedListener.php index 7eda63d..b65a6c9 100644 --- a/src/EventListener/SocialFeedListener.php +++ b/src/EventListener/SocialFeedListener.php @@ -1,5 +1,23 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\EventListener; use Contao\CoreBundle\Exception\RedirectResponseException; @@ -9,10 +27,9 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Routing\RouterInterface; - class SocialFeedListener { - const SESSION_KEY = 'social-feed-id'; + public const SESSION_KEY = 'social-feed-id'; /** * @var RouterInterface @@ -36,7 +53,7 @@ public function __construct(RouterInterface $router, SessionInterface $session) /** * On submit callback. */ - public function onSubmitCallback(DataContainer $dc) + public function onSubmitCallback(DataContainer $dc): void { if ('Instagram' === $dc->activeRecord->socialFeedType && $dc->activeRecord->psf_instagramAppId && Input::post('psf_instagramRequestToken')) { $this->requestAccessToken($dc->activeRecord->psf_instagramAppId); @@ -53,8 +70,6 @@ public function onSubmitCallback(DataContainer $dc) /** * On the request token save. - * - * @return null */ public function onRequestTokenSave() { @@ -66,7 +81,7 @@ public function onRequestTokenSave() * * @param string $clientId */ - private function requestAccessToken($clientId) + private function requestAccessToken($clientId): void { $this->session->set(self::SESSION_KEY, [ 'socialFeedId' => Input::get('id'), @@ -88,16 +103,16 @@ private function requestAccessToken($clientId) /** * Request the Facebook access token. * - * @param string $clientId + * @param string $appId */ - private function requestFbAccessToken($appId, $appSecret, $page) + private function requestFbAccessToken($appId, $appSecret, $page): void { $this->session->set(self::SESSION_KEY, [ 'socialFeedId' => Input::get('id'), 'backUrl' => Environment::get('uri'), 'clientId' => $appId, 'clientSecret' => $appSecret, - 'page' => $page + 'page' => $page, ]); $this->session->save(); @@ -105,7 +120,7 @@ private function requestFbAccessToken($appId, $appSecret, $page) $data = [ 'client_id' => $appId, 'redirect_uri' => $this->router->generate('facebook_auth', [], RouterInterface::ABSOLUTE_URL), - 'scope' => 'pages_read_engagement' + 'scope' => 'pages_read_engagement', ]; throw new RedirectResponseException('https://www.facebook.com/v11.0/dialog/oauth?'.http_build_query($data)); @@ -117,13 +132,13 @@ private function requestFbAccessToken($appId, $appSecret, $page) * @param string $clientId * @param string $clientSecret */ - private function requestLinkedinAccessToken($clientId, $clientSecret) + private function requestLinkedinAccessToken($clientId, $clientSecret): void { $this->session->set(self::SESSION_KEY, [ 'socialFeedId' => Input::get('id'), 'backUrl' => Environment::get('uri'), 'clientId' => $clientId, - 'clientSecret' => $clientSecret + 'clientSecret' => $clientSecret, ]); $this->session->save(); @@ -132,7 +147,7 @@ private function requestLinkedinAccessToken($clientId, $clientSecret) 'response_type' => 'code', 'client_id' => $clientId, 'redirect_uri' => $this->router->generate('auth_linkedin', [], RouterInterface::ABSOLUTE_URL), - 'scope' => 'r_organization_social,rw_organization_admin' + 'scope' => 'r_organization_social,rw_organization_admin', ]; throw new RedirectResponseException('https://www.linkedin.com/oauth/v2/authorization?'.http_build_query($data)); diff --git a/src/Importer/Importer.php b/src/Importer/Importer.php index 731815e..13e60d8 100644 --- a/src/Importer/Importer.php +++ b/src/Importer/Importer.php @@ -1,11 +1,27 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\Importer; use Contao\Date; -use Contao\CoreBundle\Exception\ResponseException; use Contao\System; -use Pdir\SocialFeedBundle\Importer\InstagramClient; use Pdir\SocialFeedBundle\Model\SocialFeedModel; class Importer @@ -23,13 +39,15 @@ class Importer /** * Collect data from the instagram api and return array. * - * @return void | array * @throws \RuntimeException + * + * @return void|array */ public function getInstagramPosts($accessToken, $socialFeedId, $numberPosts) { - if ('' === $accessToken) + if ('' === $accessToken) { return 'no access token given'; + } $client = System::getContainer()->get(InstagramClient::class); $items = $client->getMediaData($accessToken, (int) $socialFeedId, (int) $numberPosts); @@ -37,42 +55,37 @@ public function getInstagramPosts($accessToken, $socialFeedId, $numberPosts) return $items['data']; } - /** - * - */ - public function getAccountImage() { + public function getAccountImage() + { return $this->accountImage; } /** * Collect data from the instagram api and return array. * - * @return void | array + * @return void|array */ public function getInstagramAccount($accessToken, $socialFeedId) { - $client = System::getContainer()->get(InstagramClient::class); - $username = $client->getUserData($accessToken, (int) $socialFeedId); - return $username; + return $client->getUserData($accessToken, (int) $socialFeedId); } /** * Collect data from the instagram api and return array. * - * @return void | array + * @return void|array */ public function getInstagramAccountImage($accessToken, $socialFeedId) { $client = System::getContainer()->get(InstagramClient::class); - $image = $client->getUserImage($accessToken, (int) $socialFeedId, false); - return $image; + return $client->getUserImage($accessToken, (int) $socialFeedId, false); } - public function moderation($items) { - + public function moderation($items) + { $listItems = []; foreach ($items as $item) { @@ -80,7 +93,7 @@ public function moderation($items) { 'id' => $item['id'], 'title' => $item['caption'], 'time' => Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], strtotime($item['timestamp'])), - 'image' => strpos($item['media_url'],"jpg")!==false ? $item['media_url'] : $item['thumbnail_url'], + 'image' => false !== strpos($item['media_url'], 'jpg') ? $item['media_url'] : $item['thumbnail_url'], 'link' => $item['permalink'], ]; } @@ -88,25 +101,26 @@ public function moderation($items) { return $listItems; } - function getPostsByAccount($id, $numberPosts) { - + public function getPostsByAccount($id, $numberPosts) + { $objSocialFeed = SocialFeedModel::findBy('id', $id); - if (NULL === $objSocialFeed) { + if (null === $objSocialFeed) { return; } switch ($objSocialFeed->socialFeedType) { - case "Facebook": + case 'Facebook': return 'Facebook is currently not supported.'; break; - case "Instagram": + + case 'Instagram': return $this->getInstagramPosts($objSocialFeed->psf_instagramAccessToken, $objSocialFeed->id, $numberPosts); break; - case "Twitter": + + case 'Twitter': return 'Twitter is currently not supported.'; break; } - } } diff --git a/src/Importer/InstagramClient.php b/src/Importer/InstagramClient.php index d34575c..05258cd 100644 --- a/src/Importer/InstagramClient.php +++ b/src/Importer/InstagramClient.php @@ -1,13 +1,28 @@ - * @author Kamil Kuzminski - * @license MIT + * The code of this class is based on the Instagram Bundle from Codefog + * @author Codefog + * @author Kamil Kuzminski + * @license MIT + * + * Copyright (c) 2021 pdir / digital agentur // pdir GmbH + * + * @package social-feed-bundle + * @link https://github.com/pdir/social-feed-bundle + * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @author Mathias Arzberger + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace Pdir\SocialFeedBundle\Importer; @@ -85,12 +100,12 @@ public function getData(string $url, array $query = [], int $socialFeedId = null $data = $json_data['data']; - if($query['limit'] > 100 && isset($json_data['paging']['next'])) { - $query['limit'] = $query['limit'] - 100; + if ($query['limit'] > 100 && isset($json_data['paging']['next'])) { + $query['limit'] -= 100; $json_data['paging']['next'] = str_replace('limit=100', 'limit='.$query['limit'], $json_data['paging']['next']); - parse_str(parse_url($json_data['paging']['next'], PHP_URL_QUERY),$query); + parse_str(parse_url($json_data['paging']['next'], PHP_URL_QUERY), $query); $next_page = $this->getData($url, $query, $socialFeedId, $cache); - $data = array_merge($data,$next_page['data']); + $data = array_merge($data, $next_page['data']); } return ['data' => $data]; @@ -104,7 +119,7 @@ public function getMediaData(string $accessToken, int $socialFeedId = null, int return $this->getData('https://graph.instagram.com/me/media', [ 'access_token' => $accessToken, 'fields' => 'id,caption,media_type,media_url,thumbnail_url,permalink,timestamp', - 'limit' => $numberPosts + 'limit' => $numberPosts, ], $socialFeedId, $cache); } @@ -115,7 +130,7 @@ public function getUserData(string $accessToken, int $socialFeedId = null, bool { return $this->getData('https://graph.instagram.com/me', [ 'access_token' => $accessToken, - 'fields' => 'id,username' + 'fields' => 'id,username', ], $socialFeedId, $cache); } @@ -124,7 +139,7 @@ public function getUserData(string $accessToken, int $socialFeedId = null, bool */ public function getUserImage(string $accessToken, int $socialFeedId = null, bool $cache = true): ?array { - # not supported by instagram + // not supported by instagram return $this->getData('https://graph.instagram.com/me/picture', [ 'access_token' => $accessToken, ], $socialFeedId, $cache); @@ -228,7 +243,7 @@ public function getAccessToken(string $appId, string $appSecret, string $code, s } /** - * Get the short lived access token + * Get the short lived access token. * * @return string */ @@ -266,7 +281,7 @@ private function getShortLivedAccessToken(string $appId, string $appSecret, stri } /** - * Get the long lived access token + * Get the long lived access token. * * @return string */ diff --git a/src/Importer/InstagramRequestCache.php b/src/Importer/InstagramRequestCache.php index 080f1d1..e929999 100644 --- a/src/Importer/InstagramRequestCache.php +++ b/src/Importer/InstagramRequestCache.php @@ -1,13 +1,28 @@ - * @author Kamil Kuzminski - * @license MIT + * The code of this class is based on the Instagram Bundle from Codefog + * @author Codefog + * @author Kamil Kuzminski + * @license MIT + * + * Copyright (c) 2021 pdir / digital agentur // pdir GmbH + * + * @package social-feed-bundle + * @link https://github.com/pdir/social-feed-bundle + * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @author Mathias Arzberger + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace Pdir\SocialFeedBundle\Importer; @@ -33,9 +48,6 @@ class InstagramRequestCache /** * InstagramRequestCache constructor. - * @param Filesystem $fs - * @param int $cacheTtl - * @param string $projectDir */ public function __construct(Filesystem $fs, int $cacheTtl, string $projectDir) { diff --git a/src/Importer/NewsImporter.php b/src/Importer/NewsImporter.php index c2626d1..e55c5da 100644 --- a/src/Importer/NewsImporter.php +++ b/src/Importer/NewsImporter.php @@ -1,32 +1,47 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\Importer; use Contao\Dbafs; use Contao\File; use Contao\FilesModel; use Contao\Folder; -use Contao\Input; use Contao\NewsModel; - class NewsImporter { - protected $arrNews; - public $accountImage; + protected $arrNews; public function __construct($arrNews) { $this->arrNews = $arrNews; } - public function execute($newsArchiveId, $socialFeedType, $socialFeedAccount) { - + public function execute($newsArchiveId, $socialFeedType, $socialFeedAccount): void + { $objNews = new NewsModel(); // check if news exists - if (null !== $objNews->findBy("social_feed_id", $this->arrNews['id'])) { + if (null !== $objNews->findBy('social_feed_id', $this->arrNews['id'])) { return; } @@ -46,10 +61,10 @@ public function execute($newsArchiveId, $socialFeedType, $socialFeedAccount) { // $objNews->social_feed_account_picture = $accountPictureUuid; // post images - if('VIDEO' == $this->arrNews['media_type'] || 'IMAGE' == $this->arrNews['media_type'] || 'CAROUSEL_ALBUM' == $this->arrNews['media_type']) { - $imgSrc = strpos($this->arrNews['media_url'],"jpg")!==false ? $this->arrNews['media_url'] : $this->arrNews['thumbnail_url']; + if ('VIDEO' === $this->arrNews['media_type'] || 'IMAGE' === $this->arrNews['media_type'] || 'CAROUSEL_ALBUM' === $this->arrNews['media_type']) { + $imgSrc = false !== strpos($this->arrNews['media_url'], 'jpg') ? $this->arrNews['media_url'] : $this->arrNews['thumbnail_url']; - $picturePath = $imgPath . $objNews->social_feed_id . '.jpg'; + $picturePath = $imgPath.$objNews->social_feed_id.'.jpg'; $pictureUuid = $this->saveImage($picturePath, $imgSrc); $objNews->addImage = 1; @@ -58,21 +73,20 @@ public function execute($newsArchiveId, $socialFeedType, $socialFeedAccount) { // message and teaser $message = $this->getPostMessage($this->arrNews['caption']); - $more = ""; - if (strlen($message) > 50) - { - $more = " ..."; + $more = ''; + + if (\strlen($message) > 50) { + $more = ' ...'; } - $objNews->headline = mb_substr($message, 0, 50) . $more; + $objNews->headline = mb_substr($message, 0, 50).$more; // set headline to id if headline is not set - if('' == $objNews->headline) - { + if ('' === $objNews->headline) { $objNews->headline = $this->arrNews['id']; } - $message = str_replace("\n", "
", $message); + $message = str_replace("\n", '
', $message); $objNews->teaser = $message; // date and time @@ -89,34 +103,43 @@ public function execute($newsArchiveId, $socialFeedType, $socialFeedAccount) { $objNews->save(); } - private function getPostMessage($messageText) { + public function createImageFolder($account) + { + // Create Public Image Folder + $imgPath = 'files/social-feed/'.$account.'/'; + + if (!file_exists($imgPath)) { + new Folder($imgPath); + $file = new File('files/social-feed/.public'); + $file->write(''); + $file->close(); + } + + return $imgPath; + } + + private function getPostMessage($messageText) + { if (version_compare(VERSION, '4.5', '<')) { //reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ? - $message = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' . - '|[\x00-\x7F][\x80-\xBF]+' . - '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' . - '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' . + $message = preg_replace( + '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. + '|[\x00-\x7F][\x80-\xBF]+'. + '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. + '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', - '', $messageText); + '', + $messageText + ); } else { $message = $messageText; } - return $message; - } - public function createImageFolder($account) { - // Create Public Image Folder - $imgPath = "files/social-feed/".$account."/"; - if( !file_exists($imgPath) ) { - new Folder($imgPath); - $file = new File("files/social-feed/.public"); - $file->write(""); - $file->close(); - } - return $imgPath; + return $message; } - private function saveImage($strPath, $strUrl) { + private function saveImage($strPath, $strUrl) + { if (!file_exists($strPath)) { $strImage = file_get_contents($strUrl); $file = new File($strPath); diff --git a/src/Model/SocialFeedModel.php b/src/Model/SocialFeedModel.php index 5c0fc54..904c999 100644 --- a/src/Model/SocialFeedModel.php +++ b/src/Model/SocialFeedModel.php @@ -1,5 +1,23 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\Model; use Contao\Model; @@ -7,4 +25,4 @@ class SocialFeedModel extends Model { protected static $strTable = 'tl_social_feed'; -} \ No newline at end of file +} diff --git a/src/Module/ModuleCustomNewslist.php b/src/Module/ModuleCustomNewslist.php index b67a5b4..f1ce51a 100644 --- a/src/Module/ModuleCustomNewslist.php +++ b/src/Module/ModuleCustomNewslist.php @@ -1,27 +1,47 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Pdir\SocialFeedBundle\Module; -use Contao\ModuleNewsList; use Contao\LayoutModel; +use Contao\ModuleNewsList; class ModuleCustomNewslist extends ModuleNewsList { /** - * Template + * Template. + * * @var string */ protected $strTemplate = 'mod_newslist'; - protected function compile() + protected function compile(): void { parent::compile(); $this->Template->sfMasonry = $this->pdir_sf_enableMasonry; - $this->Template->sfColumns = " ".$this->pdir_sf_columns; + $this->Template->sfColumns = ' '.$this->pdir_sf_columns; $layout = LayoutModel::findByPk($GLOBALS['objPage']->layout); - if( strpos($layout->scripts,"lazyload") ) { + + if (strpos($layout->scripts, 'lazyload')) { $this->Template->lazyload = true; } else { $this->Template->lazyload = false; diff --git a/src/PdirSocialFeedBundle.php b/src/PdirSocialFeedBundle.php index 21c009d..f011039 100644 --- a/src/PdirSocialFeedBundle.php +++ b/src/PdirSocialFeedBundle.php @@ -1,15 +1,25 @@ - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * Copyright (c) 2021 pdir / digital agentur // pdir GmbH + * + * @package social-feed-bundle + * @link https://github.com/pdir/social-feed-bundle + * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * @author Mathias Arzberger + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ namespace Pdir\SocialFeedBundle; + use Symfony\Component\HttpKernel\Bundle\Bundle; /** @@ -19,4 +29,4 @@ */ class PdirSocialFeedBundle extends Bundle { -} \ No newline at end of file +} diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index cb5a652..444473e 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -1,16 +1,33 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Pdir\SocialFeedBundle\Module\ModuleCustomNewslist; -/** +/* * Backend modules */ -if (!isset($GLOBALS['BE_MOD']['pdir']) || !is_array($GLOBALS['BE_MOD']['pdir'])) -{ - array_insert($GLOBALS['BE_MOD'], 1, array('pdir' => array())); +if (!isset($GLOBALS['BE_MOD']['pdir']) || !is_array($GLOBALS['BE_MOD']['pdir'])) { + array_insert($GLOBALS['BE_MOD'], 1, ['pdir' => []]); } -$GLOBALS['TL_HOOKS']['parseArticles'][] = array('Pdir\SocialFeedBundle\SocialFeed\SocialFeedNewsClass', 'parseNews'); +$GLOBALS['TL_HOOKS']['parseArticles'][] = ['Pdir\SocialFeedBundle\SocialFeed\SocialFeedNewsClass', 'parseNews']; $assetsDir = 'bundles/pdirsocialfeed'; @@ -34,21 +51,20 @@ /* * Crons */ -$GLOBALS['TL_CRON']['minutely'][] = array('Pdir\SocialFeedBundle\EventListener\CronListener', 'getFbPosts'); -$GLOBALS['TL_CRON']['minutely'][] = array('Pdir\SocialFeedBundle\EventListener\CronListener', 'getInstagramPosts'); -$GLOBALS['TL_CRON']['minutely'][] = array('Pdir\SocialFeedBundle\EventListener\CronListener', 'getTwitterPosts'); -$GLOBALS['TL_CRON']['minutely'][] = array('Pdir\SocialFeedBundle\EventListener\CronListener', 'getLinkedinPosts'); -$GLOBALS['TL_CRON']['weekly'][] = array('Pdir\SocialFeedBundle\EventListener\CronListener', 'refreshLinkedInAccessToken'); +$GLOBALS['TL_CRON']['minutely'][] = ['Pdir\SocialFeedBundle\EventListener\CronListener', 'getFbPosts']; +$GLOBALS['TL_CRON']['minutely'][] = ['Pdir\SocialFeedBundle\EventListener\CronListener', 'getInstagramPosts']; +$GLOBALS['TL_CRON']['minutely'][] = ['Pdir\SocialFeedBundle\EventListener\CronListener', 'getTwitterPosts']; +$GLOBALS['TL_CRON']['minutely'][] = ['Pdir\SocialFeedBundle\EventListener\CronListener', 'getLinkedinPosts']; +$GLOBALS['TL_CRON']['weekly'][] = ['Pdir\SocialFeedBundle\EventListener\CronListener', 'refreshLinkedInAccessToken']; -/** +/* * CSS for Frontend */ -if (TL_MODE == 'FE') -{ - $GLOBALS['TL_CSS']['social_feed'] = 'bundles/pdirsocialfeed/css/social_feed.scss|static'; +if (TL_MODE === 'FE') { + $GLOBALS['TL_CSS']['social_feed'] = $assetsDir.'/css/social_feed.scss|static'; } -if (TL_MODE == 'BE') -{ - $GLOBALS['TL_CSS'][] = 'bundles/pdirsocialfeed/css/sf_moderation.scss|static'; - $GLOBALS['TL_CSS'][] = 'bundles/pdirsocialfeed/css/backend.css|static'; + +if (TL_MODE === 'BE') { + $GLOBALS['TL_CSS'][] = $assetsDir.'/css/sf_moderation.scss|static'; + $GLOBALS['TL_CSS'][] = $assetsDir.'/css/backend.css|static'; } diff --git a/src/Resources/contao/config/runonce.php b/src/Resources/contao/config/runonce.php index 24259f6..eab96be 100644 --- a/src/Resources/contao/config/runonce.php +++ b/src/Resources/contao/config/runonce.php @@ -1,22 +1,44 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +class SocialFeedRunonce extends Controller { public function __construct() { parent::__construct(); $this->import('Database'); } - public function run() + + public function run(): void { if ($this->Database->tableExists('tl_news')) { if ($this->Database->fieldExists('pdir_sf_fb_id', 'tl_news')) { $this->Database->query("ALTER TABLE tl_news CHANGE pdir_sf_fb_id social_feed_id VARCHAR(128) DEFAULT '' NOT NULL"); } + if ($this->Database->fieldExists('pdir_sf_fb_account', 'tl_news')) { $this->Database->query("ALTER TABLE tl_news CHANGE pdir_sf_fb_account social_feed_account VARCHAR(128) DEFAULT '' NOT NULL"); } + if ($this->Database->fieldExists('pdir_sf_fb_account_picture', 'tl_news')) { - $this->Database->query("ALTER TABLE tl_news CHANGE pdir_sf_fb_account_picture social_feed_account_picture BINARY(16) DEFAULT NULL"); + $this->Database->query('ALTER TABLE tl_news CHANGE pdir_sf_fb_account_picture social_feed_account_picture BINARY(16) DEFAULT NULL'); } } } diff --git a/src/Resources/contao/dca/tl_module.php b/src/Resources/contao/dca/tl_module.php index d9bd3c9..fba4fb7 100644 --- a/src/Resources/contao/dca/tl_module.php +++ b/src/Resources/contao/dca/tl_module.php @@ -1,65 +1,70 @@ + * @author Philipp Seibt + * @author pdir GmbH * - * Copyright (c) 2017 pdir / digital agentur - * @package social-feed-bundle - * @author Mathias Arzberger - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ - -/** +/* * Add palette to tl_module */ -$GLOBALS['TL_DCA']['tl_module']['palettes']['newslist'] = str_replace('cssID','cssID;{pdir_sf_settings_legend},pdir_sf_text_length,pdir_sf_columns,pdir_sf_enableMasonry,pdir_sf_enableImages', $GLOBALS['TL_DCA']['tl_module']['palettes']['newslist']); +$GLOBALS['TL_DCA']['tl_module']['palettes']['newslist'] = str_replace('cssID', 'cssID;{pdir_sf_settings_legend},pdir_sf_text_length,pdir_sf_columns,pdir_sf_enableMasonry,pdir_sf_enableImages', $GLOBALS['TL_DCA']['tl_module']['palettes']['newslist']); -$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_text_length'] = array( +$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_text_length'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_module']['pdir_sf_text_length'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array( + 'eval' => [ 'submitOnChange' => true, 'tl_class' => 'w50', - ), + ], 'sql' => "int(10) unsigned NOT NULL default '0'", -); +]; -$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_enableMasonry'] = array -( +$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_enableMasonry'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableMasonry'], 'exclude' => true, 'inputType' => 'checkbox', - 'eval' => array( + 'eval' => [ 'submitOnChange' => true, 'tl_class' => 'w50 m12', - ), + ], 'sql' => "char(1) NOT NULL default ''", -); +]; -$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_columns'] = array -( +$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_columns'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_module']['pdir_sf_columns'], 'exclude' => true, 'inputType' => 'select', 'eval' => [ - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], - 'options' => array('column1', 'columns2', 'columns3', 'columns4'), + 'options' => ['column1', 'columns2', 'columns3', 'columns4'], 'reference' => &$GLOBALS['TL_LANG']['tl_module'], 'sql' => "varchar(64) NOT NULL default 'columns3'", -); +]; -$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_enableImages'] = array -( +$GLOBALS['TL_DCA']['tl_module']['fields']['pdir_sf_enableImages'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableImages'], 'exclude' => true, 'inputType' => 'checkbox', - 'eval' => array( + 'eval' => [ 'submitOnChange' => true, 'tl_class' => 'w50 m12', - ), + ], 'sql' => "char(1) NOT NULL default '1'", -); +]; diff --git a/src/Resources/contao/dca/tl_news.php b/src/Resources/contao/dca/tl_news.php index b3419e1..f98e486 100644 --- a/src/Resources/contao/dca/tl_news.php +++ b/src/Resources/contao/dca/tl_news.php @@ -1,6 +1,28 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Contao\Backend; +use Contao\Config; use Contao\CoreBundle\DataContainer\PaletteManipulator; -/** + +/* * add global operation */ array_insert($GLOBALS['TL_DCA']['tl_news']['list']['global_operations'], 0, [ @@ -9,105 +31,97 @@ 'href' => 'key=moderate', 'class' => 'header_new header_sf_moderate', 'attributes' => 'onclick="Backend.getScrollOffset()"', - #'button_callback' => '' ], ]); -/** +/* * Add palette to tl_module */ -$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_id'] = array -( +$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_id'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['social_feed_id'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array( - 'mandatory'=>false, + 'eval' => [ + 'mandatory' => false, 'tl_class' => 'w50', 'decodeEntities' => true, - ), + ], 'sql' => "varchar(128) NOT NULL default ''", -); +]; -$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_type'] = array -( +$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_type'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['social_feed_type'], - 'exclude' => true, - 'filter' => true, - 'sorting' => true, - 'inputType' => 'select', - 'options' => array('Facebook','Instagram','Twitter'), - 'eval' => array('includeBlankOption'=>true, 'tl_class'=>'w50'), - 'sql' => "varchar(255) NOT NULL default ''" -); + 'exclude' => true, + 'filter' => true, + 'sorting' => true, + 'inputType' => 'select', + 'options' => ['Facebook', 'Instagram', 'Twitter'], + 'eval' => ['includeBlankOption' => true, 'tl_class' => 'w50'], + 'sql' => "varchar(255) NOT NULL default ''", +]; -$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_account'] = array -( +$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_account'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['social_feed_account'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array( - 'mandatory'=>false, + 'eval' => [ + 'mandatory' => false, 'tl_class' => 'w50', 'decodeEntities' => true, - ), + ], 'sql' => "varchar(128) NOT NULL default ''", -); +]; -$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_account_picture'] = array -( +$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_account_picture'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['social_feed_account_picture'], 'exclude' => true, 'inputType' => 'fileTree', - 'eval' => array( 'filesOnly'=>true, 'fieldType'=>'radio', 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal', 'tl_class'=>'w50 autoheight' ), - 'load_callback' => array - ( - array('tl_news_socialfeed', 'setSingleSrcFlags') - ), - 'sql' => "binary(16) NULL" -); + 'eval' => ['filesOnly' => true, 'fieldType' => 'radio', 'feEditable' => true, 'feViewable' => true, 'feGroup' => 'personal', 'tl_class' => 'w50 autoheight'], + 'load_callback' => [ + ['tl_news_socialfeed', 'setSingleSrcFlags'], + ], + 'sql' => 'binary(16) NULL', +]; -$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_config'] = array -( +$GLOBALS['TL_DCA']['tl_news']['fields']['social_feed_config'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['social_feed_config'], 'exclude' => true, 'inputType' => 'text', - 'eval' => array( - 'mandatory'=>false, + 'eval' => [ + 'mandatory' => false, 'tl_class' => 'w50', - 'readonly'=>'readonly' - ), - 'sql' => "int(10) unsigned NULL", -); + 'readonly' => 'readonly', + ], + 'sql' => 'int(10) unsigned NULL', +]; class tl_news_socialfeed extends Backend { /** - * Dynamically add flags to the "singleSRC" field + * Dynamically add flags to the "singleSRC" field. * - * @param mixed $varValue - * @param DataContainer $dc + * @param mixed $varValue * * @return mixed */ public function setSingleSrcFlags($varValue, DataContainer $dc) { - if ($dc->activeRecord) - { - switch ($dc->activeRecord->type) - { + if ($dc->activeRecord) { + switch ($dc->activeRecord->type) { case 'text': case 'hyperlink': case 'image': case 'accordionSingle': $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['extensions'] = Config::get('validImageTypes'); break; + case 'download': $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['extensions'] = Config::get('allowedDownload'); break; } } + return $varValue; } } diff --git a/src/Resources/contao/dca/tl_social_feed.php b/src/Resources/contao/dca/tl_social_feed.php index 9bc2f53..6500390 100644 --- a/src/Resources/contao/dca/tl_social_feed.php +++ b/src/Resources/contao/dca/tl_social_feed.php @@ -1,8 +1,32 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Contao\Backend; +use Contao\Config; +use Contao\DataContainer; +use Contao\System; +use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; + +System::loadLanguageFile('tl_social_feed'); -/** +/* * add Dca */ $GLOBALS['TL_DCA']['tl_social_feed'] = [ @@ -68,17 +92,16 @@ ], 'palettes' => [ - '__selector__' => array('socialFeedType'), + '__selector__' => ['socialFeedType'], 'default' => '{pdir_sf_type_legend},socialFeedType,psf_setup;', ], - 'subpalettes' => array - ( + 'subpalettes' => [ 'socialFeedType_Facebook' => 'pdir_sf_fb_account,pdir_sf_fb_app_id,pdir_sf_fb_app_secret,pdir_sf_fb_access_token,psf_facebookRequestToken,pdir_sf_fb_news_archive,pdir_sf_fb_news_cronjob,pdir_sf_fb_posts,pdir_sf_fb_news_last_import_date,pdir_sf_fb_news_last_import_time', 'socialFeedType_Instagram' => 'psf_instagramAppId,psf_instagramAppSecret,psf_instagramAccessToken,psf_instagramRequestToken,instagram_account,number_posts,pdir_sf_fb_news_archive,pdir_sf_fb_news_cronjob,pdir_sf_fb_news_last_import_date,pdir_sf_fb_news_last_import_time;{pdir_sf_account_image_legend},instagram_account_picture,instagram_account_picture_size', 'socialFeedType_Twitter' => 'twitter_api_key,twitter_api_secret_key,twitter_access_token,twitter_access_token_secret,twitter_account,search,number_posts,pdir_sf_fb_news_archive,pdir_sf_fb_news_cronjob,show_retweets,hashtags_link,show_reply,pdir_sf_fb_news_last_import_date,pdir_sf_fb_news_last_import_time', - 'socialFeedType_LinkedIn' => 'linkedin_client_id,linkedin_client_secret,linkedin_company_id,linkedin_request_token,linkedin_access_token,number_posts,pdir_sf_fb_news_archive,pdir_sf_fb_news_cronjob,access_token_expires,linkedin_refresh_token_expires,pdir_sf_fb_news_last_import_date,pdir_sf_fb_news_last_import_time,linkedin_account_picture,linkedin_account_picture_size' - ), + 'socialFeedType_LinkedIn' => 'linkedin_client_id,linkedin_client_secret,linkedin_company_id,linkedin_request_token,linkedin_access_token,number_posts,pdir_sf_fb_news_archive,pdir_sf_fb_news_cronjob,access_token_expires,linkedin_refresh_token_expires,pdir_sf_fb_news_last_import_date,pdir_sf_fb_news_last_import_time,linkedin_account_picture,linkedin_account_picture_size', + ], 'fields' => [ 'id' => [ @@ -91,13 +114,13 @@ 'socialFeedType' => [ 'label' => &$GLOBALS['TL_LANG']['tl_social_feed']['socialFeedType'], - 'exclude' => true, - 'filter' => true, - 'sorting' => true, - 'inputType' => 'select', - 'options' => array('Facebook','Instagram','Twitter','LinkedIn'), - 'eval' => array('includeBlankOption'=>true, 'tl_class'=>'w50', 'submitOnChange' => true), - 'sql' => "varchar(255) NOT NULL default ''" + 'exclude' => true, + 'filter' => true, + 'sorting' => true, + 'inputType' => 'select', + 'options' => ['Facebook', 'Instagram', 'Twitter', 'LinkedIn'], + 'eval' => ['includeBlankOption' => true, 'tl_class' => 'w50', 'submitOnChange' => true], + 'sql' => "varchar(255) NOT NULL default ''", ], 'pdir_sf_fb_account' => [ @@ -118,7 +141,7 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -130,7 +153,7 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -141,7 +164,7 @@ 'inputType' => 'text', 'eval' => [ 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -151,7 +174,7 @@ 'exclude' => true, 'inputType' => 'select', 'eval' => [ - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'foreignKey' => 'tl_news_archive.title', 'sql' => "varchar(64) NOT NULL default ''", @@ -163,7 +186,7 @@ 'exclude' => true, 'inputType' => 'checkbox', 'eval' => [ - 'tl_class' => 'clr' + 'tl_class' => 'clr', ], 'sql' => "char(1) NOT NULL default ''", ], @@ -173,14 +196,14 @@ 'exclude' => true, 'inputType' => 'select', 'eval' => [ - 'tl_class' => 'w50' - ], - 'options' => array('no_cronjob' => $GLOBALS['TL_LANG']['tl_social_feed']['no_cronjob'], - '60' => $GLOBALS['TL_LANG']['tl_social_feed']['minutely'], - '3600' => $GLOBALS['TL_LANG']['tl_social_feed']['hourly'], - '86400' => $GLOBALS['TL_LANG']['tl_social_feed']['daily'], - '604800' => $GLOBALS['TL_LANG']['tl_social_feed']['weekly'], - '2629800' => $GLOBALS['TL_LANG']['tl_social_feed']['monthly']), + 'tl_class' => 'w50', + ], + 'options' => ['no_cronjob' => $GLOBALS['TL_LANG']['tl_social_feed']['no_cronjob'], + '60' => $GLOBALS['TL_LANG']['tl_social_feed']['minutely'], + '3600' => $GLOBALS['TL_LANG']['tl_social_feed']['hourly'], + '86400' => $GLOBALS['TL_LANG']['tl_social_feed']['daily'], + '604800' => $GLOBALS['TL_LANG']['tl_social_feed']['weekly'], + '2629800' => $GLOBALS['TL_LANG']['tl_social_feed']['monthly'], ], 'sql' => "varchar(64) NOT NULL default ''", ], @@ -189,7 +212,7 @@ 'exclude' => true, 'inputType' => 'text', 'sql' => "varchar(255) NOT NULL default ''", - 'eval' => array('rgxp' => 'date', 'tl_class' => 'w50') + 'eval' => ['rgxp' => 'date', 'tl_class' => 'w50'], ], 'pdir_sf_fb_news_last_import_time' => [ @@ -197,7 +220,7 @@ 'exclude' => true, 'inputType' => 'text', 'sql' => "varchar(255) NOT NULL default ''", - 'eval' => array('rgxp' => 'time', 'tl_class' => 'w50') + 'eval' => ['rgxp' => 'time', 'tl_class' => 'w50'], ], 'instagram_account' => [ @@ -206,34 +229,30 @@ 'inputType' => 'text', 'eval' => [ 'maxlength' => 255, - 'tl_class' => 'w50 clr' + 'tl_class' => 'w50 clr', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'instagram_account_picture' => [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['instagram_account_picture'], 'exclude' => true, 'inputType' => 'fileTree', - 'eval' => array( 'filesOnly'=>true, 'fieldType'=>'radio', 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal', 'tl_class'=>'w50 autoheight' ), - 'load_callback' => array - ( - array('tl_social_feed', 'setSingleSrcFlags') - ), - 'sql' => "binary(16) NULL" + 'eval' => ['filesOnly' => true, 'fieldType' => 'radio', 'feEditable' => true, 'feViewable' => true, 'feGroup' => 'personal', 'tl_class' => 'w50 autoheight'], + 'load_callback' => [ + ['tl_social_feed', 'setSingleSrcFlags'], + ], + 'sql' => 'binary(16) NULL', ], 'instagram_account_picture_size' => [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['instagram_account_picture_size'], 'exclude' => true, - 'inputType' => 'imageSize', - 'options_callback' => static function () - { - return \Contao\System::getContainer()->get('contao.image.image_sizes')->getAllOptions(); - }, + 'inputType' => 'imageSize', + 'options_callback' => static fn () => System::getContainer()->get('contao.image.image_sizes')->getAllOptions(), 'reference' => &$GLOBALS['TL_LANG']['MSC'], - 'eval' => ['rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'], - 'sql' => "varchar(64) NOT NULL default ''" + 'eval' => ['rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, 'helpwizard' => true, 'tl_class' => 'w50'], + 'sql' => "varchar(64) NOT NULL default ''", ], 'psf_instagramAppId' => [ @@ -243,9 +262,9 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'psf_instagramAppSecret' => [ @@ -255,9 +274,9 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'psf_instagramAccessToken' => [ @@ -266,9 +285,9 @@ 'inputType' => 'text', 'eval' => [ 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'psf_instagramRequestToken' => [ @@ -277,10 +296,10 @@ 'inputType' => 'checkbox', 'eval' => [ 'doNotSaveEmpty' => true, - 'tl_class' => 'w50 m12' + 'tl_class' => 'w50 m12', ], 'save_callback' => [ - [\Pdir\SocialFeedBundle\EventListener\SocialFeedListener::class, 'onRequestTokenSave'], + [SocialFeedListener::class, 'onRequestTokenSave'], ], ], @@ -290,10 +309,10 @@ 'inputType' => 'checkbox', 'eval' => [ 'doNotSaveEmpty' => true, - 'tl_class' => 'w50 m12' + 'tl_class' => 'w50 m12', ], 'save_callback' => [ - [\Pdir\SocialFeedBundle\EventListener\SocialFeedListener::class, 'onRequestTokenSave'], + [SocialFeedListener::class, 'onRequestTokenSave'], ], ], @@ -304,7 +323,7 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "int(10) unsigned NOT NULL default '20'", ], @@ -315,7 +334,7 @@ 'inputType' => 'text', 'eval' => [ 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -326,7 +345,7 @@ 'inputType' => 'text', 'eval' => [ 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -336,7 +355,7 @@ 'exclude' => true, 'inputType' => 'checkbox', 'eval' => [ - 'tl_class' => 'clr' + 'tl_class' => 'clr', ], 'sql' => "char(1) NOT NULL default ''", ], @@ -346,7 +365,7 @@ 'exclude' => true, 'inputType' => 'checkbox', 'eval' => [ - 'tl_class' => 'clr' + 'tl_class' => 'clr', ], 'sql' => "char(1) NOT NULL default ''", ], @@ -356,7 +375,7 @@ 'exclude' => true, 'inputType' => 'checkbox', 'eval' => [ - 'tl_class' => 'clr' + 'tl_class' => 'clr', ], 'sql' => "char(1) NOT NULL default ''", ], @@ -368,7 +387,7 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -380,7 +399,7 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -392,7 +411,7 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], @@ -404,14 +423,14 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], 'sql' => "varchar(255) NOT NULL default ''", ], 'psf_setup' => [ 'exclude' => true, - 'input_field_callback' => ['Pdir\\SocialFeedBundle\\Dca\\tl_social_feed', 'setupExplanation'] + 'input_field_callback' => ['Pdir\\SocialFeedBundle\\Dca\\tl_social_feed', 'setupExplanation'], ], // LinkedIn @@ -422,9 +441,9 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'linkedin_client_secret' => [ @@ -434,9 +453,9 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'linkedin_company_id' => [ @@ -446,9 +465,9 @@ 'eval' => [ 'mandatory' => true, 'maxlength' => 255, - 'tl_class' => 'w50' + 'tl_class' => 'w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'linkedin_access_token' => [ @@ -456,9 +475,9 @@ 'exclude' => true, 'inputType' => 'text', 'eval' => [ - 'tl_class' => 'clr w50' + 'tl_class' => 'clr w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'linkedin_request_token' => [ @@ -467,10 +486,10 @@ 'inputType' => 'checkbox', 'eval' => [ 'doNotSaveEmpty' => true, - 'tl_class' => 'clr' + 'tl_class' => 'clr', ], 'save_callback' => [ - [\Pdir\SocialFeedBundle\EventListener\SocialFeedListener::class, 'onRequestTokenSave'], + [SocialFeedListener::class, 'onRequestTokenSave'], ], ], @@ -478,25 +497,21 @@ 'label' => &$GLOBALS['TL_LANG']['tl_news']['linkedin_account_picture'], 'exclude' => true, 'inputType' => 'fileTree', - 'eval' => array( 'filesOnly'=>true, 'fieldType'=>'radio', 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal', 'tl_class'=>'clr w50 autoheight' ), - 'load_callback' => array - ( - array('tl_social_feed', 'setSingleSrcFlags') - ), - 'sql' => "binary(16) NULL" + 'eval' => ['filesOnly' => true, 'fieldType' => 'radio', 'feEditable' => true, 'feViewable' => true, 'feGroup' => 'personal', 'tl_class' => 'clr w50 autoheight'], + 'load_callback' => [ + ['tl_social_feed', 'setSingleSrcFlags'], + ], + 'sql' => 'binary(16) NULL', ], 'linkedin_account_picture_size' => [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['linkedin_account_picture_size'], 'exclude' => true, - 'inputType' => 'imageSize', - 'options_callback' => static function () - { - return \Contao\System::getContainer()->get('contao.image.image_sizes')->getAllOptions(); - }, + 'inputType' => 'imageSize', + 'options_callback' => static fn () => System::getContainer()->get('contao.image.image_sizes')->getAllOptions(), 'reference' => &$GLOBALS['TL_LANG']['MSC'], - 'eval' => ['rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'], - 'sql' => "varchar(64) NOT NULL default ''" + 'eval' => ['rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, 'helpwizard' => true, 'tl_class' => 'w50'], + 'sql' => "varchar(64) NOT NULL default ''", ], 'access_token_expires' => [ @@ -507,8 +522,8 @@ 'eval' => [ 'rgxp' => 'datim', 'tl_class' => 'w50', - 'readonly' => 'readonly' - ] + 'readonly' => 'readonly', + ], ], 'linkedin_refresh_token' => [ @@ -516,9 +531,9 @@ 'exclude' => true, 'inputType' => 'text', 'eval' => [ - 'tl_class' => 'clr w50' + 'tl_class' => 'clr w50', ], - 'sql' => "text NULL", + 'sql' => 'text NULL', ], 'linkedin_refresh_token_expires' => [ @@ -529,8 +544,8 @@ 'eval' => [ 'rgxp' => 'datim', 'tl_class' => 'w50', - 'readonly' => 'readonly' - ] + 'readonly' => 'readonly', + ], ], ], ]; @@ -538,30 +553,29 @@ class tl_social_feed extends Backend { /** - * Dynamically add flags to the "singleSRC" field + * Dynamically add flags to the "singleSRC" field. * - * @param mixed $varValue - * @param DataContainer $dc + * @param mixed $varValue * * @return mixed */ public function setSingleSrcFlags($varValue, DataContainer $dc) { - if ($dc->activeRecord) - { - switch ($dc->activeRecord->type) - { + if ($dc->activeRecord) { + switch ($dc->activeRecord->type) { case 'text': case 'hyperlink': case 'image': case 'accordionSingle': $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['extensions'] = Config::get('validImageTypes'); break; + case 'download': $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['extensions'] = Config::get('allowedDownload'); break; } } + return $varValue; } } diff --git a/src/Resources/contao/languages/de/default.php b/src/Resources/contao/languages/de/default.php index faef83b..5d2c8ae 100644 --- a/src/Resources/contao/languages/de/default.php +++ b/src/Resources/contao/languages/de/default.php @@ -1,3 +1,21 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $GLOBALS['TL_LANG']['BE_MOD']['socialFeedModerate']['importMessage'] = 'Es wurden %s Einträge importiert.'; diff --git a/src/Resources/contao/languages/de/modules.php b/src/Resources/contao/languages/de/modules.php index db33384..15fa5d8 100644 --- a/src/Resources/contao/languages/de/modules.php +++ b/src/Resources/contao/languages/de/modules.php @@ -1,20 +1,29 @@ + * @author Philipp Seibt + * @author pdir GmbH * - * Copyright (c) 2017 pdir / digital agentur - * @package social-feed-bundle - * @author Mathias Arzberger - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ -/** +/* * Module translation */ -$GLOBALS['TL_LANG']['MOD']['pdir'][0] = "pdir Apps"; -$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][0] = "Social Feed Info"; -$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][1] = "Verwalten Sie hier das Social Feed Bundle"; -$GLOBALS['TL_LANG']['MOD']['socialFeed'][0] = "Social Feed Accounts"; -$GLOBALS['TL_LANG']['MOD']['socialFeed'][1] = "Konfigurieren Sie hier das Social Feed Bundle."; \ No newline at end of file +$GLOBALS['TL_LANG']['MOD']['pdir'][0] = 'pdir Apps'; +$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][0] = 'Social Feed Info'; +$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][1] = 'Verwalten Sie hier das Social Feed Bundle'; +$GLOBALS['TL_LANG']['MOD']['socialFeed'][0] = 'Social Feed Accounts'; +$GLOBALS['TL_LANG']['MOD']['socialFeed'][1] = 'Konfigurieren Sie hier das Social Feed Bundle.'; diff --git a/src/Resources/contao/languages/de/tl_module.php b/src/Resources/contao/languages/de/tl_module.php index b15eaa2..e0dd1a0 100644 --- a/src/Resources/contao/languages/de/tl_module.php +++ b/src/Resources/contao/languages/de/tl_module.php @@ -1,25 +1,34 @@ + * @author Philipp Seibt + * @author pdir GmbH * - * Copyright (c) 2017 pdir / digital agentur - * @package social-feed-bundle - * @author Mathias Arzberger - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ -/** +/* * Module translation */ $GLOBALS['TL_LANG']['tl_module']['pdir_sf_settings_legend'] = 'Social Feed Einstellungen'; -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_text_length'] = array('Maximale Textlänge', 'Bitte geben Sie hier die maximale Textlänge der Posts an. Geben Sie 0 an, um den kompletten Text anzuzeigen.'); -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableMasonry'] = array('Masonry aktivieren', 'Elemente werden basierend auf der verfügbaren vertikalen Position in einer optimalen Position platziert, ähnlich wie bei einem Maurer, der Steine in einer Wand einpasst.'); +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_text_length'] = ['Maximale Textlänge', 'Bitte geben Sie hier die maximale Textlänge der Posts an. Geben Sie 0 an, um den kompletten Text anzuzeigen.']; +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableMasonry'] = ['Masonry aktivieren', 'Elemente werden basierend auf der verfügbaren vertikalen Position in einer optimalen Position platziert, ähnlich wie bei einem Maurer, der Steine in einer Wand einpasst.']; $GLOBALS['TL_LANG']['tl_module']['column1'] = 'Einspaltig'; $GLOBALS['TL_LANG']['tl_module']['columns2'] = 'Zweispaltig'; $GLOBALS['TL_LANG']['tl_module']['columns3'] = 'Dreispaltig'; $GLOBALS['TL_LANG']['tl_module']['columns4'] = 'Vierspaltig'; -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_columns'] = array('Anzahl der Spalten', 'Geben Sie hier die gewünschte Darstellung der Elemente aus.'); -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableImages'] = array('Bilder anzeigen', 'Wenn aktiv, werden die Bilder dargestellt.'); \ No newline at end of file +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_columns'] = ['Anzahl der Spalten', 'Geben Sie hier die gewünschte Darstellung der Elemente aus.']; +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableImages'] = ['Bilder anzeigen', 'Wenn aktiv, werden die Bilder dargestellt.']; diff --git a/src/Resources/contao/languages/de/tl_news.php b/src/Resources/contao/languages/de/tl_news.php index 8271f92..7766b3a 100644 --- a/src/Resources/contao/languages/de/tl_news.php +++ b/src/Resources/contao/languages/de/tl_news.php @@ -1,5 +1,23 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $GLOBALS['TL_LANG']['tl_news']['pdir_sf_settings_legend'] = 'Social Feed Einstellungen'; $GLOBALS['TL_LANG']['tl_news']['social_feed_id'] = ['Social Feed Post-ID', '']; $GLOBALS['TL_LANG']['tl_news']['social_feed_type'] = ['Social Feed Typ', '']; diff --git a/src/Resources/contao/languages/de/tl_social_feed.php b/src/Resources/contao/languages/de/tl_social_feed.php index 773beba..06acbe5 100644 --- a/src/Resources/contao/languages/de/tl_social_feed.php +++ b/src/Resources/contao/languages/de/tl_social_feed.php @@ -1,53 +1,71 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$GLOBALS['TL_LANG']['tl_social_feed']['edit'] = ['', 'Editieren']; +$GLOBALS['TL_LANG']['tl_social_feed']['delete'] = ['', 'Löschen']; +$GLOBALS['TL_LANG']['tl_social_feed']['show'] = ['', 'Informationen anzeigen']; +$GLOBALS['TL_LANG']['tl_social_feed']['new'] = ['Neuen Social-Feed-Account anlegen', '']; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_type_legend'] = 'Social Feed Konfiguration'; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_account_image_legend'] = 'Profilbild Konfiguration'; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_legend'] = 'Facebook-Konfiguration'; -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_account'] = array("Facebook-Account","Geben Sie hier den Namen der Facebook-Seite an, wie er in der URL steht (z. B. meissen.online)."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_id'] = array("App ID","Geben Sie hier die App ID Ihrer Facebook-App an."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_secret'] = array("App Secret","Geben Sie hier den App Secret Ihrer Facebook-App an."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_access_token'] = array("Access Token","Der Access Token wird automatisch hinterlegt, wenn Sie Access Token generieren auswählen und speichern."); -$GLOBALS['TL_LANG']['tl_social_feed']['psf_facebookRequestToken'] = array("Access Token generieren","Wenn Sie speichern wird der Access Token automatisch generiert."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_archive'] = ['News-Archiv','Geben Sie hier das News-Archiv an, in welches die Posts importiert werden sollen.']; -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_cronjob'] = ['Ausführung des Cronjobes','Geben Sie hier an, wie oft der Cronjob aufgerufen werden soll, um Posts zu importieren.']; -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_date'] = array("Letzter Import (Datum) - wird automatisch ausgefüllt","Dieses Feld wird automatisch ausgefüllt und sollten Sie nicht ausfüllen."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_time'] = array("Letzter Import (Zeit) - wird automatisch ausgefüllt","Dieses Feld wird automatisch ausgefüllt und sollten Sie nicht ausfüllen."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_posts'] = array("Nur Posts der Seite importieren","Wenn diese Option aktiviert ist, werden nur die Posts der Seite importiert und keine Posts, die Nutzer an Ihre Pinnwand geschrieben haben."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account'] = array("Profilname","Geben Sie hier den Namen des Accounts ein, der auf der Webseite angezeigt werden soll. Der Accountname wird für den Import nicht zwingend benötigt."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture'] = array("Profilbild","Wählen Sie hier ein Profilbild aus, welches auf der Webseite angezeigt wird."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture_size'] = array("Bildgröße","Hier können Sie die Abmessungen des Bildes und den Skalierungsmodus festlegen."); +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_account'] = ['Facebook-Account', 'Geben Sie hier den Namen der Facebook-Seite an, wie er in der URL steht (z. B. meissen.online).']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_id'] = ['App ID', 'Geben Sie hier die App ID Ihrer Facebook-App an.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_secret'] = ['App Secret', 'Geben Sie hier den App Secret Ihrer Facebook-App an.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_access_token'] = ['Access Token', 'Der Access Token wird automatisch hinterlegt, wenn Sie Access Token generieren auswählen und speichern.']; +$GLOBALS['TL_LANG']['tl_social_feed']['psf_facebookRequestToken'] = ['Access Token generieren', 'Wenn Sie speichern wird der Access Token automatisch generiert.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_archive'] = ['News-Archiv', 'Geben Sie hier das News-Archiv an, in welches die Posts importiert werden sollen.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_cronjob'] = ['Ausführung des Cronjobes', 'Geben Sie hier an, wie oft der Cronjob aufgerufen werden soll, um Posts zu importieren.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_date'] = ['Letzter Import (Datum) - wird automatisch ausgefüllt', 'Dieses Feld wird automatisch ausgefüllt und sollten Sie nicht ausfüllen.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_time'] = ['Letzter Import (Zeit) - wird automatisch ausgefüllt', 'Dieses Feld wird automatisch ausgefüllt und sollten Sie nicht ausfüllen.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_posts'] = ['Nur Posts der Seite importieren', 'Wenn diese Option aktiviert ist, werden nur die Posts der Seite importiert und keine Posts, die Nutzer an Ihre Pinnwand geschrieben haben.']; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account'] = ['Profilname', 'Geben Sie hier den Namen des Accounts ein, der auf der Webseite angezeigt werden soll. Der Accountname wird für den Import nicht zwingend benötigt.']; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture'] = ['Profilbild', 'Wählen Sie hier ein Profilbild aus, welches auf der Webseite angezeigt wird.']; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture_size'] = ['Bildgröße', 'Hier können Sie die Abmessungen des Bildes und den Skalierungsmodus festlegen.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAppId'] = ['Instagram App ID', 'Bitte geben Sie die Instagram App ID ein.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAppSecret'] = ['Instagram App Secret', 'Bitte geben Sie das Instagram App Secret ein.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAccessToken'] = ['Instagram Access Token', 'Dies ist ein automatich erzeugter Wert, welcher beim Abschicken des Formulars generiert wird.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramRequestToken'] = ['Access Token anfordern', 'Aktivieren Sie diese Option um einen neuen Instagram Access Token anzufordern.']; -$GLOBALS['TL_LANG']['tl_social_feed']['socialFeedType'] = array("Typ","Wählen Sie hier zuerst den Typ aus."); -$GLOBALS['TL_LANG']['tl_social_feed']['no_cronjob'] = "Kein Cronjob"; -$GLOBALS['TL_LANG']['tl_social_feed']['minutely'] = "Minütlich"; -$GLOBALS['TL_LANG']['tl_social_feed']['hourly'] = "Stündlich"; -$GLOBALS['TL_LANG']['tl_social_feed']['daily'] = "Täglich"; -$GLOBALS['TL_LANG']['tl_social_feed']['monthly'] = "Monatlich"; -$GLOBALS['TL_LANG']['tl_social_feed']['weekly'] = "Wöchentlich"; -$GLOBALS['TL_LANG']['tl_social_feed']['number_posts'] = array("Maximale Anzahl an Posts","Geben Sie hier die maximale Anzahl der Posts an, die importiert werden sollen."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_account'] = array("Twitter-Account","Geben Sie hier den Namen Ihres Twitter-Accounts ein (ohne @)."); -$GLOBALS['TL_LANG']['tl_social_feed']['search'] = array("Suchbegriff","Statt nach einem bestimmten Account können Sie auch nach einem Suchbegriff suchen. Sind Account und Suchbegriff angegeben, wird der Account abgerufen und in den Tweets nach dem Suchbegriff gesucht."); -$GLOBALS['TL_LANG']['tl_social_feed']['show_retweets'] = array("Importiere auch Retweets","Wenn diese Option aktiviert ist werden auch Retweets importiert."); -$GLOBALS['TL_LANG']['tl_social_feed']['show_reply'] = array("Importiere auch Antworten","Wenn diese Option aktiviert ist werden auch Antworten importiert."); -$GLOBALS['TL_LANG']['tl_social_feed']['hashtags_link'] = array("Hashtags und Mentions verlinken","Wenn diese Option aktiviert ist werden die Hashtags und Mentions verlinkt. Dafür muss das extended-Template verwendet werden."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_key'] = array("API Key","Geben Sie hier den API Key ein."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_secret_key'] = array("API Secret Key","Geben Sie hier den API Secret Key ein."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token'] = array("Access Token","Geben Sie hier den Access Token ein."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token_secret'] = array("Access Token Secret","Geben Sie hier den Access Token Secret ein."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_id'] = array("Client ID","Geben Sie hier die Client ID aus der App ein."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_secret'] = array("Client Secret","Geben Sie hier den Client Secret aus der App ein."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_company_id'] = array("ID der Unternehmens-Seite","Geben Sie hier die ID der Unternehmens-Seite ein."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_access_token'] = array("Access Token","Der Access Token wird nach dem Speichern und Setzen der Checkbox automatisch gesetzt."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_request_token'] = array("Generiere Access Token","Wenn Sie die Checkbox setzen und anschließend Speichern wird der Access Token generiert."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture'] = array("Profilbild","Wählen Sie hier ein Profilbild aus, welches auf der Webseite angezeigt wird."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture_size'] = array("Bildgröße","Hier können Sie die Abmessungen des Bildes und den Skalierungsmodus festlegen."); -$GLOBALS['TL_LANG']['tl_social_feed']['access_token_expires'] = array("Access Token läuft ab am","Solange der Refresh Token gültig ist verlängert sich der Access Token automatisch um jeweils 2 Monate."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_refresh_token_expires'] = array("Refresh Token läuft ab am","Wenn der Refresh Token abgelaufen ist muss der Access Token manuell neu generiert werden."); +$GLOBALS['TL_LANG']['tl_social_feed']['socialFeedType'] = ['Typ', 'Wählen Sie hier zuerst den Typ aus.']; +$GLOBALS['TL_LANG']['tl_social_feed']['no_cronjob'] = 'Kein Cronjob'; +$GLOBALS['TL_LANG']['tl_social_feed']['minutely'] = 'Minütlich'; +$GLOBALS['TL_LANG']['tl_social_feed']['hourly'] = 'Stündlich'; +$GLOBALS['TL_LANG']['tl_social_feed']['daily'] = 'Täglich'; +$GLOBALS['TL_LANG']['tl_social_feed']['monthly'] = 'Monatlich'; +$GLOBALS['TL_LANG']['tl_social_feed']['weekly'] = 'Wöchentlich'; +$GLOBALS['TL_LANG']['tl_social_feed']['number_posts'] = ['Maximale Anzahl an Posts', 'Geben Sie hier die maximale Anzahl der Posts an, die importiert werden sollen.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_account'] = ['Twitter-Account', 'Geben Sie hier den Namen Ihres Twitter-Accounts ein (ohne @).']; +$GLOBALS['TL_LANG']['tl_social_feed']['search'] = ['Suchbegriff', 'Statt nach einem bestimmten Account können Sie auch nach einem Suchbegriff suchen. Sind Account und Suchbegriff angegeben, wird der Account abgerufen und in den Tweets nach dem Suchbegriff gesucht.']; +$GLOBALS['TL_LANG']['tl_social_feed']['show_retweets'] = ['Importiere auch Retweets', 'Wenn diese Option aktiviert ist werden auch Retweets importiert.']; +$GLOBALS['TL_LANG']['tl_social_feed']['show_reply'] = ['Importiere auch Antworten', 'Wenn diese Option aktiviert ist werden auch Antworten importiert.']; +$GLOBALS['TL_LANG']['tl_social_feed']['hashtags_link'] = ['Hashtags und Mentions verlinken', 'Wenn diese Option aktiviert ist werden die Hashtags und Mentions verlinkt. Dafür muss das extended-Template verwendet werden.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_key'] = ['API Key', 'Geben Sie hier den API Key ein.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_secret_key'] = ['API Secret Key', 'Geben Sie hier den API Secret Key ein.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token'] = ['Access Token', 'Geben Sie hier den Access Token ein.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token_secret'] = ['Access Token Secret', 'Geben Sie hier den Access Token Secret ein.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_id'] = ['Client ID', 'Geben Sie hier die Client ID aus der App ein.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_secret'] = ['Client Secret', 'Geben Sie hier den Client Secret aus der App ein.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_company_id'] = ['ID der Unternehmens-Seite', 'Geben Sie hier die ID der Unternehmens-Seite ein.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_access_token'] = ['Access Token', 'Der Access Token wird nach dem Speichern und Setzen der Checkbox automatisch gesetzt.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_request_token'] = ['Generiere Access Token', 'Wenn Sie die Checkbox setzen und anschließend Speichern wird der Access Token generiert.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture'] = ['Profilbild', 'Wählen Sie hier ein Profilbild aus, welches auf der Webseite angezeigt wird.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture_size'] = ['Bildgröße', 'Hier können Sie die Abmessungen des Bildes und den Skalierungsmodus festlegen.']; +$GLOBALS['TL_LANG']['tl_social_feed']['access_token_expires'] = ['Access Token läuft ab am', 'Solange der Refresh Token gültig ist verlängert sich der Access Token automatisch um jeweils 2 Monate.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_refresh_token_expires'] = ['Refresh Token läuft ab am', 'Wenn der Refresh Token abgelaufen ist muss der Access Token manuell neu generiert werden.']; diff --git a/src/Resources/contao/languages/en/default.php b/src/Resources/contao/languages/en/default.php index 6dd521d..0abc7fe 100644 --- a/src/Resources/contao/languages/en/default.php +++ b/src/Resources/contao/languages/en/default.php @@ -1,3 +1,21 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $GLOBALS['TL_LANG']['BE_MOD']['socialFeedModerate']['importMessage'] = '%s entries were imported.'; diff --git a/src/Resources/contao/languages/en/modules.php b/src/Resources/contao/languages/en/modules.php index 3163b30..afb06fc 100644 --- a/src/Resources/contao/languages/en/modules.php +++ b/src/Resources/contao/languages/en/modules.php @@ -1,20 +1,29 @@ + * @author Philipp Seibt + * @author pdir GmbH * - * Copyright (c) 2017 pdir / digital agentur - * @package social-feed-bundle - * @author Mathias Arzberger - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ -/** +/* * Module translation */ -$GLOBALS['TL_LANG']['MOD']['pdir'][0] = "pdir Apps"; -$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][0] = "Social Feed Info"; -$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][1] = "Here you can manage the social feed setup."; -$GLOBALS['TL_LANG']['MOD']['socialFeed'][0] = "Social Feed Accounts"; -$GLOBALS['TL_LANG']['MOD']['socialFeed'][1] = "Here you can manage the social feed accounts."; \ No newline at end of file +$GLOBALS['TL_LANG']['MOD']['pdir'][0] = 'pdir Apps'; +$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][0] = 'Social Feed Info'; +$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][1] = 'Here you can manage the social feed setup.'; +$GLOBALS['TL_LANG']['MOD']['socialFeed'][0] = 'Social Feed Accounts'; +$GLOBALS['TL_LANG']['MOD']['socialFeed'][1] = 'Here you can manage the social feed accounts.'; diff --git a/src/Resources/contao/languages/en/tl_module.php b/src/Resources/contao/languages/en/tl_module.php index cd88bfe..d35162b 100644 --- a/src/Resources/contao/languages/en/tl_module.php +++ b/src/Resources/contao/languages/en/tl_module.php @@ -1,25 +1,34 @@ + * @author Philipp Seibt + * @author pdir GmbH * - * Copyright (c) 2017 pdir / digital agentur - * @package social-feed-bundle - * @author Mathias Arzberger - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ -/** +/* * Module translation */ $GLOBALS['TL_LANG']['tl_module']['pdir_sf_settings_legend'] = 'Social Feed Settings'; -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_text_length'] = array('Maximum text length', 'Here you can enter the maximum text length. Enter 0 to show all the text.'); -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableMasonry'] = array('Activate Masonry', 'Masonry works by placing elements in optimal position based on available vertical space, sort of like a mason fitting stones in a wall.'); +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_text_length'] = ['Maximum text length', 'Here you can enter the maximum text length. Enter 0 to show all the text.']; +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableMasonry'] = ['Activate Masonry', 'Masonry works by placing elements in optimal position based on available vertical space, sort of like a mason fitting stones in a wall.']; $GLOBALS['TL_LANG']['tl_module']['column1'] = 'single column'; $GLOBALS['TL_LANG']['tl_module']['columns2'] = 'two columns'; $GLOBALS['TL_LANG']['tl_module']['columns3'] = 'three columns'; $GLOBALS['TL_LANG']['tl_module']['columns4'] = 'four coumns'; -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_columns'] = array('Number of columns', 'Here you can choose the number of columns for each element.'); -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableImages'] = array('Show images', 'When active, images are displayed.'); \ No newline at end of file +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_columns'] = ['Number of columns', 'Here you can choose the number of columns for each element.']; +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableImages'] = ['Show images', 'When active, images are displayed.']; diff --git a/src/Resources/contao/languages/en/tl_news.php b/src/Resources/contao/languages/en/tl_news.php index 6aa985e..16e90b1 100644 --- a/src/Resources/contao/languages/en/tl_news.php +++ b/src/Resources/contao/languages/en/tl_news.php @@ -1,12 +1,30 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $GLOBALS['TL_LANG']['tl_news']['sf_moderate'] = ['Social Feed', 'Add social feed entry.']; $GLOBALS['TL_LANG']['tl_news']['pdir_sf_settings_legend'] = 'Social Feed Settings'; -$GLOBALS['TL_LANG']['tl_news']['social_feed_id'] = array('Social Feed Post ID', ''); -$GLOBALS['TL_LANG']['tl_news']['social_feed_type'] = array('Social Feed Type', ''); -$GLOBALS['TL_LANG']['tl_news']['social_feed_account'] = array('Social Feed Account', ''); -$GLOBALS['TL_LANG']['tl_news']['social_feed_account_picture'] = array('Social Feed Account Picture', ''); +$GLOBALS['TL_LANG']['tl_news']['social_feed_id'] = ['Social Feed Post ID', '']; +$GLOBALS['TL_LANG']['tl_news']['social_feed_type'] = ['Social Feed Type', '']; +$GLOBALS['TL_LANG']['tl_news']['social_feed_account'] = ['Social Feed Account', '']; +$GLOBALS['TL_LANG']['tl_news']['social_feed_account_picture'] = ['Social Feed Account Picture', '']; $GLOBALS['TL_LANG']['tl_news']['moderate'] = ['Get Feed', 'Moderate Social Feed Posts']; $GLOBALS['TL_LANG']['tl_news_moderate']['sf_moderate'] = ['Social Feed', 'Add Social Feed Post.']; diff --git a/src/Resources/contao/languages/en/tl_social_feed.php b/src/Resources/contao/languages/en/tl_social_feed.php index fec26ab..179dbce 100644 --- a/src/Resources/contao/languages/en/tl_social_feed.php +++ b/src/Resources/contao/languages/en/tl_social_feed.php @@ -1,54 +1,72 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$GLOBALS['TL_LANG']['tl_social_feed']['edit'] = ['', 'Edit']; +$GLOBALS['TL_LANG']['tl_social_feed']['delete'] = ['', 'Delete']; +$GLOBALS['TL_LANG']['tl_social_feed']['show'] = ['', 'Show details']; +$GLOBALS['TL_LANG']['tl_social_feed']['new'] = ['Create new social feed account', '']; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_type_legend'] = 'Social Feed Configuration'; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_account_image_legend'] = 'Account Picture Configuration'; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_legend'] = 'Facebook Configuration'; -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_account'] = array("Facebook Account","Please enter the facebook acount name (from the URL)."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_id'] = array("App ID","Please enter the facebook app ID."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_secret'] = array("App Secret","Please enter the facebook app secret."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_access_token'] = array("Access Token","The Access Token is automatically stored when you select and save Generate Access Token. When you save, the Access Token is generated automatically."); -$GLOBALS['TL_LANG']['tl_social_feed']['psf_facebookRequestToken'] = array("Access Token generieren","When you save, the Access Token is generated automatically."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_archive'] = array("News archive","Please enter the news archive to which the facebook posts should be imported."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_cronjob'] = array("Execution of the cronjob","Please choose the time how often the cronjob should be called to import facebook posts."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_date'] = array("Last import (date) - will be filled out automatically","This field will be filled out automatically and you should not fill it out."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_time'] = array("Last import (time) - will be filled out automatically","This field will be filled out automatically and you should not fill it out."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_posts'] = array("Import only own posts","If this option is activated, only the posts of the page will be imported and not the posts that users have written to your feed."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account'] = array("Account name","Here you can enter a account name which will displayed on the website."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture'] = array("Account picture","Here you can choose a account picture which will displayed on the website."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture_size'] = array("Image size","Here you can set the image dimensions and the resize mode."); +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_account'] = ['Facebook Account', 'Please enter the facebook acount name (from the URL).']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_id'] = ['App ID', 'Please enter the facebook app ID.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_secret'] = ['App Secret', 'Please enter the facebook app secret.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_access_token'] = ['Access Token', 'The Access Token is automatically stored when you select and save Generate Access Token. When you save, the Access Token is generated automatically.']; +$GLOBALS['TL_LANG']['tl_social_feed']['psf_facebookRequestToken'] = ['Access Token generieren', 'When you save, the Access Token is generated automatically.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_archive'] = ['News archive', 'Please enter the news archive to which the facebook posts should be imported.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_cronjob'] = ['Execution of the cronjob', 'Please choose the time how often the cronjob should be called to import facebook posts.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_date'] = ['Last import (date) - will be filled out automatically', 'This field will be filled out automatically and you should not fill it out.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_time'] = ['Last import (time) - will be filled out automatically', 'This field will be filled out automatically and you should not fill it out.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_posts'] = ['Import only own posts', 'If this option is activated, only the posts of the page will be imported and not the posts that users have written to your feed.']; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account'] = ['Account name', 'Here you can enter a account name which will displayed on the website.']; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture'] = ['Account picture', 'Here you can choose a account picture which will displayed on the website.']; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture_size'] = ['Image size', 'Here you can set the image dimensions and the resize mode.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAppId'] = ['Instagram App ID', 'Please enter the Instagram App ID.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAppSecret'] = ['Instagram App Secret', 'Please enter the Instagram App Secret.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAccessToken'] = ['Instagram access token', 'This is an auto-generated value that will be filled in when you submit the form.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramRequestToken'] = ['Request access token and update feed', 'Check this box and save the record to request the access token and update the feed.']; -$GLOBALS['TL_LANG']['tl_social_feed']['socialFeedType'] = array("Type","Please choose here the typ of the social feed."); +$GLOBALS['TL_LANG']['tl_social_feed']['socialFeedType'] = ['Type', 'Please choose here the typ of the social feed.']; $GLOBALS['TL_LANG']['tl_social_feed']['no_cronjob'] = 'no cronjob'; $GLOBALS['TL_LANG']['tl_social_feed']['minutely'] = 'minutely'; $GLOBALS['TL_LANG']['tl_social_feed']['hourly'] = 'hourly'; $GLOBALS['TL_LANG']['tl_social_feed']['daily'] = 'daily'; $GLOBALS['TL_LANG']['tl_social_feed']['weekly'] = 'weekly'; $GLOBALS['TL_LANG']['tl_social_feed']['monthly'] = 'monthly'; -$GLOBALS['TL_LANG']['tl_social_feed']['number_posts'] = array("Maximum number of posts","Enter the maximum number of posts to be imported here."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_account'] = array("Twitter account","Please enter the twitter acount name (without @)."); -$GLOBALS['TL_LANG']['tl_social_feed']['search'] = array("Search Term","Instead of looking for a specific account, you can also search for a search term. If account and search term are specified, the account is retrieved and the search term is searched for in the tweets."); -$GLOBALS['TL_LANG']['tl_social_feed']['show_retweets'] = array("Import retweets","If this option is activated also retweets will be imported."); -$GLOBALS['TL_LANG']['tl_social_feed']['show_reply'] = array("Import reply","If this option is activated also reply will be imported."); -$GLOBALS['TL_LANG']['tl_social_feed']['hashtags_link'] = array("Link hashtags and mentions","If this option is activated the hashtags and mentions will be linked. The extended-template should be used for this feature."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_key'] = array("API Key","Please enter the api key."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_secret_key'] = array("Please enter the api secret key."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token'] = array("Access Token","Please enter the access token."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token_secret'] = array("Access Token Secret","Please enter the access token secret."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_id'] = array("Client ID","Please enter the client id from your app."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_secret'] = array("Client Secret","Please enter the client secret from your app."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_company_id'] = array("Company Page ID","Please enter the company page id."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_access_token'] = array("Access Token","This is an auto-generated value that will be filled in when you submit the form."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_request_token'] = array("Generate Access Token","Check this box and save the record to request the access token."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture'] = array("Account picture","Here you can choose a account picture which will displayed on the website."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture_size'] = array("Image size","Here you can set the image dimensions and the resize mode."); -$GLOBALS['TL_LANG']['tl_social_feed']['access_token_expires'] = array("Access token expires in","As long as the refresh token is valid, the access token is automatically extended by 2 months at a time."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_refresh_token_expires'] = array("Refresh token expires in","If the refresh token has expired, the access token must be regenerated manually."); +$GLOBALS['TL_LANG']['tl_social_feed']['number_posts'] = ['Maximum number of posts', 'Enter the maximum number of posts to be imported here.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_account'] = ['Twitter account', 'Please enter the twitter acount name (without @).']; +$GLOBALS['TL_LANG']['tl_social_feed']['search'] = ['Search Term', 'Instead of looking for a specific account, you can also search for a search term. If account and search term are specified, the account is retrieved and the search term is searched for in the tweets.']; +$GLOBALS['TL_LANG']['tl_social_feed']['show_retweets'] = ['Import retweets', 'If this option is activated also retweets will be imported.']; +$GLOBALS['TL_LANG']['tl_social_feed']['show_reply'] = ['Import reply', 'If this option is activated also reply will be imported.']; +$GLOBALS['TL_LANG']['tl_social_feed']['hashtags_link'] = ['Link hashtags and mentions', 'If this option is activated the hashtags and mentions will be linked. The extended-template should be used for this feature.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_key'] = ['API Key', 'Please enter the api key.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_secret_key'] = ['Please enter the api secret key.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token'] = ['Access Token', 'Please enter the access token.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token_secret'] = ['Access Token Secret', 'Please enter the access token secret.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_id'] = ['Client ID', 'Please enter the client id from your app.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_secret'] = ['Client Secret', 'Please enter the client secret from your app.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_company_id'] = ['Company Page ID', 'Please enter the company page id.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_access_token'] = ['Access Token', 'This is an auto-generated value that will be filled in when you submit the form.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_request_token'] = ['Generate Access Token', 'Check this box and save the record to request the access token.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture'] = ['Account picture', 'Here you can choose a account picture which will displayed on the website.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture_size'] = ['Image size', 'Here you can set the image dimensions and the resize mode.']; +$GLOBALS['TL_LANG']['tl_social_feed']['access_token_expires'] = ['Access token expires in', 'As long as the refresh token is valid, the access token is automatically extended by 2 months at a time.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_refresh_token_expires'] = ['Refresh token expires in', 'If the refresh token has expired, the access token must be regenerated manually.']; diff --git a/src/Resources/contao/languages/it/default.php b/src/Resources/contao/languages/it/default.php index 4168be1..0dc4d9b 100644 --- a/src/Resources/contao/languages/it/default.php +++ b/src/Resources/contao/languages/it/default.php @@ -1,3 +1,21 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $GLOBALS['TL_LANG']['BE_MOD']['socialFeedModerate']['importMessage'] = 'Gli elementi %s sono stati importati.'; diff --git a/src/Resources/contao/languages/it/modules.php b/src/Resources/contao/languages/it/modules.php index 2745340..fc648c3 100644 --- a/src/Resources/contao/languages/it/modules.php +++ b/src/Resources/contao/languages/it/modules.php @@ -1,20 +1,29 @@ + * @author Philipp Seibt + * @author pdir GmbH * - * Copyright (c) 2017 pdir / digital agentur - * @package social-feed-bundle - * @author Mathias Arzberger - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ -/** +/* * Module translation */ -$GLOBALS['TL_LANG']['MOD']['pdir'][0] = "Applicazioni Pdir"; -$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][0] = "Social Feed"; -$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][1] = "Gestione del modulo Social Feed"; -$GLOBALS['TL_LANG']['MOD']['socialFeed'][0] = "Social Feed Accounts"; -$GLOBALS['TL_LANG']['MOD']['socialFeed'][1] = "Configurazione del modulo Social Feed."; \ No newline at end of file +$GLOBALS['TL_LANG']['MOD']['pdir'][0] = 'Applicazioni Pdir'; +$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][0] = 'Social Feed'; +$GLOBALS['TL_LANG']['MOD']['socialFeedSetup'][1] = 'Gestione del modulo Social Feed'; +$GLOBALS['TL_LANG']['MOD']['socialFeed'][0] = 'Social Feed Accounts'; +$GLOBALS['TL_LANG']['MOD']['socialFeed'][1] = 'Configurazione del modulo Social Feed.'; diff --git a/src/Resources/contao/languages/it/tl_module.php b/src/Resources/contao/languages/it/tl_module.php index fe6ff56..27018c0 100644 --- a/src/Resources/contao/languages/it/tl_module.php +++ b/src/Resources/contao/languages/it/tl_module.php @@ -1,25 +1,34 @@ + * @author Philipp Seibt + * @author pdir GmbH * - * Copyright (c) 2017 pdir / digital agentur - * @package social-feed-bundle - * @author Mathias Arzberger - * @license http://www.gnu.org/licences/lgpl-3.0.html LGPL + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ -/** +/* * Module translation */ $GLOBALS['TL_LANG']['tl_module']['pdir_sf_settings_legend'] = 'Impostazioni del Social Feed'; -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_text_length'] = array('Lunghezza massima del testo', 'Inserisci qui la lunghezza massima del testo dei post. Inseriere 0 per visualizzare il testo completo.'); -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableMasonry'] = array('Attiva Masonry', 'Attiva funzione Masonry. Gli elementi vengono posizionati in una posizione ottimale in base alla posizione verticale disponibile.'); +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_text_length'] = ['Lunghezza massima del testo', 'Inserisci qui la lunghezza massima del testo dei post. Inseriere 0 per visualizzare il testo completo.']; +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableMasonry'] = ['Attiva Masonry', 'Attiva funzione Masonry. Gli elementi vengono posizionati in una posizione ottimale in base alla posizione verticale disponibile.']; $GLOBALS['TL_LANG']['tl_module']['column1'] = 'Colonna singola'; $GLOBALS['TL_LANG']['tl_module']['columns2'] = 'Due colonne'; $GLOBALS['TL_LANG']['tl_module']['columns3'] = 'Tre colonne'; $GLOBALS['TL_LANG']['tl_module']['columns4'] = 'Quattro colonne'; -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_columns'] = array('Numero di colonne', 'Inserisci il numero di colonne per la visualizzazione.'); -$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableImages'] = array('Visualizza le immagini', 'Se questa opzione è attiva, vengono visualizzate le immagini.'); \ No newline at end of file +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_columns'] = ['Numero di colonne', 'Inserisci il numero di colonne per la visualizzazione.']; +$GLOBALS['TL_LANG']['tl_module']['pdir_sf_enableImages'] = ['Visualizza le immagini', 'Se questa opzione è attiva, vengono visualizzate le immagini.']; diff --git a/src/Resources/contao/languages/it/tl_news.php b/src/Resources/contao/languages/it/tl_news.php index e2fc745..01393bd 100644 --- a/src/Resources/contao/languages/it/tl_news.php +++ b/src/Resources/contao/languages/it/tl_news.php @@ -1,10 +1,28 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $GLOBALS['TL_LANG']['tl_news']['pdir_sf_settings_legend'] = 'Impostazioni Social Feed'; -$GLOBALS['TL_LANG']['tl_news']['social_feed_id'] = array('Social Feed Post-ID', ''); -$GLOBALS['TL_LANG']['tl_news']['social_feed_type'] = array('Tipo di Social Feed', ''); -$GLOBALS['TL_LANG']['tl_news']['social_feed_account'] = array('Social Feed Account', ''); -$GLOBALS['TL_LANG']['tl_news']['social_feed_account_picture'] = array('Immagine del profilo Social Feed', ''); +$GLOBALS['TL_LANG']['tl_news']['social_feed_id'] = ['Social Feed Post-ID', '']; +$GLOBALS['TL_LANG']['tl_news']['social_feed_type'] = ['Tipo di Social Feed', '']; +$GLOBALS['TL_LANG']['tl_news']['social_feed_account'] = ['Social Feed Account', '']; +$GLOBALS['TL_LANG']['tl_news']['social_feed_account_picture'] = ['Immagine del profilo Social Feed', '']; $GLOBALS['TL_LANG']['tl_news_moderate']['sf_moderate'] = ['Social Feed', 'Aggiungi un nuovo Social Feed.']; $GLOBALS['TL_LANG']['tl_news_moderate']['moderate'] = ['Importa il Social Feed', 'Modera l\'importazione del Social Feed']; diff --git a/src/Resources/contao/languages/it/tl_social_feed.php b/src/Resources/contao/languages/it/tl_social_feed.php index d0884ea..17295c9 100644 --- a/src/Resources/contao/languages/it/tl_social_feed.php +++ b/src/Resources/contao/languages/it/tl_social_feed.php @@ -1,55 +1,72 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$GLOBALS['TL_LANG']['tl_social_feed']['edit'] = ['Modifica', 'Modifica']; +$GLOBALS['TL_LANG']['tl_social_feed']['delete'] = ['Elimina', 'Elimina']; +$GLOBALS['TL_LANG']['tl_social_feed']['show'] = ['Visualizza', 'Visualizza le informazioni']; +$GLOBALS['TL_LANG']['tl_social_feed']['new'] = ['Crea un nuovo account di Social Feed', '']; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_type_legend'] = 'Configurazione Social Feed'; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_account_image_legend'] = 'Configurazione dell\'immagine del profilo'; $GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_legend'] = 'Configurazione Facebook'; -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_account'] = array("Account Facebook","Inserisci il nome della pagina Facebook così com'è nell'URL (es. contao)."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_id'] = array("App ID","Inserisci qui l'ID app della tua app Facebook."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_secret'] = array("App Secret","Inserisci la chiave segreta della tua app di Facebook."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_access_token'] = array("Access Token","Inserisci il token di accesso. Le istruzioni per la generazione del token di accesso sono disponibili nella documentazione."); -$GLOBALS['TL_LANG']['tl_social_feed']['psf_facebookRequestToken'] = array("Genera token di accesso","Quando salvi, il token di accesso viene generato automaticamente."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_archive'] = ['Archivio News','Seleziona l\'archivio delle news dove devono essere importati i post.']; -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_cronjob'] = ['Esecuzione del cron job','Inserisci la frequenza con cui deve essere richiamato il cron job per importare i post.']; -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_date'] = array("Ultima importazione (data): verrà compilata automaticamente","Questo campo viene compilato automaticamente e non deve essere compilato."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_time'] = array("Ultima importazione (ora): verrà compilata automaticamente","Questo campo viene compilato automaticamente e non deve essere compilato."); -$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_posts'] = array("Importa solo i post dalla pagina","Se questa opzione è attivata, verranno importati solo i post sulla pagina e non i post che gli utenti hanno pubblicato sulla tua bacheca."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account'] = array("Nome Profilo","Immettere il nome dell'account che dovrebbe essere visualizzato sul sito Web. Il nome dell'account non è richiesto per l'importazione"); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture'] = array("Foto del profilo","Seleziona qui un'immagine del profilo, che verrà visualizzata sul sito web."); -$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture_size'] = array("Dimensione dell'immagine","Qui puoi impostare le dimensioni dell'immagine e la modalità di ridimensionamento."); +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_account'] = ['Account Facebook', "Inserisci il nome della pagina Facebook così com'è nell'URL (es. contao)."]; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_id'] = ['App ID', "Inserisci qui l'ID app della tua app Facebook."]; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_app_secret'] = ['App Secret', 'Inserisci la chiave segreta della tua app di Facebook.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_access_token'] = ['Access Token', 'Inserisci il token di accesso. Le istruzioni per la generazione del token di accesso sono disponibili nella documentazione.']; +$GLOBALS['TL_LANG']['tl_social_feed']['psf_facebookRequestToken'] = ['Genera token di accesso', 'Quando salvi, il token di accesso viene generato automaticamente.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_archive'] = ['Archivio News', 'Seleziona l\'archivio delle news dove devono essere importati i post.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_cronjob'] = ['Esecuzione del cron job', 'Inserisci la frequenza con cui deve essere richiamato il cron job per importare i post.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_date'] = ['Ultima importazione (data): verrà compilata automaticamente', 'Questo campo viene compilato automaticamente e non deve essere compilato.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_news_last_import_time'] = ['Ultima importazione (ora): verrà compilata automaticamente', 'Questo campo viene compilato automaticamente e non deve essere compilato.']; +$GLOBALS['TL_LANG']['tl_social_feed']['pdir_sf_fb_posts'] = ['Importa solo i post dalla pagina', 'Se questa opzione è attivata, verranno importati solo i post sulla pagina e non i post che gli utenti hanno pubblicato sulla tua bacheca.']; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account'] = ['Nome Profilo', "Immettere il nome dell'account che dovrebbe essere visualizzato sul sito Web. Il nome dell'account non è richiesto per l'importazione"]; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture'] = ['Foto del profilo', "Seleziona qui un'immagine del profilo, che verrà visualizzata sul sito web."]; +$GLOBALS['TL_LANG']['tl_social_feed']['instagram_account_picture_size'] = ["Dimensione dell'immagine", "Qui puoi impostare le dimensioni dell'immagine e la modalità di ridimensionamento."]; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAppId'] = ['Instagram App ID', 'Inserisci l\'ID app di Instagram.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAppSecret'] = ['Instagram App Secret', 'Inserisci la chiave segreta dell\'app Instagram.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramAccessToken'] = ['Instagram Access Token', 'Questo è un valore generato automaticamente che viene generato quando il modulo viene inviato.']; $GLOBALS['TL_LANG']['tl_social_feed']['psf_instagramRequestToken'] = ['Richiedi token di accesso', 'Attiva questa opzione per richiedere un nuovo token di accesso Instagram.']; -$GLOBALS['TL_LANG']['tl_social_feed']['socialFeedType'] = array("Tipologia Account","Selezionare il tipo di account."); -$GLOBALS['TL_LANG']['tl_social_feed']['no_cronjob'] = "Nessun Cronjob"; -$GLOBALS['TL_LANG']['tl_social_feed']['minutely'] = "Ogni minuto"; -$GLOBALS['TL_LANG']['tl_social_feed']['hourly'] = "Ogni ora"; -$GLOBALS['TL_LANG']['tl_social_feed']['daily'] = "Ogni giorno"; -$GLOBALS['TL_LANG']['tl_social_feed']['monthly'] = "Ogni mese"; -$GLOBALS['TL_LANG']['tl_social_feed']['weekly'] = "Ogni settimana"; -$GLOBALS['TL_LANG']['tl_social_feed']['number_posts'] = array("Numero massimo di post","Inserisci qui il numero massimo di post da importare."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_account'] = array("Account Twitter","Inserisci qui il nome del tuo account Twitter (senza @)."); -$GLOBALS['TL_LANG']['tl_social_feed']['search'] = array("Termine di ricerca","Invece di cercare un account specifico, puoi anche cercare un termine di ricerca. Se vengono specificati l'account e il termine di ricerca, l'account viene recuperato e il termine di ricerca viene cercato nei tweet."); -$GLOBALS['TL_LANG']['tl_social_feed']['show_retweets'] = array("Importa anche i retweet","Se questa opzione è attivata, vengono importati anche i retweet."); -$GLOBALS['TL_LANG']['tl_social_feed']['show_reply'] = array("Importa anche le risposte","Se questa opzione è attivata, verranno importate anche le risposte."); -$GLOBALS['TL_LANG']['tl_social_feed']['hashtags_link'] = array("Link hashtag e menzioni","Se questa opzione è attivata, gli hashtag e le menzioni sono collegati. A tale scopo è necessario utilizzare il modello esteso."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_key'] = array("API Key","Inserisci qui la API Key."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_secret_key'] = array("API Secret Key","Inserisci qui la chiave segreta dell'API."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token'] = array("Access Token","Inserisci qui il token di accesso."); -$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token_secret'] = array("Access Token Secret","Inserisci qui l\'Access Token Secret."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_id'] = array("Client ID","Inserisci qui l'ID cliente dall'app."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_secret'] = array("Client Secret","Inserisci qui il client secret dall'app."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_company_id'] = array("ID sito aziendale","Inserisci qui l'ID del sito aziendale."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_access_token'] = array("Access Token","Il token di accesso viene impostato automaticamente dopo aver salvato e impostato la casella di controllo."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_request_token'] = array("Genera access token","Se selezioni la casella e poi salvi, viene generato il token di accesso."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture'] = array("Immagine del profilo","Seleziona qui un'immagine del profilo, che verrà visualizzata sul sito web."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture_size'] = array("Dimensione dell'immagine"," -Qui puoi impostare le dimensioni dell'immagine e la modalità di ridimensionamento."); -$GLOBALS['TL_LANG']['tl_social_feed']['access_token_expires'] = array("Access Token scade il","Finché il token di aggiornamento è valido, il token di accesso viene automaticamente esteso di 2 mesi alla volta."); -$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_refresh_token_expires'] = array("Refresh Token scade il","Se il token di aggiornamento è scaduto, il token di accesso deve essere rigenerato manualmente."); - +$GLOBALS['TL_LANG']['tl_social_feed']['socialFeedType'] = ['Tipologia Account', 'Selezionare il tipo di account.']; +$GLOBALS['TL_LANG']['tl_social_feed']['no_cronjob'] = 'Nessun Cronjob'; +$GLOBALS['TL_LANG']['tl_social_feed']['minutely'] = 'Ogni minuto'; +$GLOBALS['TL_LANG']['tl_social_feed']['hourly'] = 'Ogni ora'; +$GLOBALS['TL_LANG']['tl_social_feed']['daily'] = 'Ogni giorno'; +$GLOBALS['TL_LANG']['tl_social_feed']['monthly'] = 'Ogni mese'; +$GLOBALS['TL_LANG']['tl_social_feed']['weekly'] = 'Ogni settimana'; +$GLOBALS['TL_LANG']['tl_social_feed']['number_posts'] = ['Numero massimo di post', 'Inserisci qui il numero massimo di post da importare.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_account'] = ['Account Twitter', 'Inserisci qui il nome del tuo account Twitter (senza @).']; +$GLOBALS['TL_LANG']['tl_social_feed']['search'] = ['Termine di ricerca', "Invece di cercare un account specifico, puoi anche cercare un termine di ricerca. Se vengono specificati l'account e il termine di ricerca, l'account viene recuperato e il termine di ricerca viene cercato nei tweet."]; +$GLOBALS['TL_LANG']['tl_social_feed']['show_retweets'] = ['Importa anche i retweet', 'Se questa opzione è attivata, vengono importati anche i retweet.']; +$GLOBALS['TL_LANG']['tl_social_feed']['show_reply'] = ['Importa anche le risposte', 'Se questa opzione è attivata, verranno importate anche le risposte.']; +$GLOBALS['TL_LANG']['tl_social_feed']['hashtags_link'] = ['Link hashtag e menzioni', 'Se questa opzione è attivata, gli hashtag e le menzioni sono collegati. A tale scopo è necessario utilizzare il modello esteso.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_key'] = ['API Key', 'Inserisci qui la API Key.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_api_secret_key'] = ['API Secret Key', "Inserisci qui la chiave segreta dell'API."]; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token'] = ['Access Token', 'Inserisci qui il token di accesso.']; +$GLOBALS['TL_LANG']['tl_social_feed']['twitter_access_token_secret'] = ['Access Token Secret', "Inserisci qui l\\'Access Token Secret."]; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_id'] = ['Client ID', "Inserisci qui l'ID cliente dall'app."]; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_client_secret'] = ['Client Secret', "Inserisci qui il client secret dall'app."]; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_company_id'] = ['ID sito aziendale', "Inserisci qui l'ID del sito aziendale."]; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_access_token'] = ['Access Token', 'Il token di accesso viene impostato automaticamente dopo aver salvato e impostato la casella di controllo.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_request_token'] = ['Genera access token', 'Se selezioni la casella e poi salvi, viene generato il token di accesso.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture'] = ['Immagine del profilo', "Seleziona qui un'immagine del profilo, che verrà visualizzata sul sito web."]; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_account_picture_size'] = ["Dimensione dell'immagine", " +Qui puoi impostare le dimensioni dell'immagine e la modalità di ridimensionamento."]; +$GLOBALS['TL_LANG']['tl_social_feed']['access_token_expires'] = ['Access Token scade il', 'Finché il token di aggiornamento è valido, il token di accesso viene automaticamente esteso di 2 mesi alla volta.']; +$GLOBALS['TL_LANG']['tl_social_feed']['linkedin_refresh_token_expires'] = ['Refresh Token scade il', 'Se il token di aggiornamento è scaduto, il token di accesso deve essere rigenerato manualmente.']; diff --git a/src/SocialFeed/SocialFeedNewsClass.php b/src/SocialFeed/SocialFeedNewsClass.php index 0bb7f79..a1f273d 100644 --- a/src/SocialFeed/SocialFeedNewsClass.php +++ b/src/SocialFeed/SocialFeedNewsClass.php @@ -1,24 +1,44 @@ + * @author Philipp Seibt + * @author pdir GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -use Pdir\SocialFeedBundle\Model\SocialFeedModel as SocialFeedModel; +namespace Pdir\SocialFeedBundle\SocialFeed; -class SocialFeedNewsClass { +use Contao\FilesModel; +use Contao\Picture; +use Contao\StringUtil; +use Pdir\SocialFeedBundle\Model\SocialFeedModel; - public function parseNews($objTemplate, $arrRow, $objModule) +class SocialFeedNewsClass +{ + public function parseNews($objTemplate, $arrRow, $objModule): void { - if($arrRow['social_feed_id'] != "") { + if ('' !== $arrRow['social_feed_id']) { + $teaser = $arrRow['teaser']; + + if ($objModule->pdir_sf_text_length > 0) { + $more = ''; - if($objModule->pdir_sf_text_length > 0) { - $teaser = $arrRow['teaser']; - $more = ""; - if( strlen($teaser) > $objModule->pdir_sf_text_length) { - $more = " ..."; + if (\strlen($teaser) > $objModule->pdir_sf_text_length) { + $more = ' ...'; } - $teaser = \StringUtil::substrHtml($teaser,$objModule->pdir_sf_text_length).$more; - } else { - $teaser = $arrRow['teaser']; + $teaser = StringUtil::substrHtml($teaser, $objModule->pdir_sf_text_length).$more; } $objTemplate->sfFbAccountPicture = $arrRow['social_feed_account_picture']; @@ -28,34 +48,35 @@ public function parseNews($objTemplate, $arrRow, $objModule) $objTemplate->teaser = $teaser; $objTemplate->socialFeedType = $arrRow['social_feed_type']; - if('' != $arrRow['social_feed_account_picture']) { - $imagePath = \FilesModel::findByUuid($arrRow['social_feed_account_picture'])->path; + if ('' !== $arrRow['social_feed_account_picture']) { + $imagePath = FilesModel::findByUuid($arrRow['social_feed_account_picture'])->path; - if(null === $imagePath) { + if (null === $imagePath) { $objTemplate->accountPicture = ''; } - if(null !== $imagePath) { - $pictureObj = \Picture::create($imagePath); + if (null !== $imagePath) { + $pictureObj = Picture::create($imagePath); - if ($pictureObj !== null && $pictureObj->size > 0) { - $objTemplate->accountPicture = $pictureObj->getTemplateData(); + if (null !== $pictureObj && $pictureObj->size > 0) { + $objTemplate->accountPicture = $pictureObj->getTemplateData(); } } } else { $socialFeedAccount = SocialFeedModel::findBy('id', $arrRow['social_feed_config']); - if ($socialFeedAccount->instagram_account_picture != "") { - $imagePath = \FilesModel::findByUuid($socialFeedAccount->instagram_account_picture)->path; + + if ('' !== $socialFeedAccount->instagram_account_picture) { + $imagePath = FilesModel::findByUuid($socialFeedAccount->instagram_account_picture)->path; $size = deserialize($socialFeedAccount->instagram_account_picture_size); - $objTemplate->accountPicture = \Picture::create($imagePath, $size)->getTemplateData(); - } else if($socialFeedAccount->linkedin_account_picture != "") { - $imagePath = \FilesModel::findByUuid($socialFeedAccount->linkedin_account_picture)->path; + $objTemplate->accountPicture = Picture::create($imagePath, $size)->getTemplateData(); + } elseif ('' !== $socialFeedAccount->linkedin_account_picture) { + $imagePath = FilesModel::findByUuid($socialFeedAccount->linkedin_account_picture)->path; $size = deserialize($socialFeedAccount->linkedin_account_picture_size); - $objTemplate->accountPicture = \Picture::create($imagePath, $size)->getTemplateData(); + $objTemplate->accountPicture = Picture::create($imagePath, $size)->getTemplateData(); } } - if($arrRow['social_feed_account'] != "") { + if ('' !== $arrRow['social_feed_account']) { $objTemplate->sfFbAccount = $arrRow['social_feed_account']; } else { $socialFeedAccount = SocialFeedModel::findBy('id', $arrRow['social_feed_config']); @@ -63,5 +84,4 @@ public function parseNews($objTemplate, $arrRow, $objModule) } } } - }