Passed
Pull Request — 4.1 (#218)
by
unknown
09:00
created
tests/SlideImageTest.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -20,197 +20,197 @@
 block discarded – undo
20 20
  */
21 21
 class SlideImageTest extends SapphireTest
22 22
 {
23
-    /**
24
-     * @var string
25
-     */
26
-    protected static $fixture_file = 'fixtures.yml';
27
-
28
-    /**
29
-     *
30
-     */
31
-    public function testGetCMSFields()
32
-    {
33
-        $object = SlideImage::singleton();
34
-        $fields = $object->getCMSFields();
35
-
36
-        $this->assertInstanceOf(FieldList::class, $fields);
37
-        $this->assertInstanceOf(TextField::class, $fields->dataFieldByName('Name'));
38
-        $this->assertInstanceOf(UploadField::class, $fields->dataFieldByName('Image'));
39
-        $this->assertInstanceOf(EmbeddedObjectField::class, $fields->dataFieldByName('Video'));
40
-        $this->assertInstanceOf(TextareaField::class, $fields->dataFieldByName('Description'));
41
-    }
42
-
43
-    /**
44
-     * @throws ValidationException
45
-     */
46
-    public function testValidateName()
47
-    {
48
-        $object = $this->objFromFixture(SlideImage::class, 'slide1');
49
-        $object->Name = '';
50
-        $object->ImageID = 1;
51
-        $this->setExpectedException(ValidationException::class);
52
-        $object->write();
53
-
54
-        $object->Name = 'Foo';
55
-        $this->assertGreaterThan(0, $object->write());
56
-    }
57
-
58
-    /**
59
-     * @throws ValidationException
60
-     */
61
-    public function testValidateImage()
62
-    {
63
-        $object = $this->objFromFixture(SlideImage::class, 'slide1');
64
-        $object->ImageID = null;
65
-        $this->setExpectedException(ValidationException::class);
66
-        $object->write();
67
-
68
-        $base->ImageID = 1;
69
-        $this->assertGreaterThan(0, $object->write());
70
-    }
71
-
72
-    /**
73
-     * @throws ValidationException
74
-     */
75
-    public function testValidateVideo()
76
-    {
77
-        $object = $this->objFromFixture(SlideImage::class, 'slide2');
78
-        $object->VideoID = null;
79
-        $this->setExpectedException(ValidationException::class);
80
-        $object->write();
81
-
82
-        $object->VideoID = 1;
83
-        $this->assertGreaterThan(0, $object->write());
84
-    }
85
-
86
-    /**
87
-     * @throws ValidationException
88
-     */
89
-    public function testValidateText()
90
-    {
91
-        $object = $this->objFromFixture(SlideImage::class, 'slide3');
92
-        $description = $object->Description;
93
-
94
-        $object->Description = null;
95
-        $this->setExpectedException(ValidationException::class);
96
-        $object->write();
97
-
98
-        $object->Description = $description;
99
-        $this->assertGreaterThan(0, $object->write());
100
-    }
101
-
102
-    /**
103
-     *
104
-     */
105
-    public function testProvidePermissions()
106
-    {
107
-        $object = SlideImage::singleton();
108
-
109
-        $expected = [
110
-            'Slide_EDIT' => 'Slide Edit',
111
-            'Slide_DELETE' => 'Slide Delete',
112
-            'Slide_CREATE' => 'Slide Create',
113
-        ];
114
-
115
-        $this->assertEquals($expected, $object->providePermissions());
116
-    }
117
-
118
-    /**
119
-     *
120
-     */
121
-    public function testCanCreate()
122
-    {
123
-        $object = $this->objFromFixture(SlideImage::class, 'slide1');
124
-        $admin = $this->objFromFixture(Member::class, 'admin');
125
-        $this->assertTrue($object->canCreate($admin));
126
-
127
-        $author = $this->objFromFixture(Member::class, 'author');
128
-        $this->assertTrue($object->canCreate($author));
129
-
130
-        $member = $this->objFromFixture(Member::class, 'default');
131
-        $this->assertFalse($object->canCreate($member));
132
-    }
133
-
134
-    /**
135
-     *
136
-     */
137
-    public function testCanEdit()
138
-    {
139
-        $object = $this->objFromFixture(SlideImage::class, 'slide1');
140
-        $admin = $this->objFromFixture(Member::class, 'admin');
141
-        $this->assertTrue($object->canEdit($admin));
142
-
143
-        $author = $this->objFromFixture(Member::class, 'author');
144
-        $this->assertTrue($object->canEdit($author));
145
-
146
-        $member = $this->objFromFixture(Member::class, 'default');
147
-        $this->assertFalse($object->canEdit($member));
148
-    }
149
-
150
-    /**
151
-     *
152
-     */
153
-    public function testCanDelete()
154
-    {
155
-        $object = $this->objFromFixture(SlideImage::class, 'slide1');
156
-        $admin = $this->objFromFixture(Member::class, 'admin');
157
-        $this->assertTrue($object->canDelete($admin));
158
-
159
-        $author = $this->objFromFixture(Member::class, 'author');
160
-        $this->assertTrue($object->canDelete($author));
161
-
162
-        $member = $this->objFromFixture(Member::class, 'default');
163
-        $this->assertFalse($object->canDelete($member));
164
-    }
165
-
166
-    /**
167
-     *
168
-     */
169
-    public function testCanView()
170
-    {
171
-        $object = $this->objFromFixture(SlideImage::class, 'slide1');
172
-        $admin = $this->objFromFixture(Member::class, 'admin');
173
-        $this->assertTrue($object->canView($admin));
174
-
175
-        $author = $this->objFromFixture(Member::class, 'author');
176
-        $this->assertTrue($object->canView($author));
177
-
178
-        $member = $this->objFromFixture(Member::class, 'default');
179
-        $this->assertTrue($object->canView($member));
180
-    }
181
-
182
-    /**
183
-     *
184
-     */
185
-    public function testImageSizeLimit()
186
-    {
187
-        $default = 512000;
188
-        $this->assertEquals(Config::modify()->get(SlideImage::class, 'image_size_limit'), $default);
189
-
190
-        $new = 1024000;
191
-        Config::modify()->update(SlideImage::class, 'image_size_limit', $new);
192
-        $this->assertEquals(Config::modify()->get(SlideImage::class, 'image_size_limit'), $new);
193
-    }
194
-
195
-    /**
196
-     *
197
-     */
198
-    public function testRenderWith()
199
-    {
200
-        $this->markTestSkipped("Todo SlideImageText::testRenderWith()");
201
-        //$slide = SlideImage::singleton();
202
-
203
-        //$this->assertInstanceOf(DBHTMLText::class, $slide->renderWith());
204
-    }
205
-
206
-    /**
207
-     *
208
-     */
209
-    public function testForTemplate()
210
-    {
211
-        $this->markTestSkipped("Todo SlideImageText::testForTemplate()");
212
-        //$slide = SlideImage::singleton();
213
-
214
-        //$this->assertInstanceOf(DBHTMLText::class, $slide->forTemplate());
215
-    }
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected static $fixture_file = 'fixtures.yml';
27
+
28
+	/**
29
+	 *
30
+	 */
31
+	public function testGetCMSFields()
32
+	{
33
+		$object = SlideImage::singleton();
34
+		$fields = $object->getCMSFields();
35
+
36
+		$this->assertInstanceOf(FieldList::class, $fields);
37
+		$this->assertInstanceOf(TextField::class, $fields->dataFieldByName('Name'));
38
+		$this->assertInstanceOf(UploadField::class, $fields->dataFieldByName('Image'));
39
+		$this->assertInstanceOf(EmbeddedObjectField::class, $fields->dataFieldByName('Video'));
40
+		$this->assertInstanceOf(TextareaField::class, $fields->dataFieldByName('Description'));
41
+	}
42
+
43
+	/**
44
+	 * @throws ValidationException
45
+	 */
46
+	public function testValidateName()
47
+	{
48
+		$object = $this->objFromFixture(SlideImage::class, 'slide1');
49
+		$object->Name = '';
50
+		$object->ImageID = 1;
51
+		$this->setExpectedException(ValidationException::class);
52
+		$object->write();
53
+
54
+		$object->Name = 'Foo';
55
+		$this->assertGreaterThan(0, $object->write());
56
+	}
57
+
58
+	/**
59
+	 * @throws ValidationException
60
+	 */
61
+	public function testValidateImage()
62
+	{
63
+		$object = $this->objFromFixture(SlideImage::class, 'slide1');
64
+		$object->ImageID = null;
65
+		$this->setExpectedException(ValidationException::class);
66
+		$object->write();
67
+
68
+		$base->ImageID = 1;
69
+		$this->assertGreaterThan(0, $object->write());
70
+	}
71
+
72
+	/**
73
+	 * @throws ValidationException
74
+	 */
75
+	public function testValidateVideo()
76
+	{
77
+		$object = $this->objFromFixture(SlideImage::class, 'slide2');
78
+		$object->VideoID = null;
79
+		$this->setExpectedException(ValidationException::class);
80
+		$object->write();
81
+
82
+		$object->VideoID = 1;
83
+		$this->assertGreaterThan(0, $object->write());
84
+	}
85
+
86
+	/**
87
+	 * @throws ValidationException
88
+	 */
89
+	public function testValidateText()
90
+	{
91
+		$object = $this->objFromFixture(SlideImage::class, 'slide3');
92
+		$description = $object->Description;
93
+
94
+		$object->Description = null;
95
+		$this->setExpectedException(ValidationException::class);
96
+		$object->write();
97
+
98
+		$object->Description = $description;
99
+		$this->assertGreaterThan(0, $object->write());
100
+	}
101
+
102
+	/**
103
+	 *
104
+	 */
105
+	public function testProvidePermissions()
106
+	{
107
+		$object = SlideImage::singleton();
108
+
109
+		$expected = [
110
+			'Slide_EDIT' => 'Slide Edit',
111
+			'Slide_DELETE' => 'Slide Delete',
112
+			'Slide_CREATE' => 'Slide Create',
113
+		];
114
+
115
+		$this->assertEquals($expected, $object->providePermissions());
116
+	}
117
+
118
+	/**
119
+	 *
120
+	 */
121
+	public function testCanCreate()
122
+	{
123
+		$object = $this->objFromFixture(SlideImage::class, 'slide1');
124
+		$admin = $this->objFromFixture(Member::class, 'admin');
125
+		$this->assertTrue($object->canCreate($admin));
126
+
127
+		$author = $this->objFromFixture(Member::class, 'author');
128
+		$this->assertTrue($object->canCreate($author));
129
+
130
+		$member = $this->objFromFixture(Member::class, 'default');
131
+		$this->assertFalse($object->canCreate($member));
132
+	}
133
+
134
+	/**
135
+	 *
136
+	 */
137
+	public function testCanEdit()
138
+	{
139
+		$object = $this->objFromFixture(SlideImage::class, 'slide1');
140
+		$admin = $this->objFromFixture(Member::class, 'admin');
141
+		$this->assertTrue($object->canEdit($admin));
142
+
143
+		$author = $this->objFromFixture(Member::class, 'author');
144
+		$this->assertTrue($object->canEdit($author));
145
+
146
+		$member = $this->objFromFixture(Member::class, 'default');
147
+		$this->assertFalse($object->canEdit($member));
148
+	}
149
+
150
+	/**
151
+	 *
152
+	 */
153
+	public function testCanDelete()
154
+	{
155
+		$object = $this->objFromFixture(SlideImage::class, 'slide1');
156
+		$admin = $this->objFromFixture(Member::class, 'admin');
157
+		$this->assertTrue($object->canDelete($admin));
158
+
159
+		$author = $this->objFromFixture(Member::class, 'author');
160
+		$this->assertTrue($object->canDelete($author));
161
+
162
+		$member = $this->objFromFixture(Member::class, 'default');
163
+		$this->assertFalse($object->canDelete($member));
164
+	}
165
+
166
+	/**
167
+	 *
168
+	 */
169
+	public function testCanView()
170
+	{
171
+		$object = $this->objFromFixture(SlideImage::class, 'slide1');
172
+		$admin = $this->objFromFixture(Member::class, 'admin');
173
+		$this->assertTrue($object->canView($admin));
174
+
175
+		$author = $this->objFromFixture(Member::class, 'author');
176
+		$this->assertTrue($object->canView($author));
177
+
178
+		$member = $this->objFromFixture(Member::class, 'default');
179
+		$this->assertTrue($object->canView($member));
180
+	}
181
+
182
+	/**
183
+	 *
184
+	 */
185
+	public function testImageSizeLimit()
186
+	{
187
+		$default = 512000;
188
+		$this->assertEquals(Config::modify()->get(SlideImage::class, 'image_size_limit'), $default);
189
+
190
+		$new = 1024000;
191
+		Config::modify()->update(SlideImage::class, 'image_size_limit', $new);
192
+		$this->assertEquals(Config::modify()->get(SlideImage::class, 'image_size_limit'), $new);
193
+	}
194
+
195
+	/**
196
+	 *
197
+	 */
198
+	public function testRenderWith()
199
+	{
200
+		$this->markTestSkipped("Todo SlideImageText::testRenderWith()");
201
+		//$slide = SlideImage::singleton();
202
+
203
+		//$this->assertInstanceOf(DBHTMLText::class, $slide->renderWith());
204
+	}
205
+
206
+	/**
207
+	 *
208
+	 */
209
+	public function testForTemplate()
210
+	{
211
+		$this->markTestSkipped("Todo SlideImageText::testForTemplate()");
212
+		//$slide = SlideImage::singleton();
213
+
214
+		//$this->assertInstanceOf(DBHTMLText::class, $slide->forTemplate());
215
+	}
216 216
 }
Please login to merge, or discard this patch.
tests/TestPage.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  */
12 12
 class TestPage extends \Page implements TestOnly
13 13
 {
14
-    private static $slide_tab_title = '';
14
+	private static $slide_tab_title = '';
15 15
 
16
-    private static $table_name = 'FlexsliderTestPage';
16
+	private static $table_name = 'FlexsliderTestPage';
17 17
 }
Please login to merge, or discard this patch.
tests/FlexSliderTest.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -12,91 +12,91 @@
 block discarded – undo
12 12
 
13 13
 class FlexSliderTest extends SapphireTest
14 14
 {
15
-    /**
16
-     * @var array
17
-     */
18
-    protected static $extra_dataobjects = [
19
-        TestPage::class,
20
-    ];
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected static $extra_dataobjects = [
19
+		TestPage::class,
20
+	];
21 21
 
22
-    /**
23
-     * @var string
24
-     */
25
-    protected static $fixture_file = 'fixtures.yml';
22
+	/**
23
+	 * @var string
24
+	 */
25
+	protected static $fixture_file = 'fixtures.yml';
26 26
 
27
-    /**
28
-     * @var array
29
-     */
30
-    protected static $required_extensions = [
31
-        TestPage::class => [
32
-            FlexSlider::class,
33
-        ],
34
-    ];
27
+	/**
28
+	 * @var array
29
+	 */
30
+	protected static $required_extensions = [
31
+		TestPage::class => [
32
+			FlexSlider::class,
33
+		],
34
+	];
35 35
 
36
-    /**
37
-     *
38
-     */
39
-    public function testTabNameConfig()
40
-    {
41
-        $page = TestPage::create();
42
-        $page->write();
43
-        $pageFields = $page->getCMSFields();
44
-        $this->assertNotNull($pageFields->dataFieldByName('Slides'));
36
+	/**
37
+	 *
38
+	 */
39
+	public function testTabNameConfig()
40
+	{
41
+		$page = TestPage::create();
42
+		$page->write();
43
+		$pageFields = $page->getCMSFields();
44
+		$this->assertNotNull($pageFields->dataFieldByName('Slides'));
45 45
 
46
-        Config::modify()
47
-            ->update(TestPage::class, 'slide_tab_title', 'MyCustomSlideTitle');
48
-        $page2 = TestPage::create();
49
-        $page2->write();
50
-        $page2Fields = $page2->getCMSFields();
51
-        $this->assertNull($page2Fields->fieldByName('Root.Slides'));
52
-        $this->assertNotNull($page2Fields->fieldByName('Root.MyCustomSlideTitle'));
53
-    }
46
+		Config::modify()
47
+			->update(TestPage::class, 'slide_tab_title', 'MyCustomSlideTitle');
48
+		$page2 = TestPage::create();
49
+		$page2->write();
50
+		$page2Fields = $page2->getCMSFields();
51
+		$this->assertNull($page2Fields->fieldByName('Root.Slides'));
52
+		$this->assertNotNull($page2Fields->fieldByName('Root.MyCustomSlideTitle'));
53
+	}
54 54
 
55
-    /**
56
-     *
57
-     */
58
-    public function testUpdateCMSFields()
59
-    {
60
-        $object = TestPage::create();
61
-        $fields = $object->getCMSFields();
62
-        $this->assertNull($fields->dataFieldByName('Slides'));
55
+	/**
56
+	 *
57
+	 */
58
+	public function testUpdateCMSFields()
59
+	{
60
+		$object = TestPage::create();
61
+		$fields = $object->getCMSFields();
62
+		$this->assertNull($fields->dataFieldByName('Slides'));
63 63
 
64
-        $object->write();
65
-        $fields = $object->getCMSFields();
66
-        $this->assertInstanceOf(FieldList::class, $fields);
67
-        $this->assertNotNull($fields->dataFieldbyName('Slides'));
68
-    }
64
+		$object->write();
65
+		$fields = $object->getCMSFields();
66
+		$this->assertInstanceOf(FieldList::class, $fields);
67
+		$this->assertNotNull($fields->dataFieldbyName('Slides'));
68
+	}
69 69
 
70
-    /**
71
-     *
72
-     */
73
-    public function testGetSlideshow()
74
-    {
75
-        $object = TestPage::create();
76
-        $object->write();
77
-        $slide1 = $this->objFromFixture(SlideImage::class, 'slide1');
78
-        $image = $this->objFromFixture(Image::class, 'image1');
79
-        $slide1->ImageID = $image->ID;
80
-        $object->Slides()->add($slide1);
81
-        $slides = $object->getSlideShow();
82
-        $this->assertInstanceOf(DataList::class, $slides);
83
-    }
70
+	/**
71
+	 *
72
+	 */
73
+	public function testGetSlideshow()
74
+	{
75
+		$object = TestPage::create();
76
+		$object->write();
77
+		$slide1 = $this->objFromFixture(SlideImage::class, 'slide1');
78
+		$image = $this->objFromFixture(Image::class, 'image1');
79
+		$slide1->ImageID = $image->ID;
80
+		$object->Slides()->add($slide1);
81
+		$slides = $object->getSlideShow();
82
+		$this->assertInstanceOf(DataList::class, $slides);
83
+	}
84 84
 
85
-    /**
86
-     *
87
-     */
88
-    public function testGetSlideshowSpeed()
89
-    {
90
-        /** @var \Dynamic\FlexSlider\ORM\FlexSlider|\Page $object */
91
-        $object = TestPage::create();
92
-        $object->FlexSliderSpeed = 0;
93
-        $this->assertEquals(
94
-            Config::inst()->get(FlexSlider::class, 'flex_slider_speed') * 1000,
95
-            $object->getSlideshowSpeed()
96
-        );
85
+	/**
86
+	 *
87
+	 */
88
+	public function testGetSlideshowSpeed()
89
+	{
90
+		/** @var \Dynamic\FlexSlider\ORM\FlexSlider|\Page $object */
91
+		$object = TestPage::create();
92
+		$object->FlexSliderSpeed = 0;
93
+		$this->assertEquals(
94
+			Config::inst()->get(FlexSlider::class, 'flex_slider_speed') * 1000,
95
+			$object->getSlideshowSpeed()
96
+		);
97 97
 
98
-        $object->FlexSliderSpeed = 0.5;
99
-        $object->write();
100
-        $this->assertEquals(500, $object->getSlideshowSpeed());
101
-    }
98
+		$object->FlexSliderSpeed = 0.5;
99
+		$object->write();
100
+		$this->assertEquals(500, $object->getSlideshowSpeed());
101
+	}
102 102
 }
Please login to merge, or discard this patch.
src/Task/DefaultSlideTypeTask.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -12,61 +12,61 @@
 block discarded – undo
12 12
  */
13 13
 class DefaultSlideTypeTask extends BuildTask
14 14
 {
15
-    /**
16
-     * @var string
17
-     */
18
-    private static $segment = 'default-slide-type-task';
15
+	/**
16
+	 * @var string
17
+	 */
18
+	private static $segment = 'default-slide-type-task';
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $title = 'Flexslider - Default Slide Type Task';
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $title = 'Flexslider - Default Slide Type Task';
24 24
 
25
-    /**
26
-     * @param \SilverStripe\Control\HTTPRequest $request
27
-     */
28
-    public function run($request)
29
-    {
30
-        $this->setDefaults();
31
-    }
25
+	/**
26
+	 * @param \SilverStripe\Control\HTTPRequest $request
27
+	 */
28
+	public function run($request)
29
+	{
30
+		$this->setDefaults();
31
+	}
32 32
 
33
-    /**
34
-     *
35
-     */
36
-    protected function setDefaults()
37
-    {
38
-        $default = SlideImage::singleton()->config()->get('defaults');
33
+	/**
34
+	 *
35
+	 */
36
+	protected function setDefaults()
37
+	{
38
+		$default = SlideImage::singleton()->config()->get('defaults');
39 39
 
40
-        if (isset($default['SlideType'])) {
41
-            $baseTable = SlideImage::singleton()->baseTable();
40
+		if (isset($default['SlideType'])) {
41
+			$baseTable = SlideImage::singleton()->baseTable();
42 42
 
43
-            $tables = [
44
-                $baseTable,
45
-                "{$baseTable}_Versions",
46
-                "{$baseTable}_Live",
47
-            ];
43
+			$tables = [
44
+				$baseTable,
45
+				"{$baseTable}_Versions",
46
+				"{$baseTable}_Live",
47
+			];
48 48
 
49
-            foreach ($tables as $table) {
50
-                $query = DB::query("SELECT * FROM \"{$table}\" WHERE \"SlideType\" IS NULL");
49
+			foreach ($tables as $table) {
50
+				$query = DB::query("SELECT * FROM \"{$table}\" WHERE \"SlideType\" IS NULL");
51 51
 
52
-                foreach ($this->yieldSingle($query) as $record) {
53
-                    DB::prepared_query(
54
-                        "UPDATE \"{$table}\" SET \"SlideType\" = ? WHERE \"ID\" = ?",
55
-                        [$default['SlideType'], $record['ID']]
56
-                    );
57
-                }
58
-            }
59
-        }
60
-    }
52
+				foreach ($this->yieldSingle($query) as $record) {
53
+					DB::prepared_query(
54
+						"UPDATE \"{$table}\" SET \"SlideType\" = ? WHERE \"ID\" = ?",
55
+						[$default['SlideType'], $record['ID']]
56
+					);
57
+				}
58
+			}
59
+		}
60
+	}
61 61
 
62
-    /**
63
-     * @param $list
64
-     * @return \Generator
65
-     */
66
-    protected function yieldSingle($list)
67
-    {
68
-        foreach ($list as $item) {
69
-            yield $item;
70
-        }
71
-    }
62
+	/**
63
+	 * @param $list
64
+	 * @return \Generator
65
+	 */
66
+	protected function yieldSingle($list)
67
+	{
68
+		foreach ($list as $item) {
69
+			yield $item;
70
+		}
71
+	}
72 72
 }
Please login to merge, or discard this patch.
src/Task/SlideLinkTask.php 2 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -14,122 +14,122 @@
 block discarded – undo
14 14
  */
15 15
 class SlideLinkTask extends BuildTask
16 16
 {
17
-    /**
18
-     * @var string
19
-     */
20
-    protected $title = 'Flexslider - Slide Link Migration Task';
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    private static $segment = 'slide-link-migration-task';
26
-
27
-    /**
28
-     * @var array
29
-     */
30
-    private $known_links = [];
31
-
32
-    /**
33
-     * @param \SilverStripe\Control\HTTPRequest $request
34
-     * @throws \SilverStripe\ORM\ValidationException
35
-     */
36
-    public function run($request)
37
-    {
38
-        $this->migrateLinks();
39
-    }
40
-
41
-    /**
42
-     * @throws \SilverStripe\ORM\ValidationException
43
-     */
44
-    protected function migrateLinks()
45
-    {
46
-        $baseTable = SlideImage::singleton()->baseTable();
47
-
48
-        $tables = [
49
-            $baseTable,
50
-            "{$baseTable}_Versions",
51
-            "{$baseTable}_Live",
52
-        ];
53
-
54
-        foreach ($tables as $table) {
55
-            foreach ($this->yieldSingle(DB::query("SELECT * FROM \"{$table}\"")) as $record) {
56
-                $linkID = $record['PageLinkID'];
57
-                $linkLabel = isset($record['LinkLabel']) ? $record['LinkLabel'] : null;
58
-
59
-                $slideLink = $this->findOrMakeLink($linkID, $linkLabel);
60
-
61
-                if ($slideLink !== false && $slideLink instanceof Link) {
62
-                    DB::prepared_query(
63
-                        "UPDATE \"{$table}\" SET \"SlideLinkID\" = ? WHERE \"ID\" = ?",
64
-                        [$slideLink->ID, $record['ID']]
65
-                    );
66
-                }
67
-            }
68
-        }
69
-    }
70
-
71
-    /**
72
-     * @param $list
73
-     * @return \Generator
74
-     */
75
-    private function yieldSingle($list)
76
-    {
77
-        foreach ($list as $item) {
78
-            yield $item;
79
-        }
80
-    }
81
-
82
-    /**
83
-     * @param int $linkID
84
-     * @param string $linkLabel
85
-     * @return bool|mixed|Link
86
-     * @throws \SilverStripe\ORM\ValidationException
87
-     */
88
-    private function findOrMakeLink($linkID = 0, $linkLabel = '')
89
-    {
90
-        if (!$linkID || !($page = SiteTree::get()->byID($linkID))) {
91
-            return false;
92
-        }
93
-
94
-        if (isset($this->getKnownLinks()[$linkID])) {
95
-            return $this->getKnownLinks()[$linkID];
96
-        }
97
-
98
-        $link = Link::create();
99
-        $link->Type = 'SiteTree';
100
-        $link->SiteTreeID = $linkID;
101
-        $link->Template = 'button';
102
-
103
-        if ($linkLabel !== null && $linkLabel !== '') {
104
-            $link->Title = $linkLabel;
105
-        } else {
106
-            $link->Title = $page->Title;
107
-        }
108
-
109
-        $link->write();
110
-
111
-        $this->addKnownLink($linkID, $link);
112
-
113
-        return $link;
114
-    }
115
-
116
-    /**
117
-     * @param $linkID
118
-     * @param $linkableLinkID
119
-     * @return $this
120
-     */
121
-    private function addKnownLink($linkID, $linkableLinkID)
122
-    {
123
-        $this->known_links[$linkID] = $linkableLinkID;
124
-
125
-        return $this;
126
-    }
127
-
128
-    /**
129
-     * @return array
130
-     */
131
-    private function getKnownLinks()
132
-    {
133
-        return $this->known_links;
134
-    }
17
+	/**
18
+	 * @var string
19
+	 */
20
+	protected $title = 'Flexslider - Slide Link Migration Task';
21
+
22
+	/**
23
+	 * @var string
24
+	 */
25
+	private static $segment = 'slide-link-migration-task';
26
+
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private $known_links = [];
31
+
32
+	/**
33
+	 * @param \SilverStripe\Control\HTTPRequest $request
34
+	 * @throws \SilverStripe\ORM\ValidationException
35
+	 */
36
+	public function run($request)
37
+	{
38
+		$this->migrateLinks();
39
+	}
40
+
41
+	/**
42
+	 * @throws \SilverStripe\ORM\ValidationException
43
+	 */
44
+	protected function migrateLinks()
45
+	{
46
+		$baseTable = SlideImage::singleton()->baseTable();
47
+
48
+		$tables = [
49
+			$baseTable,
50
+			"{$baseTable}_Versions",
51
+			"{$baseTable}_Live",
52
+		];
53
+
54
+		foreach ($tables as $table) {
55
+			foreach ($this->yieldSingle(DB::query("SELECT * FROM \"{$table}\"")) as $record) {
56
+				$linkID = $record['PageLinkID'];
57
+				$linkLabel = isset($record['LinkLabel']) ? $record['LinkLabel'] : null;
58
+
59
+				$slideLink = $this->findOrMakeLink($linkID, $linkLabel);
60
+
61
+				if ($slideLink !== false && $slideLink instanceof Link) {
62
+					DB::prepared_query(
63
+						"UPDATE \"{$table}\" SET \"SlideLinkID\" = ? WHERE \"ID\" = ?",
64
+						[$slideLink->ID, $record['ID']]
65
+					);
66
+				}
67
+			}
68
+		}
69
+	}
70
+
71
+	/**
72
+	 * @param $list
73
+	 * @return \Generator
74
+	 */
75
+	private function yieldSingle($list)
76
+	{
77
+		foreach ($list as $item) {
78
+			yield $item;
79
+		}
80
+	}
81
+
82
+	/**
83
+	 * @param int $linkID
84
+	 * @param string $linkLabel
85
+	 * @return bool|mixed|Link
86
+	 * @throws \SilverStripe\ORM\ValidationException
87
+	 */
88
+	private function findOrMakeLink($linkID = 0, $linkLabel = '')
89
+	{
90
+		if (!$linkID || !($page = SiteTree::get()->byID($linkID))) {
91
+			return false;
92
+		}
93
+
94
+		if (isset($this->getKnownLinks()[$linkID])) {
95
+			return $this->getKnownLinks()[$linkID];
96
+		}
97
+
98
+		$link = Link::create();
99
+		$link->Type = 'SiteTree';
100
+		$link->SiteTreeID = $linkID;
101
+		$link->Template = 'button';
102
+
103
+		if ($linkLabel !== null && $linkLabel !== '') {
104
+			$link->Title = $linkLabel;
105
+		} else {
106
+			$link->Title = $page->Title;
107
+		}
108
+
109
+		$link->write();
110
+
111
+		$this->addKnownLink($linkID, $link);
112
+
113
+		return $link;
114
+	}
115
+
116
+	/**
117
+	 * @param $linkID
118
+	 * @param $linkableLinkID
119
+	 * @return $this
120
+	 */
121
+	private function addKnownLink($linkID, $linkableLinkID)
122
+	{
123
+		$this->known_links[$linkID] = $linkableLinkID;
124
+
125
+		return $this;
126
+	}
127
+
128
+	/**
129
+	 * @return array
130
+	 */
131
+	private function getKnownLinks()
132
+	{
133
+		return $this->known_links;
134
+	}
135 135
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
                 $slideLink = $this->findOrMakeLink($linkID, $linkLabel);
60 60
 
61
-                if ($slideLink !== false && $slideLink instanceof Link) {
61
+                if ($slideLink!==false && $slideLink instanceof Link) {
62 62
                     DB::prepared_query(
63 63
                         "UPDATE \"{$table}\" SET \"SlideLinkID\" = ? WHERE \"ID\" = ?",
64 64
                         [$slideLink->ID, $record['ID']]
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $link->SiteTreeID = $linkID;
101 101
         $link->Template = 'button';
102 102
 
103
-        if ($linkLabel !== null && $linkLabel !== '') {
103
+        if ($linkLabel!==null && $linkLabel!=='') {
104 104
             $link->Title = $linkLabel;
105 105
         } else {
106 106
             $link->Title = $page->Title;
Please login to merge, or discard this patch.
src/Task/SlideThumbnailNavMigrationTask.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -16,91 +16,91 @@
 block discarded – undo
16 16
  */
17 17
 class SlideThumbnailNavMigrationTask extends BuildTask
18 18
 {
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $title = 'FlexSlider - Default Values';
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $title = 'FlexSlider - Default Values';
23 23
 
24
-    /**
25
-     * @var string
26
-     */
27
-    protected $description = 'Set default values for slider after the thumbnail nav update';
24
+	/**
25
+	 * @var string
26
+	 */
27
+	protected $description = 'Set default values for slider after the thumbnail nav update';
28 28
 
29
-    /**
30
-     * @var string
31
-     */
32
-    private static $segment = 'slide-thumbnail-nav-migration-task';
29
+	/**
30
+	 * @var string
31
+	 */
32
+	private static $segment = 'slide-thumbnail-nav-migration-task';
33 33
 
34
-    /**
35
-     * @var bool
36
-     */
37
-    protected $enabled = true;
34
+	/**
35
+	 * @var bool
36
+	 */
37
+	protected $enabled = true;
38 38
 
39
-    /**
40
-     * @param $request
41
-     */
42
-    public function run($request)
43
-    {
44
-        $this->defaultSliderSettings();
45
-    }
39
+	/**
40
+	 * @param $request
41
+	 */
42
+	public function run($request)
43
+	{
44
+		$this->defaultSliderSettings();
45
+	}
46 46
 
47
-    /**
48
-     * @param $class
49
-     * @return \Generator
50
-     */
51
-    protected function getObjectSet($class)
52
-    {
53
-        foreach ($class::get() as $object) {
54
-            yield $object;
55
-        }
56
-    }
47
+	/**
48
+	 * @param $class
49
+	 * @return \Generator
50
+	 */
51
+	protected function getObjectSet($class)
52
+	{
53
+		foreach ($class::get() as $object) {
54
+			yield $object;
55
+		}
56
+	}
57 57
 
58
-    /**
59
-     *
60
-     */
61
-    public function defaultSliderSettings()
62
-    {
63
-        $ct = 0;
58
+	/**
59
+	 *
60
+	 */
61
+	public function defaultSliderSettings()
62
+	{
63
+		$ct = 0;
64 64
 
65
-        $objects = ClassInfo::subclassesFor(DataObject::class);
65
+		$objects = ClassInfo::subclassesFor(DataObject::class);
66 66
 
67
-        if ($objects) {
68
-            unset($objects[DataObject::class]);
69
-            foreach ($objects as $object) {
70
-                if ($object::singleton()->hasExtension(FlexSlider::class)) {
71
-                    foreach ($this->getObjectSet($object) as $result) {
72
-                        $result->Loop = 1;
73
-                        $result->Animate = 1;
74
-                        $result->SliderControlNav = 0;
75
-                        $result->SliderDirectionNav = 1;
76
-                        $result->CarouselControlNav = 0;
77
-                        $result->CarouselDirectionNav = 1;
78
-                        $result->CarouselThumbnailCt = 6;
79
-                        if ($result instanceof SiteTree || $object::singleton()->hasExtension(Versioned::class)) {
80
-                            $result->writeToStage('Stage');
81
-                            if ($result->isPublished()) {
82
-                                $result->publishRecursive();
83
-                            }
84
-                        } else {
85
-                            $result->write();
86
-                        }
87
-                        $ct++;
88
-                    }
89
-                }
90
-            }
91
-        }
92
-        static::write_message($ct . " Sliders updated");
93
-    }
67
+		if ($objects) {
68
+			unset($objects[DataObject::class]);
69
+			foreach ($objects as $object) {
70
+				if ($object::singleton()->hasExtension(FlexSlider::class)) {
71
+					foreach ($this->getObjectSet($object) as $result) {
72
+						$result->Loop = 1;
73
+						$result->Animate = 1;
74
+						$result->SliderControlNav = 0;
75
+						$result->SliderDirectionNav = 1;
76
+						$result->CarouselControlNav = 0;
77
+						$result->CarouselDirectionNav = 1;
78
+						$result->CarouselThumbnailCt = 6;
79
+						if ($result instanceof SiteTree || $object::singleton()->hasExtension(Versioned::class)) {
80
+							$result->writeToStage('Stage');
81
+							if ($result->isPublished()) {
82
+								$result->publishRecursive();
83
+							}
84
+						} else {
85
+							$result->write();
86
+						}
87
+						$ct++;
88
+					}
89
+				}
90
+			}
91
+		}
92
+		static::write_message($ct . " Sliders updated");
93
+	}
94 94
 
95
-    /**
96
-     * @param $message
97
-     */
98
-    protected static function write_message($message)
99
-    {
100
-        if (Director::is_cli()) {
101
-            echo "{$message}\n";
102
-        } else {
103
-            echo "{$message}<br><br>";
104
-        }
105
-    }
95
+	/**
96
+	 * @param $message
97
+	 */
98
+	protected static function write_message($message)
99
+	{
100
+		if (Director::is_cli()) {
101
+			echo "{$message}\n";
102
+		} else {
103
+			echo "{$message}<br><br>";
104
+		}
105
+	}
106 106
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
                 }
90 90
             }
91 91
         }
92
-        static::write_message($ct . " Sliders updated");
92
+        static::write_message($ct." Sliders updated");
93 93
     }
94 94
 
95 95
     /**
Please login to merge, or discard this patch.
src/Model/SlideImage.php 2 patches
Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -37,315 +37,315 @@
 block discarded – undo
37 37
  */
38 38
 class SlideImage extends DataObject implements PermissionProvider
39 39
 {
40
-    /**
41
-     * @var string
42
-     */
43
-    private static $singular_name = 'Slide';
44
-
45
-    /**
46
-     * @var string
47
-     */
48
-    private static $plural_name = 'Slides';
49
-
50
-    /**
51
-     * @var array
52
-     */
53
-    private static $db = [
54
-        'Name' => 'Varchar(255)',
55
-        'Headline' => 'Varchar(255)',
56
-        'Description' => 'Text',
57
-        'SortOrder' => 'Int',
58
-        'SlideType' => 'Varchar',
59
-    ];
60
-
61
-    /**
62
-     * @var array
63
-     */
64
-    private static $has_one = [
65
-        'Image' => Image::class,
66
-        //'Video' => Embed::class,
67
-        'Page' => \Page::class,
68
-        'PageLink' => SiteTree::class,
69
-        'SlideLink' => Link::class,
70
-    ];
71
-
72
-    /**
73
-     * @var array
74
-     */
75
-    private static $owns = [
76
-        'Image',
77
-    ];
78
-
79
-    /**
80
-     * @var string
81
-     */
82
-    private static $table_name = 'SlideImage';
83
-
84
-    /**
85
-     * @var string
86
-     */
87
-    private static $default_sort = 'SortOrder';
88
-
89
-    /**
90
-     * Adds Publish button to SlideImage record
91
-     *
92
-     * @var bool
93
-     */
94
-    private static $versioned_gridfield_extensions = true;
95
-
96
-    /**
97
-     * @var array
98
-     */
99
-    private static $defaults = [
100
-        'SlideType' => 'Image',
101
-    ];
102
-
103
-    /**
104
-     * @var array
105
-     */
106
-    private static $summary_fields = [
107
-        'Image.CMSThumbnail' => 'Image',
108
-        'Name' => 'Name',
109
-    ];
110
-
111
-    /**
112
-     * @var array
113
-     */
114
-    private static $searchable_fields = [
115
-        'Name',
116
-        'Headline',
117
-        'Description',
118
-    ];
119
-
120
-    /**
121
-     * @var int
122
-     */
123
-    private static $image_size_limit = 512000;
124
-
125
-    /**
126
-     * @var array
127
-     */
128
-    private static $slide_types = [
129
-        'Image',
130
-        'Video',
131
-        'Text',
132
-    ];
133
-
134
-    /**
135
-     * @param bool $includerelations
136
-     * @return array
137
-     */
138
-    public function fieldLabels($includerelations = true)
139
-    {
140
-        $labels = parent::fieldLabels($includerelations);
141
-
142
-        $labels['Name'] = _t(__CLASS__ . '.NAME', 'Name');
143
-        $labels['Headline'] = _t(__CLASS__ . '.HEADLINE', 'Headline');
144
-        $labels['Description'] = _t(__CLASS__ . '.DESCRIPTION', 'Description');
145
-        $labels['SlideLinkID'] =  _t(__CLASS__ . '.PAGE_LINK', "Call to action link");
146
-        $labels['Image'] = _t(__CLASS__ . '.IMAGE', 'Image');
147
-        $labels['SlideType'] = _t(__CLASS__ . '.SlideType', 'Image or Video');
148
-        $labels['Video'] = _t(__CLASS__ . '.VideoLabel', 'Video URL');
149
-
150
-        return $labels;
151
-    }
152
-
153
-    /**
154
-     * @return \SilverStripe\Forms\FieldList
155
-     */
156
-    public function getCMSFields()
157
-    {
158
-        $this->beforeUpdateCMSFields(function ($fields) {
159
-            $fields->removeByName([
160
-                'ShowSlide',
161
-                'SortOrder',
162
-                'PageID',
163
-                'Image',
164
-                'SlideType',
165
-                'Video',
166
-                'VideoID',
167
-                'SlideLinkID',
168
-            ]);
169
-
170
-            // Name
171
-            $fields->dataFieldByName('Name')
172
-                ->setDescription(
173
-                    _t(__CLASS__ . '.INTERNAL_USE', 'for internal reference only')
174
-                );
175
-
176
-            // Headline
177
-            $fields->dataFieldByName('Headline')
178
-                ->setDescription(
179
-                    _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template')
180
-                );
181
-
182
-            // Description
183
-            $fields->dataFieldByName('Description')
184
-                ->setDescription(
185
-                    _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template')
186
-                );
187
-
188
-            // Page link
189
-            $fields->replaceField(
190
-                'PageLinkID',
191
-                LinkField::create('SlideLink', $this->fieldLabel('SlideLinkID'), $this)
192
-            );
193
-
194
-            // Image
195
-            $image = UploadField::create('Image', $this->fieldLabel('Image'))
196
-                ->setFolderName('Uploads/SlideImages');
197
-
198
-            $image->getValidator()->setAllowedExtensions(['jpg', 'jpeg', 'png', 'gif']);
199
-
200
-            $fields->addFieldToTab(
201
-                'Root.Main',
202
-                CompositeField::create(FieldList::create(
203
-                    DropdownField::create('SlideType', $this->fieldLabel('SlideType'))
204
-                        ->setSource($this->getTypeSource()),
205
-                    Wrapper::create(
206
-                        $image
207
-                    )->displayIf('SlideType')->isEqualTo('Image')->orIf('SlideType')->isEqualTo('Video')->end(),
208
-                    /*Wrapper::create(
40
+	/**
41
+	 * @var string
42
+	 */
43
+	private static $singular_name = 'Slide';
44
+
45
+	/**
46
+	 * @var string
47
+	 */
48
+	private static $plural_name = 'Slides';
49
+
50
+	/**
51
+	 * @var array
52
+	 */
53
+	private static $db = [
54
+		'Name' => 'Varchar(255)',
55
+		'Headline' => 'Varchar(255)',
56
+		'Description' => 'Text',
57
+		'SortOrder' => 'Int',
58
+		'SlideType' => 'Varchar',
59
+	];
60
+
61
+	/**
62
+	 * @var array
63
+	 */
64
+	private static $has_one = [
65
+		'Image' => Image::class,
66
+		//'Video' => Embed::class,
67
+		'Page' => \Page::class,
68
+		'PageLink' => SiteTree::class,
69
+		'SlideLink' => Link::class,
70
+	];
71
+
72
+	/**
73
+	 * @var array
74
+	 */
75
+	private static $owns = [
76
+		'Image',
77
+	];
78
+
79
+	/**
80
+	 * @var string
81
+	 */
82
+	private static $table_name = 'SlideImage';
83
+
84
+	/**
85
+	 * @var string
86
+	 */
87
+	private static $default_sort = 'SortOrder';
88
+
89
+	/**
90
+	 * Adds Publish button to SlideImage record
91
+	 *
92
+	 * @var bool
93
+	 */
94
+	private static $versioned_gridfield_extensions = true;
95
+
96
+	/**
97
+	 * @var array
98
+	 */
99
+	private static $defaults = [
100
+		'SlideType' => 'Image',
101
+	];
102
+
103
+	/**
104
+	 * @var array
105
+	 */
106
+	private static $summary_fields = [
107
+		'Image.CMSThumbnail' => 'Image',
108
+		'Name' => 'Name',
109
+	];
110
+
111
+	/**
112
+	 * @var array
113
+	 */
114
+	private static $searchable_fields = [
115
+		'Name',
116
+		'Headline',
117
+		'Description',
118
+	];
119
+
120
+	/**
121
+	 * @var int
122
+	 */
123
+	private static $image_size_limit = 512000;
124
+
125
+	/**
126
+	 * @var array
127
+	 */
128
+	private static $slide_types = [
129
+		'Image',
130
+		'Video',
131
+		'Text',
132
+	];
133
+
134
+	/**
135
+	 * @param bool $includerelations
136
+	 * @return array
137
+	 */
138
+	public function fieldLabels($includerelations = true)
139
+	{
140
+		$labels = parent::fieldLabels($includerelations);
141
+
142
+		$labels['Name'] = _t(__CLASS__ . '.NAME', 'Name');
143
+		$labels['Headline'] = _t(__CLASS__ . '.HEADLINE', 'Headline');
144
+		$labels['Description'] = _t(__CLASS__ . '.DESCRIPTION', 'Description');
145
+		$labels['SlideLinkID'] =  _t(__CLASS__ . '.PAGE_LINK', "Call to action link");
146
+		$labels['Image'] = _t(__CLASS__ . '.IMAGE', 'Image');
147
+		$labels['SlideType'] = _t(__CLASS__ . '.SlideType', 'Image or Video');
148
+		$labels['Video'] = _t(__CLASS__ . '.VideoLabel', 'Video URL');
149
+
150
+		return $labels;
151
+	}
152
+
153
+	/**
154
+	 * @return \SilverStripe\Forms\FieldList
155
+	 */
156
+	public function getCMSFields()
157
+	{
158
+		$this->beforeUpdateCMSFields(function ($fields) {
159
+			$fields->removeByName([
160
+				'ShowSlide',
161
+				'SortOrder',
162
+				'PageID',
163
+				'Image',
164
+				'SlideType',
165
+				'Video',
166
+				'VideoID',
167
+				'SlideLinkID',
168
+			]);
169
+
170
+			// Name
171
+			$fields->dataFieldByName('Name')
172
+				->setDescription(
173
+					_t(__CLASS__ . '.INTERNAL_USE', 'for internal reference only')
174
+				);
175
+
176
+			// Headline
177
+			$fields->dataFieldByName('Headline')
178
+				->setDescription(
179
+					_t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template')
180
+				);
181
+
182
+			// Description
183
+			$fields->dataFieldByName('Description')
184
+				->setDescription(
185
+					_t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template')
186
+				);
187
+
188
+			// Page link
189
+			$fields->replaceField(
190
+				'PageLinkID',
191
+				LinkField::create('SlideLink', $this->fieldLabel('SlideLinkID'), $this)
192
+			);
193
+
194
+			// Image
195
+			$image = UploadField::create('Image', $this->fieldLabel('Image'))
196
+				->setFolderName('Uploads/SlideImages');
197
+
198
+			$image->getValidator()->setAllowedExtensions(['jpg', 'jpeg', 'png', 'gif']);
199
+
200
+			$fields->addFieldToTab(
201
+				'Root.Main',
202
+				CompositeField::create(FieldList::create(
203
+					DropdownField::create('SlideType', $this->fieldLabel('SlideType'))
204
+						->setSource($this->getTypeSource()),
205
+					Wrapper::create(
206
+						$image
207
+					)->displayIf('SlideType')->isEqualTo('Image')->orIf('SlideType')->isEqualTo('Video')->end(),
208
+					/*Wrapper::create(
209 209
                         $videoField = HasOneButtonField::create(
210 210
                             'Video',
211 211
                             'Video',
212 212
                             $this
213 213
                         )
214 214
                     )->displayIf('SlideType')->isEqualTo('Video')->end()*/
215
-                ))->setName('MediaFields'),
216
-                'Description'
217
-            );
218
-        });
219
-
220
-        $fields = parent::getCMSFields();
221
-
222
-        $this->extend('updateSlideImageFields', $fields);
223
-
224
-        return $fields;
225
-    }
226
-
227
-    /**
228
-     * @return \SilverStripe\ORM\ValidationResult
229
-     */
230
-    public function validate()
231
-    {
232
-        $result = parent::validate();
233
-
234
-        if (!$this->Name) {
235
-            $result->addError(
236
-                _t(__CLASS__ . '.NAME_REQUIRED', 'A Name is required before you can save')
237
-            );
238
-        }
239
-
240
-        $types = $this->getTypeSource();
241
-
242
-        if (isset($types['Video']) && $this->SlideType == 'Video' && !$this->VideoID) {
243
-            $result->addError(
244
-                _t(__CLASS__ . '.VIDEO_REQUIRED', 'An Video Link is required before you can save')
245
-            );
246
-        }
247
-
248
-        if (isset($types['Image']) && $this->SlideType == 'Image' && !$this->ImageID) {
249
-            $result->addError(
250
-                _t(__CLASS__ . '.IMAGE_REQUIRED', 'An Image is required before you can save')
251
-            );
252
-        }
253
-
254
-        if (isset($types['Text']) && $this->SlideType == 'Text' && !$this->Description) {
255
-            $result->addError(
256
-                _t(__CLASS__ . '.DESCRIPTION_REQUIRED', 'A Description is required before you can save')
257
-            );
258
-        }
259
-
260
-        return $result;
261
-    }
262
-
263
-    /**
264
-     * @return array
265
-     */
266
-    public function providePermissions()
267
-    {
268
-        return [
269
-            'Slide_EDIT' => 'Slide Edit',
270
-            'Slide_DELETE' => 'Slide Delete',
271
-            'Slide_CREATE' => 'Slide Create',
272
-        ];
273
-    }
274
-
275
-    /**
276
-     * @param null $member
277
-     * @param array $context
278
-     *
279
-     * @return bool|int
280
-     */
281
-    public function canCreate($member = null, $context = [])
282
-    {
283
-        return Permission::check('Slide_CREATE', 'any', $member);
284
-    }
285
-
286
-    /**
287
-     * @param null $member
288
-     * @param array $context
289
-     *
290
-     * @return bool|int
291
-     */
292
-    public function canEdit($member = null, $context = [])
293
-    {
294
-        return Permission::check('Slide_EDIT', 'any', $member);
295
-    }
296
-
297
-    /**
298
-     * @param null $member
299
-     * @param array $context
300
-     *
301
-     * @return bool|int
302
-     */
303
-    public function canDelete($member = null, $context = [])
304
-    {
305
-        return Permission::check('Slide_DELETE', 'any', $member);
306
-    }
307
-
308
-    /**
309
-     * @param null $member
310
-     * @param array $context
311
-     *
312
-     * @return bool
313
-     */
314
-    public function canView($member = null, $context = [])
315
-    {
316
-        return true;
317
-    }
318
-
319
-    /**
320
-     * @return array
321
-     */
322
-    public function getTypeSource()
323
-    {
324
-        $types = $this->config()->get('slide_types');
325
-        asort($types);
326
-        return array_combine($types, $types);
327
-    }
328
-
329
-    /**
330
-     * @param null $template
331
-     * @param null $customFields
332
-     * @return \SilverStripe\ORM\FieldType\DBHTMLText
333
-     */
334
-    public function renderWith($template = null, $customFields = null)
335
-    {
336
-        if ($template === null) {
337
-            $template = static::class;
338
-            $template = ($this->SlideType) ? $template . "_{$this->SlideType}" : '';
339
-        }
340
-
341
-        return parent::renderWith($template);
342
-    }
343
-
344
-    /**
345
-     * @return \SilverStripe\ORM\FieldType\DBHTMLText
346
-     */
347
-    public function forTemplate()
348
-    {
349
-        return $this->renderWith();
350
-    }
215
+				))->setName('MediaFields'),
216
+				'Description'
217
+			);
218
+		});
219
+
220
+		$fields = parent::getCMSFields();
221
+
222
+		$this->extend('updateSlideImageFields', $fields);
223
+
224
+		return $fields;
225
+	}
226
+
227
+	/**
228
+	 * @return \SilverStripe\ORM\ValidationResult
229
+	 */
230
+	public function validate()
231
+	{
232
+		$result = parent::validate();
233
+
234
+		if (!$this->Name) {
235
+			$result->addError(
236
+				_t(__CLASS__ . '.NAME_REQUIRED', 'A Name is required before you can save')
237
+			);
238
+		}
239
+
240
+		$types = $this->getTypeSource();
241
+
242
+		if (isset($types['Video']) && $this->SlideType == 'Video' && !$this->VideoID) {
243
+			$result->addError(
244
+				_t(__CLASS__ . '.VIDEO_REQUIRED', 'An Video Link is required before you can save')
245
+			);
246
+		}
247
+
248
+		if (isset($types['Image']) && $this->SlideType == 'Image' && !$this->ImageID) {
249
+			$result->addError(
250
+				_t(__CLASS__ . '.IMAGE_REQUIRED', 'An Image is required before you can save')
251
+			);
252
+		}
253
+
254
+		if (isset($types['Text']) && $this->SlideType == 'Text' && !$this->Description) {
255
+			$result->addError(
256
+				_t(__CLASS__ . '.DESCRIPTION_REQUIRED', 'A Description is required before you can save')
257
+			);
258
+		}
259
+
260
+		return $result;
261
+	}
262
+
263
+	/**
264
+	 * @return array
265
+	 */
266
+	public function providePermissions()
267
+	{
268
+		return [
269
+			'Slide_EDIT' => 'Slide Edit',
270
+			'Slide_DELETE' => 'Slide Delete',
271
+			'Slide_CREATE' => 'Slide Create',
272
+		];
273
+	}
274
+
275
+	/**
276
+	 * @param null $member
277
+	 * @param array $context
278
+	 *
279
+	 * @return bool|int
280
+	 */
281
+	public function canCreate($member = null, $context = [])
282
+	{
283
+		return Permission::check('Slide_CREATE', 'any', $member);
284
+	}
285
+
286
+	/**
287
+	 * @param null $member
288
+	 * @param array $context
289
+	 *
290
+	 * @return bool|int
291
+	 */
292
+	public function canEdit($member = null, $context = [])
293
+	{
294
+		return Permission::check('Slide_EDIT', 'any', $member);
295
+	}
296
+
297
+	/**
298
+	 * @param null $member
299
+	 * @param array $context
300
+	 *
301
+	 * @return bool|int
302
+	 */
303
+	public function canDelete($member = null, $context = [])
304
+	{
305
+		return Permission::check('Slide_DELETE', 'any', $member);
306
+	}
307
+
308
+	/**
309
+	 * @param null $member
310
+	 * @param array $context
311
+	 *
312
+	 * @return bool
313
+	 */
314
+	public function canView($member = null, $context = [])
315
+	{
316
+		return true;
317
+	}
318
+
319
+	/**
320
+	 * @return array
321
+	 */
322
+	public function getTypeSource()
323
+	{
324
+		$types = $this->config()->get('slide_types');
325
+		asort($types);
326
+		return array_combine($types, $types);
327
+	}
328
+
329
+	/**
330
+	 * @param null $template
331
+	 * @param null $customFields
332
+	 * @return \SilverStripe\ORM\FieldType\DBHTMLText
333
+	 */
334
+	public function renderWith($template = null, $customFields = null)
335
+	{
336
+		if ($template === null) {
337
+			$template = static::class;
338
+			$template = ($this->SlideType) ? $template . "_{$this->SlideType}" : '';
339
+		}
340
+
341
+		return parent::renderWith($template);
342
+	}
343
+
344
+	/**
345
+	 * @return \SilverStripe\ORM\FieldType\DBHTMLText
346
+	 */
347
+	public function forTemplate()
348
+	{
349
+		return $this->renderWith();
350
+	}
351 351
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
     {
140 140
         $labels = parent::fieldLabels($includerelations);
141 141
 
142
-        $labels['Name'] = _t(__CLASS__ . '.NAME', 'Name');
143
-        $labels['Headline'] = _t(__CLASS__ . '.HEADLINE', 'Headline');
144
-        $labels['Description'] = _t(__CLASS__ . '.DESCRIPTION', 'Description');
145
-        $labels['SlideLinkID'] =  _t(__CLASS__ . '.PAGE_LINK', "Call to action link");
146
-        $labels['Image'] = _t(__CLASS__ . '.IMAGE', 'Image');
147
-        $labels['SlideType'] = _t(__CLASS__ . '.SlideType', 'Image or Video');
148
-        $labels['Video'] = _t(__CLASS__ . '.VideoLabel', 'Video URL');
142
+        $labels['Name'] = _t(__CLASS__.'.NAME', 'Name');
143
+        $labels['Headline'] = _t(__CLASS__.'.HEADLINE', 'Headline');
144
+        $labels['Description'] = _t(__CLASS__.'.DESCRIPTION', 'Description');
145
+        $labels['SlideLinkID'] = _t(__CLASS__.'.PAGE_LINK', "Call to action link");
146
+        $labels['Image'] = _t(__CLASS__.'.IMAGE', 'Image');
147
+        $labels['SlideType'] = _t(__CLASS__.'.SlideType', 'Image or Video');
148
+        $labels['Video'] = _t(__CLASS__.'.VideoLabel', 'Video URL');
149 149
 
150 150
         return $labels;
151 151
     }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function getCMSFields()
157 157
     {
158
-        $this->beforeUpdateCMSFields(function ($fields) {
158
+        $this->beforeUpdateCMSFields(function($fields) {
159 159
             $fields->removeByName([
160 160
                 'ShowSlide',
161 161
                 'SortOrder',
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
             // Name
171 171
             $fields->dataFieldByName('Name')
172 172
                 ->setDescription(
173
-                    _t(__CLASS__ . '.INTERNAL_USE', 'for internal reference only')
173
+                    _t(__CLASS__.'.INTERNAL_USE', 'for internal reference only')
174 174
                 );
175 175
 
176 176
             // Headline
177 177
             $fields->dataFieldByName('Headline')
178 178
                 ->setDescription(
179
-                    _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template')
179
+                    _t(__CLASS__.'.USED_IN_TEMPLATE', 'optional, used in template')
180 180
                 );
181 181
 
182 182
             // Description
183 183
             $fields->dataFieldByName('Description')
184 184
                 ->setDescription(
185
-                    _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template')
185
+                    _t(__CLASS__.'.USED_IN_TEMPLATE', 'optional, used in template')
186 186
                 );
187 187
 
188 188
             // Page link
@@ -233,27 +233,27 @@  discard block
 block discarded – undo
233 233
 
234 234
         if (!$this->Name) {
235 235
             $result->addError(
236
-                _t(__CLASS__ . '.NAME_REQUIRED', 'A Name is required before you can save')
236
+                _t(__CLASS__.'.NAME_REQUIRED', 'A Name is required before you can save')
237 237
             );
238 238
         }
239 239
 
240 240
         $types = $this->getTypeSource();
241 241
 
242
-        if (isset($types['Video']) && $this->SlideType == 'Video' && !$this->VideoID) {
242
+        if (isset($types['Video']) && $this->SlideType=='Video' && !$this->VideoID) {
243 243
             $result->addError(
244
-                _t(__CLASS__ . '.VIDEO_REQUIRED', 'An Video Link is required before you can save')
244
+                _t(__CLASS__.'.VIDEO_REQUIRED', 'An Video Link is required before you can save')
245 245
             );
246 246
         }
247 247
 
248
-        if (isset($types['Image']) && $this->SlideType == 'Image' && !$this->ImageID) {
248
+        if (isset($types['Image']) && $this->SlideType=='Image' && !$this->ImageID) {
249 249
             $result->addError(
250
-                _t(__CLASS__ . '.IMAGE_REQUIRED', 'An Image is required before you can save')
250
+                _t(__CLASS__.'.IMAGE_REQUIRED', 'An Image is required before you can save')
251 251
             );
252 252
         }
253 253
 
254
-        if (isset($types['Text']) && $this->SlideType == 'Text' && !$this->Description) {
254
+        if (isset($types['Text']) && $this->SlideType=='Text' && !$this->Description) {
255 255
             $result->addError(
256
-                _t(__CLASS__ . '.DESCRIPTION_REQUIRED', 'A Description is required before you can save')
256
+                _t(__CLASS__.'.DESCRIPTION_REQUIRED', 'A Description is required before you can save')
257 257
             );
258 258
         }
259 259
 
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
      */
334 334
     public function renderWith($template = null, $customFields = null)
335 335
     {
336
-        if ($template === null) {
336
+        if ($template===null) {
337 337
             $template = static::class;
338
-            $template = ($this->SlideType) ? $template . "_{$this->SlideType}" : '';
338
+            $template = ($this->SlideType) ? $template."_{$this->SlideType}" : '';
339 339
         }
340 340
 
341 341
         return parent::renderWith($template);
Please login to merge, or discard this patch.
src/ORM/FlexSlider.php 2 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -37,189 +37,189 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class FlexSlider extends DataExtension
39 39
 {
40
-    use Configurable;
40
+	use Configurable;
41 41
 
42
-    /**
43
-     * @var array
44
-     */
45
-    private static $db = [
46
-        'Animation' => "Enum('slide, fade', 'slide')",
47
-        'Loop' => 'Boolean',
48
-        'Animate' => 'Boolean',
49
-        'ThumbnailNav' => 'Boolean',
50
-        'SliderControlNav' => 'Boolean',
51
-        'SliderDirectionNav' => 'Boolean',
52
-        'CarouselControlNav' => 'Boolean',
53
-        'CarouselDirectionNav' => 'Boolean',
54
-        'CarouselThumbnailCt' => 'Int',
55
-        'FlexSliderSpeed' => 'Double',
56
-    ];
42
+	/**
43
+	 * @var array
44
+	 */
45
+	private static $db = [
46
+		'Animation' => "Enum('slide, fade', 'slide')",
47
+		'Loop' => 'Boolean',
48
+		'Animate' => 'Boolean',
49
+		'ThumbnailNav' => 'Boolean',
50
+		'SliderControlNav' => 'Boolean',
51
+		'SliderDirectionNav' => 'Boolean',
52
+		'CarouselControlNav' => 'Boolean',
53
+		'CarouselDirectionNav' => 'Boolean',
54
+		'CarouselThumbnailCt' => 'Int',
55
+		'FlexSliderSpeed' => 'Double',
56
+	];
57 57
 
58
-    /**
59
-     * @var array
60
-     */
61
-    private static $has_many = [
62
-        'Slides' => SlideImage::class,
63
-    ];
58
+	/**
59
+	 * @var array
60
+	 */
61
+	private static $has_many = [
62
+		'Slides' => SlideImage::class,
63
+	];
64 64
 
65
-    /**
66
-     *
67
-     */
68
-    public function populateDefaults()
69
-    {
70
-        $this->owner->Loop = 1;
71
-        $this->owner->Animate = 1;
72
-        $this->owner->SliderControlNav = 0;
73
-        $this->owner->SliderDirectionNav = 1;
74
-        $this->owner->CarouselControlNav = 0;
75
-        $this->owner->CarouselDirectionNav = 1;
76
-        $this->owner->CarouselThumbnailCt = 6;
77
-        $this->owner->FlexSliderSpeed = $this->getDefaultSpeed();
65
+	/**
66
+	 *
67
+	 */
68
+	public function populateDefaults()
69
+	{
70
+		$this->owner->Loop = 1;
71
+		$this->owner->Animate = 1;
72
+		$this->owner->SliderControlNav = 0;
73
+		$this->owner->SliderDirectionNav = 1;
74
+		$this->owner->CarouselControlNav = 0;
75
+		$this->owner->CarouselDirectionNav = 1;
76
+		$this->owner->CarouselThumbnailCt = 6;
77
+		$this->owner->FlexSliderSpeed = $this->getDefaultSpeed();
78 78
 
79
-        return parent::populateDefaults();
80
-    }
79
+		return parent::populateDefaults();
80
+	}
81 81
 
82
-    /**
83
-     * @param FieldList $fields
84
-     */
85
-    public function updateCMSFields(FieldList $fields)
86
-    {
87
-        $fields->removeByName([
88
-            'Animation',
89
-            'Loop',
90
-            'Animate',
91
-            'ThumbnailNav',
92
-            'SliderControlNav',
93
-            'SliderDirectionNav',
94
-            'CarouselControlNav',
95
-            'CarouselDirectionNav',
96
-            'CarouselThumbnailCt',
97
-            'FlexSliderSpeed',
98
-            'Slides',
99
-        ]);
82
+	/**
83
+	 * @param FieldList $fields
84
+	 */
85
+	public function updateCMSFields(FieldList $fields)
86
+	{
87
+		$fields->removeByName([
88
+			'Animation',
89
+			'Loop',
90
+			'Animate',
91
+			'ThumbnailNav',
92
+			'SliderControlNav',
93
+			'SliderDirectionNav',
94
+			'CarouselControlNav',
95
+			'CarouselDirectionNav',
96
+			'CarouselThumbnailCt',
97
+			'FlexSliderSpeed',
98
+			'Slides',
99
+		]);
100 100
 
101
-        // Slides
102
-        if ($this->owner->ID) {
103
-            $config = GridFieldConfig_RecordEditor::create();
104
-            $config->addComponent(new GridFieldOrderableRows('SortOrder'));
105
-            $config->removeComponentsByType([
106
-                GridFieldAddExistingAutocompleter::class,
107
-                GridFieldDeleteAction::class,
108
-            ]);
109
-            $SlidesField = GridField::create(
110
-                'Slides',
111
-                _t(__CLASS__ . '.SLIDES', 'Slides'),
112
-                $this->owner->Slides()->sort('SortOrder'),
113
-                $config
114
-            );
101
+		// Slides
102
+		if ($this->owner->ID) {
103
+			$config = GridFieldConfig_RecordEditor::create();
104
+			$config->addComponent(new GridFieldOrderableRows('SortOrder'));
105
+			$config->removeComponentsByType([
106
+				GridFieldAddExistingAutocompleter::class,
107
+				GridFieldDeleteAction::class,
108
+			]);
109
+			$SlidesField = GridField::create(
110
+				'Slides',
111
+				_t(__CLASS__ . '.SLIDES', 'Slides'),
112
+				$this->owner->Slides()->sort('SortOrder'),
113
+				$config
114
+			);
115 115
 
116
-            $slideTitle = $this->owner->slide_tab_title ?: _t(__CLASS__ . '.SLIDES', 'Slides');
116
+			$slideTitle = $this->owner->slide_tab_title ?: _t(__CLASS__ . '.SLIDES', 'Slides');
117 117
 
118
-            $animations = [];
119
-            $animationOptions = $this->owner->dbObject('Animation')->getEnum();
120
-            foreach ($animationOptions as $value) {
121
-                $animations[$value] = _t(__CLASS__ . ".$value", $value);
122
-            }
118
+			$animations = [];
119
+			$animationOptions = $this->owner->dbObject('Animation')->getEnum();
120
+			foreach ($animationOptions as $value) {
121
+				$animations[$value] = _t(__CLASS__ . ".$value", $value);
122
+			}
123 123
 
124
-            $fields->addFieldsToTab("Root.{$slideTitle}", [
125
-                $SlidesField,
126
-                ToggleCompositeField::create('ConfigHD', _t(__CLASS__ . '.SettingsLabel', 'Slider Settings'), [
127
-                    DropdownField::create(
128
-                        'Animation',
129
-                        _t(__CLASS__ . '.ANIMATION_OPTION', 'Animation option'),
130
-                        $animations
131
-                    ),
132
-                    CheckboxField::create(
133
-                        'Animate',
134
-                        _t(__CLASS__ . '.ANIMATE', 'Animate automatically')
135
-                    ),
136
-                    CheckboxField::create(
137
-                        'Loop',
138
-                        _t(__CLASS__ . '.LOOP', 'Loop the carousel')
139
-                    ),
140
-                    CheckboxField::create(
141
-                        'SliderControlNav',
142
-                        _t(__CLASS__ . '.CONTROL_NAV', 'Show ControlNav')
143
-                    ),
144
-                    CheckboxField::create(
145
-                        'SliderDirectionNav',
146
-                        _t(__CLASS__ . '.DIRECTION_NAV', 'Show DirectionNav')
147
-                    ),
148
-                    CheckboxField::create(
149
-                        'ThumbnailNav',
150
-                        _t(__CLASS__ . '.THUMBNAIL_NAV', 'Thumbnail Navigation')
151
-                    ),
152
-                    //DisplayLogicWrapper::create(
153
-                    CheckboxField::create(
154
-                        'CarouselControlNav',
155
-                        _t(__CLASS__ . '.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav')
156
-                    ),
157
-                    CheckboxField::create(
158
-                        'CarouselDirectionNav',
159
-                        _t(__CLASS__ . '.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav')
160
-                    ),
161
-                    NumericField::create(
162
-                        'CarouselThumbnailCt',
163
-                        _t(__CLASS__ . '.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails')
164
-                    ),
165
-                    NumericField::create(
166
-                        'FlexSliderSpeed',
167
-                        _t(__CLASS__ . '.SLIDER_SPEED', 'Slider Speed')
168
-                    )
169
-                        ->setDescription('In Seconds')
170
-                        ->setScale(2),
171
-                ]),
172
-            ]);
173
-        }
174
-    }
124
+			$fields->addFieldsToTab("Root.{$slideTitle}", [
125
+				$SlidesField,
126
+				ToggleCompositeField::create('ConfigHD', _t(__CLASS__ . '.SettingsLabel', 'Slider Settings'), [
127
+					DropdownField::create(
128
+						'Animation',
129
+						_t(__CLASS__ . '.ANIMATION_OPTION', 'Animation option'),
130
+						$animations
131
+					),
132
+					CheckboxField::create(
133
+						'Animate',
134
+						_t(__CLASS__ . '.ANIMATE', 'Animate automatically')
135
+					),
136
+					CheckboxField::create(
137
+						'Loop',
138
+						_t(__CLASS__ . '.LOOP', 'Loop the carousel')
139
+					),
140
+					CheckboxField::create(
141
+						'SliderControlNav',
142
+						_t(__CLASS__ . '.CONTROL_NAV', 'Show ControlNav')
143
+					),
144
+					CheckboxField::create(
145
+						'SliderDirectionNav',
146
+						_t(__CLASS__ . '.DIRECTION_NAV', 'Show DirectionNav')
147
+					),
148
+					CheckboxField::create(
149
+						'ThumbnailNav',
150
+						_t(__CLASS__ . '.THUMBNAIL_NAV', 'Thumbnail Navigation')
151
+					),
152
+					//DisplayLogicWrapper::create(
153
+					CheckboxField::create(
154
+						'CarouselControlNav',
155
+						_t(__CLASS__ . '.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav')
156
+					),
157
+					CheckboxField::create(
158
+						'CarouselDirectionNav',
159
+						_t(__CLASS__ . '.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav')
160
+					),
161
+					NumericField::create(
162
+						'CarouselThumbnailCt',
163
+						_t(__CLASS__ . '.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails')
164
+					),
165
+					NumericField::create(
166
+						'FlexSliderSpeed',
167
+						_t(__CLASS__ . '.SLIDER_SPEED', 'Slider Speed')
168
+					)
169
+						->setDescription('In Seconds')
170
+						->setScale(2),
171
+				]),
172
+			]);
173
+		}
174
+	}
175 175
 
176
-    /**
177
-     * @return mixed
178
-     */
179
-    public function getSlideShow()
180
-    {
181
-        $owner = $this->owner;
176
+	/**
177
+	 * @return mixed
178
+	 */
179
+	public function getSlideShow()
180
+	{
181
+		$owner = $this->owner;
182 182
 
183
-        if (!($owner instanceof SiteTree)) {
184
-            $this->getCustomScript();
185
-        }
183
+		if (!($owner instanceof SiteTree)) {
184
+			$this->getCustomScript();
185
+		}
186 186
 
187
-        return $this->owner->Slides()->sort('SortOrder');
188
-    }
187
+		return $this->owner->Slides()->sort('SortOrder');
188
+	}
189 189
 
190
-    /**
191
-     * add requirements to PageController init()
192
-     */
193
-    public function contentcontrollerInit()
194
-    {
195
-        // only call custom script if page has Slides and DataExtension
196
-        if (DataObject::has_extension($this->owner->Classname, FlexSlider::class)) {
197
-            if ($this->owner->getSlideShow()->exists()) {
198
-                $this->getCustomScript();
199
-            }
200
-        }
201
-    }
190
+	/**
191
+	 * add requirements to PageController init()
192
+	 */
193
+	public function contentcontrollerInit()
194
+	{
195
+		// only call custom script if page has Slides and DataExtension
196
+		if (DataObject::has_extension($this->owner->Classname, FlexSlider::class)) {
197
+			if ($this->owner->getSlideShow()->exists()) {
198
+				$this->getCustomScript();
199
+			}
200
+		}
201
+	}
202 202
 
203
-    /**
204
-     *
205
-     */
206
-    public function getCustomScript()
207
-    {
208
-        // Flexslider options
209
-        $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : '';
203
+	/**
204
+	 *
205
+	 */
206
+	public function getCustomScript()
207
+	{
208
+		// Flexslider options
209
+		$sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : '';
210 210
 
211
-        $before = $this->owner->hasMethod('flexSliderBeforeAction')
212
-            ? $this->owner->flexSliderBeforeAction()
213
-            : 'function(){}';
211
+		$before = $this->owner->hasMethod('flexSliderBeforeAction')
212
+			? $this->owner->flexSliderBeforeAction()
213
+			: 'function(){}';
214 214
 
215
-        $after = $this->owner->hasMethod('flexSliderAfterAction')
216
-            ? $this->owner->flexSliderAfterAction()
217
-            : 'function(){}';
215
+		$after = $this->owner->hasMethod('flexSliderAfterAction')
216
+			? $this->owner->flexSliderAfterAction()
217
+			: 'function(){}';
218 218
 
219
-        $speed = $this->getSlideshowSpeed();
219
+		$speed = $this->getSlideshowSpeed();
220 220
 
221
-        Requirements::customScript(
222
-            "(function($) {
221
+		Requirements::customScript(
222
+			"(function($) {
223 223
                 $(document).ready(function(){
224 224
                     jQuery('.flexslider').each(function(index){
225 225
 
@@ -265,39 +265,39 @@  discard block
 block discarded – undo
265 265
                     })
266 266
                 });
267 267
             }(jQuery));'
268
-        );
269
-    }
268
+		);
269
+	}
270 270
 
271
-    /**
272
-     * @return int
273
-     */
274
-    public function getSlideshowSpeed()
275
-    {
276
-        $speed = $this->owner->FlexSliderSpeed > 0
277
-            ? $this->owner->FlexSliderSpeed
278
-            : $this->getDefaultSpeed();
271
+	/**
272
+	 * @return int
273
+	 */
274
+	public function getSlideshowSpeed()
275
+	{
276
+		$speed = $this->owner->FlexSliderSpeed > 0
277
+			? $this->owner->FlexSliderSpeed
278
+			: $this->getDefaultSpeed();
279 279
 
280
-        return $speed * 1000;
281
-    }
280
+		return $speed * 1000;
281
+	}
282 282
 
283
-    /**
284
-     * @return mixed
285
-     */
286
-    protected function getDefaultSpeed()
287
-    {
288
-        return $this->owner->config()->get('flex_slider_speed')
289
-            ?: Config::inst()->get(FlexSlider::class, 'flex_slider_speed');
290
-    }
283
+	/**
284
+	 * @return mixed
285
+	 */
286
+	protected function getDefaultSpeed()
287
+	{
288
+		return $this->owner->config()->get('flex_slider_speed')
289
+			?: Config::inst()->get(FlexSlider::class, 'flex_slider_speed');
290
+	}
291 291
 
292
-    /**
293
-     *
294
-     */
295
-    public function onBeforeWrite()
296
-    {
297
-        parent::onBeforeWrite();
292
+	/**
293
+	 *
294
+	 */
295
+	public function onBeforeWrite()
296
+	{
297
+		parent::onBeforeWrite();
298 298
 
299
-        if (!$this->owner->CarouselThumbnailCt) {
300
-            $this->owner->CarouselThumbnailCt = 6;
301
-        }
302
-    }
299
+		if (!$this->owner->CarouselThumbnailCt) {
300
+			$this->owner->CarouselThumbnailCt = 6;
301
+		}
302
+	}
303 303
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -108,63 +108,63 @@  discard block
 block discarded – undo
108 108
             ]);
109 109
             $SlidesField = GridField::create(
110 110
                 'Slides',
111
-                _t(__CLASS__ . '.SLIDES', 'Slides'),
111
+                _t(__CLASS__.'.SLIDES', 'Slides'),
112 112
                 $this->owner->Slides()->sort('SortOrder'),
113 113
                 $config
114 114
             );
115 115
 
116
-            $slideTitle = $this->owner->slide_tab_title ?: _t(__CLASS__ . '.SLIDES', 'Slides');
116
+            $slideTitle = $this->owner->slide_tab_title ?: _t(__CLASS__.'.SLIDES', 'Slides');
117 117
 
118 118
             $animations = [];
119 119
             $animationOptions = $this->owner->dbObject('Animation')->getEnum();
120 120
             foreach ($animationOptions as $value) {
121
-                $animations[$value] = _t(__CLASS__ . ".$value", $value);
121
+                $animations[$value] = _t(__CLASS__.".$value", $value);
122 122
             }
123 123
 
124 124
             $fields->addFieldsToTab("Root.{$slideTitle}", [
125 125
                 $SlidesField,
126
-                ToggleCompositeField::create('ConfigHD', _t(__CLASS__ . '.SettingsLabel', 'Slider Settings'), [
126
+                ToggleCompositeField::create('ConfigHD', _t(__CLASS__.'.SettingsLabel', 'Slider Settings'), [
127 127
                     DropdownField::create(
128 128
                         'Animation',
129
-                        _t(__CLASS__ . '.ANIMATION_OPTION', 'Animation option'),
129
+                        _t(__CLASS__.'.ANIMATION_OPTION', 'Animation option'),
130 130
                         $animations
131 131
                     ),
132 132
                     CheckboxField::create(
133 133
                         'Animate',
134
-                        _t(__CLASS__ . '.ANIMATE', 'Animate automatically')
134
+                        _t(__CLASS__.'.ANIMATE', 'Animate automatically')
135 135
                     ),
136 136
                     CheckboxField::create(
137 137
                         'Loop',
138
-                        _t(__CLASS__ . '.LOOP', 'Loop the carousel')
138
+                        _t(__CLASS__.'.LOOP', 'Loop the carousel')
139 139
                     ),
140 140
                     CheckboxField::create(
141 141
                         'SliderControlNav',
142
-                        _t(__CLASS__ . '.CONTROL_NAV', 'Show ControlNav')
142
+                        _t(__CLASS__.'.CONTROL_NAV', 'Show ControlNav')
143 143
                     ),
144 144
                     CheckboxField::create(
145 145
                         'SliderDirectionNav',
146
-                        _t(__CLASS__ . '.DIRECTION_NAV', 'Show DirectionNav')
146
+                        _t(__CLASS__.'.DIRECTION_NAV', 'Show DirectionNav')
147 147
                     ),
148 148
                     CheckboxField::create(
149 149
                         'ThumbnailNav',
150
-                        _t(__CLASS__ . '.THUMBNAIL_NAV', 'Thumbnail Navigation')
150
+                        _t(__CLASS__.'.THUMBNAIL_NAV', 'Thumbnail Navigation')
151 151
                     ),
152 152
                     //DisplayLogicWrapper::create(
153 153
                     CheckboxField::create(
154 154
                         'CarouselControlNav',
155
-                        _t(__CLASS__ . '.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav')
155
+                        _t(__CLASS__.'.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav')
156 156
                     ),
157 157
                     CheckboxField::create(
158 158
                         'CarouselDirectionNav',
159
-                        _t(__CLASS__ . '.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav')
159
+                        _t(__CLASS__.'.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav')
160 160
                     ),
161 161
                     NumericField::create(
162 162
                         'CarouselThumbnailCt',
163
-                        _t(__CLASS__ . '.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails')
163
+                        _t(__CLASS__.'.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails')
164 164
                     ),
165 165
                     NumericField::create(
166 166
                         'FlexSliderSpeed',
167
-                        _t(__CLASS__ . '.SLIDER_SPEED', 'Slider Speed')
167
+                        _t(__CLASS__.'.SLIDER_SPEED', 'Slider Speed')
168 168
                     )
169 169
                         ->setDescription('In Seconds')
170 170
                         ->setScale(2),
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public function getCustomScript()
207 207
     {
208 208
         // Flexslider options
209
-        $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : '';
209
+        $sync = ($this->owner->ThumbnailNav==true) ? "sync: '.fs-carousel:eq('+index+')'," : '';
210 210
 
211 211
         $before = $this->owner->hasMethod('flexSliderBeforeAction')
212 212
             ? $this->owner->flexSliderBeforeAction()
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
 
226 226
                          if(jQuery('.fs-carousel').eq(index).length) {
227 227
                              jQuery('.fs-carousel').eq(index).flexslider({
228
-                                slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ",
228
+                                slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean().",
229 229
                                 animation: 'slide',
230
-                                animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ",
231
-                                controlNav: " . $this->owner->obj('CarouselControlNav')->NiceAsBoolean() . ",
232
-                                directionNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean() . ",
230
+                                animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean().",
231
+                                controlNav: " . $this->owner->obj('CarouselControlNav')->NiceAsBoolean().",
232
+                                directionNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean().",
233 233
                                 prevText: '',
234 234
                                 nextText: '',
235 235
                                 pausePlay: false,
236 236
                                 asNavFor: '.flexslider:eq('+index+')',
237
-                                minItems: " . $this->owner->obj('CarouselThumbnailCt') . ",
238
-                                maxItems: " . $this->owner->obj('CarouselThumbnailCt') . ",
239
-                                move: " . $this->owner->obj('CarouselThumbnailCt') . ",
237
+                                minItems: " . $this->owner->obj('CarouselThumbnailCt').",
238
+                                maxItems: " . $this->owner->obj('CarouselThumbnailCt').",
239
+                                move: " . $this->owner->obj('CarouselThumbnailCt').",
240 240
                                 itemWidth: 100,
241 241
                                 itemMargin: 10
242 242
                               });
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
 
245 245
                         if(jQuery('.flexslider').eq(index).length){
246 246
                             jQuery('.flexslider').eq(index).flexslider({
247
-                                slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ",
248
-                                animation: '" . $this->owner->Animation . "',
249
-                                animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ",
250
-                                controlNav: " . $this->owner->obj('SliderControlNav')->NiceAsBoolean() . ",
251
-                                directionNav: " . $this->owner->obj('SliderDirectionNav')->NiceAsBoolean() . ",
247
+                                slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean().",
248
+                                animation: '" . $this->owner->Animation."',
249
+                                animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean().",
250
+                                controlNav: " . $this->owner->obj('SliderControlNav')->NiceAsBoolean().",
251
+                                directionNav: " . $this->owner->obj('SliderDirectionNav')->NiceAsBoolean().",
252 252
                                 prevText: '',
253 253
                                 nextText: '',
254 254
                                 pauseOnAction: true,
255 255
                                 pauseOnHover: true,
256
-                                " . $sync . "
256
+                                " . $sync."
257 257
                                 start: function(slider){
258 258
                                   $('body').removeClass('loading');
259 259
                                 },
260
-                                before: " . $before . ',
261
-                                after: ' . $after . ',
262
-                                slideshowSpeed: ' . $speed . '
260
+                                before: " . $before.',
261
+                                after: ' . $after.',
262
+                                slideshowSpeed: ' . $speed.'
263 263
                             });
264 264
                         }
265 265
                     })
Please login to merge, or discard this patch.