|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
* @copyright 2013 - 2016 Cross Solution <http://cross-solution.de> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** */ |
|
11
|
|
|
namespace Core\Form; |
|
12
|
|
|
|
|
13
|
|
|
use Zend\Form\Element; |
|
14
|
|
|
use Zend\Stdlib\PriorityList; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* ${CARET} |
|
18
|
|
|
* |
|
19
|
|
|
* @author Mathias Gelhausen <[email protected]> |
|
20
|
|
|
* @todo write test |
|
21
|
|
|
*/ |
|
22
|
|
|
class WizardContainer extends Container implements HeadscriptProviderInterface, \IteratorAggregate |
|
23
|
|
|
{ |
|
24
|
|
|
protected $tabs = []; |
|
25
|
|
|
protected $scripts = [ |
|
26
|
|
|
'/js/jquery.bootstrapwizard.min.js', |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
|
|
protected $tabContainerPrototype; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Sets the array of script names. |
|
33
|
|
|
* |
|
34
|
|
|
* @param string[] $scripts |
|
35
|
|
|
* |
|
36
|
|
|
* @return self |
|
37
|
|
|
*/ |
|
38
|
|
|
public function setHeadscripts(array $scripts) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->scripts = $scripts; |
|
41
|
|
|
|
|
42
|
|
|
return $this; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Gets the array of script names. |
|
47
|
|
|
* |
|
48
|
|
|
* @return string[] |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getHeadscripts() |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->scripts; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function setForm($key, $spec, $enabled = true) |
|
56
|
|
|
{ |
|
57
|
|
|
if (is_object($spec)) { |
|
58
|
|
|
if (!$spec instanceOf Container) { |
|
59
|
|
|
throw new \InvalidArgumentException('Tab container must be of the type \Core\Form\Container'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if (!$spec->getLabel()) { |
|
|
|
|
|
|
63
|
|
|
throw new \InvalidArgumentException('Container instances must have a label.'); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if (is_array($spec)) { |
|
68
|
|
|
if (!isset($spec['type'])) { |
|
69
|
|
|
$spec['type'] = 'Core/Container'; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/* |
|
73
|
|
|
* For convenience, forms may be specified outside the options array. |
|
74
|
|
|
* But in order to be passed through to the form element manager, |
|
75
|
|
|
* we must move it to the options. |
|
76
|
|
|
*/ |
|
77
|
|
|
if (!isset($spec['options']['forms']) && isset($spec['forms'])) { |
|
78
|
|
|
$spec['options']['forms'] = $spec['forms']; |
|
79
|
|
|
unset($spec['forms']); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return parent::setForm($key, $spec, $enabled); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function getForm($key, $asInstance = true) |
|
87
|
|
|
{ |
|
88
|
|
|
$form = parent::getForm($key, $asInstance); |
|
89
|
|
|
|
|
90
|
|
|
/* |
|
91
|
|
|
* We must check here, if a lazy loaded top level form is an |
|
92
|
|
|
* instance of Container. |
|
93
|
|
|
*/ |
|
94
|
|
|
if ($asInstance && false === strpos($key, '.') && (!$form instanceOf Container || !$form->getLabel())) { |
|
|
|
|
|
|
95
|
|
|
throw new \UnexpectedValueException(sprintf( |
|
96
|
|
|
'The registered form with key "%s" is not an instance of \Core\Form\Container or does not have a label.', $key |
|
97
|
|
|
)); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
return $form; |
|
101
|
|
|
} |
|
102
|
|
|
} |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: