Skip to content
Snippets Groups Projects
Commit db2b4b4c authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] add teaser plugin

parent 7f045a3b
No related branches found
No related tags found
No related merge requests found
Showing
with 210 additions and 25 deletions
<?php
namespace SGalinski\SgJobs\Controller;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* The JobTeaser plugin controller
*/
class JobTeaserController extends ActionController {
/**
* @var \SGalinski\SgJobs\Domain\Repository\JobRepository
* @inject
*/
private $jobRepository;
/**
* Get marked offers and display them
*
* @return void
*/
public function indexAction() {
$totalAmountOfOffers = $this->jobRepository->countAll();
$featuredOffers = $this->jobRepository->findByFeaturedOffer(TRUE);
$this->view->assign('totalAmountOfOffers', $totalAmountOfOffers);
$this->view->assign('featuredOffers', $featuredOffers);
}
}
......@@ -72,10 +72,11 @@ class JoblistController extends ActionController {
* Show all job offers and options to manage them
*
* @param array $filters
* @param int $jobId
* @return void
* @throws \InvalidArgumentException
*/
public function indexAction(array $filters = []) {
public function indexAction(array $filters = [], $jobId = null) {
if ($filters) {
$this->view->assign('selectedCountry', $filters['filterCountry']);
$this->view->assign('selectedCompany', $filters['filterCompany']);
......@@ -90,21 +91,26 @@ class JoblistController extends ActionController {
$this->assignFilterValues($storagePid);
$this->view->assign('recordPageId', $storagePid);
// pagination logic
$jobLimit = (int) $this->settings['jobLimit'];
$offset = 0;
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgjobs_pagebrowser')['currentPage'];
if ($currentPageBrowserPage && $jobLimit) {
$offset = $currentPageBrowserPage * $jobLimit;
}
// get all jobs for the current page
$jobs = FrontendFilterService::getJobs($filters, $storagePid, $jobLimit, $offset);
if ($jobId) {
$jobs = [$this->jobRepository->findByUid($jobId)];
$numberOfPages = 1;
} else {
// pagination logic
$offset = 0;
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgjobs_pagebrowser')['currentPage'];
if ($currentPageBrowserPage && $jobLimit) {
$offset = $currentPageBrowserPage * $jobLimit;
}
// get all jobs for the current page
$jobsCount = \count(FrontendFilterService::getJobs($filters, $storagePid));
$numberOfPages = ($jobLimit <= 0 ? 0 : ceil($jobsCount / $jobLimit));
// get all jobs for the current page
$jobs = FrontendFilterService::getJobs($filters, $storagePid, $jobLimit, $offset);
// get all jobs for the current page
$jobsCount = \count(FrontendFilterService::getJobs($filters, $storagePid));
$numberOfPages = ($jobLimit <= 0 ? 0 : ceil($jobsCount / $jobLimit));
}
$this->view->assign('jobs', $jobs);
$this->view->assign('limit', $jobLimit);
......
......@@ -58,6 +58,11 @@ class Job extends AbstractEntity {
*/
protected $area = '';
/**
* @var bool
*/
protected $featuredOffer = FALSE;
/**
* @var string $alternativeStartDate
*/
......@@ -222,4 +227,18 @@ class Job extends AbstractEntity {
public function setAlternativeStartDate(string $alternativeStartDate) {
$this->alternativeStartDate = $alternativeStartDate;
}
/**
* @return bool
*/
public function isFeaturedOffer() {
return $this->featuredOffer;
}
/**
* @param bool $featuredOffer
*/
public function setFeaturedOffer($featuredOffer) {
$this->featuredOffer = $featuredOffer;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.plugin_options</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<settings.offersPage>
<TCEforms>
<label>LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.offers_page</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.offersPage>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
......@@ -17,5 +17,13 @@ call_user_func(
$pluginSignature,
'FILE:EXT:sg_jobs/Configuration/FlexForms/JobApplication.xml'
);
$pluginSignature = $extensionName . '_' . strtolower('JobTeaser');
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:sg_jobs/Configuration/FlexForms/JobTeaser.xml'
);
}
);
......@@ -26,7 +26,7 @@ return [
'Resources/Public/Icons/tx_sgjobs_domain_model_job.svg'
],
'interface' => [
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, title, job_id, area, start_date, alternative_start_date,
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, title, job_id, area, featured_offer, start_date, alternative_start_date,
company, task, qualification, description, contact',
],
'types' => [
......@@ -42,7 +42,7 @@ return [
'canNotCollapse' => 1,
],
'palette_title_start' => ['showitem' => 'start_date, alternative_start_date', 'canNotCollapse' => 1],
'palette_area_function' => ['showitem' => 'area', 'canNotCollapse' => 1],
'palette_area_function' => ['showitem' => 'area, featured_offer', 'canNotCollapse' => 1],
'palette_location_contact' => ['showitem' => 'company, contact', 'canNotCollapse' => 1]
],
'columns' => [
......@@ -153,6 +153,13 @@ return [
'eval' => 'trim'
],
],
'featured_offer' => [
'exclude' => 1,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.featuredOffer',
'config' => [
'type' => 'check',
],
],
'start_date' => [
'exclude' => 1,
'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.start_date',
......
......@@ -25,6 +25,10 @@
<source>Job Offers</source>
<target>Stellenangebote</target>
</trans-unit>
<trans-unit id="teaserPlugin" approved="yes">
<source>[SgJobs] Job Teaser</source>
<target>[SgJobs] Job Teaser</target>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
\ No newline at end of file
......@@ -133,6 +133,10 @@
<source>Job description</source>
<target>Beschreibung</target>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.featuredOffer" approved="yes">
<source>Featured Offer (will show up in the job offer teaser)</source>
<target>Diese Stellenausschreibung im Job-Teaser anzeigen</target>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.jobId" approved="yes">
<source>Job ID (optional)</source>
<target>Job ID (optional)</target>
......@@ -145,6 +149,10 @@
<source>Location</source>
<target>Arbeitsort</target>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.offers_page" approved="yes">
<source>Page that lists all job offers</source>
<target>Seite auf der alle Stellenanzeigen gelistet werden</target>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.plugin_options" approved="yes">
<source>Joblist plugin options</source>
<target>Joblist Plugin-Optionen</target>
......
......@@ -9,12 +9,12 @@
<authorEmail>fabian@sgalinski.de</authorEmail>
</header>
<body>
<trans-unit id="listPlugin">
<source>[SgJobs] Joblist</source>
</trans-unit>
<trans-unit id="applyPlugin">
<source>[SgJobs] Job Application</source>
</trans-unit>
<trans-unit id="listPlugin">
<source>[SgJobs] Joblist</source>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr">
<source>Job Offers</source>
</trans-unit>
......@@ -24,6 +24,9 @@
<trans-unit id="mlang_tabs_tab">
<source>Job Offers</source>
</trans-unit>
<trans-unit id="teaserPlugin">
<source>[SgJobs] Job Teaser</source>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
\ No newline at end of file
......@@ -102,6 +102,9 @@
<trans-unit id="tx_sgjobs_domain_model_job.description">
<source>Job description</source>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.featuredOffer">
<source>Featured Offer (will show up in the job offer teaser)</source>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.jobId">
<source>Job ID (optional)</source>
</trans-unit>
......@@ -111,6 +114,9 @@
<trans-unit id="tx_sgjobs_domain_model_job.location">
<source>Location</source>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.offers_page">
<source>Page that lists all job offers</source>
</trans-unit>
<trans-unit id="tx_sgjobs_domain_model_job.plugin_options">
<source>Joblist plugin options</source>
</trans-unit>
......
<div class="col-md-6 col-sm-6 col-cs-12">
<div class="default-content-element">
<article class="pia-card">
<article class="pia-card" id="offer-{job.uid}">
<div class="pia-card-header">
<h2>{job.title}</h2>
<h3>
......
<article class="default-content-element pia-job-offers-teaser">
<h2>
<span class="pia-job-offers-teaser-number">
{totalAmountOfOffers}
</span>
Offene Stellen weltweit
</h2>
<ul class="pia-job-offers-teaser-list">
<f:for each="{featuredOffers}" as="offer">
<li>
<f:link.action pageUid="{settings.offersPage}" controller="Joblist" action="index"
pluginName="Joblist" arguments="{jobId: offer.uid}">
{offer.title}
</f:link.action>
</li>
</f:for>
</ul>
<f:link.typolink parameter="{settings.offersPage}" class="cta-link pia-job-offers-teaser-more">
Alle offenen Stellen
</f:link.typolink>
</article>
......@@ -16,9 +16,7 @@
</div>
<div id="sgjobs-pagination">
<f:format.raw>
<sg:pageBrowser numberOfPages="{numberOfPages}" />
</f:format.raw>
<f:format.raw><sg:pageBrowser numberOfPages="{numberOfPages}" /></f:format.raw>
</div>
</div>
</f:section>
......@@ -31,7 +31,18 @@ $tsPath = $extPath . 'Configuration/TypoScript/Common/';
'Joblist' => 'applyForm, apply'
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SGalinski.sg_jobs',
'JobTeaser',
[
// Cacheable actions
'JobTeaser' => 'index'
],
[
// Uncacheable actions
'JobTeaser' => ''
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SGalinski.sg_jobs',
'PageBrowser',
......
......@@ -19,6 +19,13 @@
'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_backend.xlf:applyPlugin'
);
// Register frontend plugins
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'sg_jobs',
'JobTeaser',
'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_backend.xlf:teaserPlugin'
);
if (TYPO3_MODE === 'BE') {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_sgjobs_domain_model_job');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_sgjobs_domain_model_contact');
......
......@@ -13,6 +13,7 @@ CREATE TABLE tx_sgjobs_domain_model_job (
description text DEFAULT '' NOT NULL,
area text DEFAULT '' NOT NULL,
contact int(11) unsigned DEFAULT '0' NOT NULL,
featured_offer tinyint(4) unsigned DEFAULT '0' NOT NULL,
-- TYPO3 fields
sorting int(11) unsigned DEFAULT '0' NOT NULL,
......
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