Skip to content

Commit

Permalink
transitioned to typo3 dates
Browse files Browse the repository at this point in the history
  • Loading branch information
itx-benjamin-jasper committed Mar 6, 2020
1 parent e77e549 commit 286c384
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/BackendController.php
Expand Up @@ -149,7 +149,7 @@ public function listApplicationsAction()
}
else
{
$postingsFilter = $this->postingRepository->findAllWithOrder();
$postingsFilter = $this->postingRepository->findAllWithOrderIgnoreEnable();
}

// Fetch all Contacts and Statuses for select-Box
Expand Down
9 changes: 8 additions & 1 deletion Classes/Controller/PostingController.php
Expand Up @@ -75,7 +75,7 @@ public function initializeShowAction()
// If application form an posting are on the same page, the posting object is part of the application plugin.
if (!$this->request->hasArgument("posting"))
{
if(isset($_REQUEST["tx_jobapplications_applicationform"]["posting"]))
if (isset($_REQUEST["tx_jobapplications_applicationform"]["posting"]))
{
$this->request->setArgument("posting", $_REQUEST["tx_jobapplications_applicationform"]["posting"]);
}
Expand Down Expand Up @@ -273,11 +273,18 @@ public function showAction(\ITX\Jobapplications\Domain\Model\Posting $posting =
]
];
}

/** @deprecated */
if ($posting->getValidThrough() instanceof \DateTime)
{
$googleJobsJSON["validThrough"] = $posting->getValidThrough()->format("c");
}

if ($posting->getEndtime() instanceof \DateTime)
{
$googleJobsJSON["validThrough"] = $posting->getEndtime()->format("c");
}

$googleJobs = "<script type=\"application/ld+json\">".strval(json_encode($googleJobsJSON))."</script>";

$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
Expand Down
44 changes: 42 additions & 2 deletions Classes/Domain/Model/Posting.php
Expand Up @@ -39,6 +39,12 @@ class Posting extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/** @var boolean */
protected $deleted;

/** @var \DateTime */
protected $starttime;

/** @var \DateTime */
protected $endtime;

/**
* title
*
Expand Down Expand Up @@ -127,6 +133,7 @@ class Posting extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* validThrough
*
* @var \DateTime
* @deprecated will be removed in next version
*/
protected $validThrough = null;

Expand Down Expand Up @@ -182,8 +189,6 @@ class Posting extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $categories = null;



