Commit 37b09bf8 authored by Philipp Müller's avatar Philipp Müller
Browse files

Initial commit

parents
.DS_Store
/.idea/
/composer.lock
/.Build/
<?php
/**
* This file is part of the "counter" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace Lavitto\Counter\Hooks\PageLayoutView;
use Lavitto\Counter\Utility\FlexFormUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* Class CounterPreviewRenderer
*
* @package Lavitto\Counter\Hooks\PageLayoutView
*/
class CounterPreviewRenderer implements PageLayoutViewDrawItemHookInterface
{
/**
* Preprocesses the preview rendering of a content element of type "counter_counter"
*
* @param PageLayoutView $parentObject Calling parent object
* @param bool $drawItem Whether to draw the item using the default functionality
* @param string $headerContent Header content
* @param string $itemContent Item content
* @param array $row Record row of tt_content
*/
public function preProcess(
PageLayoutView &$parentObject,
&$drawItem,
&$headerContent,
&$itemContent,
array &$row
): void {
if ($row['CType'] === 'counter_counter') {
$flexFormContent = $row['pi_flexform'] ?? null;
if ($flexFormContent !== null) {
$flexFormArray = FlexFormUtility::getFlexFormService()->convertFlexFormContentToArray($flexFormContent);
$start = (int)$flexFormArray['start'];
$end = (int)$flexFormArray['end'];
$label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'CType',
$row['CType']);
$itemContent = '';
if ($label) {
$itemContent .= LocalizationUtility::translate($label);
}
$itemContent .= ' (' . $start . '-' . $end . ')';
$itemContent = $parentObject->linkEditContent('<strong>' . $itemContent . '</strong>', $row);
$drawItem = false;
}
}
}
}
<?php
/**
* This file is part of the "counter" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace Lavitto\Counter\Utility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class RenderFlexFormSettingsViewHelper
*
* @package Lavitto\Counter\Utility
*/
class FlexFormUtility
{
/**
* Returns the FlexFormService
*
* @return object
*/
public static function getFlexFormService()
{
if (version_compare(TYPO3_branch, '9.5', '>=')) {
/** @noinspection ClassConstantCanBeUsedInspection */
$flexFormServiceClass = 'TYPO3\CMS\Core\Service\FlexFormService';
} else {
/** @noinspection ClassConstantCanBeUsedInspection */
$flexFormServiceClass = 'TYPO3\CMS\Extbase\Service\FlexFormService';
}
return GeneralUtility::makeInstance($flexFormServiceClass);
}
}
<?php
/**
* This file is part of the "counter" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace Lavitto\Counter\ViewHelpers;
use Lavitto\Counter\Utility\FlexFormUtility;
use TYPO3Fluid\Fluid\Core\Exception;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class RenderFlexFormSettingsViewHelper
*
* @package Lavitto\Counter\ViewHelpers
*/
class RenderFlexFormSettingsViewHelper extends AbstractViewHelper
{
/**
* Initialize arguments.
*
* @return void
*/
public function initializeArguments(): void
{
$this->registerArgument(
'flexform',
'string',
'The flexform-xml of the content element',
true
);
$this->registerArgument(
'defaultSettings',
'array',
'Default settings array',
true
);
}
/**
* Returns the value of a flexform option
*
* @return array
* @throws Exception
*/
public function render(): array
{
$flexFormArray = [];
$flexFormContent = $this->arguments['flexform'] ?? null;
$defaultSettings = $this->arguments['defaultSettings'] ?? [];
if ($flexFormContent !== null) {
$flexFormArray = FlexFormUtility::getFlexFormService()->convertFlexFormContentToArray($flexFormContent);
}
return array_merge($defaultSettings, $flexFormArray);
}
}
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.sheet.general
</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<start>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.start
</label>
<config>
<type>input</type>
<size>5</size>
<eval>int,required</eval>
<default>0</default>
</config>
</TCEforms>
</start>
<end>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.end
</label>
<config>
<type>input</type>
<size>5</size>
<eval>int,required</eval>
<default>100</default>
</config>
</TCEforms>
</end>
</el>
</ROOT>
</sDEF>
<sAppearance>
<ROOT>
<TCEforms>
<sheetTitle>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.sheet.appearance
</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<duration>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.duration
</label>
<config>
<type>input</type>
<size>5</size>
<eval>double2,required</eval>
<default>5</default>
</config>
</TCEforms>
</duration>
<delay>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.delay
</label>
<config>
<type>input</type>
<size>5</size>
<eval>double2,required</eval>
<default>0</default>
</config>
</TCEforms>
</delay>
<startEffect>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.start_effect
</label>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.start_effect.none
</numIndex>
<numIndex index="1">none</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.start_effect.fadein
</numIndex>
<numIndex index="1">fadein</numIndex>
</numIndex>
</items>
<minItems>1</minItems>
<maxItems>1</maxItems>
<default>none</default>
</config>
</TCEforms>
</startEffect>
<easing>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.easing
</label>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.easing.linear
</numIndex>
<numIndex index="1">linear</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.easing.easein
</numIndex>
<numIndex index="1">easeInQuint</numIndex>
</numIndex>
<numIndex index="3" type="array">
<numIndex index="0">
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.easing.easeout
</numIndex>
<numIndex index="1">easeOutQuint</numIndex>
</numIndex>
<numIndex index="4" type="array">
<numIndex index="0">
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.easing.easeinout
</numIndex>
<numIndex index="1">easeInOutQuint</numIndex>
</numIndex>
</items>
<minItems>1</minItems>
<maxItems>1</maxItems>
<default>linear</default>
</config>
</TCEforms>
</easing>
</el>
</ROOT>
</sAppearance>
<sContents>
<ROOT>
<TCEforms>
<sheetTitle>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.sheet.contents
</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<title>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.title
</label>
<config>
<type>input</type>
<size>50</size>
<eval>trim</eval>
</config>
</TCEforms>
</title>
<description>
<TCEforms>
<exclude>0</exclude>
<label>
LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform.description
</label>
<config>
<type>text</type>
<enableRichtext>1</enableRichtext>
<richtextConfiguration>default</richtextConfiguration>
</config>
</TCEforms>
</description>
</el>
</ROOT>
</sContents>
</sheets>
</T3DataStructure>
<?php
/**
* This file is part of the "counter" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'counter',
'Configuration/TypoScript',
'Counter'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'counter',
'Configuration/TypoScript/Css',
'Counter CSS (optional, only recommended if Bootstrap 4 is not used)'
);
<?php
/**
* This file is part of the "counter" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
/** @noinspection PhpFullyQualifiedNameUsageInspection */
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
[
'LLL:EXT:counter/Resources/Private/Language/Tca.xlf:counter_counter',
'counter_counter',
'EXT:counter/Resources/Public/Icons/ContentElements/counter_counter.svg'
],
'CType',
'counter'
);
$GLOBALS['TCA']['tt_content']['palettes']['counter_counter'] = [
'label' => 'LLL:EXT:counter/Resources/Private/Language/Tca.xlf:counter_counter',
'showitem' => 'pi_flexform;LLL:EXT:counter/Resources/Private/Language/Tca.xlf:tt_content.counter_counter.pi_flexform'
];
$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['*,counter_counter'] = 'FILE:EXT:counter/Configuration/FlexForm/Counter.xml';
$GLOBALS['TCA']['tt_content']['types']['counter_counter'] = [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
--palette--;;headers,
--palette--;;counter_counter,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
--palette--;;frames,
--palette--;;appearanceLinks,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;language,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;;access,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
rowDescription,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,'
];
mod.wizards.newContentElement.wizardItems.common {
elements {
counter_counter {
iconIdentifier = ext-counter-counter
title = LLL:EXT:counter/Resources/Private/Language/Tca.xlf:counter_counter.wizard.title
description = LLL:EXT:counter/Resources/Private/Language/Tca.xlf:counter_counter.wizard.description
tt_content_defValues {
CType = counter_counter
}
}
}
show := addToList(counter_counter)
}
page.includeCSS.tx_counter = EXT:counter/Resources/Public/Css/Counter.min.css
plugin.tx_counter {
# cat=plugin.tx_counter/basic/b1; type=boolean; label=Load jQuery: Enable this, if your website does not already use jQuery (loads jquery 3.4.1)
enableJquery = 0
# cat=plugin.tx_counter/basic/b1; type=boolean; label=Load jQuery UI: Enable this, if your website does not already use jQuery UI (loads jquery-ui 1.12.1)
enableJqueryUi = 0
}
lib.contentElement {
templateRootPaths.1569833847 = EXT:counter/Resources/Private/Templates/
partialRootPaths.1569833847 = EXT:counter/Resources/Private/Partials/
}
tt_content {
counter_counter =< lib.contentElement
counter_counter {
templateName = Counter
settings {
counter {
start = 0
end = 100
duration = 5000
delay = 0
lazyStart = 1
startEffect = none
startEffectDuration = 500
easing = linear
title =
description =
}
}
}
}
page {
cssInline {
1569833847 = TEXT
1569833847.value = .counter-invisible{opacity:0}
}
includeJSFooter {
tx_counter_jquery = EXT:counter/Resources/Public/Libraries/jquery-3.4.1/jquery-3.4.1.min.js
tx_counter_jquery.if.isTrue = {$plugin.tx_counter.enableJquery}
tx_counter_jqueryui = EXT:counter/Resources/Public/Libraries/jqueryui-1.12.1/jquery-ui-1.12.1.min.js
tx_counter_jqueryui.if.isTrue = {$plugin.tx_counter.enableJqueryUi}
tx_counter = EXT:counter/Resources/Public/JavaScript/Counter.min.js
tx_counter.async = 1
}
}
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1427832976" source-language="en" datatype="plaintext" original="messages" date="2014-02-07T20:22:32Z"
product-name="counter">
<header/>
<body>
<!-- General -->
<trans-unit id="counter_counter">
<source>Animated Counter</source>
</trans-unit>
<!-- Wizard -->
<trans-unit id="counter_counter.wizard.title">
<source>Animated Counter</source>
</trans-unit>
<trans-unit id="counter_counter.wizard.description">
<source>Adds an animated counter to the page</source>
</trans-unit>
<!-- Flexform -->
<trans-unit id="tt_content.counter_counter.pi_flexform">
<source>Settings</source>
</trans-unit>
<!-- Flexform Sheet: General -->
<trans-unit id="tt_content.counter_counter.pi_flexform.sheet.general">
<source>General</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.start">
<source>First number</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.end">
<source>Last number</source>
</trans-unit>
<!-- Flexform Sheet: Appearance -->
<trans-unit id="tt_content.counter_counter.pi_flexform.sheet.appearance">
<source>Appearance</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.duration">
<source>Duration (seconds)</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.delay">
<source>Start delay (seconds)</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.start_effect">
<source>Start effect</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.start_effect.none">
<source>None</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.start_effect.fadein">
<source>Fade in</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.easing">
<source>Effect/Easing</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.easing.linear">
<source>Standard (Linear)</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.easing.easein">
<source>Slow start</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.easing.easeout">
<source>Slow end</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.easing.easeinout">
<source>Slow start and end</source>
</trans-unit>
<!-- Flexform Sheet: General -->
<trans-unit id="tt_content.counter_counter.pi_flexform.sheet.contents">
<source>Title/Description</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.title">
<source>Title</source>
</trans-unit>
<trans-unit id="tt_content.counter_counter.pi_flexform.description">
<source>Description</source>
</trans-unit>
</body>
</file>
</xliff>
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1427832976" source-language="en" target-language="de" datatype="plaintext" original="messages" date="2014-02-07T20:22:32Z"
product-name="counter">
<header/>
<body>
<!-- General -->
<trans-unit id="counter_counter">
<source>Animated Counter</source>
<target>Animierter Zähler</target>
</trans-unit>
<!-- Wizard -->
<trans-unit id="counter_counter.wizard.title">
<source>Animated Counter</source>
<target>Animierter Zähler</target>
</trans-unit>
<trans-unit id="counter_counter.wizard.description">
<source>Adds an animated counter to the page</source>
<target>Fügt einen animierten Zähler auf der Seite ein</target>
</trans-unit>
<!-- Flexform -->
<trans-unit id="tt_content.counter_counter.pi_flexform">
<source>Settings</source>
<target>Einstellungen</target>
</trans-unit>