Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Classes/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
declare(strict_types=1);
namespace In2code\Instagram\Controller;

use Psr\Http\Message\ResponseInterface;
use In2code\Instagram\Domain\Repository\FeedRepository;
use In2code\Instagram\Domain\Repository\TokenRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
Expand Down Expand Up @@ -35,13 +36,14 @@ public function __construct(FeedRepository $feedRepository, TokenRepository $tok
/**
* @return void
*/
public function showAction()
public function showAction(): ResponseInterface
{
$feed = $this->feedRepository->findDataByUsername((string)$this->settings['username']);
$this->view->assignMultiple([
'data' => $this->configurationManager->getContentObject()->data,
'feed' => $feed,
'token' => $this->tokenRepository->findValidTokenByUsername((string)$this->settings['username'])
]);
return $this->htmlResponse();
}
}
14 changes: 7 additions & 7 deletions Classes/Domain/Repository/FeedRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ class FeedRepository
public function findDataByUsername(string $username): array
{
$queryBuilder = DatabaseUtility::getQueryBuilderForTable(self::TABLE_NAME);
$data = (string)$queryBuilder
$data = $queryBuilder
->select('data')
->from(self::TABLE_NAME)
->where(
$queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username))
)
->setMaxResults(1)
->orderBy('uid', 'desc')
->execute()
->fetchColumn();
if (ArrayUtility::isJsonArray($data)) {
return json_decode($data, true);
->executeQuery()
->fetchFirstColumn();
if (ArrayUtility::isJsonArray($data[0])) {
return json_decode($data[0], true);
}
return [];
}
Expand Down Expand Up @@ -59,7 +59,7 @@ protected function deleteByUsername(string $username): void
->where(
$queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username))
)
->execute();
->executeStatement();
}

