Completed
Push — master ( 2ad7fe...4fb981 )
by Leo
03:07
created
code/ExtendedBlocks/TriColumnBlock.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class TriColumnBlock extends Block {
4
-	protected static $db = array (
5
-		'LeftColumn'		=>	'HTMLText',
6
-		'MiddleColumn'	=>	'HTMLText',
7
-		'RightColumn'	=>	'HTMLText'
8
-	);
4
+    protected static $db = array (
5
+        'LeftColumn'		=>	'HTMLText',
6
+        'MiddleColumn'	=>	'HTMLText',
7
+        'RightColumn'	=>	'HTMLText'
8
+    );
9 9
 }
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DualColumnBlock extends Block {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'LeftColumn'		=>	'HTMLText',
6 6
 		'RightColumn'	=>	'HTMLText'
7 7
 	);
Please login to merge, or discard this patch.
code/ExtendedBlocks/DualColumnBlock.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DualColumnBlock extends Block {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'LeftColumn'		=>	'HTMLText',
6 6
 		'RightColumn'	=>	'HTMLText'
7 7
 	);
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DualColumnBlock extends Block {
4
-	protected static $singular_name = 'Dual-column Block';
5
-	protected static $db = array (
6
-		'LeftColumn'		=>	'HTMLText',
7
-		'RightColumn'	=>	'HTMLText'
8
-	);
4
+    protected static $singular_name = 'Dual-column Block';
5
+    protected static $db = array (
6
+        'LeftColumn'		=>	'HTMLText',
7
+        'RightColumn'	=>	'HTMLText'
8
+    );
9 9
 }
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
code/ExtendedBlocks/SingleColumnBlock.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class SingleColumnBlock extends Block {
4
-	protected static $db = array (
5
-		'Content'	=>	'HTMLText'
6
-	);
4
+    protected static $db = array (
5
+        'Content'	=>	'HTMLText'
6
+    );
7 7
 }
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class SingleColumnBlock extends Block {
4
-	protected static $db = array (
4
+	protected static $db = array(
5 5
 		'Content'	=>	'HTMLText'
6 6
 	);
7 7
 }
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
code/BlocksAdmin.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 			$subBlocks = ClassInfo::subclassesFor('Block');
31 31
 			if (is_null($subBlocks)) {
32 32
 				$subBlocks = array('Block');
33
-			}else{
33
+			} else {
34 34
 				unset($subBlocks['Block']);
35 35
 			}
36 36
 			
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 			$subBlocks = ClassInfo::subclassesFor('Block');
36 36
 			if (is_null($subBlocks)) {
37 37
 				$subBlocks = array('Block');
38
-			}else{
38
+			} else{
39 39
 				unset($subBlocks['Block']);
40 40
 			}
41 41
 			$multiClass->setClasses($subBlocks);
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -4,38 +4,38 @@
 block discarded – undo
4 4
  *
5 5
  * Left-hand-side tab : Admin Blocks
6 6
  * */
7
-	class BlocksAdmin extends ModelAdmin {
8
-		private static $managed_models = array('Block');
9
-		private static $url_segment = 'blocks';
10
-		private static $menu_title = 'Blocks';
11
-		private static $menu_priority = 10;
12
-		private static $menu_icon = 'silverstripe-block/images/icon-block.png';
7
+    class BlocksAdmin extends ModelAdmin {
8
+        private static $managed_models = array('Block');
9
+        private static $url_segment = 'blocks';
10
+        private static $menu_title = 'Blocks';
11
+        private static $menu_priority = 10;
12
+        private static $menu_icon = 'silverstripe-block/images/icon-block.png';
13 13
 			
14
-		public function getEditForm($id = null, $fields = null) {
15
-			$form = parent::getEditForm($id, $fields);
14
+        public function getEditForm($id = null, $fields = null) {
15
+            $form = parent::getEditForm($id, $fields);
16 16
 			
17
-			$grid = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
17
+            $grid = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
18 18
 			
19
-			$grid->getConfig()
20
-				->removeComponentsByType('GridFieldPaginator')
21
-				->removeComponentsByType('GridFieldAddNewButton')
22
-				->removeComponentsByType('GridFieldPrintButton')
23
-				->removeComponentsByType('GridFieldExportButton')
24
-				->addComponents(
25
-					new GridFieldPaginatorWithShowAll(30),
26
-					$multiClass = new MultiClassSelector(),
27
-					$sortable = new GridFieldOrderableRows('SortOrder')
28
-				);
19
+            $grid->getConfig()
20
+                ->removeComponentsByType('GridFieldPaginator')
21
+                ->removeComponentsByType('GridFieldAddNewButton')
22
+                ->removeComponentsByType('GridFieldPrintButton')
23
+                ->removeComponentsByType('GridFieldExportButton')
24
+                ->addComponents(
25
+                    new GridFieldPaginatorWithShowAll(30),
26
+                    $multiClass = new MultiClassSelector(),
27
+                    $sortable = new GridFieldOrderableRows('SortOrder')
28
+                );
29 29
 			
30
-			$subBlocks = ClassInfo::subclassesFor('Block');
31
-			if (is_null($subBlocks)) {
32
-				$subBlocks = array('Block');
33
-			}else{
34
-				unset($subBlocks['Block']);
35
-			}
30
+            $subBlocks = ClassInfo::subclassesFor('Block');
31
+            if (is_null($subBlocks)) {
32
+                $subBlocks = array('Block');
33
+            }else{
34
+                unset($subBlocks['Block']);
35
+            }
36 36
 			
37
-			$multiClass->setClasses($subBlocks);
38
-			$grid->setTitle('All Blcoks');
39
-			return $form;
40
-		}
41
-	}
42 37
\ No newline at end of file
38
+            $multiClass->setClasses($subBlocks);
39
+            $grid->setTitle('All Blcoks');
40
+            return $form;
41
+        }
42
+    }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
code/Extensions/BlockinPage.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class BlockinPage extends Extension {
3
-	protected static $belongs_many_many = array (
3
+	protected static $belongs_many_many = array(
4 4
 		'Blocks'			=>	'Block'
5 5
 	);
6 6
 	
7
-	public function updateCMSFields( FieldList $fields ) {
7
+	public function updateCMSFields(FieldList $fields) {
8 8
 		$ancestry = ClassInfo::ancestry($this->owner->ClassName);
9 9
 		if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
10 10
 			$blocks = $this->owner->Blocks();
11
-			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
11
+			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true, 'GridFieldConfig_RelationEditor');
12 12
 			$docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
13 13
 			
14 14
 			$fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		$grid = new GridField($name, $label, $source);
28 28
 		$config = $gridHeaderType::create();
29 29
 		$config->removeComponentsByType('GridFieldAddNewButton');
30
-		if ( $canAdd ) {
30
+		if ($canAdd) {
31 31
 			$config->addComponents(
32 32
 				$multiClass = new GridFieldAddNewMultiClass(),
33 33
 				$sortable = new GridFieldOrderableRows('SortOrder')
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 			$subBlocks = ClassInfo::subclassesFor('Block');
36 36
 			if (is_null($subBlocks)) {
37 37
 				$subBlocks = array('Block');
38
-			}else{
38
+			} else {
39 39
 				unset($subBlocks['Block']);
40 40
 			}
41 41
 			$multiClass->setClasses($subBlocks);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 				$IDs[] = $BlockID;
56 56
 			}
57 57
 		}
58
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
58
+		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder', 'ASC');
59 59
 		return $blocks;
60 60
 	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 			$subBlocks = ClassInfo::subclassesFor('Block');
36 36
 			if (is_null($subBlocks)) {
37 37
 				$subBlocks = array('Block');
38
-			}else{
38
+			} else{
39 39
 				unset($subBlocks['Block']);
40 40
 			}
41 41
 			$multiClass->setClasses($subBlocks);
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,65 +1,65 @@
 block discarded – undo
1 1
 <?php
2 2
 class BlockinPage extends Extension {
3
-	protected static $belongs_many_many = array (
4
-		'Blocks'			=>	'Block'
5
-	);
3
+    protected static $belongs_many_many = array (
4
+        'Blocks'			=>	'Block'
5
+    );
6 6
 	
7
-	public function updateCMSFields( FieldList $fields ) {
8
-		$ancestry = ClassInfo::ancestry($this->owner->ClassName);
9
-		if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
10
-			$blocks = $this->owner->Blocks();
11
-			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
12
-			$docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
7
+    public function updateCMSFields( FieldList $fields ) {
8
+        $ancestry = ClassInfo::ancestry($this->owner->ClassName);
9
+        if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
10
+            $blocks = $this->owner->Blocks();
11
+            $blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
12
+            $docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
13 13
 			
14
-			$fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
15
-			$fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
16
-		}
17
-	}
14
+            $fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
15
+            $fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
16
+        }
17
+    }
18 18
 	
19
-	private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
20
-		/*
19
+    private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
20
+        /*
21 21
 		GridFieldConfig_Base
22 22
 		GridFieldConfig_RecordViewer
23 23
 		GridFieldConfig_RecordEditor
24 24
 		GridFieldConfig_RelationEditor
25 25
 		*/
26
-		if ($label == '') { $label = $name; }
27
-		$grid = new GridField($name, $label, $source);
28
-		$config = $gridHeaderType::create();
29
-		$config->removeComponentsByType('GridFieldAddNewButton');
30
-		if ( $canAdd ) {
31
-			$config->addComponents(
32
-				$multiClass = new MultiClassSelector(),
33
-				$sortable = new GridFieldOrderableRows('SortOrder')
34
-			);
35
-			$subBlocks = ClassInfo::subclassesFor('Block');
36
-			if (is_null($subBlocks)) {
37
-				$subBlocks = array('Block');
38
-			}else{
39
-				unset($subBlocks['Block']);
26
+        if ($label == '') { $label = $name; }
27
+        $grid = new GridField($name, $label, $source);
28
+        $config = $gridHeaderType::create();
29
+        $config->removeComponentsByType('GridFieldAddNewButton');
30
+        if ( $canAdd ) {
31
+            $config->addComponents(
32
+                $multiClass = new MultiClassSelector(),
33
+                $sortable = new GridFieldOrderableRows('SortOrder')
34
+            );
35
+            $subBlocks = ClassInfo::subclassesFor('Block');
36
+            if (is_null($subBlocks)) {
37
+                $subBlocks = array('Block');
38
+            }else{
39
+                unset($subBlocks['Block']);
40 40
 				
41
-				foreach ($subBlocks as $key => &$value) {
42
-					$value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name;
43
-				}
44
-			}
45
-			$multiClass->setClasses($subBlocks);
46
-		}
47
-		$grid->setConfig($config);
48
-		return $grid;
49
-	}
41
+                foreach ($subBlocks as $key => &$value) {
42
+                    $value = empty($key::$singular_name) ? ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $value)))) : $key::$singular_name;
43
+                }
44
+            }
45
+            $multiClass->setClasses($subBlocks);
46
+        }
47
+        $grid->setConfig($config);
48
+        return $grid;
49
+    }
50 50
 		
