Skip to content

Commit

Permalink
[TASK] Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrodala committed Feb 23, 2018
0 parents commit f1d07e4
Show file tree
Hide file tree
Showing 79 changed files with 6,303 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true
charset = utf-8

trim_trailing_whitespace = true

[*]
end_of_line = lf
insert_final_newline = true

[*.less]
indent_style = space
indent_size = 2

[*.php]
indent_style = space
indent_size = 4

[*.ts]
indent_style = space
indent_size = 2
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
bower.json export-ignore
Gruntfile.js export-ignore
package.json export-ignore
phpcs.xml export-ignore
phpstan.neon export-ignore
phpunit-functional.xml export-ignore
phpunit.xml export-ignore

.grunt/ export-ignore
Tests/ export-ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/bin
/bower_components
/composer.lock
/node_modules
/vendor
/web
7 changes: 7 additions & 0 deletions .grunt/aliases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default:
- clean:css
- clean:js
- bower
- less
- umd
- uglify
7 changes: 7 additions & 0 deletions .grunt/bower.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
install: {
options: {
targetDir: '<%= paths.resources.public %>',
},
},
};
4 changes: 4 additions & 0 deletions .grunt/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
css: '<%= paths.resources.public %>Css/**/*.css',
js: '<%= paths.resources.public %>JavaScript/**/*.js',
};
15 changes: 15 additions & 0 deletions .grunt/less.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
options: {
compress: true,
ieCompat: false,
// Make LESS files from components accessible
paths: 'bower_components',
},
files: {
cwd: '<%= paths.resources.private %>Less/',
src: '*.less',
dest: '<%= paths.resources.public %>Css/',
ext: '.css',
expand: true,
},
};
10 changes: 10 additions & 0 deletions .grunt/uglify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
js: {
files: [{
expand: true,
cwd: '<%= paths.resources.private %>JavaScript/',
src: '**/*.js',
dest: '<%= paths.resources.public %>JavaScript/',
}],
},
};
9 changes: 9 additions & 0 deletions .grunt/umd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
daterangepicker: {
src: '<%= paths.resources.public %>/JavaScript/knockout-daterangepicker/daterangepicker.js',
deps: {
default: ['$', 'moment', 'ko'],
amd: ['jquery', 'moment', 'TYPO3/CMS/Formlog/knockout/knockout'],
},
},
};
75 changes: 75 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
dist: trusty
sudo: false
language: php

cache:
directories:
- $HOME/.composer/cache

install:
- composer require typo3/cms="$TYPO3_VERSION"

script:
- composer test

jobs:
include:
- php: 7.0
env: TYPO3_VERSION=^8.7
- php: 7.1
env: TYPO3_VERSION=^8.7

- &lint
php: 7.0
env: PHP lint
install:
- composer install
script:
- composer lint:php
- <<: *lint
php: 7.1
- <<: *lint
php: 7.1
env: TypoScript lint
script:
- composer lint:typoscript
- <<: *lint
php: 7.1
env: XML lint
script:
- composer lint:xml
- <<: *lint
php: 7.1
env: Codestyle
script:
- composer lint:style
- <<: *lint
php: 7.1
env: Static analysis
script:
- composer analyze:php

- stage: deploy
if: tag IS present
php: 7.1
before_install: skip
install: skip
before_script: skip
script: |
echo -e "Preparing upload of release ${TRAVIS_TAG} to TER\n"
TAG_ANNOTATION="$(git tag -n -l $TRAVIS_TAG)"
TAG_MESSAGE="${TAG_ANNOTATION#* }"
git reset --hard
git clean -xfd
export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null)
composer global require helhum/ter-client dev-master
echo "Uploading release ${TRAVIS_TAG} to TER"
ter-client upload $(composer config extra.typo3/cms.extension-key) . -u "$TYPO3_ORG_USERNAME" -p "$TYPO3_ORG_PASSWORD" -m "$TAG_MESSAGE"
notifications:
slack:
secure: TPgLYBAyIa6V6RT3YqndCnpkiifnY01ehmPrhVHU3G3yC4e4PtnqftgCrg8D4IBbmlVTxncNbsDqNbFfBEaJ1dMv6tv0yMpYlllfN5Syl3nBcjh43rHN4DWEffgJ59dAhJJtWjHvPfYR1/80EdKzsmepQl1i1+CXH1ryxtS6jEU=
154 changes: 154 additions & 0 deletions Classes/Controller/Backend/FormLogController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?php
declare(strict_types = 1);
namespace Pagemachine\Formlog\Controller\Backend;

/*
* This file is part of the Pagemachine TYPO3 Formlog project.
*/

