Completed
Push — master ( 627e2d...409536 )
by Michael
02:53
created
code/forms/gridfield/GridFieldSiteTreeAddNewButton.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
      * Provide actions to this component.
97 97
      *
98 98
      * @param GridField $gridField
99
-     * @return array
99
+     * @return string[]
100 100
     **/
101 101
     public function getActions($gridField)
102 102
     {
Please login to merge, or discard this patch.
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -11,133 +11,133 @@
 block discarded – undo
11 11
  * @author Michael Strong <[email protected]>
12 12
  */
13 13
 class GridFieldSiteTreeAddNewButton extends GridFieldAddNewButton
14
-    implements GridField_ActionProvider
14
+	implements GridField_ActionProvider
15 15
 {
16 16
 
17
-    /**
18
-     * Determine the list of classnames and titles allowed for a given parent object
19
-     *
20
-     * @param SiteTree $parent
21
-     * @return boolean
22
-     */
23
-    public function getAllowedChildren(SiteTree $parent = null)
24
-    {
25
-        if (!$parent || !$parent->canAddChildren()) {
26
-            return array();
27
-        }
28
-
29
-        $nonHiddenPageTypes = SiteTree::page_type_classes();
30
-        $allowedChildren = $parent->allowedChildren();
31
-        $children = array();
32
-        foreach ($allowedChildren as $class) {
33
-            if (Config::inst()->get($class, "show_in_sitetree") === false) {
34
-                $instance = Injector::inst()->get($class);
35
-                // Note: Second argument to SiteTree::canCreate will support inherited permissions
36
-                // post 3.1.12, and will default to the old permission model in 3.1.11 or below
37
-                // See http://docs.silverstripe.org/en/changelogs/3.1.11
38
-                if ($instance->canCreate(null, array('Parent' => $parent)) && in_array($class, $nonHiddenPageTypes)) {
39
-                    $children[$class] = $instance->i18n_singular_name();
40
-                }
41
-            }
42
-        }
43
-        return $children;
44
-    }
45
-
46
-    public function getHTMLFragments($gridField)
47
-    {
48
-        $state = $gridField->State->GridFieldSiteTreeAddNewButton;
49
-
50
-        $parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
51
-
52
-        if ($parent) {
53
-            $state->currentPageID = $parent->ID;
54
-        }
55
-
56
-        $children = $this->getAllowedChildren($parent);
57
-        if (empty($children)) {
58
-            return array();
59
-        } elseif (count($children) > 1) {
60
-            $pageTypes = DropdownField::create("PageType", "Page Type", $children, $parent->defaultChild());
61
-            $pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
62
-
63
-            $state->pageType = $parent->defaultChild();
64
-
65
-            if (!$this->buttonName) {
66
-                $this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
67
-            }
68
-        } else {
69
-            $keys = array_keys($children);
70
-            $pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
71
-
72
-            $state->pageType = $keys[0];
73
-
74
-            if (!$this->buttonName) {
75
-                $this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
76
-            }
77
-        }
78
-
79
-        $addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
80
-        $addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
81
-
82
-        $forTemplate = new ArrayData(array());
83
-        $forTemplate->Fields = new ArrayList();
84
-        $forTemplate->Fields->push($pageTypes);
85
-        $forTemplate->Fields->push($addAction);
86
-
87
-        Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
88
-        Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
89
-
90
-        return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     * Provide actions to this component.
97
-     *
98
-     * @param GridField $gridField
99
-     * @return array
100
-    **/
101
-    public function getActions($gridField)
102
-    {
103
-        return array("add");
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * Handles the add action, but only acts as a wrapper for {@link CMSPageAddController::doAdd()}
110
-     *
111
-     * @param GridField $gridField
112
-     * @param string $actionName
113
-     * @param mixed $arguments
114
-     * @param array $data
115
-    **/
116
-    public function handleAction(GridField $gridField, $actionName, $arguments, $data)
117
-    {
118
-        if ($actionName == "add") {
119
-            $tmpData = json_decode($data['ChildPages']['GridState'], true);
120
-            $tmpData = $tmpData['GridFieldSiteTreeAddNewButton'];
121
-
122
-            $data = array(
123
-                "ParentID" => $tmpData['currentPageID'],
124
-                "PageType" => $tmpData['pageType']
125
-            );
126
-
127
-            $controller = Injector::inst()->create("CMSPageAddController");
128
-
129
-            $form = $controller->AddForm();
130
-            $form->loadDataFrom($data);
131
-
132
-            $controller->doAdd($data, $form);
133
-            $response = $controller->getResponseNegotiator()->getResponse();
134
-
135
-            // Get the current record
136
-            $record = SiteTree::get()->byId($controller->currentPageID());
137
-            if ($record) {
138
-                $response->redirect(Director::absoluteBaseURL() . $record->CMSEditLink(), 301);
139
-            }
140
-            return $response;
141
-        }
142
-    }
17
+	/**
18
+	 * Determine the list of classnames and titles allowed for a given parent object
19
+	 *
20
+	 * @param SiteTree $parent
21
+	 * @return boolean
22
+	 */
23
+	public function getAllowedChildren(SiteTree $parent = null)
24
+	{
25
+		if (!$parent || !$parent->canAddChildren()) {
26
+			return array();
27
+		}
28
+
29
+		$nonHiddenPageTypes = SiteTree::page_type_classes();
30
+		$allowedChildren = $parent->allowedChildren();
31
+		$children = array();
32
+		foreach ($allowedChildren as $class) {
33
+			if (Config::inst()->get($class, "show_in_sitetree") === false) {
34
+				$instance = Injector::inst()->get($class);
35
+				// Note: Second argument to SiteTree::canCreate will support inherited permissions
36
+				// post 3.1.12, and will default to the old permission model in 3.1.11 or below
37
+				// See http://docs.silverstripe.org/en/changelogs/3.1.11
38
+				if ($instance->canCreate(null, array('Parent' => $parent)) && in_array($class, $nonHiddenPageTypes)) {
39
+					$children[$class] = $instance->i18n_singular_name();
40
+				}
41
+			}
42
+		}
43
+		return $children;
44
+	}
45
+
46
+	public function getHTMLFragments($gridField)
47
+	{
48
+		$state = $gridField->State->GridFieldSiteTreeAddNewButton;
49
+
50
+		$parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
51
+
52
+		if ($parent) {
53
+			$state->currentPageID = $parent->ID;
54
+		}
55
+
56
+		$children = $this->getAllowedChildren($parent);
57
+		if (empty($children)) {
58
+			return array();
59
+		} elseif (count($children) > 1) {
60
+			$pageTypes = DropdownField::create("PageType", "Page Type", $children, $parent->defaultChild());
61
+			$pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
62
+
63
+			$state->pageType = $parent->defaultChild();
64
+
65
+			if (!$this->buttonName) {
66
+				$this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
67
+			}
68
+		} else {
69
+			$keys = array_keys($children);
70
+			$pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
71
+
72
+			$state->pageType = $keys[0];
73
+
74
+			if (!$this->buttonName) {
75
+				$this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
76
+			}
77
+		}
78
+
79
+		$addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
80
+		$addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
81
+
82
+		$forTemplate = new ArrayData(array());
83
+		$forTemplate->Fields = new ArrayList();
84
+		$forTemplate->Fields->push($pageTypes);
85
+		$forTemplate->Fields->push($addAction);
86
+
87
+		Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
88
+		Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
89
+
90
+		return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 * Provide actions to this component.
97
+	 *
98
+	 * @param GridField $gridField
99
+	 * @return array
100
+	 **/
101
+	public function getActions($gridField)
102
+	{
103
+		return array("add");
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * Handles the add action, but only acts as a wrapper for {@link CMSPageAddController::doAdd()}
110
+	 *
111
+	 * @param GridField $gridField
112
+	 * @param string $actionName
113
+	 * @param mixed $arguments
114
+	 * @param array $data
115
+	 **/
116
+	public function handleAction(GridField $gridField, $actionName, $arguments, $data)
117
+	{
118
+		if ($actionName == "add") {
119
+			$tmpData = json_decode($data['ChildPages']['GridState'], true);
120
+			$tmpData = $tmpData['GridFieldSiteTreeAddNewButton'];
121
+
122
+			$data = array(
123
+				"ParentID" => $tmpData['currentPageID'],
124
+				"PageType" => $tmpData['pageType']
125
+			);
126
+
127
+			$controller = Injector::inst()->create("CMSPageAddController");
128
+
129
+			$form = $controller->AddForm();
130
+			$form->loadDataFrom($data);
131
+
132
+			$controller->doAdd($data, $form);
133
+			$response = $controller->getResponseNegotiator()->getResponse();
134
+
135
+			// Get the current record
136
+			$record = SiteTree::get()->byId($controller->currentPageID());
137
+			if ($record) {
138
+				$response->redirect(Director::absoluteBaseURL() . $record->CMSEditLink(), 301);
139
+			}
140
+			return $response;
141
+		}
142
+	}
143 143
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
         $forTemplate->Fields->push($pageTypes);
85 85
         $forTemplate->Fields->push($addAction);
86 86
 
87
-        Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
88
-        Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
87
+        Requirements::css(LUMBERJACK_DIR."/css/lumberjack.css");
88
+        Requirements::javascript(LUMBERJACK_DIR."/javascript/GridField.js");
89 89
 
90 90
         return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
91 91
     }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             // Get the current record
136 136
             $record = SiteTree::get()->byId($controller->currentPageID());
137 137
             if ($record) {
138
-                $response->redirect(Director::absoluteBaseURL() . $record->CMSEditLink(), 301);
138
+                $response->redirect(Director::absoluteBaseURL().$record->CMSEditLink(), 301);
139 139
             }
140 140
             return $response;
141 141
         }
Please login to merge, or discard this patch.
tests/LumberjackTest.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -3,65 +3,65 @@
 block discarded – undo
3 3
 class LumberjackTest extends SapphireTest
4 4
 {
5 5
 
6
-    protected static $fixture_file = 'fixtures.yml';
6
+	protected static $fixture_file = 'fixtures.yml';
7 7
 
8
-    protected $extraDataObjects = array(
9
-        'SiteTree_Lumberjack',
10
-        'SiteTree_LumberjackHidden',
11
-        'SiteTree_LumberjackShown',
12
-    );
8
+	protected $extraDataObjects = array(
9
+		'SiteTree_Lumberjack',
10
+		'SiteTree_LumberjackHidden',
11
+		'SiteTree_LumberjackShown',
12
+	);
13 13
 
14
-    public function testGetExcludedSiteTreeClassNames()
15
-    {
16
-        $standard = $this->objFromFixture('SiteTree_Lumberjack', 'standard');
14
+	public function testGetExcludedSiteTreeClassNames()
15
+	{
16
+		$standard = $this->objFromFixture('SiteTree_Lumberjack', 'standard');
17 17
 
18
-        $excluded = $standard->getExcludedSiteTreeClassNames();
19
-        $excluded = $this->filteredClassNames($excluded, $this->extraDataObjects);
20
-        $this->assertEquals($excluded, array('SiteTree_LumberjackHidden' => 'SiteTree_LumberjackHidden'));
18
+		$excluded = $standard->getExcludedSiteTreeClassNames();
19
+		$excluded = $this->filteredClassNames($excluded, $this->extraDataObjects);
20
+		$this->assertEquals($excluded, array('SiteTree_LumberjackHidden' => 'SiteTree_LumberjackHidden'));
21 21
 
22
-        Config::inst()->update('SiteTree', 'show_in_sitetree', false);
23
-        $excluded = $standard->getExcludedSiteTreeClassNames();
24
-        $excluded = $this->filteredClassNames($excluded, $this->extraDataObjects);
25
-        $this->assertEquals($excluded, array(
26
-            'SiteTree_Lumberjack' => 'SiteTree_Lumberjack',
27
-            'SiteTree_LumberjackHidden' => 'SiteTree_LumberjackHidden'
28
-        ));
29
-    }
22
+		Config::inst()->update('SiteTree', 'show_in_sitetree', false);
23
+		$excluded = $standard->getExcludedSiteTreeClassNames();
24
+		$excluded = $this->filteredClassNames($excluded, $this->extraDataObjects);
25
+		$this->assertEquals($excluded, array(
26
+			'SiteTree_Lumberjack' => 'SiteTree_Lumberjack',
27
+			'SiteTree_LumberjackHidden' => 'SiteTree_LumberjackHidden'
28
+		));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Because we don't know what other test classes are included, we filter to the ones we know
34
-     * and want to test.
35
-     *
36
-     * @param array $classNames
37
-     *
38
-     * @return array
39
-     */
40
-    protected function filteredClassNames($classNames, $explicitClassNames)
41
-    {
42
-        $classNames = array_filter($classNames, function ($value) use ($explicitClassNames) {
43
-            return in_array($value, $explicitClassNames);
44
-        });
45
-        return $classNames;
46
-    }
32
+	/**
33
+	 * Because we don't know what other test classes are included, we filter to the ones we know
34
+	 * and want to test.
35
+	 *
36
+	 * @param array $classNames
37
+	 *
38
+	 * @return array
39
+	 */
40
+	protected function filteredClassNames($classNames, $explicitClassNames)
41
+	{
42
+		$classNames = array_filter($classNames, function ($value) use ($explicitClassNames) {
43
+			return in_array($value, $explicitClassNames);
44
+		});
45
+		return $classNames;
46
+	}
47 47
 }
48 48
 
49 49
 class SiteTree_Lumberjack extends SiteTree implements TestOnly
50 50
 {
51 51
 
52
-    private static $extensions = array(
53
-        'Lumberjack',
54
-    );
52
+	private static $extensions = array(
53
+		'Lumberjack',
54
+	);
55 55
 }
56 56
 
57 57
 class SiteTree_LumberjackHidden extends SiteTree_Lumberjack implements TestOnly
58 58
 {
59 59
 
60
-    private static $show_in_sitetree = false;
60
+	private static $show_in_sitetree = false;
61 61
 }
62 62
 
63 63
 class SiteTree_LumberjackShown extends SiteTree_LumberjackHidden implements TestOnly
64 64
 {
65 65
 
66
-    private static $show_in_sitetree = true;
66
+	private static $show_in_sitetree = true;
67 67
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
      */
40 40
     protected function filteredClassNames($classNames, $explicitClassNames)
41 41
     {
42
-        $classNames = array_filter($classNames, function ($value) use ($explicitClassNames) {
42
+        $classNames = array_filter($classNames, function($value) use ($explicitClassNames) {
43 43
             return in_array($value, $explicitClassNames);
44 44
         });
45 45
         return $classNames;
Please login to merge, or discard this patch.
code/forms/gridfield/GridFieldConfig_Lumberjack.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,20 +11,20 @@
 block discarded – undo
11 11
 class GridFieldConfig_Lumberjack extends GridFieldConfig
12 12
 {
13 13
 
14
-    public function __construct($itemsPerPage = null)
15
-    {
16
-        parent::__construct($itemsPerPage);
17
-        $this->addComponent(new GridFieldButtonRow('before'));
18
-        $this->addComponent(new GridFieldSiteTreeAddNewButton('buttons-before-left'));
19
-        $this->addComponent(new GridFieldToolbarHeader());
20
-        $this->addComponent(new GridFieldSortableHeader());
21
-        $this->addComponent(new GridFieldFilterHeader());
22
-        $this->addComponent(new GridFieldDataColumns());
23
-        $this->addComponent(new GridFieldSiteTreeEditButton());
24
-        $this->addComponent(new GridFieldPageCount('toolbar-header-right'));
25
-        $this->addComponent($pagination = new GridFieldPaginator($itemsPerPage));
26
-        $this->addComponent(new GridFieldSiteTreeState());
14
+	public function __construct($itemsPerPage = null)
15
+	{
16
+		parent::__construct($itemsPerPage);
17
+		$this->addComponent(new GridFieldButtonRow('before'));
18
+		$this->addComponent(new GridFieldSiteTreeAddNewButton('buttons-before-left'));
19
+		$this->addComponent(new GridFieldToolbarHeader());
20
+		$this->addComponent(new GridFieldSortableHeader());
21
+		$this->addComponent(new GridFieldFilterHeader());
22
+		$this->addComponent(new GridFieldDataColumns());
23
+		$this->addComponent(new GridFieldSiteTreeEditButton());
24
+		$this->addComponent(new GridFieldPageCount('toolbar-header-right'));
25
+		$this->addComponent($pagination = new GridFieldPaginator($itemsPerPage));
26
+		$this->addComponent(new GridFieldSiteTreeState());
27 27
 
28
-        $pagination->setThrowExceptionOnBadDataType(true);
29
-    }
28
+		$pagination->setThrowExceptionOnBadDataType(true);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
code/forms/gridfield/GridFieldSiteTreeState.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -11,79 +11,79 @@
 block discarded – undo
11 11
 class GridFieldSiteTreeState implements GridField_ColumnProvider
12 12
 {
13 13
 
14
-    public function augmentColumns($gridField, &$columns)
15
-    {
16
-        // Ensure Actions always appears as the last column.
17
-        $key = array_search("Actions", $columns);
18
-        if ($key !== false) {
19
-            unset($columns[$key]);
20
-        }
14
+	public function augmentColumns($gridField, &$columns)
15
+	{
16
+		// Ensure Actions always appears as the last column.
17
+		$key = array_search("Actions", $columns);
18
+		if ($key !== false) {
19
+			unset($columns[$key]);
20
+		}
21 21
 
22
-        $columns = array_merge($columns, array(
23
-            "State",
24
-            "Actions",
25
-        ));
26
-    }
22
+		$columns = array_merge($columns, array(
23
+			"State",
24
+			"Actions",
25
+		));
26
+	}
27 27
 
28
-    public function getColumnsHandled($gridField)
29
-    {
30
-        return array("State");
31
-    }
28
+	public function getColumnsHandled($gridField)
29
+	{
30
+		return array("State");
31
+	}
32 32
 
33
-    public function getColumnContent($gridField, $record, $columnName)
34
-    {
35
-        if ($columnName == "State") {
36
-            if ($record->hasMethod("isPublished")) {
37
-                $modifiedLabel = "";
38
-                if ($record->isModifiedOnStage) {
39
-                    $modifiedLabel = "<span class='modified'>" . _t("GridFieldSiteTreeState.Modified", "Modified") . "</span>";
40
-                }
33
+	public function getColumnContent($gridField, $record, $columnName)
34
+	{
35
+		if ($columnName == "State") {
36
+			if ($record->hasMethod("isPublished")) {
37
+				$modifiedLabel = "";
38
+				if ($record->isModifiedOnStage) {
39
+					$modifiedLabel = "<span class='modified'>" . _t("GridFieldSiteTreeState.Modified", "Modified") . "</span>";
40
+				}
41 41
 
42
-                $published = $record->isPublished();
43
-                if (!$published) {
44
-                    return _t(
45
-                        "GridFieldSiteTreeState.Draft",
46
-                        '<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}',
47
-                        "State for when a post is saved.",
48
-                        array(
49
-                            "date" => $record->dbObject("LastEdited")->Nice()
50
-                        )
51
-                    );
52
-                } else {
53
-                    return _t(
54
-                        "GridFieldSiteTreeState.Published",
55
-                        '<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}',
56
-                        "State for when a post is published.",
57
-                        array(
58
-                            "date" => $record->dbObject("LastEdited")->Nice()
59
-                        )
60
-                    ) . $modifiedLabel;
61
-                }
62
-            }
63
-        }
64
-    }
42
+				$published = $record->isPublished();
43
+				if (!$published) {
44
+					return _t(
45
+						"GridFieldSiteTreeState.Draft",
46
+						'<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}',
47
+						"State for when a post is saved.",
48
+						array(
49
+							"date" => $record->dbObject("LastEdited")->Nice()
50
+						)
51
+					);
52
+				} else {
53
+					return _t(
54
+						"GridFieldSiteTreeState.Published",
55
+						'<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}',
56
+						"State for when a post is published.",
57
+						array(
58
+							"date" => $record->dbObject("LastEdited")->Nice()
59
+						)
60
+					) . $modifiedLabel;
61
+				}
62
+			}
63
+		}
64
+	}
65 65
 
66
-    public function getColumnAttributes($gridField, $record, $columnName)
67
-    {
68
-        if ($columnName == "State") {
69
-            if ($record->hasMethod("isPublished")) {
70
-                $published = $record->isPublished();
71
-                if (!$published) {
72
-                    $class = "gridfield-icon draft";
73
-                } else {
74
-                    $class = "gridfield-icon published";
75
-                }
76
-                return array("class" => $class);
77
-            }
78
-        }
79
-        return array();
80
-    }
66
+	public function getColumnAttributes($gridField, $record, $columnName)
67
+	{
68
+		if ($columnName == "State") {
69
+			if ($record->hasMethod("isPublished")) {
70
+				$published = $record->isPublished();
71
+				if (!$published) {
72
+					$class = "gridfield-icon draft";
73
+				} else {
74
+					$class = "gridfield-icon published";
75
+				}
76
+				return array("class" => $class);
77
+			}
78
+		}
79
+		return array();
80
+	}
81 81
 
82
-    public function getColumnMetaData($gridField, $columnName)
83
-    {
84
-        switch ($columnName) {
85
-            case 'State':
86
-                return array("title" => _t("GridFieldSiteTreeState.StateTitle", "State", "Column title for state"));
87
-        }
88
-    }
82
+	public function getColumnMetaData($gridField, $columnName)
83
+	{
84
+		switch ($columnName) {
85
+			case 'State':
86
+				return array("title" => _t("GridFieldSiteTreeState.StateTitle", "State", "Column title for state"));
87
+		}
88
+	}
89 89
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             if ($record->hasMethod("isPublished")) {
37 37
                 $modifiedLabel = "";
38 38
                 if ($record->isModifiedOnStage) {
39
-                    $modifiedLabel = "<span class='modified'>" . _t("GridFieldSiteTreeState.Modified", "Modified") . "</span>";
39
+                    $modifiedLabel = "<span class='modified'>"._t("GridFieldSiteTreeState.Modified", "Modified")."</span>";
40 40
                 }
41 41
 
42 42
                 $published = $record->isPublished();
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                         array(
58 58
                             "date" => $record->dbObject("LastEdited")->Nice()
59 59
                         )
60
-                    ) . $modifiedLabel;
60
+                    ).$modifiedLabel;
61 61
                 }
62 62
             }
63 63
         }
Please login to merge, or discard this patch.
code/forms/gridfield/GridFieldSiteTreeEditButton.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,22 +13,22 @@
 block discarded – undo
13 13
 class GridFieldSiteTreeEditButton extends GridFieldEditButton
14 14
 {
15 15
     
16
-    /**
17
-     * @param GridField $gridField
18
-     * @param DataObject $record
19
-     * @param string $columnName
20
-     *
21
-     * @return string - the HTML for the column 
22
-     */
23
-    public function getColumnContent($gridField, $record, $columnName)
24
-    {
25
-        // No permission checks - handled through GridFieldDetailForm
26
-        // which can make the form readonly if no edit permissions are available.
16
+	/**
17
+	 * @param GridField $gridField
18
+	 * @param DataObject $record
19
+	 * @param string $columnName
20
+	 *
21
+	 * @return string - the HTML for the column 
22
+	 */
23
+	public function getColumnContent($gridField, $record, $columnName)
24
+	{
25
+		// No permission checks - handled through GridFieldDetailForm
26
+		// which can make the form readonly if no edit permissions are available.
27 27
 
28
-        $data = new ArrayData(array(
29
-            'Link' => $record->CMSEditLink()
30
-        ));
28
+		$data = new ArrayData(array(
29
+			'Link' => $record->CMSEditLink()
30
+		));
31 31
 
32
-        return $data->renderWith('GridFieldEditButton');
33
-    }
32
+		return $data->renderWith('GridFieldEditButton');
33
+	}
34 34
 }
Please login to merge, or discard this patch.
code/extensions/Lumberjack.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -13,145 +13,145 @@
 block discarded – undo
13 13
 class Lumberjack extends SiteTreeExtension
14 14
 {
15 15
 
16
-    /**
17
-     * Loops through subclasses of the owner (intended to be SiteTree) and checks if they've been hidden.
18
-     *
19
-     * @return array
20
-     **/
21
-    public function getExcludedSiteTreeClassNames()
22
-    {
23
-        $classes = array();
24
-        $siteTreeClasses = $this->owner->allowedChildren();
25
-        foreach ($siteTreeClasses as $class) {
26
-            if (Config::inst()->get($class, 'show_in_sitetree') === false) {
27
-                $classes[$class] = $class;
28
-            }
29
-        }
30
-        return $classes;
31
-    }
32
-
33
-
34
-    /**
35
-     * This is responsible for adding the child pages tab and gridfield.
36
-     *
37
-     * @param FieldList $fields
38
-     */
39
-    public function updateCMSFields(FieldList $fields)
40
-    {
41
-        $excluded = $this->owner->getExcludedSiteTreeClassNames();
42
-        if (!empty($excluded)) {
43
-            $pages = SiteTree::get()->filter(array(
44
-                'ParentID' => $this->owner->ID,
45
-                'ClassName' => $excluded
46
-            ));
47
-            $gridField = new GridField(
48
-                "ChildPages",
49
-                $this->getLumberjackTitle(),
50
-                $pages,
51
-                $this->getLumberjackGridFieldConfig()
52
-            );
53
-
54
-            $tab = new Tab('ChildPages', $this->getLumberjackTitle(), $gridField);
55
-            $fields->insertAfter($tab, 'Main');
56
-        }
57
-    }
58
-
59
-
60
-    /**
61
-     * Augments (@link Hierarchy::stageChildren()}
62
-     *
63
-     * @param boolean showAll Include all of the elements, even those not shown in the menus.
64
-     *   (only applicable when extension is applied to {@link SiteTree}).
65
-     * @return DataList
66
-     */
67
-    public function stageChildren($showAll = false)
68
-    {
69
-        $baseClass = ClassInfo::baseDataClass($this->owner->class);
70
-        $staged = $baseClass::get()
71
-            ->filter('ParentID', (int)$this->owner->ID)
72
-            ->exclude('ID', (int)$this->owner->ID);
73
-        if (!$showAll && $this->owner->db('ShowInMenus')) {
74
-            $staged = $staged->filter('ShowInMenus', 1);
75
-        }
76
-        $this->owner->extend("augmentStageChildren", $staged, $showAll);
77
-
78
-        if ($this->shouldFilter()) {
79
-            // Filter the SiteTree
80
-            return $staged->exclude("ClassName", $this->owner->getExcludedSiteTreeClassNames());
81
-        }
82
-        return $staged;
83
-    }
84
-
85
-
86
-    /**
87
-     * Augments (@link Hierarchy::liveChildren()} by hiding excluded child classnames
88
-     *
89
-     * @param boolean $showAll Include all of the elements, even those not shown in the menus.
90
-     *   (only applicable when extension is applied to {@link SiteTree}).
91
-     * @param boolean $onlyDeletedFromStage Only return items that have been deleted from stage
92
-     * @return SS_List
93
-     */
94
-    public function liveChildren($showAll = false, $onlyDeletedFromStage = false)
95
-    {
96
-        $baseClass = ClassInfo::baseDataClass($this->owner->class);
97
-        $children = $baseClass::get()
98
-            ->filter('ParentID', (int)$this->owner->ID)
99
-            ->exclude('ID', (int)$this->owner->ID)
100
-            ->setDataQueryParam(array(
101
-                'Versioned.mode' => $onlyDeletedFromStage ? 'stage_unique' : 'stage',
102
-                'Versioned.stage' => 'Live'
103
-            ));
104
-
105
-        if (!$showAll) {
106
-            $children = $children->filter('ShowInMenus', 1);
107
-        }
108
-
109
-        if ($this->shouldFilter()) {
110
-            // Filter the SiteTree
111
-            return $children->exclude("ClassName", $this->owner->getExcludedSiteTreeClassNames());
112
-        }
113
-        return $children;
114
-    }
115
-
116
-
117
-    /**
118
-     * This returns the title for the tab and GridField. This can be overwritten
119
-     * in the owner class.
120
-     *
121
-     * @return string
122
-     */
123
-    protected function getLumberjackTitle()
124
-    {
125
-        if (method_exists($this->owner, 'getLumberjackTitle')) {
126
-            return $this->owner->getLumberjackTitle();
127
-        }
128
-        return _t("Lumberjack.TabTitle", "Child Pages");
129
-    }
130
-
131
-
132
-    /**
133
-     * This returns the gird field config for the lumberjack gridfield.
134
-     *
135
-     * @return GridFieldConfig
136
-     */
137
-    protected function getLumberjackGridFieldConfig()
138
-    {
139
-        if (method_exists($this->owner, 'getLumberjackGridFieldConfig')) {
140
-            return $this->owner->getLumberjackGridFieldConfig();
141
-        }
142
-        return GridFieldConfig_Lumberjack::create();
143
-    }
144
-
145
-
146
-    /**
147
-     * Checks if we're on a controller where we should filter. ie. Are we loading the SiteTree?
148
-     *
149
-     * @return bool
150
-     */
151
-    protected function shouldFilter()
152
-    {
153
-        $controller = Controller::curr();
154
-        return $controller instanceof LeftAndMain
155
-            && in_array($controller->getAction(), array("treeview", "listview", "getsubtree"));
156
-    }
16
+	/**
17
+	 * Loops through subclasses of the owner (intended to be SiteTree) and checks if they've been hidden.
18
+	 *
19
+	 * @return array
20
+	 **/
21
+	public function getExcludedSiteTreeClassNames()
22
+	{
23
+		$classes = array();
24
+		$siteTreeClasses = $this->owner->allowedChildren();
25
+		foreach ($siteTreeClasses as $class) {
26
+			if (Config::inst()->get($class, 'show_in_sitetree') === false) {
27
+				$classes[$class] = $class;
28
+			}
29
+		}
30
+		return $classes;
31
+	}
32
+
33
+
34
+	/**
35
+	 * This is responsible for adding the child pages tab and gridfield.
36
+	 *
37
+	 * @param FieldList $fields
38
+	 */
39
+	public function updateCMSFields(FieldList $fields)
40
+	{
41
+		$excluded = $this->owner->getExcludedSiteTreeClassNames();
42
+		if (!empty($excluded)) {
43
+			$pages = SiteTree::get()->filter(array(
44
+				'ParentID' => $this->owner->ID,
45
+				'ClassName' => $excluded
46
+			));
47
+			$gridField = new GridField(
48
+				"ChildPages",
49
+				$this->getLumberjackTitle(),
50
+				$pages,
51
+				$this->getLumberjackGridFieldConfig()
52
+			);
53
+
54
+			$tab = new Tab('ChildPages', $this->getLumberjackTitle(), $gridField);
55
+			$fields->insertAfter($tab, 'Main');
56
+		}
57
+	}
58
+
59
+
60
+	/**
61
+	 * Augments (@link Hierarchy::stageChildren()}
62
+	 *
63
+	 * @param boolean showAll Include all of the elements, even those not shown in the menus.
64
+	 *   (only applicable when extension is applied to {@link SiteTree}).
65
+	 * @return DataList
66
+	 */
67
+	public function stageChildren($showAll = false)
68
+	{
69
+		$baseClass = ClassInfo::baseDataClass($this->owner->class);
70
+		$staged = $baseClass::get()
71
+			->filter('ParentID', (int)$this->owner->ID)
72
+			->exclude('ID', (int)$this->owner->ID);
73
+		if (!$showAll && $this->owner->db('ShowInMenus')) {
74
+			$staged = $staged->filter('ShowInMenus', 1);
75
+		}
76
+		$this->owner->extend("augmentStageChildren", $staged, $showAll);
77
+
78
+		if ($this->shouldFilter()) {
79
+			// Filter the SiteTree
80
+			return $staged->exclude("ClassName", $this->owner->getExcludedSiteTreeClassNames());
81
+		}
82
+		return $staged;
83
+	}
84
+
85
+
86
+	/**
87
+	 * Augments (@link Hierarchy::liveChildren()} by hiding excluded child classnames
88
+	 *
89
+	 * @param boolean $showAll Include all of the elements, even those not shown in the menus.
90
+	 *   (only applicable when extension is applied to {@link SiteTree}).
91
+	 * @param boolean $onlyDeletedFromStage Only return items that have been deleted from stage
92
+	 * @return SS_List
93
+	 */
94
+	public function liveChildren($showAll = false, $onlyDeletedFromStage = false)
95
+	{
96
+		$baseClass = ClassInfo::baseDataClass($this->owner->class);
97
+		$children = $baseClass::get()
98
+			->filter('ParentID', (int)$this->owner->ID)
99
+			->exclude('ID', (int)$this->owner->ID)
100
+			->setDataQueryParam(array(
101
+				'Versioned.mode' => $onlyDeletedFromStage ? 'stage_unique' : 'stage',
102
+				'Versioned.stage' => 'Live'
103
+			));
104
+
105
+		if (!$showAll) {
106
+			$children = $children->filter('ShowInMenus', 1);
107
+		}
108
+
109
+		if ($this->shouldFilter()) {
110
+			// Filter the SiteTree
111
+			return $children->exclude("ClassName", $this->owner->getExcludedSiteTreeClassNames());
112
+		}
113
+		return $children;
114
+	}
115
+
116
+
117
+	/**
118
+	 * This returns the title for the tab and GridField. This can be overwritten
119
+	 * in the owner class.
120
+	 *
121
+	 * @return string
122
+	 */
123
+	protected function getLumberjackTitle()
124
+	{
125
+		if (method_exists($this->owner, 'getLumberjackTitle')) {
126
+			return $this->owner->getLumberjackTitle();
127
+		}
128
+		return _t("Lumberjack.TabTitle", "Child Pages");
129
+	}
130
+
131
+
132
+	/**
133
+	 * This returns the gird field config for the lumberjack gridfield.
134
+	 *
135
+	 * @return GridFieldConfig
136
+	 */
137
+	protected function getLumberjackGridFieldConfig()
138
+	{
139
+		if (method_exists($this->owner, 'getLumberjackGridFieldConfig')) {
140
+			return $this->owner->getLumberjackGridFieldConfig();
141
+		}
142
+		return GridFieldConfig_Lumberjack::create();
143
+	}
144
+
145
+
146
+	/**
147
+	 * Checks if we're on a controller where we should filter. ie. Are we loading the SiteTree?
148
+	 *
149
+	 * @return bool
150
+	 */
151
+	protected function shouldFilter()
152
+	{
153
+		$controller = Controller::curr();
154
+		return $controller instanceof LeftAndMain
155
+			&& in_array($controller->getAction(), array("treeview", "listview", "getsubtree"));
156
+	}
157 157
 }
Please login to merge, or discard this patch.