Completed
Push — master ( 720fed...5dcbd9 )
by Leo
02:39
created
code/Extensions/BlockinPage.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,62 +1,62 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class BlockinPage extends Extension {
4
-	protected static $belongs_many_many = array (
5
-		'Blocks'			=>	'Block'
6
-	);
4
+    protected static $belongs_many_many = array (
5
+        'Blocks'			=>	'Block'
6
+    );
7 7
 	
8
-	public function updateCMSFields( FieldList $fields ) {
9
-		$ancestry = ClassInfo::ancestry($this->owner->ClassName);
10
-		if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
11
-			$blocks = $this->owner->Blocks();
12
-			$blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
13
-			$docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
8
+    public function updateCMSFields( FieldList $fields ) {
9
+        $ancestry = ClassInfo::ancestry($this->owner->ClassName);
10
+        if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
11
+            $blocks = $this->owner->Blocks();
12
+            $blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true,'GridFieldConfig_RelationEditor');
13
+            $docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
14 14
 			
15
-			$fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
16
-			$fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
17
-		}
18
-	}
15
+            $fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
16
+            $fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
17
+        }
18
+    }
19 19
 	
20
-	private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
21
-		/*
20
+    private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
21
+        /*
22 22
 		GridFieldConfig_Base
23 23
 		GridFieldConfig_RecordViewer
24 24
 		GridFieldConfig_RecordEditor
25 25
 		GridFieldConfig_RelationEditor
26 26
 		*/
27
-		if ($label == '') { $label = $name; }
28
-		$grid = new GridField($name, $label, $source);
29
-		$config = $gridHeaderType::create();
30
-		$config->removeComponentsByType('GridFieldAddNewButton');
31
-		if ( $canAdd ) {
32
-			$config
33
-			->removeComponentsByType('GridFieldPaginator')
34
-			->removeComponentsByType('GridFieldDetailForm')
35
-			->addComponents(
36
-				new VersionedForm(),
37
-				new GridFieldPaginatorWithShowAll(30),
38
-				$multiClass = new MultiClassSelector(),
39
-				$sortable = new GridFieldOrderableRows('SortOrder')
40
-			);
41
-			$subBlocks = BlocksAdmin::getAvaiableTypes();
42
-			$multiClass->setClasses($subBlocks);
43
-		}
44
-		$grid->setConfig($config);
45
-		return $grid;
46
-	}
27
+        if ($label == '') { $label = $name; }
28
+        $grid = new GridField($name, $label, $source);
29
+        $config = $gridHeaderType::create();
30
+        $config->removeComponentsByType('GridFieldAddNewButton');
31
+        if ( $canAdd ) {
32
+            $config
33
+            ->removeComponentsByType('GridFieldPaginator')
34
+            ->removeComponentsByType('GridFieldDetailForm')
35
+            ->addComponents(
36
+                new VersionedForm(),
37
+                new GridFieldPaginatorWithShowAll(30),
38
+                $multiClass = new MultiClassSelector(),
39
+                $sortable = new GridFieldOrderableRows('SortOrder')
40
+            );
41
+            $subBlocks = BlocksAdmin::getAvaiableTypes();
42
+            $multiClass->setClasses($subBlocks);
43
+        }
44
+        $grid->setConfig($config);
45
+        return $grid;
46
+    }
47 47
 		
48
-	private function dockedBlocks() {
49
-		$blocks = Block::get();
50
-		$IDs = array();
51
-		$ClassName = $this->owner->ClassName;
52
-		$Classes = $blocks->map('ID', 'shownInClass');
53
-		foreach ($Classes as $BlockID => $Class) {
54
-			$listedClasses = explode(',', $Class);
55
-			if (in_array($ClassName, $listedClasses)) {
56
-				$IDs[] = $BlockID;
57
-			}
58
-		}
59
-		$blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
60
-		return $blocks;
61
-	}
48
+    private function dockedBlocks() {
49
+        $blocks = Block::get();
50
+        $IDs = array();
51
+        $ClassName = $this->owner->ClassName;
52
+        $Classes = $blocks->map('ID', 'shownInClass');
53
+        foreach ($Classes as $BlockID => $Class) {
54
+            $listedClasses = explode(',', $Class);
55
+            if (in_array($ClassName, $listedClasses)) {
56
+                $IDs[] = $BlockID;
57
+            }
58
+        }
59
+        $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder','ASC');
60
+        return $blocks;
61
+    }
62 62
 }
63 63
\ No newline at end of file
Please login to merge, or discard this patch.
code/Extensions/PrintBlocks.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,41 +1,41 @@
 block discarded – undo
1 1
 <?php
2 2
 class PrintBlocks extends Extension {
3 3
 	
4
-	public function getAllBlocks() {
5
-		$blocks = new ArrayList();
6
-		$blocks->merge($this->getMyBlocks());
7
-		$blocks->merge($this->getDockedBlocks());
8
-		return $blocks;
9
-	}
4
+    public function getAllBlocks() {
5
+        $blocks = new ArrayList();
6
+        $blocks->merge($this->getMyBlocks());
7
+        $blocks->merge($this->getDockedBlocks());
8
+        return $blocks;
9
+    }
10 10
 		
11
-	public function getMyBlocks() {
12
-		$blocks = $this->owner->Blocks()->sort(array('SortOrder' => 'ASC', 'ID' => 'DESC'));
13
-		$published_blocks = new ArrayList();
14
-		foreach ($blocks as $block) {
15
-			if ($block->isPublished()) {
16
-				$published_blocks->push($block);
17
-			}
18
-		}
11
+    public function getMyBlocks() {
12
+        $blocks = $this->owner->Blocks()->sort(array('SortOrder' => 'ASC', 'ID' => 'DESC'));
13
+        $published_blocks = new ArrayList();
14
+        foreach ($blocks as $block) {
15
+            if ($block->isPublished()) {
16
+                $published_blocks->push($block);
17
+            }
18
+        }
19 19
 		
20
-		return $published_blocks;
21
-	}
20
+        return $published_blocks;
21
+    }
22 22
 	
23
-	public function getDockedBlocks() {
24
-		$blocks = Block::get()->filter(array('showBlockbyClass' => true));
25
-		$blocks_map = $blocks->map('ID', 'shownInClass');
26
-		foreach ($blocks_map as $blockID => $Classes) {
27
-			$Classes = explode(',', $Classes);
28
-			if (!in_array($this->owner->ClassName, $Classes)) {
29
-				$blocks = $blocks->exclude('ID', $blockID);
30
-			}
31
-		}
32
-		$published_blocks = new ArrayList();
33
-		foreach ($blocks as $block) {
34
-			if ($block->isPublished()) {
35
-				$published_blocks->push($block);
36
-			}
37
-		}
23
+    public function getDockedBlocks() {
24
+        $blocks = Block::get()->filter(array('showBlockbyClass' => true));
25
+        $blocks_map = $blocks->map('ID', 'shownInClass');
26
+        foreach ($blocks_map as $blockID => $Classes) {
27
+            $Classes = explode(',', $Classes);
28
+            if (!in_array($this->owner->ClassName, $Classes)) {
29
+                $blocks = $blocks->exclude('ID', $blockID);
30
+            }
31
+        }
32
+        $published_blocks = new ArrayList();
33
+        foreach ($blocks as $block) {
34
+            if ($block->isPublished()) {
35
+                $published_blocks->push($block);
36
+            }
37
+        }
38 38
 		
39
-		return $published_blocks->sort('SortOrder', 'ASC');
40
-	}
39
+        return $published_blocks->sort('SortOrder', 'ASC');
40
+    }
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.