-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 24d1c61
Showing
29 changed files
with
1,857 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GAYA\ContentUsage\Configuration; | ||
|
||
class TcaConfiguration | ||
{ | ||
/** | ||
* @var mixed[] | ||
*/ | ||
private array $tca = []; | ||
|
||
public function __construct() | ||
{ | ||
$this->tca = $GLOBALS['TCA']; | ||
} | ||
|
||
/** | ||
* @return \GAYA\ContentUsage\Domain\Model\Doktype[] | ||
*/ | ||
public function getDoktypes(): array | ||
{ | ||
$doktypes = []; | ||
|
||
foreach ($this->tca['pages']['columns']['doktype']['config']['items'] as $doktypeItem) { | ||
if ($doktypeItem[1] === '--div--') { | ||
continue; | ||
} | ||
|
||
$doktype = new \GAYA\ContentUsage\Domain\Model\Doktype(); | ||
$doktype->setId((int)$doktypeItem[1]); | ||
$doktype->setLabel($this->getTranslation($doktypeItem[0])); | ||
$doktype->setIcon($doktypeItem[2] ?? ''); | ||
|
||
$doktypes[] = $doktype; | ||
} | ||
|
||
return $doktypes; | ||
} | ||
|
||
/** | ||
* @return \GAYA\ContentUsage\Domain\Model\Ctype[] | ||
*/ | ||
public function getCtypes(): array | ||
{ | ||
$ctypes = []; | ||
|
||
foreach ($this->tca['tt_content']['columns']['CType']['config']['items'] as $ctypeItem) { | ||
if ($ctypeItem[1] === '--div--') { | ||
continue; | ||
} | ||
|
||
$ctype = new \GAYA\ContentUsage\Domain\Model\Ctype(); | ||
$ctype->setId($ctypeItem[1]); | ||
$ctype->setLabel($this->getTranslation($ctypeItem[0])); | ||
$ctype->setIcon($ctypeItem[2] ?? ''); | ||
|
||
$ctypes[] = $ctype; | ||
} | ||
|
||
return $ctypes; | ||
} | ||
|
||
/** | ||
* @return \GAYA\ContentUsage\Domain\Model\Plugin[] | ||
*/ | ||
public function getPlugins(): array | ||
{ | ||
$plugins = []; | ||
|
||
foreach ($this->tca['tt_content']['columns']['list_type']['config']['items'] as $pluginItem) { | ||
if ($pluginItem[1] === '') { | ||
continue; | ||
} | ||
|
||
$plugin = new \GAYA\ContentUsage\Domain\Model\Plugin(); | ||
$plugin->setId($pluginItem[1]); | ||
$plugin->setLabel($this->getTranslation($pluginItem[0])); | ||
$plugin->setIcon($pluginItem[2] ?? ''); | ||
|
||
$plugins[] = $plugin; | ||
} | ||
|
||
return $plugins; | ||
} | ||
|
||
private function getTranslation(string $key): string | ||
{ | ||
if (str_starts_with($key, 'LLL:')) { | ||
return \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key); | ||
} | ||
|
||
return $key; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GAYA\ContentUsage\Controller; | ||
|
||
use GAYA\ContentUsage\Configuration\TcaConfiguration; | ||
use GAYA\ContentUsage\Domain\Repository\ContentRepository; | ||
use GAYA\ContentUsage\Domain\Repository\PageRepository; | ||
use TYPO3\CMS\Backend\Template\ModuleTemplate; | ||
use TYPO3\CMS\Beuser\Domain\Model\ModuleData; | ||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; | ||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; | ||
|
||
class ReportController extends ActionController | ||
{ | ||
private TcaConfiguration $tcaConfiguration; | ||
|
||
private PageRepository $pageRepository; | ||
|
||
private ContentRepository $contentRepository; | ||
|
||
protected ?ModuleData $moduleData = null; | ||
|
||
protected ?ModuleTemplate $moduleTemplate = null; | ||
|
||
public function __construct( | ||
TcaConfiguration $tcaConfiguration, | ||
PageRepository $pageRepository, | ||
ContentRepository $contentRepository | ||
) { | ||
$this->pageRepository = $pageRepository; | ||
$this->tcaConfiguration = $tcaConfiguration; | ||
$this->contentRepository = $contentRepository; | ||
|
||
} | ||
|
||
public function mainAction() | ||
{ | ||
|
||
} | ||
|
||
public function doktypesAction() | ||
{ | ||
$doktypes = $this->tcaConfiguration->getDoktypes(); | ||
foreach ($doktypes as $doktype) { | ||
$doktype->setTotalActivePages($this->pageRepository->countActiveByDoktype($doktype)); | ||
$doktype->setTotalDisabledPages($this->pageRepository->countDisabledByDoktype($doktype)); | ||
$doktype->setTotalDeletedPages($this->pageRepository->countDeletedByDoktype($doktype)); | ||
} | ||
|
||
$this->view->assign('doktypes', $doktypes); | ||
} | ||
|
||
public function ctypesAction() | ||
{ | ||
$ctypes = $this->tcaConfiguration->getCtypes(); | ||
foreach ($ctypes as $ctype) { | ||
$ctype->setTotalActiveContents($this->contentRepository->countActiveByCtype($ctype)); | ||
$ctype->setTotalDisabledContents($this->contentRepository->countDisabledByCtype($ctype)); | ||
$ctype->setTotalDeletedContents($this->contentRepository->countDeletedByCtype($ctype)); | ||
} | ||
|
||
$this->view->assign('ctypes', $ctypes); | ||
} | ||
|
||
public function listTypesAction() | ||
{ | ||
$plugins = $this->tcaConfiguration->getPlugins(); | ||
foreach ($plugins as $plugin) { | ||
$plugin->setTotalActiveContents($this->contentRepository->countActiveByPlugin($plugin)); | ||
$plugin->setTotalDisabledContents($this->contentRepository->countDisabledByPlugin($plugin)); | ||
$plugin->setTotalDeletedContents($this->contentRepository->countDeletedByPlugin($plugin)); | ||
} | ||
|
||
$this->view->assign('plugins', $plugins); | ||
} | ||
|
||
public function doktypeDetailAction(int $doktypeId, string $status) | ||
{ | ||
$doktype = null; | ||
$doktypeFound = false; | ||
foreach ($this->tcaConfiguration->getDoktypes() as $doktype) { | ||
if ($doktype->getId() === $doktypeId) { | ||
$doktypeFound = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!$doktypeFound) { | ||
$this->redirect('main'); | ||
} | ||
|
||
switch ($status) { | ||
case 'active': | ||
$doktype->setActivePages($this->pageRepository->findActiveByDoktype($doktype)); | ||
break; | ||
case 'disabled': | ||
$doktype->setDisabledPages($this->pageRepository->findDisabledByDoktype($doktype)); | ||
break; | ||
case 'deleted': | ||
$doktype->setDeletedPages($this->pageRepository->findDeletedByDoktype($doktype)); | ||
break; | ||
}; | ||
|
||
$this->view->assign('doktype', $doktype); | ||
$this->view->assign('status', $status); | ||
} | ||
|
||
public function ctypeDetailAction(string $ctypeName, string $status) | ||
{ | ||
$ctype = null; | ||
$ctypeFound = false; | ||
foreach ($this->tcaConfiguration->getCtypes() as $ctype) { | ||
if ($ctype->getId() === $ctypeName) { | ||
$ctypeFound = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!$ctypeFound) { | ||
$this->redirect('main'); | ||
} | ||
|
||
switch ($status) { | ||
case 'active': | ||
$ctype->setActiveContents($this->contentRepository->findActiveByCtype($ctype)); | ||
break; | ||
case 'disabled': | ||
$ctype->setDisabledContents($this->contentRepository->findDisabledByCtype($ctype)); | ||
break; | ||
case 'deleted': | ||
$ctype->setDeletedContents($this->contentRepository->findDeletedByCtype($ctype)); | ||
break; | ||
}; | ||
|
||
$this->view->assign('ctype', $ctype); | ||
$this->view->assign('status', $status); | ||
} | ||
|
||
public function listTypeDetailAction(string $listType, string $status) | ||
{ | ||
$plugin = null; | ||
$pluginFound = false; | ||
foreach ($this->tcaConfiguration->getPlugins() as $plugin) { | ||
if ($plugin->getId() === $listType) { | ||
$pluginFound = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!$pluginFound) { | ||
$this->redirect('main'); | ||
} | ||
|
||
switch ($status) { | ||
case 'active': | ||
$plugin->setActiveContents($this->contentRepository->findActiveByPlugin($plugin)); | ||
break; | ||
case 'disabled': | ||
$plugin->setDisabledContents($this->contentRepository->findDisabledByPlugin($plugin)); | ||
break; | ||
case 'deleted': | ||
$plugin->setDeletedContents($this->contentRepository->findDeletedByPlugin($plugin)); | ||
break; | ||
}; | ||
|
||
$this->view->assign('plugin', $plugin); | ||
$this->view->assign('status', $status); | ||
} | ||
|
||
protected function getBackendUser(): BackendUserAuthentication | ||
{ | ||
return $GLOBALS['BE_USER']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GAYA\ContentUsage\Domain\Model; | ||
|
||
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; | ||
|
||
class Content extends AbstractEntity | ||
{ | ||
protected string $header = ''; | ||
|
||
protected string $ctype = ''; | ||
|
||
protected string $listType = ''; | ||
|
||
protected int $sysLanguageUid = 0; | ||
|
||
protected int $t3verWsid = 0; | ||
|
||
public function getHeader(): string | ||
{ | ||
return $this->header; | ||
} | ||
|
||
public function setHeader(string $header): void | ||
{ | ||
$this->header = $header; | ||
} | ||
|
||
public function getCtype(): string | ||
{ | ||
return $this->ctype; | ||
} | ||
|
||
public function setCtype(string $ctype): void | ||
{ | ||
$this->ctype = $ctype; | ||
} | ||
|
||
public function getListType(): string | ||
{ | ||
return $this->listType; | ||
} | ||
|
||
public function setListType(string $listType): void | ||
{ | ||
$this->listType = $listType; | ||
} | ||
|
||
public function getSysLanguageUid(): int | ||
{ | ||
return $this->sysLanguageUid; | ||
} | ||
|
||
public function setSysLanguageUid(int $sysLanguageUid): void | ||
{ | ||
$this->sysLanguageUid = $sysLanguageUid; | ||
} | ||
|
||
public function getT3verWsid(): int | ||
{ | ||
return $this->t3verWsid; | ||
} | ||
|
||
public function setT3verWsid(int $t3verWsid): void | ||
{ | ||
$this->t3verWsid = $t3verWsid; | ||
} | ||
} |
Oops, something went wrong.