Commit bfe242a1 authored by Stefan Busemann's avatar Stefan Busemann

Merge branch 'task/update-to-v10' into 'master'

Task/update to v10

See merge request !5
parents a3f3c402 0d71bc05
<?php
declare(strict_types=1);
namespace T3o\Certifications\Controller;
/**
......@@ -20,7 +21,6 @@ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class ListingController extends ActionController
{
/**
* feUsersRepository
*
......@@ -28,19 +28,30 @@ class ListingController extends ActionController
*/
protected $userRepository;
/**
* injectFeUsersRepository
*
* @param UserRepository $userRepository
* @return void
*/
public function injectFeUsersRepository(UserRepository $userRepository): void
{
$this->userRepository = $userRepository;
}
/**
* listAction
*
* @param string $char
* @return void
*/
public function listAction($char = NULL)
public function listAction($char = null): void
{
if (empty($char)) {
$char = 'A';
}
$chars = range('A', 'Z');
array_push($chars, '#');
$chars[] = '#';
$feUsers = $this->userRepository->findByFirstChar($char);
$this->view->assignMultiple(
[
......@@ -50,29 +61,4 @@ class ListingController extends ActionController
]
);
}
/**
* action show
*
* @param User $user
* @return void
*/
public function showAction(User $user)
{
$this->view->assign('certUser', $user);
}
/**
* injectFeUsersRepository
*
* @param UserRepository $userRepository
* @return void
*/
public function injectFeUsersRepository(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
}
?>
\ No newline at end of file
<?php
declare(strict_types=1);
namespace T3o\Certifications\Domain\Model;
/**
......@@ -24,30 +25,29 @@ class Certificate extends AbstractEntity
* certificationDate
*
* @var DateTime
* @TYPO3\CMS\Extbase\Annotation\Validate NotEmpty
*/
protected $certificationDate;
protected $certificationDate = null;
/**
* expirationDate
*
* @var DateTime
*/
protected $expirationDate;
protected $expirationDate = null;
/**
* allowListing
*
* @var boolean
*/
protected $allowListing = TRUE;
protected $allowListing = true;
/**
* true for all certifications for 4.x
*
* @var boolean
*/
protected $versionFour = FALSE;
protected $versionFour = false;
/**
* certificateType
......@@ -61,7 +61,7 @@ class Certificate extends AbstractEntity
*
* @return DateTime $certificationDate
*/
public function getCertificationDate()
public function getCertificationDate(): ?DateTime
{
return $this->certificationDate;
}
......@@ -72,7 +72,7 @@ class Certificate extends AbstractEntity
* @param DateTime $certificationDate
* @return void
*/
public function setCertificationDate($certificationDate)
public function setCertificationDate(DateTime $certificationDate): void
{
$this->certificationDate = $certificationDate;
}
......@@ -82,7 +82,7 @@ class Certificate extends AbstractEntity
*
* @return DateTime $expirationDate
*/
public function getExpirationDate()
public function getExpirationDate(): ?DateTime
{
return $this->expirationDate;
}
......@@ -93,17 +93,27 @@ class Certificate extends AbstractEntity
* @param DateTime $expirationDate
* @return void
*/
public function setExpirationDate($expirationDate)
public function setExpirationDate(DateTime $expirationDate): void
{
$this->expirationDate = $expirationDate;
}
/**
* Returns the boolean state of allowListing
*
* @return boolean
*/
public function isAllowListing(): bool
{
return $this->getAllowListing();
}
/**
* Returns the allowListing
*
* @return boolean $allowListing
*/
public function getAllowListing()
public function getAllowListing(): bool
{
return $this->allowListing;
}
......@@ -114,19 +124,19 @@ class Certificate extends AbstractEntity
* @param boolean $allowListing
* @return void
*/
public function setAllowListing($allowListing)
public function setAllowListing(bool $allowListing): void
{
$this->allowListing = $allowListing;
}
/**
* Returns the boolean state of allowListing
* Returns the boolean state of version_four
*
* @return boolean
*/
public function isAllowListing()
public function isVersionFour(): bool
{
return $this->getAllowListing();
return $this->getVersionFour();
}
/**
......@@ -134,7 +144,7 @@ class Certificate extends AbstractEntity
*
* @return boolean $version_four
*/
public function getVersionFour()
public function getVersionFour(): bool
{
return $this->versionFour;
}
......@@ -145,27 +155,17 @@ class Certificate extends AbstractEntity
* @param boolean $version_four
* @return void
*/
public function setVersionFour($versionFour)
public function setVersionFour(bool $versionFour): void
{
$this->versionFour = $versionFour;
}
/**
* Returns the boolean state of version_four
*
* @return boolean
*/
public function isVersionFour()
{
return $this->getVersionFour();
}
/**
* Returns the certificateType
*
* @return CertificateType $certificateType
*/
public function getCertificateType()
public function getCertificateType(): CertificateType
{
return $this->certificateType;
}
......@@ -176,11 +176,9 @@ class Certificate extends AbstractEntity
* @param CertificateType $certificateType
* @return void
*/
public function setCertificateType(CertificateType $certificateType)
public function setCertificateType(CertificateType $certificateType): void
{
$this->certificateType = $certificateType;
}
}
?>
\ No newline at end of file
<?php
declare(strict_types=1);
namespace T3o\Certifications\Domain\Model;
/**
......@@ -31,7 +32,7 @@ class CertificateType extends AbstractEntity
*
* @return string $title
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}
......@@ -42,11 +43,9 @@ class CertificateType extends AbstractEntity
* @param string $title
* @return void
*/
public function setTitle($title)
public function setTitle(string $title): void
{
$this->title = $title;
}
}
?>
\ No newline at end of file
This diff is collapsed.
......@@ -22,11 +22,7 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
class UserRepository extends Repository
{
/**
* @return array|QueryResultInterface
*/
public function findAll()
public function findAll(): QueryResultInterface
{
$query = $this->createQuery();
$query->setOrderings([
......@@ -34,17 +30,11 @@ class UserRepository extends Repository
'first_name' => QueryInterface::ORDER_ASCENDING,
'country' => QueryInterface::ORDER_ASCENDING
]);
$return = $query->execute();
return $return;
return $query->execute();
}
/**
* findByFistChar
*
* @param string $char
* @return QueryResultInterface
*/
public function findByFirstChar($char = 'A')
public function findByFirstChar(string $char = 'A'): QueryResultInterface
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('fe_users');
$char = $queryBuilder->escapeLikeWildcards($char);
......@@ -73,56 +63,7 @@ class UserRepository extends Repository
$query->logicalOr($constraints)
)
);
return $query->execute();
}
/**
* @param $sortby
* @param $sorting
* @return array|QueryResultInterface
*/
public function findBySortBy($sortby, $sorting)
{
$query = $this->createQuery();
if ($sortby === 'country') {
if ($sorting === 'asc') {
$query->setOrderings([
'country' => QueryInterface::ORDER_ASCENDING,
'last_name' => QueryInterface::ORDER_ASCENDING,
'first_name' => QueryInterface::ORDER_ASCENDING,
'certificates' => QueryInterface::ORDER_ASCENDING
]);
} elseif ($sorting === 'desc') {
$query->setOrderings([
'country' => QueryInterface::ORDER_DESCENDING,
'last_name' => QueryInterface::ORDER_ASCENDING,
'first_name' => QueryInterface::ORDER_ASCENDING,
'certificates' => QueryInterface::ORDER_ASCENDING
]);
}
} elseif ($sortby === 'certificate') {
if ($sorting === 'asc') {
$query->setOrderings([
'certificates' => QueryInterface::ORDER_ASCENDING,
'last_name' => QueryInterface::ORDER_ASCENDING,
'first_name' => QueryInterface::ORDER_ASCENDING,
'country' => QueryInterface::ORDER_ASCENDING
]);
} elseif ($sorting === 'desc') {
$query->setOrderings([
'certificates' => QueryInterface::ORDER_DESCENDING,
'last_name' => QueryInterface::ORDER_ASCENDING,
'first_name' => QueryInterface::ORDER_ASCENDING,
'country' => QueryInterface::ORDER_ASCENDING
]);
}
}
$return = $query->execute();
return $return;
return $query->execute();
}
}
?>
<?php
namespace T3o\Certifications\ViewHelpers;
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use stdClass;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
/**
* Resizes a given image (if required) and renders the respective img tag
*
* = Examples =
*
* <code title="Default">
* <f:image src="EXT:myext/Resources/Public/typo3_logo.png" alt="alt text" />
* </code>
* <output>
* <img alt="alt text" src="typo3conf/ext/myext/Resources/Public/typo3_logo.png" width="396" height="375" />
* or (in BE mode):
* <img alt="alt text" src="../typo3conf/ext/viewhelpertest/Resources/Public/typo3_logo.png" width="396" height="375" />
* </output>
*
* <code title="Inline notation">
* {f:image(src: 'EXT:viewhelpertest/Resources/Public/typo3_logo.png', alt: 'alt text', minWidth: 30, maxWidth: 40)}
* </code>
* <output>
* <img alt="alt text" src="../typo3temp/pics/f13d79a526.png" width="40" height="38" />
* (depending on your TYPO3s encryption key)
* </output>
*
* <code title="non existing image">
* <f:image src="NonExistingImage.png" alt="foo" />
* </code>
* <output>
* Could not get image resource for "NonExistingImage.png".
* </output>
*/
class GrayImageViewHelper extends AbstractTagBasedViewHelper
{
/**
* @var ContentObjectRenderer
*/
protected $contentObject;
/**
* @var string
*/
protected $tagName = 'img';
/**
* @var TypoScriptFrontendController contains a backup of the current $GLOBALS['TSFE'] if used in BE mode
*/
protected $tsfeBackup;
/**
* @var string
*/
protected $workingDirectoryBackup;
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @param ConfigurationManagerInterface $configurationManager
* @return void
*/
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
$this->configurationManager = $configurationManager;
$this->contentObject = $this->configurationManager->getContentObject();
}
/**
* Initialize arguments.
*
* @return void
* @author Bastian Waidelich <bastian@typo3.org>
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerTagAttribute('alt', 'string', 'Specifies an alternate text for an image', TRUE);
$this->registerTagAttribute('ismap', 'string', 'Specifies an image as a server-side image-map. Rarely used. Look at usemap instead', FALSE);
$this->registerTagAttribute('longdesc', 'string', 'Specifies the URL to a document that contains a long description of an image', FALSE);
$this->registerTagAttribute('usemap', 'string', 'Specifies an image as a client-side image-map', FALSE);
}
/**
* Resizes a given image (if required) and renders the respective img tag
* @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4164427
*
* @param string $src
* @param string $width width of the image. This can be a numeric value representing the fixed width of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
* @param string $height height of the image. This can be a numeric value representing the fixed height of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
* @param integer $minWidth minimum width of the image
* @param integer $minHeight minimum height of the image
* @param integer $maxWidth maximum width of the image
* @param integer $maxHeight maximum height of the image
*
* @return string rendered tag.
* @author Sebastian Böttger <sboettger@cross-content.com>
* @author Bastian Waidelich <bastian@typo3.org>
*/
public function render($src, $width = NULL, $height = NULL, $minWidth = NULL, $minHeight = NULL, $maxWidth = NULL, $maxHeight = NULL)
{
if (TYPO3_MODE === 'BE') {
$this->simulateFrontendEnvironment();
}
$setup = [
'width' => $width,
'height' => $height,
'minW' => $minWidth,
'minH' => $minHeight,
'maxW' => $maxWidth,
'maxH' => $maxHeight
];
if (TYPO3_MODE === 'BE' && substr($src, 0, 3) === '../') {
$src = substr($src, 3);
}
$imageInfo = $this->contentObject->getImgResource($src, $setup);
$GLOBALS['TSFE']->lastImageInfo = $imageInfo;
if (!is_array($imageInfo)) {
if (TYPO3_MODE === 'BE') {
$this->resetFrontendEnvironment();
}
throw new Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
}
$imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
//Convert to grey
$newFile = substr($imageInfo[3], 0, -4) . '.jpg';
$cmd = CommandUtility::imageMagickCommand('convert', '"' . $imageInfo[3] . '" -colorspace Gray "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
CommandUtility::exec($cmd);
$imageInfo[3] = $newFile;
if (@is_file($newFile)) {
GeneralUtility::fixPermissions($newFile);
}
$GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
$imageSource = $GLOBALS['TSFE']->absRefPrefix . rawUrlEncodeFP($imageInfo[3]);
if (TYPO3_MODE === 'BE') {
$imageSource = '../' . $imageSource;
$this->resetFrontendEnvironment();
}
$this->tag->addAttribute('src', $imageSource);
$this->tag->addAttribute('width', $imageInfo[0]);
$this->tag->addAttribute('height', $imageInfo[1]);
//the alt-attribute is mandatory to have valid html-code, therefore add it even if it is empty
if (empty($this->arguments['alt'])) {
$this->tag->addAttribute('alt', '');
}
if (empty($this->arguments['title']) && !empty($this->arguments['alt'])) {
$this->tag->addAttribute('title', $this->arguments['alt']);
}
return $this->tag->render();
}
/**
* Prepares $GLOBALS['TSFE'] for Backend mode
* This somewhat hacky work around is currently needed because the getImgResource() function of tslib_cObj relies on those variables to be set
*
* @return void
* @author Bastian Waidelich <bastian@typo3.org>
*/
protected function simulateFrontendEnvironment()
{
$this->tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : NULL;
// set the working directory to the site root
$this->workingDirectoryBackup = getcwd();
chdir(Environment::getPublicPath() . '/');
$typoScriptSetup = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$GLOBALS['TSFE'] = new stdClass();
$template = GeneralUtility::makeInstance('t3lib_TStemplate');
$template->tt_track = 0;
$template->init();
$template->getFileName_backPath = Environment::getPublicPath() . '/';
$GLOBALS['TSFE']->tmpl = $template;
$GLOBALS['TSFE']->tmpl->setup = $typoScriptSetup;
$GLOBALS['TSFE']->config = $typoScriptSetup;
}
/**
* Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()
*
* @return void
* @author Bastian Waidelich <bastian@typo3.org>
* @see simulateFrontendEnvironment()
*/
protected function resetFrontendEnvironment()
{
$GLOBALS['TSFE'] = $this->tsfeBackup;
chdir($this->workingDirectoryBackup);
}
}
\ No newline at end of file
#
# Extension Builder settings for extension certifications
# generated 2014-04-24
#
# See http://www.yaml.org/spec/1.2/spec.html
#
---
########### Overwrite settings ###########
#
# These settings only apply, if the roundtrip feature of the extension builder
# is enabled in the extension manager
#
# Usage:
# nesting reflects the file structure
# a setting applies to a file or recursive to all files and subfolders
#
# merge:
# means for classes: All properties ,methods and method bodies
# of the existing class will be modified according to the new settings
# but not overwritten
#
# for locallang xml files: Existing keys and labels are always
# preserved (renaming in the GUI has only influence on the property and method names)
#
# for other files: You will find a Split token at the end of the file
# After this token you can write whatever you want and it will be appended
# everytime the code is generated
#
# keep:
# files are never overwritten
# These settings may break the functionality of the extension builder!
# Handle with care!
#
#
############ extension settings ##############
overwriteSettings:
Classes:
Controller: merge
Domain:
Model: merge
Repository: merge
Configuration:
#TCA: merge
#TypoScript: keep
Resources:
Private:
Language: