/htdocs/typo3conf/ext/baumer/Classes/Controller/ContentController.php

https://gitlab.com/uralgenc/bourdon-haenni.com · PHP · 135 lines · 64 code · 11 blank · 60 comment · 3 complexity · d45e41420f29345738ef7a4e7740f239 MD5 · raw file

  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. *
  5. * (c) 2015 Hans Höchtl <jhoechtl@gmail.com>
  6. * All rights reserved
  7. *
  8. * This script is part of the TYPO3 project. The TYPO3 project is
  9. * free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * The GNU General Public License can be found at
  15. * http://www.gnu.org/copyleft/gpl.html.
  16. * A copy is found in the textfile GPL.txt and important notices to the license
  17. * from the author is found in LICENSE.txt distributed with these scripts.
  18. *
  19. *
  20. * This script is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * This copyright notice MUST APPEAR in all copies of the script!
  26. ***************************************************************/
  27. namespace Baumer\Baumer\Controller;
  28. use Baumer\Baumer\Domain\Model\CsView;
  29. class ContentController extends \FluidTYPO3\Fluidcontent\Controller\ContentController
  30. {
  31. /**
  32. * @var \Baumer\Baumer\Domain\Repository\CsViewRecordRepository
  33. * @inject
  34. */
  35. protected $csViewRecordRepository;
  36. /**
  37. * @var \Baumer\Baumer\Domain\Repository\CsViewRepository
  38. * @inject
  39. */
  40. protected $csViewRepository;
  41. /**
  42. * @var \Baumer\Baumer\Service\Elasticsearch\Connection
  43. * @inject
  44. */
  45. protected $elasticConnection;
  46. /**
  47. * CE: Views/Configurator
  48. * Find the CsViewRecord that belongs to a configurator view by the
  49. * configured contentServId. Renders the Encoway Configurator Controller.
  50. * @return void
  51. */
  52. public function configuratorAction()
  53. {
  54. $data = $this->getData();
  55. $csViewRecord = null;
  56. if (isset($data['contentServId']) && !empty($data['contentServId'])) {
  57. $csViewRecord = $this->csViewRecordRepository->findOneByContentServId($data['contentServId']);
  58. }
  59. $this->view->assign('csViewRecord', $csViewRecord);
  60. }
  61. /**
  62. * CE: Views/Selector
  63. * Find the CsView that belongs to a selector view by the
  64. * configured contentServId. Renders the Encoway Configurator Controller.
  65. * @return void
  66. */
  67. public function selectorAction()
  68. {
  69. $data = $this->getData();
  70. $csView = null;
  71. if (isset($data['contentServId'])) {
  72. $csView = $this->csViewRepository->findSelectorByContentServId($data['contentServId']);
  73. }
  74. $this->view->assign('csView', $csView);
  75. }
  76. /**
  77. * List all available selectors
  78. */
  79. public function listSelectorsAction()
  80. {
  81. $selectors = $this->csViewRepository->findByClass(CsView::CLASS_SELECTOR);
  82. $this->view->assign('selectors', $selectors);
  83. }
  84. /**
  85. * Download Center
  86. */
  87. public function downloadCenterAction()
  88. {
  89. /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */
  90. $db = $GLOBALS['TYPO3_DB'];
  91. $currentContentElement = $this->getRecord();
  92. $categoryUids = array_map(
  93. function ($row) {
  94. return $row['uid_local'];
  95. },
  96. $db->exec_SELECTgetRows(
  97. 'uid_local',
  98. 'sys_category_record_mm',
  99. 'tablenames = "tt_content" AND fieldname = "downloadcenter_categories" AND uid_foreign = ' . $currentContentElement['uid'])
  100. );
  101. $this->view->assign('categories', $categoryUids);
  102. $this->view->assign('selectorConfig', json_encode($this->elasticConnection->getElasticConfig('FILE')));
  103. $this->view->assign('csAttributes', json_encode($this->settings['downloadcenter']));
  104. }
  105. /**
  106. * Distributor Map
  107. */
  108. public function distributorMapAction()
  109. {
  110. /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */
  111. $db = $GLOBALS['TYPO3_DB'];
  112. $currentContentElement = $this->getRecord();
  113. $categoryUids = array_map(
  114. function ($row) {
  115. return $row['uid_local'];
  116. },
  117. $db->exec_SELECTgetRows(
  118. 'uid_local',
  119. 'sys_category_record_mm',
  120. 'tablenames = "tt_content" AND fieldname = "distributor-map_categories" AND uid_foreign = ' . $currentContentElement['uid'])
  121. );
  122. $this->view->assign('categories', $categoryUids);
  123. }
  124. }