Completed
Push — master ( abeeee...712df8 )
by Leo
02:34
created
code/BlocksAdmin.php 1 patch
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
- * @file BlocksAdmin.php
4
- *
5
- * Left-hand-side tab : Admin Blocks
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';
3
+     * @file BlocksAdmin.php
4
+     *
5
+     * Left-hand-side tab : Admin Blocks
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';
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 GridFieldAddNewMultiClass(),
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 GridFieldAddNewMultiClass(),
27
+                    $sortable = new GridFieldOrderableRows('SortOrder')
28
+                );
29 29
 			
30
-			$subBlocks = ClassInfo::subclassesFor('Block') || array();
31
-			unset($subBlocks['Block']);
30
+            $subBlocks = ClassInfo::subclassesFor('Block') || array();
31
+            unset($subBlocks['Block']);
32 32
 			
33
-			$multiClass->setClasses($subBlocks);
34
-			$grid->setTitle('All Blcoks');
35
-			return $form;
36
-		}
37
-	}
38 33
\ No newline at end of file
34
+            $multiClass->setClasses($subBlocks);
35
+            $grid->setTitle('All Blcoks');
36
+            return $form;
37
+        }
38
+    }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
code/Extensions/BlockinPage.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,57 +1,57 @@
 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 GridFieldAddNewMultiClass(),
33
-				$sortable = new GridFieldOrderableRows('SortOrder')
34
-			);
35
-			$subBlocks = ClassInfo::subclassesFor('Block') || array();
36
-			unset($subBlocks['Block']);
37
-			$multiClass->setClasses($subBlocks);
38
-		}
39
-		$grid->setConfig($config);
40
-		return $grid;
41
-	}
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 GridFieldAddNewMultiClass(),
33
+                $sortable = new GridFieldOrderableRows('SortOrder')
34
+            );
35
+            $subBlocks = ClassInfo::subclassesFor('Block') || array();
36
+            unset($subBlocks['Block']);
37
+            $multiClass->setClasses($subBlocks);
38
+        }
39
+        $grid->setConfig($config);
40
+        return $grid;
41
+    }
42 42
 		
43
-	private function dockedBlocks() {
44
-		$blocks = Block::get();
45
-		$IDs = array();
46
-		$ClassName = $this->owner->ClassName;
47
-		$Classes = $blocks->map('ID', 'shownInClass');
48
-		foreach ($Classes as $BlockID => $Class) {
49
-			$listedClasses = explode(',', $Class);
50
-			if (in_array($ClassName, $listedClasses)) {
51
-				$IDs[] = $BlockID;
52
-			}
53
-		}
54
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
55
-		return $blocks;
56
-	}
43
+    private function dockedBlocks() {
44
+        $blocks = Block::get();
45
+        $IDs = array();
46
+        $ClassName = $this->owner->ClassName;
47
+        $Classes = $blocks->map('ID', 'shownInClass');
48
+        foreach ($Classes as $BlockID => $Class) {
49
+            $listedClasses = explode(',', $Class);
50
+            if (in_array($ClassName, $listedClasses)) {
51
+                $IDs[] = $BlockID;
52
+            }
53
+        }
54
+        $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
55
+        return $blocks;
56
+    }
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.