/**
* __construct
*/
Expand Down Expand Up @@ -475,6 +480,7 @@ public function setBaseSalary($baseSalary)
* Returns the validThrough
*
* @return \DateTime validThrough
* @deprecated will be removed in next version
*/
public function getValidThrough()
{
Expand All @@ -487,6 +493,7 @@ public function getValidThrough()
* @param \DateTime $validThrough
*
* @return void
* @deprecated will be removed in next version
*/
public function setValidThrough(\DateTime $validThrough)
{
Expand Down Expand Up @@ -627,6 +634,7 @@ public function setListViewImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $

/**
* @return boolean
* @deprecated will be removed in next version
*/
public function getIsValid()
{
Expand Down Expand Up @@ -683,4 +691,36 @@ public function setDeleted(bool $deleted): void
{
$this->deleted = $deleted;
}

/**
* @return \DateTime
*/
public function getStarttime()
{
return $this->starttime;
}

/**
* @param \DateTime $starttime
*/
public function setStarttime($starttime)
{
$this->starttime = $starttime;
}

/**
* @return \DateTime
*/
public function getEndtime()
{
return $this->endtime;
}

/**
* @param \DateTime $endtime
*/
public function setEndtime($endtime)
{
$this->endtime = $endtime;
}
}
15 changes: 10 additions & 5 deletions Classes/Domain/Repository/ApplicationRepository.php
Expand Up @@ -39,6 +39,7 @@ class ApplicationRepository extends \ITX\Jobapplications\Domain\Repository\Jobap

/**
* Function for filtering applications
*
* @param int $contact
* @param int $posting
* @param int $status
Expand All @@ -53,7 +54,8 @@ public function findByFilter(int $contact, int $posting, int $status, int $archi
string $order = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectStoragePage(false)
->setIgnoreEnableFields(true);

$andArray = [];

Expand Down Expand Up @@ -90,7 +92,9 @@ public function findByFilter(int $contact, int $posting, int $status, int $archi
*/
public function findAll()
{
$query = $this->createQuery();
$query = $this->createQuery()->getQuerySettings()
->setRespectStoragePage(false)
->setIgnoreEnableFields(true);
$query->setOrderings(array(
"crdate" => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
));
Expand All @@ -107,7 +111,8 @@ public function findNewApplicationsByContact(int $contact)
{
$query = $this->createQuery();
$query->getQuerySettings()
->setRespectStoragePage(false);
->setRespectStoragePage(false)
->setIgnoreEnableFields(true);
$query->matching(
$query->logicalAnd([
$query->equals('posting.contact.uid', $contact),
Expand All @@ -131,7 +136,7 @@ public function findNewApplicationsByContact(int $contact)
public function findOlderThan(int $timestamp, bool $status = false)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectStoragePage(false)->setIgnoreEnableFields(true);

$andArray = [];
$andArray[] = $query->lessThanOrEqual("crdate", $timestamp);
Expand Down Expand Up @@ -163,7 +168,7 @@ public function findNotAnonymizedOlderThan(int $timestamp, bool $status = false)
{
$query = $this->createQuery();

$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectStoragePage(false)->setIgnoreEnableFields(true);

$andArray = [];
$andArray[] = $query->lessThanOrEqual("crdate", $timestamp);
Expand Down
11 changes: 7 additions & 4 deletions Classes/Domain/Repository/PostingRepository.php
Expand Up @@ -221,14 +221,17 @@ public function findByFilter(string $division, string $careerLevel, string $empl
}

/**
* Only for use in Backend context
*
* @param $contact int Contact Uid
* @param $orderBy string
* @param $order string
*/
public function findByContact(int $contact, string $orderBy = "title", string $order = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectStoragePage(false)
->setIgnoreEnableFields(true);

$query->matching($query->equals("contact.uid", $contact));
$query->setOrderings([$orderBy => $order]);
Expand All @@ -237,14 +240,14 @@ public function findByContact(int $contact, string $orderBy = "title", string $o
}

/**
* Returns all objects of this repository.
* Returns all objects of this repository. Only for use in backend context
*
* @return QueryResultInterface|array
*/
public function findAllWithOrder(string $orderBy = "title", string $order = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING)
public function findAllWithOrderIgnoreEnable(string $orderBy = "title", string $order = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectStoragePage(false)->setIgnoreEnableFields(true);

$query->setOrderings([
$orderBy => $order
Expand Down
14 changes: 6 additions & 8 deletions Configuration/TCA/tx_jobapplications_domain_model_posting.php
Expand Up @@ -20,7 +20,7 @@
'iconfile' => 'EXT:jobapplications/Resources/Public/Icons/Extension.svg'
],
'interface' => [
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, date_posted, career_level, division, employment_type, terms_of_employment, company_description, job_description, role_description, skill_requirements, benefits, base_salary, valid_through, required_documents, company_information, detail_view_image, list_view_image, location, contact',
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, starttime, endtime, title, date_posted, career_level, division, employment_type, terms_of_employment, company_description, job_description, role_description, skill_requirements, benefits, base_salary, required_documents, company_information, detail_view_image, list_view_image, location, contact',
],
'columns' => [
'sys_language_uid' => [
Expand Down Expand Up @@ -92,28 +92,25 @@
),
'starttime' => [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
'label' => 'LLL:EXT:jobapplications/Resources/Private/Language/locallang_db.xlf:tx_jobapplications_domain_model_posting.starttime',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime,int',
'default' => 0,
'default' => time(),
'behaviour' => [
'allowLanguageSynchronization' => true
]
],
],
'endtime' => [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
'label' => 'LLL:EXT:jobapplications/Resources/Private/Language/locallang_db.xlf:tx_jobapplications_domain_model_posting.valid_through',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime,int',
'default' => 0,
'range' => [
'upper' => mktime(0, 0, 0, 1, 1, 2038)
],
'behaviour' => [
'allowLanguageSynchronization' => true
]
Expand Down Expand Up @@ -290,6 +287,7 @@
'eval' => 'trim'
],
],
// @deprecated
'valid_through' => [
'exclude' => true,
'label' => 'LLL:EXT:jobapplications/Resources/Private/Language/locallang_db.xlf:tx_jobapplications_domain_model_posting.valid_through',
Expand Down Expand Up @@ -504,7 +502,7 @@
'showitem' => 'career_level, employment_type, terms_of_employment'
],
'dates' => [
'showitem' => 'date_posted, valid_through'
'showitem' => 'date_posted, starttime ,endtime'
],
'relations' => [
'showitem' => 'location, contact'
Expand Down
10 changes: 10 additions & 0 deletions Documentation/ChangeLog/Index.rst
Expand Up @@ -21,7 +21,17 @@ Changelog
is very new and may not be stable. If you encounter any bugs or have feedback other feedback please report it on our GitHub Repo.
* [FEATURE] New button in the Backend Module on the settings page, where it is possible to trigger a batch indexing request
for the new Google Indexing API Feature.
* [FEATURE] converted datetimes to standard TYPO3 fields starttime and endtime, so it integrates better with TYPO3
There are 3 date fields now: "Date Posted", "Publish Date", "Valid Through".
For more informations concerning the functionality of these fields please read the documentation :ref:`here <editors>`
In specific cases this conversion raises some compatibility issues:

#. Users having customized the template and used the frontend f:if viewhelper with isValid() it will work just fine as the fields and the functionality are still there
but are deprecated and will be removed in the next version
#. Users using the standard bootstrap layout will have to manually edit the dates in specific the "Valid Through" field as the mecanism has been removed in the frontend

* [BUGFIX] replaced tca image field definitions with more recent ones, that support image cropping
* [BUGFIX] corrected label for property of cv field in standard template

0.9.2 - New Feature & Bugfixes
-------------------------------
Expand Down
11 changes: 8 additions & 3 deletions Documentation/Editors/Index.rst
Expand Up @@ -77,11 +77,16 @@ Location & contact
These are both of the fields that were mentionend before. They reference the location and contact record.
One of each type can be selected of all of the records previously created.

Date posted & valid through
Date posted
~~~~~~~~~~~
The date posted will be shown in the frontend, and is also the datePosted field in Google Jobs context. It has no effect
though whether the posting will be shown or not.

Publish date & valid through
~~~~~~~~~~~~~~~~~~~~~~~~~~~
These two dates are not only displayed in the frontend but also decide when the posting is published or taken down again.
These two dates decide when the posting is published or taken down again.
The *Valid through* field is optional, meaning it can stay empty which results in the posting staying active until its
manually taken down.
manually taken down. The valid through field is used for Google Jobs as well.

Base salary
~~~~~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Expand Up @@ -63,6 +63,9 @@
<trans-unit id="tx_jobapplications_domain_model_posting.contact" resname="tx_jobapplications_domain_model_posting.contact">
<source>Contact</source>
</trans-unit>
<trans-unit id="tx_jobapplications_domain_model_posting.starttime" resname="tx_jobapplications_domain_model_posting.starttime">
<source>Publish Date</source>
</trans-unit>
<trans-unit id="tx_jobapplications_domain_model_contact" resname="tx_jobapplications_domain_model_contact">
<source>Contact</source>
</trans-unit>
Expand Down
6 changes: 3 additions & 3 deletions Resources/Private/Partials/Posting/Properties.html
Expand Up @@ -107,7 +107,7 @@ <h6>
</div>
</div>
</f:if>
<f:if condition="{posting.baseSalary} || {posting.validThrough}">
<f:if condition="{posting.baseSalary} || {posting.endtime}">
<div class="row">
<f:if condition="{posting.baseSalary}">
<div class="col-3">
Expand All @@ -119,14 +119,14 @@ <h6>
{posting.baseSalary}
</div>
</f:if>
<f:if condition="{posting.validThrough}">
<f:if condition="{posting.endtime}">
<div class="col-3">
<h6>
<f:translate key="tx_jobapplications_domain_model_posting.valid_through"/>
</h6>
</div>
<div class="col-3">
<f:format.date format="{f:translate(key: 'date_format')}">{posting.validThrough}</f:format.date>
<f:format.date format="{f:translate(key: 'date_format')}">{posting.endtime}</f:format.date>
</div>
</f:if>
</div>
Expand Down

0 comments on commit 286c384

Please sign in to comment.