51
-	private function dockedBlocks() {
52
-		$blocks = Block::get();
53
-		$IDs = array();
54
-		$ClassName = $this->owner->ClassName;
55
-		$Classes = $blocks->map('ID', 'shownInClass');
56
-		foreach ($Classes as $BlockID => $Class) {
57
-			$listedClasses = explode(',', $Class);
58
-			if (in_array($ClassName, $listedClasses)) {
59
-				$IDs[] = $BlockID;
60
-			}
61
-		}
62
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
63
-		return $blocks;
64
-	}
51
+    private function dockedBlocks() {
52
+        $blocks = Block::get();
53
+        $IDs = array();
54
+        $ClassName = $this->owner->ClassName;
55
+        $Classes = $blocks->map('ID', 'shownInClass');
56
+        foreach ($Classes as $BlockID => $Class) {
57
+            $listedClasses = explode(',', $Class);
58
+            if (in_array($ClassName, $listedClasses)) {
59
+                $IDs[] = $BlockID;
60
+            }
61
+        }
62
+        $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
63
+        return $blocks;
64
+    }
65 65
 }
66 66
\ No newline at end of file
Please login to merge, or discard this patch.
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.
code/Extensions/CustomBlockPermissions.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,37 +1,37 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3 3
 class CustomBlockPermission extends DataExtension implements PermissionProvider {
4
-	public function canConfigPageAndType($member = false) {
5
-		return Permission::check(get_class($this->owner) . '_config_page_and_type');
6
-	}
4
+    public function canConfigPageAndType($member = false) {
5
+        return Permission::check(get_class($this->owner) . '_config_page_and_type');
6
+    }
7 7
 	
8
-	public function canConfigMemberVisibility($member = false) {
9
-		return Permission::check(get_class($this->owner) . '_config_member_visibility');
10
-	}
8
+    public function canConfigMemberVisibility($member = false) {
9
+        return Permission::check(get_class($this->owner) . '_config_member_visibility');
10
+    }
11 11
 	
12
-	public function providePermissions() {
13
-		$permissions = array();
14
-		foreach ($this->getClassList() as $class) {
15
-			foreach (array(
16
-				'config_page_and_type',
17
-				'config_member_visibility'
18
-			) as $name) {
19
-				$permissions[$class . '_' . $name] = $class . '_' . $name;
20
-			}
21
-		}
22
-		return $permissions;
23
-	}
12
+    public function providePermissions() {
13
+        $permissions = array();
14
+        foreach ($this->getClassList() as $class) {
15
+            foreach (array(
16
+                'config_page_and_type',
17
+                'config_member_visibility'
18
+            ) as $name) {
19
+                $permissions[$class . '_' . $name] = $class . '_' . $name;
20
+            }
21
+        }
22
+        return $permissions;
23
+    }
24 24
 	
25
-	private function getClassList() {
26
-		$classes = array();
27
-		foreach (ClassInfo::subclassesFor('DataObject') as $class => $file) {
28
-			$extensions = Config::inst()->get($class, 'extensions');
29
-			if (!is_null($extensions)) {
30
-				if (in_array(get_class($this), $extensions)) {
31
-					$classes[] = $class;
32
-				}
33
-			}
34
-		}
35
-		return $classes;
36
-	}
25
+    private function getClassList() {
26
+        $classes = array();
27
+        foreach (ClassInfo::subclassesFor('DataObject') as $class => $file) {
28
+            $extensions = Config::inst()->get($class, 'extensions');
29
+            if (!is_null($extensions)) {
30
+                if (in_array(get_class($this), $extensions)) {
31
+                    $classes[] = $class;
32
+                }
33
+            }
34
+        }
35
+        return $classes;
36
+    }
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 class CustomBlockPermission extends DataExtension implements PermissionProvider {
4 4
 	public function canConfigPageAndType($member = false) {
5
-		return Permission::check(get_class($this->owner) . '_config_page_and_type');
5
+		return Permission::check(get_class($this->owner).'_config_page_and_type');
6 6
 	}
7 7
 	
8 8
 	public function canConfigMemberVisibility($member = false) {
9
-		return Permission::check(get_class($this->owner) . '_config_member_visibility');
9
+		return Permission::check(get_class($this->owner).'_config_member_visibility');
10 10
 	}
11 11
 	
12 12
 	public function providePermissions() {
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 				'config_page_and_type',
17 17
 				'config_member_visibility'
18 18
 			) as $name) {
19
-				$permissions[$class . '_' . $name] = $class . '_' . $name;
19
+				$permissions[$class.'_'.$name] = $class.'_'.$name;
20 20
 			}
21 21
 		}
