...
 
Commits (4)
cache:
key: "$CI_BUILD_REF_NAME-$CI_BUILD_STAGE"
paths:
- .composer/
- .php_cs.cache
variables:
COMPOSER_CACHE_DIR: ".composer"
COMPOSER_PROCESS_TIMEOUT: "1800"
COMPOSER_ALLOW_SUPERUSER: "1"
TYPO3_PATH_WEB: "$CI_PROJECT_DIR/.Build/Web"
TYPO3_VERSION: ^9
MYSQL_DATABASE: "typo3"
MYSQL_ROOT_PASSWORD: "joh316"
typo3DatabaseName: "typo3"
typo3DatabaseHost: "mysql"
typo3DatabaseUsername: "root"
typo3DatabasePassword: "joh316"
cgl:
image: composer
stage: test
before_script:
- composer require typo3/minimal="${TYPO3_VERSION}"
- composer install
script:
- .Build/bin/php-cs-fixer fix --config=Build/.php_cs.php -v --dry-run --using-cache=no --path-mode=intersection `git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE`
typo3_8lts_php70:
variables:
TYPO3_VERSION: ^8
image: php:7.0-alpine
stage: test
services:
- mysql:5
before_script:
- apk --no-cache add bash curl git mercurial openssh openssl parallel subversion tini
- docker-php-ext-install mysqli
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- composer require typo3/cms="${TYPO3_VERSION}"
script:
- .Build/bin/phpunit --colors -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/
typo3_8lts_php71:
variables:
TYPO3_VERSION: ^8
image: php:7.1-alpine
stage: test
services:
- mysql:5
before_script:
- apk --no-cache add bash curl git mercurial openssh openssl parallel subversion tini
- docker-php-ext-install mysqli
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- composer require typo3/cms="${TYPO3_VERSION}"
script:
- .Build/bin/phpunit --colors -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/
typo3_8lts_php72:
variables:
TYPO3_VERSION: ^8
image: php:7.2-alpine
stage: test
services:
- mysql:5
before_script:
- apk --no-cache add bash curl git mercurial openssh openssl parallel subversion tini
- docker-php-ext-install mysqli
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- composer require typo3/cms="${TYPO3_VERSION}"
script:
- .Build/bin/phpunit --colors -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/
typo3_8lts_php73:
variables:
TYPO3_VERSION: ^8
image: php:7.3-alpine
stage: test
services:
- mysql:5
before_script:
- apk --no-cache add bash curl git mercurial openssh openssl parallel subversion tini
- docker-php-ext-install mysqli
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- composer require typo3/cms="${TYPO3_VERSION}"
script:
- .Build/bin/phpunit --colors -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/
typo3_9lts_php72:
variables:
TYPO3_VERSION: ^9
image: php:7.2-alpine
stage: test
services:
- mysql:5
before_script:
- apk --no-cache add bash curl git mercurial openssh openssl parallel subversion tini
- docker-php-ext-install mysqli
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- composer require typo3/minimal="${TYPO3_VERSION}"
script:
- .Build/bin/phpunit --colors -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/
typo3_9lts_php73:
variables:
TYPO3_VERSION: ^9
image: php:7.3-alpine
stage: test
services:
- mysql:5
before_script:
- apk --no-cache add bash curl git mercurial openssh openssl parallel subversion tini
- docker-php-ext-install mysqli
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- composer require typo3/minimal="${TYPO3_VERSION}"
script:
- .Build/bin/phpunit --colors -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/
<?php
/**
* This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines
* Install @fabpot's great php-cs-fixer tool via
*
* $ composer global require friendsofphp/php-cs-fixer
*
* And then simply run
*
* $ php-cs-fixer fix --config ../Build/.php_cs
*
* inside the TYPO3 directory. Warning: This may take up to 10 minutes.
*
* For more information read:
* https://www.php-fig.org/psr/psr-2/
* https://cs.sensiolabs.org
*/
if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}
// Define in which folders to search and which folders to exclude
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/../');
// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
// - Remove leading slashes in use clauses.
// - PHP single-line arrays should not have trailing comma.
// - Single-line whitespace before closing semicolon are prohibited.
// - Remove unused use statements in the PHP source code
// - Ensure Concatenation to have at least one whitespace around
// - Remove trailing whitespace at the end of blank lines.
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@DoctrineAnnotation' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'concat_space' => ['spacing' => 'one'],
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'single_quote' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'no_blank_lines_after_phpdoc' => true,
'array_syntax' => ['syntax' => 'short'],
'whitespace_after_comma_in_array' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'no_alias_functions' => true,
'lowercase_cast' => true,
'no_leading_namespace_whitespace' => true,
'native_function_casing' => true,
'no_short_bool_cast' => true,
'no_unneeded_control_parentheses' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_trim' => true,
'no_superfluous_elseif' => true,
'no_useless_else' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'cast_spaces' => ['space' => 'none'],
'declare_equal_normalize' => ['space' => 'single'],
'dir_constant' => true,
'phpdoc_no_access' => true
])
->setFinder($finder);
......@@ -20,7 +20,7 @@ use TYPO3\CMS\Backend\Module\BaseScriptClass;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Cal\Controller\DateParser;
use TYPO3\CMS\Cal\Model\CalDate;
use TYPO3\CMS\Cal\Model\CalendarDateTime;
use TYPO3\CMS\Cal\Utility\RecurrenceGenerator;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -359,9 +359,9 @@ class CalIndexer extends BaseScriptClass
/**
* @param $timeString
* @return CalDate
* @return CalendarDateTime
*/
private function getTimeParsed($timeString): CalDate
private function getTimeParsed($timeString): CalendarDateTime
{
$dp = GeneralUtility::makeInstance(DateParser::class);
$dp->parse($timeString, 0, '');
......
......@@ -18,7 +18,7 @@ use TYPO3\CMS\Backend\Module\BaseScriptClass;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Cal\Controller\DateParser;
use TYPO3\CMS\Cal\Model\CalDate;
use TYPO3\CMS\Cal\Model\CalendarDateTime;
use TYPO3\CMS\Cal\Utility\RecurrenceGenerator;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -265,9 +265,9 @@ class CalIndexerOld extends BaseScriptClass
/**
* @param $timeString
* @return CalDate
* @return CalendarDateTime
*/
private function getTimeParsed($timeString): CalDate
private function getTimeParsed($timeString): CalendarDateTime
{
$dp = GeneralUtility::makeInstance(DateParser::class);
$dp->parse($timeString, 0, '');
......
......@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Cal\Backend\TCA;
* The TYPO3 extension Calendar Base (cal) project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Cal\Model\CalDate;
use TYPO3\CMS\Cal\Model\CalendarDateTime;
/**
* Class Labels
......@@ -30,27 +30,17 @@ class Labels
*/
public function getEventRecordLabel(&$params, &$pObj)
{
if ($params['table'] != 'tx_cal_event' && $params['table'] != 'tx_cal_exception_event') {
if ($params['table'] !== 'tx_cal_event' && $params['table'] !== 'tx_cal_exception_event') {
return '';
}
// Get complete record
$rec = BackendUtility::getRecordWSOL($params['table'], $params['row']['uid']);
$dateObj = new CalDate($rec['start_date'] . '000000');
$dateObj = new CalendarDateTime($rec['start_date'] . '000000');
$dateObj->setTZbyID('UTC');
$format = str_replace([
'd',
'm',
'y',
'Y'
], [
'%d',
'%m',
'%y',
'%Y'
], $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
if ($rec['allday'] || $params['table'] == 'tx_cal_exception_event') {
$format = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
if ($rec['allday'] || $params['table'] === 'tx_cal_exception_event') {
/* If we have an all day event, only show the date */
$datetime = $dateObj->format($format);
$params['start_date'] = $datetime;
......@@ -81,7 +71,7 @@ class Labels
*/
public function getAttendeeRecordLabel(&$params, &$pObj)
{
if (!$params['table'] == 'tx_cal_attendee') {
if (!$params['table'] === 'tx_cal_attendee') {
return '';
}
......@@ -107,7 +97,7 @@ class Labels
*/
public function getMonitoringRecordLabel(&$params, &$pObj)
{
if (!$params['table'] == 'tx_cal_fe_user_event_monitor_mm') {
if (!$params['table'] === 'tx_cal_fe_user_event_monitor_mm') {
return '';
}
......@@ -142,7 +132,7 @@ class Labels
*/
public function getDeviationRecordLabel(&$params, &$pObj)
{
if (!$params['table'] == 'tx_cal_event_deviation') {
if (!$params['table'] === 'tx_cal_event_deviation') {
return '';
}
......@@ -152,7 +142,7 @@ class Labels
$label = $GLOBALS['LANG']->sL('LLL:EXT:cal/Resources/Private/Language/locallang_db.xml:tx_cal_event.deviation') . ': ';
if ($rec['orig_start_date']) {
$dateObj = new CalDate($rec['orig_start_date'] . '000000');
$dateObj = new CalendarDateTime($rec['orig_start_date'] . '000000');
$dateObj->setTZbyID('UTC');
$format = str_replace([
......
......@@ -396,7 +396,7 @@ class Api
*/
public function findEventsWithin($startTimestamp, $endTimestamp, $type = '', $pidList = ''): array
{
return $this->modelObj->findAllWithin('cal_event_model', $startTimestamp, $endTimestamp, $type, 'event', $pidList);
return $this->modelObj->findAllWithin('cal_event_model', clone $startTimestamp, clone $endTimestamp, $type, 'event', $pidList);
}
/**
......
......@@ -14,8 +14,7 @@ namespace TYPO3\CMS\Cal\Controller;
*
* The TYPO3 extension Calendar Base (cal) project - inspiring people to share!
*/
use TYPO3\CMS\Cal\Model\CalDate;
use TYPO3\CMS\Cal\Model\Pear\Date\Calc;
use TYPO3\CMS\Cal\Model\CalendarDateTime;
/**
* This class combines all the time related functions
......@@ -86,116 +85,96 @@ class Calendar
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateStartDayTime($dateObject = ''): CalDate
public static function calculateStartDayTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = new CalDate();
$timeObj->setTZbyID('UTC');
if ($dateObject) {
$timeObj->copy($dateObject);
}
$timeObj->setHour(0);
$timeObj->setMinute(0);
$timeObj->setSecond(0);
return $timeObj;
$dateObject->setTZbyID('UTC');
$dateObject->setHour(0);
$dateObject->setMinute(0);
$dateObject->setSecond(0);
return $dateObject;
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateEndDayTime($dateObject = ''): CalDate
public static function calculateEndDayTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = new CalDate();
$timeObj->setTZbyID('UTC');
if ($dateObject) {
$timeObj->copy($dateObject);
}
$timeObj->setHour(23);
$timeObj->setMinute(59);
$timeObj->setSecond(59);
return $timeObj;
$dateObject->setTZbyID('UTC');
$dateObject->setHour(23);
$dateObject->setMinute(59);
$dateObject->setSecond(59);
return $dateObject;
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateStartWeekTime($dateObject = ''): CalDate
public static function calculateStartWeekTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = self::calculateStartDayTime($dateObject);
$timeObj = new CalDate(Calc::beginOfWeek(
$timeObj->getDay(),
$timeObj->getMonth(),
$timeObj->getYear()
));
$timeObj->setTZbyID('UTC');
return $timeObj;
$dateObject = self::calculateStartDayTime($dateObject);
$dateObject->setDay($dateObject->format('j') - $dateObject->format('w'));
return $dateObject;
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateEndWeekTime($dateObject = ''): CalDate
public static function calculateEndWeekTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = self::calculateStartWeekTime($dateObject);
$timeObj->addSeconds(604799);
return $timeObj;
$dateObject = self::calculateStartWeekTime($dateObject);
$dateObject->addSeconds(604799);
return $dateObject;
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateStartMonthTime($dateObject = ''): CalDate
public static function calculateStartMonthTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = self::calculateStartDayTime($dateObject);
$timeObj->setDay(1);
return $timeObj;
$dateObject = self::calculateStartDayTime($dateObject);
$dateObject->setDay(1);
return $dateObject;
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateEndMonthTime($dateObject = ''): CalDate
public static function calculateEndMonthTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = self::calculateStartDayTime($dateObject);
$timeObj = new CalDate(Calc::endOfNextMonth(
$timeObj->getDay(),
$timeObj->getMonth(),
$timeObj->getYear()
));
$timeObj->setDay(1);
$timeObj->subtractSeconds(1);
$timeObj->setTZbyID('UTC');
return $timeObj;
$dateObject = self::calculateEndDayTime($dateObject);
$dateObject->setDay($dateObject->format('t'));
return $dateObject;
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateStartYearTime($dateObject = ''): CalDate
public static function calculateStartYearTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = self::calculateStartMonthTime($dateObject);
$timeObj->setMonth(1);
return $timeObj;
$dateObject = self::calculateStartMonthTime($dateObject);
$dateObject->setMonth(1);
return $dateObject;
}
/**
* @param string $dateObject
* @return CalDate
* @param CalendarDateTime $dateObject
* @return CalendarDateTime
*/
public static function calculateEndYearTime($dateObject = ''): CalDate
public static function calculateEndYearTime(CalendarDateTime $dateObject): CalendarDateTime
{
$timeObj = self::calculateStartYearTime($dateObject);
$timeObj->setYear($timeObj->getYear() + 1);
$timeObj->subtractSeconds(1);
return $timeObj;
$dateObject = self::calculateStartYearTime($dateObject);
$dateObject->setYear($dateObject->getYear() + 1);
$dateObject->subtractSeconds(1);
return $dateObject;
}
/**
......
This diff is collapsed.
......@@ -14,11 +14,12 @@ namespace TYPO3\CMS\Cal\Controller;
*
* The TYPO3 extension Calendar Base (cal) project - inspiring people to share!
*/
use TYPO3\CMS\Cal\Model\CalDate;
use TYPO3\CMS\Cal\Model\CalendarDateTime;
use TYPO3\CMS\Cal\Model\Pear\Date\Calc;
/**
* date parser
* @deprecated
*/
class DateParser
{
......@@ -68,7 +69,7 @@ class DateParser
public $special = '';
/**
* @var CalDate
* @var CalendarDateTime
*/
public $timeObj;
......@@ -80,20 +81,18 @@ class DateParser
/**
* @param $value
* @param array $conf
* @param string $timeObj
* @param CalendarDateTime $timeObj
*/
public function parse($value, $conf = [], $timeObj = '')
public function parse($value, $conf = [], $timeObj = null)
{
if ($timeObj === '') {
$timeObj = new CalDate();
if ($timeObj === null) {
$timeObj = new CalendarDateTime();
$timeObj->setTZbyID('UTC');
}
$this->timeObj = $timeObj;
$this->conf = &$conf;
if (!empty($value) && is_array($value)) {
foreach ($value as $iValue) {
$chr = $iValue;
foreach ($value as $chr) {
switch ($chr) {
case ' ':
case '_':
......@@ -271,27 +270,27 @@ class DateParser
break;
case 'now':
$this->stack[] = [
'abs' => $this->timeObj->getTime()
'abs' => $this->timeObj->format('U')
];
break;
case 'today':
$this->stack[] = [
'today' => $this->timeObj->getTime()
'today' => $this->timeObj->format('U')
];
break;
case 'current':
$this->stack[] = [
'today' => $this->timeObj->getTime()
'today' => $this->timeObj->format('U')
];
break;
case 'tomorrow':
$this->stack[] = [
'tomorrow' => $this->timeObj->getTime()
'tomorrow' => $this->timeObj->format('U')
];
break;
case 'yesterday':
$this->stack[] = [
'yesterday' => $this->timeObj->getTime()
'yesterday' => $this->timeObj->format('U')
];
break;
......@@ -540,13 +539,13 @@ class DateParser
}
/**
* @return CalDate
* @return CalendarDateTime
*/
public function getDateObjectFromStack(): CalDate
public function getDateObjectFromStack(): CalendarDateTime
{
$date = new CalDate();
$date = new CalendarDateTime();
$date->setTZbyID('UTC');
$date->copy($this->timeObj);
$date->copy($this->timeObj ?? new CalendarDateTime());
$lastKey = '';
$post = [];
$foundMonth = false;
......@@ -696,7 +695,7 @@ class DateParser
}
/**
* @param CalDate$date
* @param CalendarDateTime$date
* @param $range
* @param $rangeValue
*/
......@@ -721,7 +720,7 @@ class DateParser
$date->getMonth(),
$date->getYear()
);
$date = new CalDate($formatedDate);
$date = new CalendarDateTime($formatedDate);
$date->setTZbyID('UTC');
}
} elseif ($key === 'weekday' && $range < 0) {
......@@ -732,7 +731,7 @@ class DateParser
$date->getMonth(),
$date->getYear()
);
$date = new CalDate($formatedDate);
$date = new CalendarDateTime($formatedDate);
$date->setTZbyID('UTC');
}
} elseif ($value === 'week' && $range > 0) {
......@@ -745,7 +744,7 @@ class DateParser
if ($rangeValue === 'month') {
for ($i = 0; $i < $range; $i++) {
$days = Calc::daysInMonth($date->getMonth(), $date->getYear());
$endOfNextMonth = new CalDate(Calc::endOfNextMonth(
$endOfNextMonth = new CalendarDateTime(Calc::endOfNextMonth(
$date->getDay(),
$date->getMonth(),
$date->getYear()
......@@ -769,7 +768,7 @@ class DateParser
} elseif ($range < 0) {
if ($rangeValue === 'month') {
for ($i = 0; $i > $range; $i--) {
$endOfPrevMonth = new CalDate(Calc::endOfPrevMonth(
$endOfPrevMonth = new CalendarDateTime(Calc::endOfPrevMonth(
$date->getDay(),
$date->getMonth(),
$date->getYear()
......
This diff is collapsed.
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Cal\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* This file is part of the TYPO3 extension Calendar Base (cal).
*
* 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 extension Calendar Base (cal) project - inspiring people to share!
*/
class Location extends AbstractEntity
{
/**
* @var string
*/
protected $name = '';
/**
* @var string
*/
protected $description = '';
/**
* @var string
*/
protected $street = '';
/**
* @var string
*/
protected $zip = '';
/**
* @var string
*/
protected $city = '';
/**
* @var string
*/
protected $countryZone = '';
/**
* @var string
*/
protected $country = '';
/**
* @var string
*/
protected $phone = '';
/**
* @var string
*/
protected $fax = '';
/**
* @var string
*/
protected $email = '';
/**
* @var string
*/
protected $link = '';
/**
* @var float
*/
protected $latitude = 0.0;
/**
* @var float
*/
protected $longitude = 0.0;
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getStreet(): string
{
return $this->street;
}
/**
* @param string $street
*/
public function setStreet(string $street)
{
$this->street = $street;
}
/**
* @return string
*/
public function getZip(): string
{
return $this->zip;
}
/**
* @param string $zip
*/
public function setZip(string $zip)
{
$this->zip = $zip;
}
/**
* @return string
*/
public function getCity(): string
{
return $this->city;
}
/**
* @param string $city
*/
public function setCity(string $city)
{
$this->city = $city;
}
/**
* @return string
*/
public function getCountryZone(): string
{
return $this->countryZone;
}
/**
* @param string $countryZone
*/
public function setCountryZone(string $countryZone)
{
$this->countryZone = $countryZone;
}
/**
* @return string
*/
public function getCountry(): string
{
return $this->country;
}
/**
* @param string $country
*/
public function setCountry(string $country)
{
$this->country = $country;
}
/**
* @return string
*/
public function getPhone(): string
{
return $this->phone;
}
/**
* @param string $phone
*/
public function setPhone(string $phone)
{
$this->phone = $phone;
}
/**
* @return string
*/
public function getFax(): string
{
return $this->fax;
}
/**
* @param string $fax
*/
public function setFax(string $fax)
{
$this->fax = $fax;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email)
{
$this->email = $email;
}
/**
* @return string
*/
public function getLink(): string
{
return $this->link;
}
/**
* @param string $link
*/
public function setLink(string $link)
{
$this->link = $link;
}
/**
* @return float
*/
public function getLatitude(): float
{
return $this->latitude;
}
/**
* @param float $latitude
*/
public function setLatitude(float $latitude)
{
$this->latitude = $latitude;
}
/**
* @return float
*/
public function getLongitude(): float
{
return $this->longitude;
}
/**
* @param float $longitude
*/
public function setLongitude(float $longitude)
{
$this->longitude = $longitude;
}
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Cal\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* This file is part of the TYPO3 extension Calendar Base (cal).
*
* 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 extension Calendar Base (cal) project - inspiring people to share!
*/
class Organizer extends AbstractEntity
{
/**
* @var string
*/
protected $name = '';
/**
* @var string
*/
protected $description = '';
/**
* @var string
*/
protected $street = '';
/**
* @var string
*/
protected $zip = '';
/**
* @var string
*/
protected $city = '';
/**
* @var string
*/
protected $countryZone = '';
/**
* @var string
*/
protected $country = '';
/**
* @var string
*/
protected $phone = '';
/**
* @var string
*/
protected $fax = '';
/**
* @var string
*/
protected $email = '';
/**
* @var string
*/
protected $link = '';
/**
* @var int
*/
protected $feUserId = 0;
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getStreet(): string
{
return $this->street;
}
/**
* @param string $street
*/
public function setStreet(string $street)
{
$this->street = $street;
}
/**
* @return string
*/
public function getZip(): string
{
return $this->zip;
}
/**
* @param string $zip
*/
public function setZip(string $zip)
{
$this->zip = $zip;
}
/**
* @return string
*/
public function getCity(): string
{
return $this->city;
}
/**
* @param string $city
*/
public function setCity(string $city)
{
$this->city = $city;
}
/**
* @return string
*/
public function getCountryZone(): string
{
return $this->countryZone;
}
/**
* @param string $countryZone
*/
public function setCountryZone(string $countryZone)
{
$this->countryZone = $countryZone;
}
/**
* @return string
*/
public function getCountry(): string
{
return $this->country;
}
/**
* @param string $country
*/
public function setCountry(string $country)
{
$this->country = $country;
}
/**
* @return string
*/
public function getPhone(): string
{
return $this->phone;
}
/**
* @param string $phone
*/
public function setPhone(string $phone)
{
$this->phone = $phone;
}
/**
* @return string
*/
public function getFax(): string
{
return $this->fax;
}
/**
* @param string $fax
*/
public function setFax(string $fax)
{
$this->fax = $fax;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email)
{
$this->email = $email;
}
/**
* @return string
*/
public function getLink(): string
{
return $this->link;
}
/**
* @param string $link
*/
public function setLink(string $link)
{
$this->link = $link;
}
/**
* @return int
*/
public function getFeUserId(): int
{
return $this->feUserId;
}
/**
* @param int $feUserId
*/
public function setFeUserId(int $feUserId)
{
$this->feUserId = $feUserId;
}
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Cal\Domain\Repository;
/**
* This file is part of the TYPO3 extension Calendar Base (cal).
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 extension Calendar Base (cal) project - inspiring people to share!
*/
/**
* Class AttendeeRepository
*/
class AttendeeRepository extends DoctrineRepository
{
/**
* @var string
*/
protected $table = 'tx_cal_attendee';
/**
* @var EventIndexRepository
*/
protected $eventIndexRepository;
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Cal\Domain\Repository;
use TYPO3\CMS\Cal\Service\RightsService;
use TYPO3\CMS\Cal\Utility\Registry;
/**
* This file is part of the TYPO3 extension Calendar Base (cal).
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 extension Calendar Base (cal) project - inspiring people to share!
*/
/**
* Class CalendarRepository
*/
class CalendarRepository extends DoctrineRepository
{
/**
* @var string
*/
protected $table = 'tx_cal_calendar';
/**
* @var UserGroupMMRepository
*/
protected $userGroupMMRepository;
/**
* @param string $limitationList
* @param $pidList
* @param $includePublic
* @param bool $includeData
* @param bool $onlyPublic
* @return array
*/
public function getAccessibleCalendars($limitationList, $pidList, $includePublic, $includeData = false, $onlyPublic = false): array
{
$groupIds = '';
$userId = '';
$calendarIds = [];
$queryBuilder = $this->getQueryBuilder();
$queryBuilder
->select('*')
->from($this->table, 'calendar')
->groupBy('uid');
// Lets see if the user is logged in
/** @var RightsService $rightsObj */
$rightsObj = &Registry::Registry('basic', 'rightscontroller');
if (!$onlyPublic && $rightsObj->isLoggedIn()) {
$userId = $rightsObj->getUserId();
$groupIds = implode(',', $rightsObj->getUserGroups());
}
if ($userId === '') {
return [];
}
$userGroupMMs = $this->userGroupMMRepository->findAll();
if (!empty($userGroupMMs)) {
$userGroupUids = [];
foreach ($userGroupMMs as $userGroupMM) {
$userGroupUids[] = $userGroupMM['uid_local'];
}
$queryBuilder->andWhere(
$queryBuilder->expr()->notIn('uid', array_unique($userGroupUids))
);
}
if ($pidList !== '') {
$queryBuilder->andWhere(
$queryBuilder->expr()->in('pid', $pidList)
);
}
if ($onlyPublic === false) {
if ($userId) {
$queryBuilder->join('calendar', 'tx_cal_calendar_user_group_mm', 'mm', 'mm.local_uid = calendar.uid');
$queryBuilder->where(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->in('mm.uid_foreign', $userId),
$queryBuilder->expr()->in('mm.tablenames', 'fe_users')
),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->in('mm.uid_foreign', $groupIds),
$queryBuilder->expr()->in('mm.tablenames', 'fe_groups')
)
)
);
}
if ($limitationList !== '') {
$queryBuilder->andWhere(
$queryBuilder->expr()->in('uid', $limitationList)
);
}
}
$calendars = $queryBuilder
->execute()
->fetchAll();
foreach ($calendars as $calendar) {
$calendarIds[] = $includeData ? $calendar : $calendar['uid'];
}
return $calendarIds;
}
/**
* @param UserGroupMMRepository $userGroupMMRepository
*/
public function injectUserGroupMMRepository(UserGroupMMRepository $userGroupMMRepository)
{
$this->userGroupMMRepository = $userGroupMMRepository;
}
}
......@@ -13,12 +13,17 @@ namespace TYPO3\CMS\Cal\Domain\Repository;
*/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* Class DoctrineRepository
*/
class DoctrineRepository
class DoctrineRepository extends Repository
{
/**
......@@ -26,6 +31,11 @@ class DoctrineRepository
*/
protected $table = '';
/**
* @var string
*/
protected $model = '';
/**
* @return QueryBuilder
*/
......@@ -36,34 +46,6 @@ class DoctrineRepository
->createQueryBuilder();
}
/**
* @return array
*/
public function findAll(): array
{
$queryBuilder = $this->getQueryBuilder();
return $queryBuilder
->select('*')
->from($this->table)
->execute()
->fetchAll();
}
/**
* @param int $uid
* @return array
*/
public function findOneByUid(int $uid): array
{
$queryBuilder = $this->getQueryBuilder();
return $queryBuilder
->select('*')
->from($this->table)
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
->execute()
->fetch();
}
/**
* @param int $uid
* @param array $values
......@@ -78,4 +60,20 @@ class DoctrineRepository
->values($values)
->execute();
}
/**
* This function creates an extbase object from the database result.
*
* @param array $row
* @return AbstractEntity
*/
public function getObject(array $row): AbstractEntity
{
if ($this->model === '') {
throw new Exception('No model is defined to handle objects from table ' . $this->table . '.', 1550607468);
}
return GeneralUtility::makeInstance(ObjectManager::class)
->get(DataMapper::class)
->map($this->model, [$row])[0];
}
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Cal\Domain\Repository;
use TYPO3\CMS\Cal\Model\CalDate;
/**
* This file is part of the TYPO3 extension Calendar Base (cal).
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 extension Calendar Base (cal) project - inspiring people to share!
*/
/**
* Class EventIndexRepository
*/
class EventIndexRepository extends DoctrineRepository
{
/**
* @var string
*/
protected $table = 'tx_cal_index';
/**
* @param CalDate $starttime
* @param CalDate $endtime
* @return array
*/
public function findRecurringEvents(CalDate $starttime, CalDate $endtime): array
{
$queryBuilder = $this->getQueryBuilder();
return $queryBuilder
->select('*')
->from($this->table)
->where(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->gte('start_datetime', $starttime->format('%Y%m%d%H%M%S')),
$queryBuilder->expr()->lte('start_datetime', $endtime->format('%Y%m%d%H%M%S'))
),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->lt('start_datetime', $starttime->format('%Y%m%d%H%M%S')),
$queryBuilder->expr()->gt('end_datetime', $starttime->format('%Y%m%d%H%M%S'))
),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->lt('start_datetime', $endtime->format('%Y%m%d%H%M%S')),
$queryBuilder->expr()->gt('end_datetime', $endtime->format('%Y%m%d%H%M%S'))
)
)
)
->groupBy('event_uid')
->execute()
->fetchAll();
}
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Cal\Domain\Repository;
use TYPO3\CMS\Cal\Model\CalDate;
/**
* This file is part of the TYPO3 extension Calendar Base (cal).
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 extension Calendar Base (cal) project - inspiring people to share!
*/
/**
* Class EventRepository
*/
class EventRepository extends DoctrineRepository
{
/**
* @var string
*/
protected $table = 'tx_cal_event';
/**
* @var EventIndexRepository
*/