Skip to content
Snippets Groups Projects
Commit 03b6b687 authored by Ole Anders's avatar Ole Anders
Browse files

Merge branch 'f_manual_sorting' into 'master'

F manual sorting

See merge request !17
parents 4b1260cf b4e1eb3c
No related branches found
No related tags found
1 merge request!17F manual sorting
......@@ -159,10 +159,12 @@ class JoblistController extends ActionController {
$offset = $currentPageBrowserPage * $jobLimit;
}
$frontendPluginSettings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$frontendPluginSettings = $frontendPluginSettings['settings'];
// get all jobs for the current page
$ordering = (int) $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
)['settings']['orderBy'];
$ordering = (int)$frontendPluginSettings['orderBy'];
FrontendFilterService::setAllowManualSorting($frontendPluginSettings['allowManualSorting']);
$jobs = FrontendFilterService::getJobs($filters, $jobLimit, $offset, $ordering);
// get all jobs for the current page
......
......@@ -44,6 +44,11 @@ class JobRepository extends Repository {
const ORDER_BY_CRDATE = 2;
const ORDER_BY_SORTING = 0;
/**
* @var bool $allowManualSorting
*/
protected $allowManualSorting = false;
/**
* initializes the object
*/
......@@ -191,7 +196,10 @@ class JobRepository extends Repository {
array $filters = [], $limit = 0, $offset = 0, $ordering = 0
): ExtbaseQueryResultInterface {
$query = $this->createQuery();
if ($ordering === self::ORDER_BY_TITLE) {
if ($ordering === self::ORDER_BY_TITLE || (!$this->allowManualSorting && $ordering === self::ORDER_BY_SORTING)) {
$query->setOrderings(
[
'title' => QueryInterface::ORDER_ASCENDING,
......@@ -207,7 +215,7 @@ class JobRepository extends Repository {
);
}
if ($ordering === self::ORDER_BY_SORTING) {
if ($ordering === self::ORDER_BY_SORTING && $this->allowManualSorting) {
$query->setOrderings(
[
'sorting' => QueryInterface::ORDER_ASCENDING
......@@ -327,4 +335,20 @@ class JobRepository extends Repository {
return $query->matching($query->logicalAnd($constraints))->execute();
}
/**
* @return bool
*/
public function isAllowManualSorting(): bool {
return $this->allowManualSorting;
}
/**
* @param bool $allowManualSorting
*/
public function setAllowManualSorting(bool $allowManualSorting) {
$this->allowManualSorting = $allowManualSorting;
}
}
......@@ -51,4 +51,22 @@ class FrontendFilterService {
$jobRepository = $objectManager->get(JobRepository::class);
return $jobRepository->findJobsByFilter($filters, $limit, $offset, $ordering)->toArray();
}
/**
* @return bool
*/
public static function isAllowManualSorting(): bool {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$jobRepository = $objectManager->get(JobRepository::class);
return $jobRepository->isAllowManualSorting();
}
/**
* @param bool $allowManualSorting
*/
public static function setAllowManualSorting(bool $allowManualSorting) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$jobRepository = $objectManager->get(JobRepository::class);
$jobRepository->setAllowManualSorting($allowManualSorting);
}
}
......@@ -13,6 +13,8 @@ plugin.tx_sgjobs {
settings {
# cat=plugin.tx_sgjobs/other; type=string; label=Mail address to send submitted applications to
applicationEmail =
# cat=plugin.tx_sgjobs/other; type=boolean; label=Enable manual sorting
allowManualSorting = 0
# cat=plugin.tx_sgjobs/other; type=string; label=Allowed file extensions for uploads in the controller (comma separated)
allowedFileExtensions = pdf
# cat=plugin.tx_sgjobs/other; type=string; label=Allowed mime types for uploads in the Fluid template (comma separated)
......
......@@ -23,6 +23,7 @@ plugin.tx_sgjobs {
settings {
allowedFileExtensions = {$plugin.tx_sgjobs.settings.allowedFileExtensions}
allowManualSorting = {$plugin.tx_sgjobs.settings.allowManualSorting}
allowedMimeTypes = {$plugin.tx_sgjobs.settings.allowedMimeTypes}
allowedMaxFileSize = {$plugin.tx_sgjobs.settings.allowedMaxFileSize}
privacyPolicyPage = {$plugin.tx_sgjobs.settings.privacyPolicyPage}
......
......@@ -214,8 +214,8 @@
<target><![CDATA[Sortierung der Stellenangebote]]></target>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.orderBy_1" approved="yes">
<source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module)]]></source>
<target><![CDATA[Manuell (Stellenangebote werden wie im "Stellenangebote" Modul sortiert)]]></target>
<source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module. Must be enabled in configuration)]]></source>
<target><![CDATA[Manuell (Stellenangebote werden wie im "Stellenangebote" Modul sortiert. Muss in den Einstellungen erlaubt sein.)]]></target>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.orderBy_2" approved="yes">
<source><![CDATA[Alphabetically by job title (A-Z)]]></source>
......@@ -371,4 +371,4 @@
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
</xliff>
......@@ -166,7 +166,7 @@
<source><![CDATA[Sorting of job offers]]></source>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.orderBy_1">
<source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module)]]></source>
<source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module. Must be enabled in configuration)]]></source>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.orderBy_2">
<source><![CDATA[Alphabetically by job title (A-Z)]]></source>
......@@ -284,4 +284,4 @@
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
</xliff>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment