Skip to content

Commit

Permalink
Code Styling
Browse files Browse the repository at this point in the history
  • Loading branch information
abplana committed Sep 27, 2019
1 parent 06e6197 commit 01f5f1e
Show file tree
Hide file tree
Showing 6 changed files with 625 additions and 645 deletions.
290 changes: 143 additions & 147 deletions Classes/Controller/SlugController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
declare(strict_types = 1);
namespace Ig\IgSlug\Controller;


use TYPO3\CMS\Core\Utility\GeneralUtility;
use \TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
Expand All @@ -21,159 +20,158 @@
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;


class SlugController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {


protected $search=[];
protected $depth=0; // get from .....
class SlugController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
protected $search=[];
protected $depth=0; // get from .....

/**
* Initializes the backend module by setting internal variables, initializing the menu.
*/
protected function init()
{
$this->id = (int)GeneralUtility::_GP('id');
$this->objectManager=GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$this->initializeSiteLanguages();
$this->slugsUtility= $this->objectManager->get(\Ig\IgSlug\Utility\SlugsUtility::class, $this->siteLanguages);
$this->slugTables=$this->slugsUtility->getSlugTables();
$this->perms_clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
if( $this->request->hasArgument('search') ) {
$this->search = $this->request->getArgument('search');
}
$this->id = (int)GeneralUtility::_GP('id');
$this->objectManager=GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$this->initializeSiteLanguages();
$this->slugsUtility= $this->objectManager->get(\Ig\IgSlug\Utility\SlugsUtility::class, $this->siteLanguages);
$this->slugTables=$this->slugsUtility->getSlugTables();
$this->perms_clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
if ($this->request->hasArgument('search')) {
$this->search = $this->request->getArgument('search');
}

if( isset($this->search['table']) ) {
$activeTable = $this->search['table'];
if( !isset($this->slugTables[$activeTable])) {
throw new Exception(sprintf('access rights are missing on "%s"', $activeTable), 1549656272 );
}
$this->slugTable=$this->slugTables[$activeTable];
} else {
$this->slugTable=reset($this->slugTables);
}
$this->activeTable=$this->slugTable['table'];
// Why not in PageRendererViewHelper.php argument addInlineLanguageLabelFile
$pageRenderer=GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_core.xlf');
$pageRenderer->addInlineLanguageLabelFile('EXT:ig_slug/Resources/Private/Language/locallang.xlf');
if (isset($this->search['table'])) {
$activeTable = $this->search['table'];
if (!isset($this->slugTables[$activeTable])) {
throw new Exception(sprintf('access rights are missing on "%s"', $activeTable), 1549656272);
}
$this->slugTable=$this->slugTables[$activeTable];
} else {
$this->slugTable=reset($this->slugTables);
}
$this->activeTable=$this->slugTable['table'];
// Why not in PageRendererViewHelper.php argument addInlineLanguageLabelFile
$pageRenderer=GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_core.xlf');
$pageRenderer->addInlineLanguageLabelFile('EXT:ig_slug/Resources/Private/Language/locallang.xlf');

$this->lang = isset($this->search['lang']) && $this->search['lang']!='' ? intval($this->search['lang']) : null;
$this->depth = isset($this->search['depth']) ? intval($this->search['depth']) : 0;
$this->lang = isset($this->search['lang']) && $this->search['lang']!='' ? intval($this->search['lang']) : null;
$this->depth = isset($this->search['depth']) ? intval($this->search['depth']) : 0;


$this->slugsUtility->setTable( $this->slugTable['table'] );
$this->slugsUtility->setSlugFieldName( $this->slugTable['slugFieldName'] );
$this->slugsUtility->setSlugLockedFieldName( $this->slugTable['slugLockedFieldName'] );
// $BE_USER->check('tables_modify', 'pages');
//$BE_USER->check('non_exclude_fields', this->table . ':' . $this->fieldName);
$this->slugsUtility->setTable($this->slugTable['table']);
$this->slugsUtility->setSlugFieldName($this->slugTable['slugFieldName']);
$this->slugsUtility->setSlugLockedFieldName($this->slugTable['slugLockedFieldName']);
// $BE_USER->check('tables_modify', 'pages');
//$BE_USER->check('non_exclude_fields', this->table . ':' . $this->fieldName);
}
public function main() {
$this->view = $this->getFluidTemplateObject();
$this->search = GeneralUtility::_GP('search');
$this->update=(int)GeneralUtility::_GP('update');
$this->init();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/IgSlug/Confirm');
$this->moduleTemplate->getPageRenderer()->addCssFile('EXT:ig_slug/Resources/Public/Css/ig_slug_be.css');
$tableTitle = $this->slugTable['title'];
public function main()
{
$this->view = $this->getFluidTemplateObject();
$this->search = GeneralUtility::_GP('search');
$this->update=(int)GeneralUtility::_GP('update');
$this->init();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/IgSlug/Confirm');
$this->moduleTemplate->getPageRenderer()->addCssFile('EXT:ig_slug/Resources/Public/Css/ig_slug_be.css');
$tableTitle = $this->slugTable['title'];

$filterMenus=$this->modMenu();
$filterMenus=$this->modMenu();

$this->view->assign('filterMenus', $filterMenus);
$this->view->assign('search', $this->search);
$this->view->assign('filterMenus', $filterMenus);
$this->view->assign('search', $this->search);

$fields=$this->slugsUtility->getSlugFields();
$this->slugsUtility->setFieldNamesToShow($fields);
$this->view->assign('fields', $fields);
if($this->update) {
if ($this->slugTable['table']=='pages') {
$pagesCount=$this->slugsUtility->populateSlugsByUidRecursive( [$this->id], $this->depth, $this->lang );
}else{
$pageUids=$this->slugsUtility->getPageRecordsRecursive( $this->id, $this->depth, [$this->id]);
$pagesCount=$this->slugsUtility->populateSlugs( $pageUids, $this->lang );
}

$message=\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($pagesCount!=1 ? 'igSlug.populatedSlugs' : 'igSlug.populatedSlug', 'ig_slug', [$pagesCount]);
$flashMessage = GeneralUtility::makeInstance(
FlashMessage::class,
'',
$message,
FlashMessage::OK
);
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
}
if ($this->slugTable['table']=='pages') {
$entries=$this->slugsUtility->viewSlugsByUidRecursive( [$this->id], $this->depth, $this->lang );
} else {
$pageUids=$this->slugsUtility->getPageRecordsRecursive( $this->id, $this->depth, [$this->id]);
$entries=$this->slugsUtility->viewSlugs( $pageUids, $this->lang );
}
$fields=$this->slugsUtility->getSlugFields();
$this->slugsUtility->setFieldNamesToShow($fields);
$this->view->assign('fields', $fields);
if ($this->update) {
if ($this->slugTable['table']=='pages') {
$pagesCount=$this->slugsUtility->populateSlugsByUidRecursive([$this->id], $this->depth, $this->lang);
} else {
$pageUids=$this->slugsUtility->getPageRecordsRecursive($this->id, $this->depth, [$this->id]);
$pagesCount=$this->slugsUtility->populateSlugs($pageUids, $this->lang);
}

$message=\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($pagesCount!=1 ? 'igSlug.populatedSlugs' : 'igSlug.populatedSlug', 'ig_slug', [$pagesCount]);
$flashMessage = GeneralUtility::makeInstance(
FlashMessage::class,
'',
$message,
FlashMessage::OK
);
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
}
if ($this->slugTable['table']=='pages') {
$entries=$this->slugsUtility->viewSlugsByUidRecursive([$this->id], $this->depth, $this->lang);
} else {
$pageUids=$this->slugsUtility->getPageRecordsRecursive($this->id, $this->depth, [$this->id]);
$entries=$this->slugsUtility->viewSlugs($pageUids, $this->lang);
}

$this->view->assign('entries', $entries);
$this->view->assign('slugTables', $this->slugTables);
$this->view->assign('activeTable', $this->activeTable);
$this->view->assign('entries', $entries);
$this->view->assign('slugTables', $this->slugTables);
$this->view->assign('activeTable', $this->activeTable);

$this->view->assign('pageUid', $this->id);
return $this->view->render();
$this->view->assign('pageUid', $this->id);
return $this->view->render();
}

/*
* Action: list
*
* @return void
*/
public function listAction()
{
$this->init();
$tableTitle = $this->slugTable['title'];
/*
* Action: list
*
* @return void
*/
public function listAction()
{
$this->init();
$tableTitle = $this->slugTable['title'];

$filterMenus=$this->modMenu();
$this->view->assign('filterMenus', $filterMenus);
$this->view->assign('search', $this->search);
$filterMenus=$this->modMenu();
$this->view->assign('filterMenus', $filterMenus);
$this->view->assign('search', $this->search);

$fields=$this->slugsUtility->getSlugFields();
$this->slugsUtility->setFieldNamesToShow($fields);
$this->view->assign('fields', $fields);

if ($this->slugTable['table']=='pages') {
$entries=$this->slugsUtility->viewSlugsByUidRecursive( [$this->id], $this->depth, $this->lang );
} else {
$pageUids=$this->slugsUtility->getPageRecordsRecursive( $this->id, $this->depth, [$this->id]);
$entries=$this->slugsUtility->viewSlugs( $pageUids, $this->lang );
}
$fields=$this->slugsUtility->getSlugFields();
$this->slugsUtility->setFieldNamesToShow($fields);
$this->view->assign('fields', $fields);

if ($this->slugTable['table']=='pages') {
$entries=$this->slugsUtility->viewSlugsByUidRecursive([$this->id], $this->depth, $this->lang);
} else {
$pageUids=$this->slugsUtility->getPageRecordsRecursive($this->id, $this->depth, [$this->id]);
$entries=$this->slugsUtility->viewSlugs($pageUids, $this->lang);
}

$this->view->assign('entries', $entries);
$this->view->assign('slugTables', $this->slugTables);
$this->view->assign('activeTable', $this->activeTable);
$this->view->assign('entries', $entries);
$this->view->assign('slugTables', $this->slugTables);
$this->view->assign('activeTable', $this->activeTable);

$this->view->assign('pageUid', $this->id);
}
$this->view->assign('pageUid', $this->id);
}


/*
* Action: update
*
* @return void
*/
public function updateAction()
{
$this->init();
if( $this->activeTable=='pages' ) {
$pagesCount=$this->slugsUtility->populateSlugsByUidRecursive( [$this->id], $this->depth, $this->lang );
} else {
$pageUids=$this->slugsUtility->getPageRecordsRecursive( $this->id, $this->depth, [$this->id]);
$pagesCount=$this->slugsUtility->populateSlugs( $pageUids, $this->lang );
}
$this->addFlashMessage( \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($pagesCount!=1 ? 'igSlug.populatedSlugs' : 'igSlug.populatedSlug', 'ig_slug', [$pagesCount]));
/*
* Action: update
*
* @return void
*/
public function updateAction()
{
$this->init();
if ($this->activeTable=='pages') {
$pagesCount=$this->slugsUtility->populateSlugsByUidRecursive([$this->id], $this->depth, $this->lang);
} else {
$pageUids=$this->slugsUtility->getPageRecordsRecursive($this->id, $this->depth, [$this->id]);
$pagesCount=$this->slugsUtility->populateSlugs($pageUids, $this->lang);
}
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($pagesCount!=1 ? 'igSlug.populatedSlugs' : 'igSlug.populatedSlug', 'ig_slug', [$pagesCount]));

$this->forward('list');
}
$this->forward('list');
}



Expand All @@ -182,24 +180,24 @@ protected function modMenu()
$lang = $this->getLanguageService();
$menuArray = [
'depth' => [
0 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
1 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
2 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
3 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
4 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
999 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
],
'show' => [
0 => $lang->sL('LLL:EXT:ig_slug/Resources/Private/Language/locallang.xlf:igSlug.all'),
1 => $lang->sL('LLL:EXT:ig_slug/Resources/Private/Language/locallang.xlf:igSlug.changes'),

]
0 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
1 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
2 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
3 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
4 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
999 => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
],
'show' => [
0 => $lang->sL('LLL:EXT:ig_slug/Resources/Private/Language/locallang.xlf:igSlug.all'),
1 => $lang->sL('LLL:EXT:ig_slug/Resources/Private/Language/locallang.xlf:igSlug.changes'),

]
];
// Languages:
$menuArray['lang'] = [];
foreach ($this->siteLanguages as $language) {
$menuArray['lang'][$language->getLanguageId()] = $language->getTitle();
$menuArray['lang'][$language->getLanguageId()] = $language->getTitle();
}
return $menuArray;
}
Expand All @@ -219,8 +217,8 @@ protected function getFluidTemplateObject()
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:ig_slug/Resources/Private/Templates/Slug/Index.html'));

$view->getRequest()->setControllerExtensionName('ig_slug');
$this->request=$view->getRequest();
$this->id = (int)GeneralUtility::_GP('id');
$this->request=$view->getRequest();
$this->id = (int)GeneralUtility::_GP('id');

return $view;
}
Expand Down Expand Up @@ -253,6 +251,4 @@ protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}

}

Loading

0 comments on commit 01f5f1e

Please sign in to comment.