1 | <?php |
||
3 | class FlexSlider extends DataExtension |
||
4 | { |
||
5 | /** |
||
6 | * @var array |
||
7 | */ |
||
8 | public static $db = array( |
||
9 | 'Animation' => "Enum('slide, fade', 'slide')", |
||
10 | 'Loop' => 'Boolean', |
||
11 | 'Animate' => 'Boolean', |
||
12 | 'ThumbnailNav' => 'Boolean', |
||
13 | 'SliderControlNav' => 'Boolean', |
||
14 | 'SliderDirectionNav' => 'Boolean', |
||
15 | 'CarouselControlNav' => 'Boolean', |
||
16 | 'CarouselDirectionNav' => 'Boolean', |
||
17 | 'CarouselItemWidth' => 'Int', |
||
18 | 'CarouselItemMargin' => 'Int', |
||
19 | 'CarouselThumbnailCt' => 'Int', |
||
20 | ); |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | public static $has_many = array( |
||
26 | 'Slides' => 'SlideImage', |
||
27 | ); |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | */ |
||
32 | 4 | public function populateDefaults() |
|
45 | |||
46 | /** |
||
47 | * @param FieldList $fields |
||
48 | */ |
||
49 | 2 | public function updateCMSFields(FieldList $fields) |
|
100 | |||
101 | /** |
||
102 | * @return DataList |
||
103 | */ |
||
104 | 2 | public function SlideShow() |
|
114 | |||
115 | /** |
||
116 | * add requirements to Page_Controller init() |
||
117 | */ |
||
118 | public function contentcontrollerInit() |
||
127 | |||
128 | /** |
||
129 | * |
||
130 | */ |
||
131 | public function getCustomScript() |
||
132 | { |
||
133 | // Flexslider options |
||
134 | $animate = ($this->owner->Animate) ? 'true' : 'false'; |
||
|
|||
135 | $loop = ($this->owner->Loop) ? 'true' : 'false'; |
||
136 | $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.carousel:eq('+index+')'," : ''; |
||
137 | $before = (method_exists($this->owner->ClassName, 'flexSliderBeforeAction')) |
||
138 | ? $this->owner->flexSliderBeforeAction() |
||
139 | : 'function(){}'; |
||
140 | $after = (method_exists($this->owner->ClassName, 'flexSliderAfterAction')) |
||
141 | ? $this->owner->flexSliderAfterAction() |
||
142 | : 'function(){}'; |
||
143 | $speed = (method_exists($this->owner->ClassName, 'setFlexSliderSpeed')) |
||
144 | ? $this->owner->setFlexSliderSpeed() |
||
145 | : 7000; |
||
146 | |||
147 | Requirements::customScript(" |
||
148 | (function($) { |
||
149 | $(document).ready(function(){ |
||
150 | jQuery('.flexslider').each(function(index){ |
||
151 | |||
152 | if(jQuery('.carousel').eq(index).length) { |
||
153 | jQuery('.carousel').eq(index).flexslider({ |
||
154 | animation: '" . $this->owner->Animation . "', |
||
155 | controlNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean() . ", |
||
156 | directionNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean() . ", |
||
157 | animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ", |
||
158 | slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ", |
||
159 | itemWidth: " . $this->owner->obj('CarouselItemWidth') . ", |
||
160 | pausePlay: false, |
||
161 | asNavFor: '.flexslider:eq('+index+')', |
||
162 | itemMargin: " . $this->owner->obj('CarouselItemMargin') . ", |
||
163 | minItems: " . $this->owner->obj('CarouselThumbnailCt') . ", |
||
164 | maxItems: " . $this->owner->obj('CarouselThumbnailCt') . ", |
||
165 | move: " . $this->owner->obj('CarouselThumbnailCt') . " |
||
166 | }); |
||
167 | } |
||
168 | |||
169 | if(jQuery('.flexslider').eq(index).length){ |
||
170 | jQuery('.flexslider').eq(index).flexslider({ |
||
171 | slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ", |
||
172 | animation: '" . $this->owner->Animation . "', |
||
173 | animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ", |
||
174 | controlNav: " . $this->owner->obj('SliderControlNav')->NiceAsBoolean() . ", |
||
175 | directionNav: " . $this->owner->obj('SliderDirectionNav')->NiceAsBoolean() . ", |
||
176 | prevText: '', |
||
177 | nextText: '', |
||
178 | pauseOnAction: true, |
||
179 | pauseOnHover: true, |
||
180 | " . $sync . " |
||
181 | start: function(slider){ |
||
182 | $('body').removeClass('loading'); |
||
183 | }, |
||
184 | before: " . $before . ', |
||
185 | after: ' . $after . ', |
||
186 | slideshowSpeed: ' . $speed . ' |
||
187 | }); |
||
188 | } |
||
189 | }) |
||
190 | }); |
||
191 | }(jQuery));' |
||
192 | ); |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * |
||
197 | */ |
||
198 | 3 | public function onBeforeWrite() |
|
215 | } |
||
216 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.