Skip to content

Commit

Permalink
[BUGFIX] Fix for icons in list view
Browse files Browse the repository at this point in the history
  • Loading branch information
jmverges committed Jul 24, 2015
1 parent ba66792 commit 3ee1bd8
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 26 deletions.
56 changes: 32 additions & 24 deletions Classes/Hooks/ContentIconHookSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
<?php
namespace FluidTYPO3\Flux\Hooks;
/***************************************************************
* Copyright notice
*
* (c) 2014 Claus Due <claus@namelesscoder.net>
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.

/*
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Flux\Form;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Utility\MiscellaneousUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList;
Expand All @@ -39,6 +24,15 @@
*/
class ContentIconHookSubscriber {

/**
* @var boolean
*/
protected static $assetsIncluded = FALSE;

protected $templates = array(
'iconWrapper' => '</div><span class="t3-icon t3-icon-empty t3-icon-empty-empty fluidcontent-icon">%s</span><div class="fluidcontent-hack">'
);

/**
* @var ObjectManagerInterface
*/
Expand Down Expand Up @@ -85,6 +79,7 @@ public function __construct() {
* @return string
*/
public function addSubIcon(array $parameters, $caller = NULL) {
$this->attachAssets();
list ($table, $uid, $record) = $parameters;
$icon = NULL;
if (NULL !== $caller) {
Expand All @@ -109,9 +104,10 @@ public function addSubIcon(array $parameters, $caller = NULL) {
$label = trim($form->getLabel());
$icon = '<img width="16" height="16" src="' . $icon . '" alt="' . $label . '"
title="' . $label . '" class="" />';
$icon = '<span class="t3-icon t3-icon-empty t3-icon-empty-empty"
style="float: left; vertical-align: bottom; margin-top: 2px;">' . $icon . '</span>';
} else {
$icon = '<span class="t3-icon t3-icon-apps t3-icon-apps-pagetree t3-icon-pagetree-root"> </span>';
}
$icon = sprintf($this->templates['iconWrapper'], $icon);
}
}
}
Expand All @@ -135,4 +131,16 @@ protected function detectFirstFlexTypeFieldInTableFromPossibilities($table, $fie
return NULL;
}

/**
* @return void
*/
protected function attachAssets() {
if (FALSE === self::$assetsIncluded) {
$doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
$doc->backPath = $GLOBALS['BACK_PATH'];
$doc->getPageRenderer()->addCssFile($doc->backPath . ExtensionManagementUtility::extRelPath('flux') . 'Resources/Public/css/icon.css');
self::$assetsIncluded = TRUE;
}
}

}
21 changes: 21 additions & 0 deletions Classes/Hooks/LegacyContentIconHookSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace FluidTYPO3\Flux\Hooks;

/*
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

/**
* Class LegacyContentIconHookSubscriber
*/
class LegacyContentIconHookSubscriber extends ContentIconHookSubscriber {

protected $templates = array(
'iconWrapper' => '<span class="t3-icon t3-icon-empty t3-icon-empty-empty"
style="float: left; vertical-align: bottom; margin-top: 2px;">%s</span>'
);

}
33 changes: 33 additions & 0 deletions Resources/Public/css/icon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Hack icon iinto page and list */
.t3-js-clickmenutrigger {
z-index: 2;
position: relative
}

.t3-js-clickmenutrigger .t3-icon-pagetree-root {
opacity: 0
}

.fluidcontent-icon {
margin-top: 7px;
position: absolute;
left: 12px;
z-index: 1
}

.fluidcontent-hack {
display: none
}

.t3-page-ce-header-icons-left .t3-js-clickmenutrigger + .t3-icon-empty-empty {
display: none
}

.t3-page-ce-header {
position: relative
}

.t3-page-ce-header .fluidcontent-icon {
margin-top: 3px;
left: 10px;
}
32 changes: 31 additions & 1 deletion Tests/Unit/Hooks/ContentIconHookSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,37 @@ public function getAddSubIconTestValues() {
array(array('tt_content', 1, array()), NULL, NULL),
array(array('tt_content', 1, array()), $providerWithoutForm, NULL),
array(array('tt_content', 1, array('field' => 'test')), $providerWithoutForm, NULL),
array(array('tt_content', 1, array('field' => 'test')), $providerWithFormWithoutIcon, NULL),
array(array('tt_content', 1, array('field' => 'test')), $providerWithFormWithoutIcon, '</div>
<style>
.t3-js-clickmenutrigger {
z-index: 2;
position: relative
}
.t3-js-clickmenutrigger .t3-icon-pagetree-root {
opacity: 0
}
.fluidcontent-icon {
margin-top: 7px;
position: absolute;
left: 12px;
z-index: 1
}
.fluidcontent-hack {
display: none
}
.t3-page-ce-header-icons-left .t3-js-clickmenutrigger+span.t3-icon-empty-empty {
display: none
}
.t3-page-ce-header {
position: relative
}
.t3-page-ce-header .fluidcontent-icon {
margin-top: 3px;
left: 10px;
}
</style>
<span class="t3-icon t3-icon-empty t3-icon-empty-empty fluidcontent-icon">%s</span>
<div class="fluidcontent-hack">'),
array(array('tt_content', 1, array('field' => 'test')), $providerWithFormWithIcon, 'icon'),
);
}
Expand Down
4 changes: 3 additions & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@
unset($extbaseObjectContainer);
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook']['flux'] = 'FluidTYPO3\Flux\Hooks\WizardItemsHookSubscriber';

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']['flux'] = 'FluidTYPO3\\Flux\\Hooks\\ContentIconHookSubscriber->addSubIcon';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']['flux'] = TRUE === version_compare(TYPO3_version, '7.1', '<')
? 'FluidTYPO3\\Flux\\Hooks\\LegacyContentIconHookSubscriber->addSubIcon'
: 'FluidTYPO3\\Flux\\Hooks\\ContentIconHookSubscriber->addSubIcon';

0 comments on commit 3ee1bd8

Please sign in to comment.