use Pagemachine\Formlog\Domain\FormLog\Filters;
use Pagemachine\Formlog\Domain\Repository\FormLogEntryRepository;
use Pagemachine\Formlog\Mvc\View\Export\CsvView;
use Pagemachine\Formlog\Mvc\View\Export\XlsxView;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;

/**
* Controller for form log management
*/
class FormLogController extends ActionController
{
/**
* @var \TYPO3\CMS\Extbase\Mvc\View\ViewInterface|\Pagemachine\Formlog\Mvc\View\ConfigurableViewInterface
*/
protected $view = null;

/**
* @var array
*/
protected $viewFormatToObjectNameMap = [
'csv' => CsvView::class,
'xlsx' => XlsxView::class,
];

/**
* @var string
*/
protected $defaultViewObjectName = BackendTemplateView::class;

/**
* @var FormLogEntryRepository $formLogEntryRepository
*/
protected $formLogEntryRepository;

/**
* @param FormLogEntryRepository $formLogEntryRepository
*/
public function injectFormLogEntryRepository(FormLogEntryRepository $formLogEntryRepository)
{
$this->formLogEntryRepository = $formLogEntryRepository;
}

/**
* Initialize all actions
*
* @return void
*/
public function initializeAction()
{
if ($this->arguments->hasArgument('filters')) {
$this->request->setArgument('filters', $this->request->hasArgument('filters') ? $this->request->getArgument('filters') : []);
$filtersArgument = $this->arguments->getArgument('filters');
$filtersArgument->getPropertyMappingConfiguration()
->allowAllProperties()
->forProperty('*')
->allowAllProperties();
}
}

/**
* Main overview action
*
* @param Filters $filters
* @param array $pagination
* @return void
*/
public function indexAction(Filters $filters, array $pagination = [])
{
$this->view->assignMultiple([
'entries' => $this->formLogEntryRepository->findAllFiltered($filters),
'filters' => $filters,
'pagination' => $pagination,
'dateFormat' => $this->settings['dateTimeFormat'] ?: \DateTime::W3C,
'isoDateFormat' => \DateTime::W3C,
'daterangepickerTranslations' => $this->prepareDaterangepickerTranslations(),
'inlineSettings' => [
'formlog' => [
'suggestUri' => (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('ajax_formlog_suggest'),
'language' => $GLOBALS['BE_USER']->uc['lang'],
'timeZone' => date_default_timezone_get(),
],
],
]);
}

/**
* Export CSV of form log entries
*
* @param Filters $filters
* @return void
*/
public function exportAction(Filters $filters)
{
$now = new \DateTime();
$fileBasename = sprintf('formlog-%s', $now->format('Y-m-d-H-i-s'));

$this->view->setConfiguration([
'columns' => $this->settings['export']['columns'],
'dateTimeFormat' => $this->settings['dateTimeFormat'],
'fileBasename' => $fileBasename,
]);
$this->view->assign('items', $this->formLogEntryRepository->findAllFiltered($filters));
}

/**
* Prepare localized daterangepicker labels
*
* @return array
*/
protected function prepareDaterangepickerTranslations(): array
{
$translationIdentifiers = [
'labels' => [
'applyButtonTitle',
'cancelButtonTitle',
'startLabel',
'endLabel',
],
'ranges' => [
'last30days',
'lastYear',
'other',
],
'periods' => [
'day',
'week',
'month',
'quarter',
'year',
],
];
$translations = [];

foreach ($translationIdentifiers as $section => $identifiers) {
foreach ($identifiers as $identifier) {
$translations[$section][$identifier] = LocalizationUtility::translate('formlog.daterangepicker.' . $section . '.' . $identifier, 'Formlog');
}
}

return $translations;
}
}
45 changes: 45 additions & 0 deletions Classes/Controller/Backend/FormLogSuggestController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
declare(strict_types = 1);
namespace Pagemachine\Formlog\Controller\Backend;

/*
* This file is part of the Pagemachine TYPO3 Formlog project.
*/

use Pagemachine\Formlog\Domain\FormLog\Suggestions;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Controller for form log suggestions
*/
class FormLogSuggestController
{
/**
* @var Suggestions
*/
protected $suggestions;

/**
* @param Suggestions|null $suggestions
*/
public function __construct(Suggestions $suggestions = null)
{
$this->suggestions = $suggestions ?: GeneralUtility::makeInstance(Suggestions::class);
}

/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function searchAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
{
$body = $request->getParsedBody();
$suggestions = $this->suggestions->getForProperty($body['property']);
$response->getBody()->write(json_encode($suggestions));

return $response;
}
}
Loading

0 comments on commit f1d07e4

Please sign in to comment.