|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* 2017 Romain CANON <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
7
|
|
|
* under the terms of the GNU General Public License, either |
|
8
|
|
|
* version 3 of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, see: |
|
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Romm\Formz\AssetHandler\Css; |
|
15
|
|
|
|
|
16
|
|
|
use Romm\Formz\AssetHandler\AbstractAssetHandler; |
|
17
|
|
|
use Romm\Formz\Form\Definition\Step\Step\Substep\Substeps; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* This asset handler generates the CSS code used to display/hide a substep |
|
21
|
|
|
* container when the current form substep is not the correct one. |
|
22
|
|
|
*/ |
|
23
|
|
|
class SubstepCssAssetHandler extends AbstractAssetHandler |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @return string |
|
28
|
|
|
*/ |
|
29
|
|
|
public function getSubstepCss() |
|
30
|
|
|
{ |
|
31
|
|
|
$cssBlocks = []; |
|
32
|
|
|
$formDefinition = $this->getFormObject()->getDefinition(); |
|
33
|
|
|
|
|
34
|
|
|
if ($formDefinition->hasSteps()) { |
|
35
|
|
|
foreach ($formDefinition->getSteps()->getEntries() as $step) { |
|
36
|
|
|
if ($step->hasSubsteps()) { |
|
37
|
|
|
$cssBlocks += $this->aze($step->getSubsteps()); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return implode(CRLF, $cssBlocks); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
protected function aze(Substeps $substeps) |
|
46
|
|
|
{ |
|
47
|
|
|
$cssBlocks = []; |
|
48
|
|
|
$formName = $this->getFormObject()->getName(); |
|
49
|
|
|
|
|
50
|
|
|
foreach ($substeps->getEntries() as $substep) { |
|
51
|
|
|
$substepIdentifier = $substep->getIdentifier(); |
|
52
|
|
|
|
|
53
|
|
|
$cssBlocks[] = <<<CSS |
|
54
|
|
|
form[name="$formName"]:not([fz-substep="$substepIdentifier"]) div[fz-substep="$substepIdentifier"] { |
|
55
|
|
|
display: none; |
|
56
|
|
|
} |
|
57
|
|
|
CSS; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return $cssBlocks; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|