Completed
Push — master ( 2ad7fe...4fb981 )
by Leo
03:07
created
code/Block.php 3 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	public function VisibleTo() {
42 42
 		if (strlen(trim($this->MemberVisibility)) > 0) {
43 43
 			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
44
-		}else{
44
+		} else{
45 45
 			$lists = '<em>&lt;All&gt;</em>';
46 46
 		}
47 47
 		
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 		if ($this->showBlockbyClass) {
57 57
 			if (strlen(trim($this->shownInClass)) > 0) {
58 58
 				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
59
-			}else{
59
+			} else{
60 60
 				$lists = '<em>&lt;not assigned&gt;</em>';
61 61
 			}
62
-		}else{
62
+		} else{
63 63
 			if ($this->Pages()->count() > 0) {
64 64
 				$lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
65
-			}else{
65
+			} else{
66 66
 				$lists = '<em>&lt;not assigned&gt;</em>';
67 67
 			}
68 68
 		}
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -1,214 +1,214 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class Block extends DataObject {
4
-	protected static $db = array (
5
-		'SortOrder'			=>	'Int',
6
-		'Title'				=>	'Varchar(64)',
7
-		'TitleWrapper'		=>	'Enum("h2,h3,h4,h5,h6")',
8
-		'hideTitle'			=>	'Boolean',
9
-		'showBlockbyClass'	=>	'Boolean',
10
-		'Description'		=>	'Varchar(128)',
11
-		'MemberVisibility'	=>	'Varchar(255)',
12
-		'shownInClass'		=>	'Text',
13
-		'WrapperClasses'	=>	'Varchar(255)',
14
-		'HeadingClasses'	=>	'Varchar(255)',
15
-		'addMarginTop'		=>	'Boolean',
16
-		'addMarginBottom'	=>	'Boolean',
17
-		'addPaddingTop'		=>	'Boolean',
18
-		'addPaddingBottom'	=>	'Boolean',
19
-		'SectionWrapper'	=>	'Boolean'
20
-	);
4
+    protected static $db = array (
5
+        'SortOrder'			=>	'Int',
6
+        'Title'				=>	'Varchar(64)',
7
+        'TitleWrapper'		=>	'Enum("h2,h3,h4,h5,h6")',
8
+        'hideTitle'			=>	'Boolean',
9
+        'showBlockbyClass'	=>	'Boolean',
10
+        'Description'		=>	'Varchar(128)',
11
+        'MemberVisibility'	=>	'Varchar(255)',
12
+        'shownInClass'		=>	'Text',
13
+        'WrapperClasses'	=>	'Varchar(255)',
14
+        'HeadingClasses'	=>	'Varchar(255)',
15
+        'addMarginTop'		=>	'Boolean',
16
+        'addMarginBottom'	=>	'Boolean',
17
+        'addPaddingTop'		=>	'Boolean',
18
+        'addPaddingBottom'	=>	'Boolean',
19
+        'SectionWrapper'	=>	'Boolean'
20
+    );
21 21
 	
22
-	protected static $many_many = array (
23
-		'Pages'				=>	'Page'
24
-	);
22
+    protected static $many_many = array (
23
+        'Pages'				=>	'Page'
24
+    );
25 25
 		
26
-	protected static $create_table_options = array(
27
-		'MySQLDatabase'		=> 'ENGINE=MyISAM'
26
+    protected static $create_table_options = array(
27
+        'MySQLDatabase'		=> 'ENGINE=MyISAM'
28 28
     );
29 29
 	
30
-	protected static $extensions = array (
31
-		'StandardPermissions'
32
-	);
30
+    protected static $extensions = array (
31
+        'StandardPermissions'
32
+    );
33 33
 	
34
-	protected static $summary_fields = array(
35
-		'BlockType',
36
-		'Title', 
37
-		'Description',
38
-		'shownOn',
39
-		'VisibleTo'
40
-	);
34
+    protected static $summary_fields = array(
35
+        'BlockType',
36
+        'Title', 
37
+        'Description',
38
+        'shownOn',
39
+        'VisibleTo'
40
+    );
41 41
 	
42
-	protected static $field_labels = array(
43
-		'BlockType'			=>	'Block type',
44
-		'shownOn'			=>	'is shown on',
45
-		'VisibleTo'			=>	'Visible to'
46
-	);
42
+    protected static $field_labels = array(
43
+        'BlockType'			=>	'Block type',
44
+        'shownOn'			=>	'is shown on',
45
+        'VisibleTo'			=>	'Visible to'
46
+    );
47 47
 	
48
-	public function VisibleTo() {
49
-		if (strlen(trim($this->MemberVisibility)) > 0) {
50
-			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
51
-		}else{
52
-			$lists = '<em>&lt;All&gt;</em>';
53
-		}
54
-		
55
-		return new LiteralField('VisibleTo',$lists);
56
-	}
48
+    public function VisibleTo() {
49
+        if (strlen(trim($this->MemberVisibility)) > 0) {
50
+            $lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
51
+        }else{
52
+            $lists = '<em>&lt;All&gt;</em>';
53
+        }
54
+		
55
+        return new LiteralField('VisibleTo',$lists);
56
+    }
57 57
 	
58
-	public function BlockType() {
59
-		return $this->singular_name();
60
-	}
58
+    public function BlockType() {
59
+        return $this->singular_name();
60
+    }
61 61
 	
62
-	public function shownOn() {
63
-		if ($this->showBlockbyClass) {
64
-			if (strlen(trim($this->shownInClass)) > 0) {
65
-				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
66
-			}else{
67
-				$lists = '<em>&lt;not assigned&gt;</em>';
68
-			}
69
-		}else{
70
-			if ($this->Pages()->count() > 0) {
71
-				$lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
72
-			}else{
73
-				$lists = '<em>&lt;not assigned&gt;</em>';
74
-			}
75
-		}
76
-		return new LiteralField('shownOn',$lists);
77
-	}
62
+    public function shownOn() {
63
+        if ($this->showBlockbyClass) {
64
+            if (strlen(trim($this->shownInClass)) > 0) {
65
+                $lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
66
+            }else{
67
+                $lists = '<em>&lt;not assigned&gt;</em>';
68
+            }
69
+        }else{
70
+            if ($this->Pages()->count() > 0) {
71
+                $lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
72
+            }else{
73
+                $lists = '<em>&lt;not assigned&gt;</em>';
74
+            }
75
+        }
76
+        return new LiteralField('shownOn',$lists);
77
+    }
78 78
 	
79
-	public function getCMSFields() {
80
-		$fields = parent::getCMSFields();
81
-		$fields->removeFieldFromTab('Root', 'Pages');
82
-		$fields->removeFieldsFromTab('Root.Main', array(
83
-			'SortOrder',
84
-			'showBlockbyClass',
85
-			'shownInClass',
86
-			'MemberVisibility'
87
-		));
88
-		
89
-		$memberGroups = Group::get();
90
-		$sourcemap = $memberGroups->map('Code', 'Title');
91
-		$source = array(
92
-			'anonymous'		=>	'Anonymous visitors'
93
-		);
94
-		foreach ($sourcemap as $mapping => $key) {
95
-			$source[$mapping] = $key;
96
-		}
97
-		
98
-		$memberVisibility = new CheckboxSetField(
99
-			$name = "MemberVisibility",
100
-			$title = "Show block for specific groups",
101
-			$source
102
-		);
103
-		
104
-		$memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
105
-		
106
-		$availabelClasses = $this->availableClasses();
107
-		$inClass = new CheckboxSetField(
108
-			$name = "shownInClass",
109
-			$title = "Show block for specific content types",
110
-			$availabelClasses
111
-		);
112
-		
113
-		$filterSelector = OptionsetField::create(
114
-			'showBlockbyClass',
115
-			'Choose filter set',
116
-			array(
117
-				'0'			=>	'by page',
118
-				'1'			=>	'by page/data type'
119
-			)
120
-		)->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
121
-		
122
-		$availablePages = Page::get()->exclude('ClassName', array(
123
-			'ErrorPage',
124
-			'RedirectorPage',
125
-			'VirtualPage'
126
-		));
127
-		$pageSelector = new CheckboxSetField(
128
-			$name = "Pages",
129
-			$title = "Show on Page(s)",
130
-			$availablePages->map('ID','Title')
131
-		);
132
-		
133
-		
134
-		if ($this->canConfigPageAndType(Member::currentUser())) {
135
-			$fields->addFieldsToTab('Root.VisibilitySettings', array(
136
-				$filterSelector,
137
-				$pageSelector,
138
-				$inClass
139
-			));
140
-		}
141
-		
142
-		if ($this->canConfigMemberVisibility(Member::currentUser())) {
143
-			$fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
144
-		}
79
+    public function getCMSFields() {
80
+        $fields = parent::getCMSFields();
81
+        $fields->removeFieldFromTab('Root', 'Pages');
82
+        $fields->removeFieldsFromTab('Root.Main', array(
83
+            'SortOrder',
84
+            'showBlockbyClass',
85
+            'shownInClass',
86
+            'MemberVisibility'
87
+        ));
88
+		
89
+        $memberGroups = Group::get();
90
+        $sourcemap = $memberGroups->map('Code', 'Title');
91
+        $source = array(
92
+            'anonymous'		=>	'Anonymous visitors'
93
+        );
94
+        foreach ($sourcemap as $mapping => $key) {
95
+            $source[$mapping] = $key;
96
+        }
97
+		
98
+        $memberVisibility = new CheckboxSetField(
99
+            $name = "MemberVisibility",
100
+            $title = "Show block for specific groups",
101
+            $source
102
+        );
103
+		
104
+        $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
105
+		
106
+        $availabelClasses = $this->availableClasses();
107
+        $inClass = new CheckboxSetField(
108
+            $name = "shownInClass",
109
+            $title = "Show block for specific content types",
110
+            $availabelClasses
111
+        );
112
+		
113
+        $filterSelector = OptionsetField::create(
114
+            'showBlockbyClass',
115
+            'Choose filter set',
116
+            array(
117
+                '0'			=>	'by page',
118
+                '1'			=>	'by page/data type'
119
+            )
120
+        )->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
121
+		
122
+        $availablePages = Page::get()->exclude('ClassName', array(
123
+            'ErrorPage',
124
+            'RedirectorPage',
125
+            'VirtualPage'
126
+        ));
127
+        $pageSelector = new CheckboxSetField(
128
+            $name = "Pages",
129
+            $title = "Show on Page(s)",
130
+            $availablePages->map('ID','Title')
131
+        );
132
+		
133
+		
134
+        if ($this->canConfigPageAndType(Member::currentUser())) {
135
+            $fields->addFieldsToTab('Root.VisibilitySettings', array(
136
+                $filterSelector,
137
+                $pageSelector,
138
+                $inClass
139
+            ));
140
+        }
141
+		
142
+        if ($this->canConfigMemberVisibility(Member::currentUser())) {
143
+            $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
144
+        }
145 145
 
146
-		if (!$fields->fieldByName('Options')) {
147
-				$fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
148
-		}
146
+        if (!$fields->fieldByName('Options')) {
147
+                $fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
148
+        }
149 149
 
150
-		$fields->addFieldsToTab('Options', array(
151
-			TextField::create('WrapperClasses', 'Additional block wrapper Class'),
152
-			TextField::create('HeadingClasses', 'Additional block title Class'),
153
-			CheckboxField::create('addMarginTop','Add Margin to top'),
154
-			CheckboxField::create('addMarginBottom','Add Margin to bottom'),
155
-			CheckboxField::create('addPaddingTop','Add Padding to top'),
156
-			CheckboxField::create('addPaddingBottom','Add Padding to bottom'),
157
-			CheckboxField::create('SectionWrapper', 'Use &lt;section /&gt; as block wrapper')
158
-		));
150
+        $fields->addFieldsToTab('Options', array(
151
+            TextField::create('WrapperClasses', 'Additional block wrapper Class'),
152
+            TextField::create('HeadingClasses', 'Additional block title Class'),
153
+            CheckboxField::create('addMarginTop','Add Margin to top'),
154
+            CheckboxField::create('addMarginBottom','Add Margin to bottom'),
155
+            CheckboxField::create('addPaddingTop','Add Padding to top'),
156
+            CheckboxField::create('addPaddingBottom','Add Padding to bottom'),
157
+            CheckboxField::create('SectionWrapper', 'Use &lt;section /&gt; as block wrapper')
158
+        ));
159 159
 
160
-		return $fields;
161
-	}
160
+        return $fields;
161
+    }
162 162
 	
163
-	private function availableClasses() {
164
-		$Classes = array_diff(
165
-			ClassInfo::subclassesFor('Page'),
166
-			ClassInfo::subclassesFor('RedirectorPage'),
167
-			ClassInfo::subclassesFor('VirtualPage')
168
-		);
169
-		return $Classes;
170
-	}
163
+    private function availableClasses() {
164
+        $Classes = array_diff(
165
+            ClassInfo::subclassesFor('Page'),
166
+            ClassInfo::subclassesFor('RedirectorPage'),
167
+            ClassInfo::subclassesFor('VirtualPage')
168
+        );
169
+        return $Classes;
170
+    }
171 171
 	
172
-	public function forTemplate() {
173
-		if ($this->canDisplayMemberCheck()) {
174
-			return $this->renderWith(array($this->getClassName(), 'BaseBlock'));
175
-		}
172
+    public function forTemplate() {
173
+        if ($this->canDisplayMemberCheck()) {
174
+            return $this->renderWith(array($this->getClassName(), 'BaseBlock'));
175
+        }
176 176
 		
177
-		return false;
178
-	}
177
+        return false;
178
+    }
179 179
 	
180
-	private function canDisplayMemberCheck() {
181
-		$rawVisibility = $this->MemberVisibility;
182
-		
183
-		if (empty($rawVisibility)) {
184
-			return true;
185
-		}
186
-		
187
-		$visibility = explode(',', $rawVisibility);
188
-		$member = Member::currentUser();
189
-		
190
-		if (!$member && in_array('anonymous', $visibility)) {
191
-			return true;
192
-		}
193
-		
194
-		if ($member) {
195
-			$memberGroups = $member->Groups()->column('Code');
196
-			foreach ($memberGroups as $memberGroup) {
197
-				if (in_array($memberGroup, $visibility)) {
198
-					return true;
199
-				}
200
-			}
201
-		}
202
-		
203
-		return false;
204
-	}
180
+    private function canDisplayMemberCheck() {
181
+        $rawVisibility = $this->MemberVisibility;
182
+		
183
+        if (empty($rawVisibility)) {
184
+            return true;
185
+        }
186
+		
187
+        $visibility = explode(',', $rawVisibility);
188
+        $member = Member::currentUser();
189
+		
190
+        if (!$member && in_array('anonymous', $visibility)) {
191
+            return true;
192
+        }
193
+		
194
+        if ($member) {
195
+            $memberGroups = $member->Groups()->column('Code');
196
+            foreach ($memberGroups as $memberGroup) {
197
+                if (in_array($memberGroup, $visibility)) {
198
+                    return true;
199
+                }
200
+            }
201
+        }
202
+		
203
+        return false;
204
+    }
205 205
 	
206
-	public function frontendEditable() {
207
-		$member = Member::currentUser();		
208
-		return $this->canEdit($member);
209
-	}
206
+    public function frontendEditable() {
207
+        $member = Member::currentUser();		
208
+        return $this->canEdit($member);
209
+    }
210 210
 	
211
-	public function Type2Class() {
212
-		return strtolower(str_replace(' ', '-', $this->singular_name()));
213
-	}
211
+    public function Type2Class() {
212
+        return strtolower(str_replace(' ', '-', $this->singular_name()));
213
+    }
214 214
 }
215 215
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class Block extends DataObject {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'SortOrder'			=>	'Int',
6 6
 		'Title'				=>	'Varchar(64)',
7 7
 		'TitleWrapper'		=>	'Enum("h2,h3,h4,h5,h6")',
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		'SectionWrapper'	=>	'Boolean'
20 20
 	);
21 21
 	
22
-	protected static $many_many = array (
22
+	protected static $many_many = array(
23 23
 		'Pages'				=>	'Page'
24 24
 	);
25 25
 		
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		'MySQLDatabase'		=> 'ENGINE=MyISAM'
28 28
     );
29 29
 	
30
-	protected static $extensions = array (
30
+	protected static $extensions = array(
31 31
 		'StandardPermissions'
32 32
 	);
33 33
 	
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 	
48 48
 	public function VisibleTo() {
49 49
 		if (strlen(trim($this->MemberVisibility)) > 0) {
50
-			$lists = 'Group: ' . str_replace(',','<br />Group: ', $this->MemberVisibility);
51
-		}else{
50
+			$lists = 'Group: '.str_replace(',', '<br />Group: ', $this->MemberVisibility);
51
+		} else {
52 52
 			$lists = '<em>&lt;All&gt;</em>';
53 53
 		}
54 54
 		
55
-		return new LiteralField('VisibleTo',$lists);
55
+		return new LiteralField('VisibleTo', $lists);
56 56
 	}
57 57
 	
58 58
 	public function BlockType() {
@@ -62,18 +62,18 @@  discard block
 block discarded – undo
62 62
 	public function shownOn() {
63 63
 		if ($this->showBlockbyClass) {
64 64
 			if (strlen(trim($this->shownInClass)) > 0) {
65
-				$lists = 'Type: ' . str_replace(',','<br />Type: ', $this->shownInClass);
66
-			}else{
65
+				$lists = 'Type: '.str_replace(',', '<br />Type: ', $this->shownInClass);
66
+			} else {
67 67
 				$lists = '<em>&lt;not assigned&gt;</em>';
68 68
 			}
69
-		}else{
69
+		} else {
70 70
 			if ($this->Pages()->count() > 0) {
71
-				$lists = 'Page: ' . implode('<br />Page: ', $this->Pages()->column('Title'));
72
-			}else{
71
+				$lists = 'Page: '.implode('<br />Page: ', $this->Pages()->column('Title'));
72
+			} else {
73 73
 				$lists = '<em>&lt;not assigned&gt;</em>';
74 74
 			}
75 75
 		}
76
-		return new LiteralField('shownOn',$lists);
76
+		return new LiteralField('shownOn', $lists);
77 77
 	}
78 78
 	
79 79
 	public function getCMSFields() {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		$pageSelector = new CheckboxSetField(
128 128
 			$name = "Pages",
129 129
 			$title = "Show on Page(s)",
130
-			$availablePages->map('ID','Title')
130
+			$availablePages->map('ID', 'Title')
131 131
 		);
132 132
 		
133 133
 		
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 		$fields->addFieldsToTab('Options', array(
151 151
 			TextField::create('WrapperClasses', 'Additional block wrapper Class'),
152 152
 			TextField::create('HeadingClasses', 'Additional block title Class'),
153
-			CheckboxField::create('addMarginTop','Add Margin to top'),
154
-			CheckboxField::create('addMarginBottom','Add Margin to bottom'),
155
-			CheckboxField::create('addPaddingTop','Add Padding to top'),
156
-			CheckboxField::create('addPaddingBottom','Add Padding to bottom'),
153
+			CheckboxField::create('addMarginTop', 'Add Margin to top'),
154
+			CheckboxField::create('addMarginBottom', 'Add Margin to bottom'),
155
+			CheckboxField::create('addPaddingTop', 'Add Padding to top'),
156
+			CheckboxField::create('addPaddingBottom', 'Add Padding to bottom'),
157 157
 			CheckboxField::create('SectionWrapper', 'Use &lt;section /&gt; as block wrapper')
158 158
 		));
159 159
 
Please login to merge, or discard this patch.