diff --git a/.gitignore b/.gitignore index 3867cbdbd784c898fb16f0a88ff78f2e3d8ac19e..a133c5b17e1f1686b989b65b00d6efdf93e4189c 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .sass-cache -node_modules -vendor \ No newline at end of file +node_modules \ No newline at end of file diff --git a/Classes/Controller/GroupController.php b/Classes/Controller/GroupController.php index fcf71e7c0a722b11dd3f9f2fe619069a7e91979a..4b8822c12ce9753943224de7f2094b28087cdabf 100755 --- a/Classes/Controller/GroupController.php +++ b/Classes/Controller/GroupController.php @@ -27,7 +27,12 @@ namespace Subugoe\Substaff\Controller; ***************************************************************/ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use TYPO3\CMS\Core\Page\PageRenderer; +use TYPO3\CMS\Core\Utility\GeneralUtility; +/** + * Class GroupController + */ class GroupController extends ActionController { /** @@ -44,6 +49,13 @@ class GroupController extends ActionController { */ protected $categoryRepository; + /** + * personRepository + * @inject + * @var \Subugoe\Substaff\Domain\Repository\PersonRepository + */ + protected $personRepository; + /** * Show the list of available categories * @return void @@ -65,16 +77,40 @@ class GroupController extends ActionController { * @return void */ public function showAction(\TYPO3\CMS\Extbase\Domain\Model\Category $category) { + /** @var \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer */ + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); + $activeCategory = 'var activeCategory = ' . ($category->getUid() ? $category->getUid(): 'false') . ';'; + $pageRenderer->addJsInlineCode('activeCategory', $activeCategory); + // person's name should be shown as title + $GLOBALS['TSFE']->page['title'] = $category->getTitle(); + $person = new PersonController(); + $person->addInlineJavaScript($this->request); $categoryId = $category->getUid(); $personsWithoutCategories = $this->groupRepository->findPersonsInThisCategory($categoryId, $this->settings['correspondingMembersUid'], $this->settings['fullMembersUid']); $persons = array(); foreach ($personsWithoutCategories as $k => $person) { $personCategories = $this->groupRepository->findPersonCategories($person['uid'], $this->settings['correspondingMembersUid'], $this->settings['fullMembersUid']); + $isThisPersonACorrespondingMember = $this->groupRepository->findIfThisPersonIsACorrespondingMember($person['uid'], $this->settings['correspondingMembersUid']); + $belongsThisPersonToPhilologicalHistoricalClass = $this->groupRepository->findIfThisPersonBelongsToPhilologicalHistoricalClass($person['uid'], $this->settings['philologicalHistoricalUid']); + $belongsThisPersonToMathematicalPhysicalClass = $this->groupRepository->findIfThisPersonBelongsToMathematicalPhysicalClass($person['uid'], $this->settings['mathematicalPhysicalUid']); + $person['isThisPersonACorrespondingMember'] = $isThisPersonACorrespondingMember['isThisPersonACorrespondingMember']; + $person['belongsThisPersonToPhilologicalHistoricalClass'] = $belongsThisPersonToPhilologicalHistoricalClass['belongsThisPersonToPhilologicalHistoricalClass']; + $person['belongsThisPersonToMathematicalPhysicalClass'] = $belongsThisPersonToMathematicalPhysicalClass['belongsThisPersonToMathematicalPhysicalClass']; $person['personCategories'] = $personCategories; array_push($persons, $person); } - // person's name should be shown as title - $GLOBALS['TSFE']->page['title'] = $category->getTitle(); + + $mainCategories = $this->categoryRepository->findByParent($this->settings['fachgebieteBaseCategory']); + $categories = []; + foreach ($mainCategories as $mainCategory) { + $subCategories = $this->personRepository->findSelectedGroup($mainCategory->getUid()); + if ($subCategories->num_rows > 0) { + foreach ($subCategories as $key => $subCategory) { + $categories[$mainCategory->getTitle()][$key] = ['categoryUid' => $mainCategory->getUid(), 'uid' => $subCategory['uid'], 'title' => $subCategory['title']]; + } + } + } + $this->view ->assign('group', $category) ->assign('persons', $persons) @@ -82,7 +118,8 @@ class GroupController extends ActionController { ->assign('fullMembersUid', $this->settings['fullMembersUid']) ->assign('allMembersPid', $this->settings['allMembersPid']) ->assign('fullMembersPid', $this->settings['fullMembersPid']) - ->assign('correspondingMembersPid', $this->settings['correspondingMembersPid']); + ->assign('correspondingMembersPid', $this->settings['correspondingMembersPid']) + ->assign('categories', $categories);; } /** @@ -125,4 +162,4 @@ class GroupController extends ActionController { ->assign('correspondingMembersPid', $this->settings['correspondingMembersPid']); } -} \ No newline at end of file +} diff --git a/Classes/Controller/PersonController.php b/Classes/Controller/PersonController.php index e5876db5710c1e39c4358e86ca223bf325cee4f6..2fcd045e173732859c6bedf40bdcd69b4a121c19 100755 --- a/Classes/Controller/PersonController.php +++ b/Classes/Controller/PersonController.php @@ -2,9 +2,6 @@ namespace Subugoe\Substaff\Controller; -use TYPO3\CMS\Core\Page\PageRenderer; -use TYPO3\CMS\Core\Utility\GeneralUtility; - /*************************************************************** * Copyright notice * @@ -28,6 +25,13 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ + +use TYPO3\CMS\Core\Page\PageRenderer; +use TYPO3\CMS\Core\Utility\GeneralUtility; + +/** + * Class PersonController + */ class PersonController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController { /** @@ -43,15 +47,19 @@ class PersonController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle */ protected $groupRepository; + /** + * @var \TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository + * @inject + */ + protected $categoryRepository; + /** * List all members * * @return void */ public function listAction() { - - $this->addInlineJavaScript(); - + $this->addInlineJavaScript($this->request); $personsWithoutCategories = $this->personRepository->findPersons($this->settings['correspondingMembersUid'], $this->settings['fullMembersUid']); $persons = []; @@ -60,20 +68,30 @@ class PersonController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle $isThisPersonACorrespondingMember = $this->groupRepository->findIfThisPersonIsACorrespondingMember($person['uid'], $this->settings['correspondingMembersUid']); $belongsThisPersonToPhilologicalHistoricalClass = $this->groupRepository->findIfThisPersonBelongsToPhilologicalHistoricalClass($person['uid'], $this->settings['philologicalHistoricalUid']); $belongsThisPersonToMathematicalPhysicalClass = $this->groupRepository->findIfThisPersonBelongsToMathematicalPhysicalClass($person['uid'], $this->settings['mathematicalPhysicalUid']); - $person['isThisPersonACorrespondingMember'] = $isThisPersonACorrespondingMember['isThisPersonACorrespondingMember']; $person['belongsThisPersonToPhilologicalHistoricalClass'] = $belongsThisPersonToPhilologicalHistoricalClass['belongsThisPersonToPhilologicalHistoricalClass']; $person['belongsThisPersonToMathematicalPhysicalClass'] = $belongsThisPersonToMathematicalPhysicalClass['belongsThisPersonToMathematicalPhysicalClass']; $person['personCategories'] = $personCategories; - array_push($persons, $person); } + $mainCategories = $this->categoryRepository->findByParent($this->settings['fachgebieteBaseCategory']); + $categories = []; + foreach ($mainCategories as $mainCategory) { + $subCategories = $this->personRepository->findSelectedGroup($mainCategory->getUid()); + if ($subCategories->num_rows > 0) { + foreach ($subCategories as $key => $subCategory) { + $categories[$mainCategory->getTitle()][$key] = ['categoryUid' => $mainCategory->getUid(), 'uid' => $subCategory['uid'], 'title' => $subCategory['title']]; + } + } + } + $this->view ->assign('persons', $persons) ->assign('allMembersPid', $this->settings['allMembersPid']) ->assign('fullMembersPid', $this->settings['fullMembersPid']) - ->assign('correspondingMembersPid', $this->settings['correspondingMembersPid']); + ->assign('correspondingMembersPid', $this->settings['correspondingMembersPid']) + ->assign('categories', $categories); } /** @@ -99,17 +117,17 @@ class PersonController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle $this->view->assign('person', $person); } - protected function addInlineJavaScript() { + /** + * @param \TYPO3\CMS\Extbase\Mvc\Request $request + */ + public function addInlineJavaScript(\TYPO3\CMS\Extbase\Mvc\Request $request) { /** @var \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer */ $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $memberJavaScript = []; - - $memberJavaScript[] = 'var fullMembership = ' . ($this->request->hasArgument('full') ? 'true' : 'false') . ';'; - $memberJavaScript[] = 'var correspondingMembership = ' . ($this->request->hasArgument('corresponding') ? 'true' : 'false') . ';'; - $memberJavaScript[] = 'var phClass = ' . ($this->request->hasArgument('ph') ? 'true' : 'false') . ';'; - $memberJavaScript[] = 'var mpClass = ' . ($this->request->hasArgument('mp') ? 'true' : 'false') . ';'; - + $memberJavaScript[] = 'var fullMembership = ' . ($request->hasArgument('full') ? 'true' : 'false') . ';'; + $memberJavaScript[] = 'var correspondingMembership = ' . ($request->hasArgument('corresponding') ? 'true' : 'false') . ';'; + $memberJavaScript[] = 'var phClass = ' . ($request->hasArgument('ph') ? 'true' : 'false') . ';'; + $memberJavaScript[] = 'var mpClass = ' . ($request->hasArgument('mp') ? 'true' : 'false') . ';'; $pageRenderer->addJsInlineCode('substaffmembership', implode(PHP_EOL, $memberJavaScript)); } diff --git a/Classes/Domain/Repository/PersonRepository.php b/Classes/Domain/Repository/PersonRepository.php index a093637a1c716591adb0bcc16491bff72dbe25ba..3b632c8baf615689489b9d6b69675c084e8ac9f3 100755 --- a/Classes/Domain/Repository/PersonRepository.php +++ b/Classes/Domain/Repository/PersonRepository.php @@ -28,8 +28,27 @@ namespace Subugoe\Substaff\Domain\Repository; use TYPO3\CMS\Extbase\Persistence\Repository; +/** + * Class PersonRepository + */ class PersonRepository extends Repository { + /** + * @param int $categoryId + * @return mixed + */ + public function findSelectedGroup($categoryId) { + $categories = $GLOBALS['TYPO3_DB']->exec_SELECTquery( + 's.*, count(sm.uid_local) AS count', + 'sys_category s INNER JOIN sys_category_record_mm sm ON s.uid = sm.uid_local', + 's.parent = ' . $categoryId, + 's.uid HAVING count(sm.uid_local) > 0', + 's.title', + '' + ); + return $categories; + } + /** * @param integer $correspondingMembersUid The uid of corresponding members category * @param integer $fullMembersUid The uid of full members category