/**
Expand All @@ -77,6 +77,6 @@ protected function insertByUsername(string $username, array $feed): void
'data' => json_encode($feed),
'import_date' => time()
])
->execute();
->executeStatement();
}
}
22 changes: 11 additions & 11 deletions Classes/Domain/Repository/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function addEmptyToken(string $username, string $appId, string $appSecret
'app_return_url' => $appReturnUrl,
'crdate' => time(),
])
->execute();
->executeStatement();
}

/**
Expand All @@ -58,16 +58,16 @@ public function addEmptyToken(string $username, string $appId, string $appSecret
public function updateToken(string $username, string $token, int $expires, $userId = '0'): void
{
$queryBuilder = DatabaseUtility::getQueryBuilderForTable(self::TABLE_NAME);
$uid = (int)$queryBuilder
$uid = $queryBuilder
->select('uid')
->from(self::TABLE_NAME)
->where(
$queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username))
)
->orderBy('crdate', 'desc')
->execute()
->fetchColumn();
if ($uid === 0) {
->executeQuery()
->fetchFirstColumn();
if (empty($uid)) {
throw new ConfigurationException('No empty token record found that can be extended', 1615748471);
}

Expand All @@ -79,7 +79,7 @@ public function updateToken(string $username, string $token, int $expires, $user
$properties += ['user_id' => $userId];
}
$connection = DatabaseUtility::getConnectionForTable(self::TABLE_NAME);
$connection->update(self::TABLE_NAME, $properties, ['uid' => (int)$uid]);
$connection->update(self::TABLE_NAME, $properties, ['uid' => (int)$uid[0]]);
}

/**
Expand All @@ -99,8 +99,8 @@ public function findLatestEmptyToken(): array
$queryBuilder->expr()->eq('expire_date', 0)
)
->orderBy('crdate', 'desc')
->execute()
->fetch();
->executeQuery()
->fetchAssociative();
if ($username === false) {
throw new ConfigurationException('No empty token record found that can be filled', 1615750700);
}
Expand Down Expand Up @@ -135,8 +135,8 @@ public function findValidTokenByUsername(string $username): array
$queryBuilder->expr()->gt('expire_date', time())
)
->orderBy('crdate', 'desc')
->execute()
->fetch();
->executeQuery()
->fetchAssociative();
if ($token === false) {
return [];
}
Expand All @@ -157,7 +157,7 @@ protected function removeTokensByUsername(string $username): void
->where(
$queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username))
)
->execute();
->executeStatement();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Classes/Hooks/PageLayoutView/AbstractPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace In2code\Instagram\Hooks\PageLayoutView;

use In2code\Instagram\Exception\ConfigurationException;
use TYPO3\CMS\Backend\Preview\StandardContentPreviewRenderer;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use TYPO3\CMS\Core\Service\FlexFormService;
Expand All @@ -13,7 +14,7 @@
/**
* Class AbstractPreviewRenderer
*/
abstract class AbstractPreviewRenderer implements PageLayoutViewDrawItemHookInterface
abstract class AbstractPreviewRenderer extends StandardContentPreviewRenderer
{
/**
* @var array tt_content.*
Expand Down
1 change: 1 addition & 0 deletions Classes/Tca/GetToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
class GetToken extends AbstractFormElement
{

/**
* Note when a token is nearly expired - define the number of days
*
Expand Down
4 changes: 4 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ services:
autoconfigure: true
public: false

In2code\Instagram\:
resource: '../Classes/*'
exclude: '../Classes/{Domain/Model}'

In2code\Instagram\Command\ImportFeedCommand:
tags:
- name: 'console.command'
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/sys_template.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('TYPO3_MODE') || die();
defined('TYPO3') || die();

/**
* Register Static Template
Expand Down
4 changes: 2 additions & 2 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
defined('TYPO3_MODE') || die();
defined('TYPO3') || die();

/**
* Register Plugins
*/
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('instagram', 'Pi1', 'Instagram');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('Instagram', 'Pi1', 'Instagram');

/**
* Disable not needed fields in tt_content
Expand Down
10 changes: 10 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@ page {
includeCSS {
instagram = EXT:instagram/Resources/Public/Css/style.css
}
}

plugin {
tx_instagram_pi1 {
view {
templateRootPaths {
0 = EXT:instagram/Resources/Private/Templates/
}
}
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"type": "typo3-cms-extension",
"license": "GPL-2.0-or-later",
"require": {
"php": "^7.2",
"typo3/cms-core": "^10.4 || ^11.5",
"php": "^7.2 || ^8.0",
"typo3/cms-core": "^11.5 || ^12",
"ext-json": "*"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
'state' => 'stable',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-11.5.99',
'php' => '7.2.0-7.99.99'
'typo3' => '11.5.0-12.5.99',
'php' => '7.2.0-8.1.99'
],
'conflicts' => [],
'suggests' => [],
Expand Down
20 changes: 12 additions & 8 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

if (!defined('TYPO3_MODE')) {
use In2code\Instagram\Controller\ProfileController;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

if (!defined('TYPO3')) {
die('Access denied.');
}

Expand All @@ -9,18 +13,18 @@ function () {
/**
* Include Frontend Plugins
*/
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'In2code.instagram',
ExtensionUtility::configurePlugin(
'Instagram',
'Pi1',
[
In2code\Instagram\Controller\ProfileController::class => 'show'
]
[ProfileController::class => 'show'],
[],
ExtensionUtility::PLUGIN_TYPE_PLUGIN
);

/**
* Caching framework
*/
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['instagram'])) {
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['instagram'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['instagram'] = [];
}

Expand All @@ -36,7 +40,7 @@ function () {
/**
* ContentElementWizard
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
ExtensionManagementUtility::addPageTSConfig(
'@import "EXT:instagram/Configuration/TSConfig/ContentElementWizard.typoscript"'
);
}
Expand Down
2 changes: 1 addition & 1 deletion ext_tables.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('TYPO3_MODE') || die();
defined('TYPO3') || die();

call_user_func(
function () {
Expand Down