22 22
 		return $permissions;
Please login to merge, or discard this patch.
_config.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('BLOCK_DIR',basename(dirname(__FILE__)));
4
-LeftAndMain::require_javascript( BLOCK_DIR. '/js/silverstripe-block.script.js' );
3
+define('BLOCK_DIR', basename(dirname(__FILE__)));
4
+LeftAndMain::require_javascript(BLOCK_DIR.'/js/silverstripe-block.script.js');
5 5
 Requirements::css(BLOCK_DIR.'/css/blocks.css');
6 6
\ No newline at end of file
Please login to merge, or discard this patch.
code/MultiClassSelector.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class MultiClassSelector extends GridFieldAddNewMultiClass {
4
-	private static $allowed_actions = array(
5
-		'handleAdd'
6
-	);
4
+    private static $allowed_actions = array(
5
+        'handleAdd'
6
+    );
7 7
 
8
-	// Should we add an empty string to the add class dropdown?
9
-	private static $showEmptyString = true;
8
+    // Should we add an empty string to the add class dropdown?
9
+    private static $showEmptyString = true;
10 10
 
11
-	private $fragment;
11
+    private $fragment;
12 12
 
13
-	private $title;
13
+    private $title;
14 14
 
15
-	private $classes;
15
+    private $classes;
16 16
 
17
-	private $defaultClass;
17
+    private $defaultClass;
18 18
 
19 19
 
20
-	public function getHTMLFragments($grid) {
21
-		$classes = $this->getClasses($grid);
20
+    public function getHTMLFragments($grid) {
21
+        $classes = $this->getClasses($grid);
22 22
 
23
-		if(!count($classes)) {
24
-			return array();
25
-		}
23
+        if(!count($classes)) {
24
+            return array();
25
+        }
26 26
 
27
-		GridFieldExtensions::include_requirements();
27
+        GridFieldExtensions::include_requirements();
28 28
 
29
-		$field = new DropdownField(sprintf('%s[ClassName]', __CLASS__), '', $classes, $this->defaultClass);
30
-		$field->setAttribute('id', uniqid());
31
-		if (Config::inst()->get('GridFieldAddNewMultiClass', 'showEmptyString')) {
32
-			$field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
33
-		}
34
-		$field->addExtraClass('no-change-track');
29
+        $field = new DropdownField(sprintf('%s[ClassName]', __CLASS__), '', $classes, $this->defaultClass);
30
+        $field->setAttribute('id', uniqid());
31
+        if (Config::inst()->get('GridFieldAddNewMultiClass', 'showEmptyString')) {
32
+            $field->setEmptyString(_t('GridFieldExtensions.SELECTTYPETOCREATE', '(Select type to create)'));
33
+        }
34
+        $field->addExtraClass('no-change-track');
35 35
 
36
-		$data = new ArrayData(array(
37
-			'Title'      => $this->getTitle(),
38
-			'Link'       => Controller::join_links($grid->Link(), 'add-multi-class', '{class}'),
39
-			'ClassField' => $field
40
-		));
36
+        $data = new ArrayData(array(
37
+            'Title'      => $this->getTitle(),
38
+            'Link'       => Controller::join_links($grid->Link(), 'add-multi-class', '{class}'),
39
+            'ClassField' => $field
40
+        ));
41 41
 
42
-		return array(
43
-			$this->getFragment() => $data->renderWith('GridFieldAddNewMultiClass')
44
-		);
45
-	}
42
+        return array(
43
+            $this->getFragment() => $data->renderWith('GridFieldAddNewMultiClass')
44
+        );
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	public function getHTMLFragments($grid) {
21 21
 		$classes = $this->getClasses($grid);
22 22
 
23
-		if(!count($classes)) {
23
+		if (!count($classes)) {
24 24
 			return array();
25 25
 		}
26 26
 
Please login to merge, or discard this patch.