-
Notifications
You must be signed in to change notification settings - Fork 3
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 343e84e
Showing
14 changed files
with
1,142 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,3 @@ | ||
/.todos.json | ||
/.idea | ||
.DS_Store |
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,104 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace JosefGlatz\Iconcheck\Controller; | ||
|
||
use JosefGlatz\Iconcheck\Domain\Model\Dto\ExtensionConfiguration; | ||
use TYPO3\CMS\Backend\View\BackendTemplateView; | ||
use TYPO3\CMS\Core\Imaging\IconRegistry; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; | ||
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; | ||
|
||
|
||
class IconcheckController extends ActionController | ||
{ | ||
|
||
/** | ||
* Backend Template Container. | ||
* Takes care of outer "docheader" and other stuff this module is embedded in. | ||
* | ||
* @var string | ||
*/ | ||
protected $defaultViewObjectName = BackendTemplateView::class; | ||
|
||
/** | ||
* BackendTemplateContainer | ||
* | ||
* @var BackendTemplateView | ||
*/ | ||
protected $view; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $languageFilePrefix = 'LLL:EXT:iconcheck/Resources/Private/Language/locallang.xlf:'; | ||
|
||
/** | ||
* Method is called before each action and sets up the doc header. | ||
* | ||
* @param ViewInterface $view | ||
*/ | ||
protected function initializeView(ViewInterface $view) | ||
{ | ||
parent::initializeView($view); | ||
|
||
// Early return for actions without valid view like tcaCreateAction or tcaDeleteAction | ||
if (!($this->view instanceof BackendTemplateView)) { | ||
return; | ||
} | ||
|
||
$this->view->assign('currentAction', $this->request->getControllerActionName()); | ||
|
||
// Shortcut button | ||
$buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); | ||
$getVars = $this->request->getArguments(); | ||
$extensionName = $this->request->getControllerExtensionName(); | ||
$moduleName = $this->request->getPluginName(); | ||
if (\count($getVars) === 0) { | ||
$modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName); | ||
$getVars = array('id', 'M', $modulePrefix); | ||
} | ||
$shortcutButton = $buttonBar->makeShortcutButton() | ||
->setModuleName($moduleName) | ||
->setGetVariables($getVars); | ||
$buttonBar->addButton($shortcutButton); | ||
} | ||
|
||
/** | ||
* Overview | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function indexAction() | ||
{ | ||
// Instantiate TYPO3 icon registry | ||
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); | ||
// Retrieve all registered icons from registry | ||
$iconsAll = $iconRegistry->getAllRegisteredIconIdentifiers(); | ||
|
||
// Load extConf | ||
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class); | ||
|
||
// Show all icon identifiers alphabetically if enabled | ||
if ($extConf->isListAllIconIdentifiers()) { | ||
$listAll = $iconsAll; | ||
natcasesort($listAll); | ||
$this->view->assign('allIcons', $listAll); | ||
} | ||
|
||
// Render userdefined icons in module | ||
if (!empty($extConf->getListIconsWithPrefix())) { | ||
$iconsToShow = []; | ||
foreach ($extConf->getListIconsWithPrefix() as $string) { | ||
foreach ($iconsAll as $key) { | ||
if (strpos($key, $string) === 0) { | ||
$iconsToShow[$string][] = $key; | ||
} | ||
} | ||
// Sort icons | ||
natcasesort($iconsToShow[$string]); | ||
} | ||
$this->view->assign('iconsToShow', $iconsToShow); | ||
} | ||
} | ||
} |
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,64 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace JosefGlatz\Iconcheck\Domain\Model\Dto; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class ExtensionConfiguration | ||
{ | ||
|
||
/** @var bool */ | ||
protected $listAllIconIdentifiers; | ||
|
||
/** @var string */ | ||
protected $listIconsWithPrefix; | ||
|
||
/** @var bool */ | ||
protected $enableModuleForEverybody; | ||
|
||
/** @var bool */ | ||
protected $disableModule; | ||
|
||
public function __construct() | ||
{ | ||
/** @noinspection UnserializeExploitsInspection */ | ||
$settings = (array)unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['iconcheck']); | ||
foreach ($settings as $key => $value) { | ||
if (property_exists(__CLASS__, $key)) { | ||
$this->$key = $value; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isListAllIconIdentifiers(): bool | ||
{ | ||
return (bool)$this->listAllIconIdentifiers; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getListIconsWithPrefix(): array | ||
{ | ||
return GeneralUtility::trimExplode(',', $this->listIconsWithPrefix, true); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isEnableModuleForEverybody(): bool | ||
{ | ||
return (bool)$this->enableModuleForEverybody; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isDisableModule(): bool | ||
{ | ||
return (bool)$this->disableModule; | ||
} | ||
} |
Oops, something went wrong.