Completed
Push — master ( 3f8c63...25a516 )
by Sam
10s
created
code/controller/SiteConfigLeftAndMain.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
 	/**
108 108
 	 * Used for preview controls, mainly links which switch between different states of the page.
109 109
 	 *
110
-	 * @return ArrayData
110
+	 * @return SilverStripe\Model\FieldType\DBField
111 111
 	 */
112 112
     public function getSilverStripeNavigator()
113 113
     {
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return Form
44 44
 	 */
45
-    public function getEditForm($id = null, $fields = null)
46
-    {
45
+	public function getEditForm($id = null, $fields = null)
46
+	{
47 47
 		$siteConfig = SiteConfig::current_site_config();
48 48
 		$fields = $siteConfig->getCMSFields();
49 49
 
@@ -84,20 +84,20 @@  discard block
 block discarded – undo
84 84
 		$form->addExtraClass('cms-content center cms-edit-form');
85 85
 		$form->setAttribute('data-pjax-fragment', 'CurrentForm');
86 86
 
87
-        if ($form->Fields()->hasTabset()) {
88
-            $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
89
-        }
87
+		if ($form->Fields()->hasTabset()) {
88
+			$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
89
+		}
90 90
 		$form->setHTMLID('Form_EditForm');
91 91
 		$form->loadDataFrom($siteConfig);
92 92
 		$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
93 93
 
94 94
 		// Use <button> to allow full jQuery UI styling
95 95
 		$actions = $actions->dataFields();
96
-        if ($actions) {
97
-            foreach ($actions as $action) {
98
-                $action->setUseButtonTag(true);
99
-            }
100
-        }
96
+		if ($actions) {
97
+			foreach ($actions as $action) {
98
+				$action->setUseButtonTag(true);
99
+			}
100
+		}
101 101
 
102 102
 		$this->extend('updateEditForm', $form);
103 103
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return ArrayData
111 111
 	 */
112
-    public function getSilverStripeNavigator()
113
-    {
112
+	public function getSilverStripeNavigator()
113
+	{
114 114
 		return $this->renderWith('CMSSettingsController_SilverStripeNavigator');
115 115
 	}
116 116
 
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 * @param Form $form 
122 122
 	 * @return String
123 123
 	 */
124
-    public function save_siteconfig($data, $form)
125
-    {
124
+	public function save_siteconfig($data, $form)
125
+	{
126 126
 		$siteConfig = SiteConfig::current_site_config();
127 127
 		$form->saveInto($siteConfig);
128 128
 		
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	}
140 140
 	
141 141
 
142
-    public function Breadcrumbs($unlinked = false)
143
-    {
142
+	public function Breadcrumbs($unlinked = false)
143
+	{
144 144
 		$defaultTitle = self::menu_title_for_class(get_class($this));
145 145
 
146 146
 		return new ArrayList(array(
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		)->setHTMLID('Form_EditForm');
71 71
 		$form->setValidationResponseCallback(function() use ($negotiator, $form) {
72 72
 			$request = $this->getRequest();
73
-			if($request->isAjax() && $negotiator) {
73
+			if ($request->isAjax() && $negotiator) {
74 74
 				$form->setupFormErrors();
75 75
 				$result = $form->forTemplate();
76 76
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		
129 129
 		try {
130 130
 			$siteConfig->write();
131
-		} catch(ValidationException $ex) {
131
+		} catch (ValidationException $ex) {
132 132
 			$form->sessionMessage($ex->getResult()->message(), 'bad');
133 133
 			return $this->getResponseNegotiator()->respond($this->request);
134 134
 		}
Please login to merge, or discard this patch.
tests/behat/features/bootstrap/Context/FeatureContext.php 3 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -2,9 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace SilverStripe\Siteconfig\Test\Behaviour;
4 4
 
5
-use SilverStripe\BehatExtension\Context\SilverStripeContext;
6
-use SilverStripe\BehatExtension\Context\BasicContext;
7
-use SilverStripe\BehatExtension\Context\LoginContext;
8 5
 use SilverStripe\BehatExtension\Context\FixtureContext;
9 6
 use SilverStripe\Cms\Test\Behaviour;
10 7
 
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -16,35 +16,35 @@
 block discarded – undo
16 16
  */
17 17
 class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureContext
18 18
 {
19
-    /**
20
-     * Initializes context.
21
-     * Every scenario gets it's own context object.
22
-     *
23
-     * @param   array   $parameters     context parameters (set them up through behat.yml)
24
-     */
25
-    public function __construct(array $parameters)
26
-    {
27
-        parent::__construct($parameters);
19
+	/**
20
+	 * Initializes context.
21
+	 * Every scenario gets it's own context object.
22
+	 *
23
+	 * @param   array   $parameters     context parameters (set them up through behat.yml)
24
+	 */
25
+	public function __construct(array $parameters)
26
+	{
27
+		parent::__construct($parameters);
28 28
 
29
-        // Override existing fixture context with more specific one
30
-        $fixtureContext = new \SilverStripe\Siteconfig\Test\Behaviour\FixtureContext($parameters);
31
-        $fixtureContext->setFixtureFactory($this->getFixtureFactory());
32
-        $this->useContext('FixtureContext', $fixtureContext);
29
+		// Override existing fixture context with more specific one
30
+		$fixtureContext = new \SilverStripe\Siteconfig\Test\Behaviour\FixtureContext($parameters);
31
+		$fixtureContext->setFixtureFactory($this->getFixtureFactory());
32
+		$this->useContext('FixtureContext', $fixtureContext);
33 33
 
34
-        // Add extra contexts with more steps
35
-        $this->useContext('ThemeContext', new \SilverStripe\Siteconfig\Test\Behaviour\ThemeContext($parameters));
36
-        if(!class_exists('SiteTree')) {
37
-            return;
38
-        }
34
+		// Add extra contexts with more steps
35
+		$this->useContext('ThemeContext', new \SilverStripe\Siteconfig\Test\Behaviour\ThemeContext($parameters));
36
+		if(!class_exists('SiteTree')) {
37
+			return;
38
+		}
39 39
 
40
-        // Use blueprints which auto-publish all subclasses of SiteTree
41
-        $factory = $fixtureContext->getFixtureFactory();
42
-        foreach (\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
43
-            $blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
44
-            $blueprint->addCallback('afterCreate', function ($obj, $identifier, &$data, &$fixtures) {
45
-                $obj->publish('Stage', 'Live');
46
-            });
47
-            $factory->define($class, $blueprint);
48
-        }
49
-    }
40
+		// Use blueprints which auto-publish all subclasses of SiteTree
41
+		$factory = $fixtureContext->getFixtureFactory();
42
+		foreach (\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
43
+			$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
44
+			$blueprint->addCallback('afterCreate', function ($obj, $identifier, &$data, &$fixtures) {
45
+				$obj->publish('Stage', 'Live');
46
+			});
47
+			$factory->define($class, $blueprint);
48
+		}
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
         // Add extra contexts with more steps
35 35
         $this->useContext('ThemeContext', new \SilverStripe\Siteconfig\Test\Behaviour\ThemeContext($parameters));
36
-        if(!class_exists('SiteTree')) {
36
+        if (!class_exists('SiteTree')) {
37 37
             return;
38 38
         }
39 39
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $factory = $fixtureContext->getFixtureFactory();
42 42
         foreach (\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
43 43
             $blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
44
-            $blueprint->addCallback('afterCreate', function ($obj, $identifier, &$data, &$fixtures) {
44
+            $blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
45 45
                 $obj->publish('Stage', 'Live');
46 46
             });
47 47
             $factory->define($class, $blueprint);
Please login to merge, or discard this patch.
features/bootstrap/SilverStripe/SiteConfig/Test/Behaviour/ThemeContext.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -54,6 +54,9 @@  discard block
 block discarded – undo
54 54
         $this->requireFile(BASE_PATH . '/themes/' . $theme . '/templates/' . $template, $content);
55 55
     }
56 56
 
57
+    /**
58
+     * @param string $filename
59
+     */
57 60
     protected function requireFile($filename, $content)
58 61
     {
59 62
         // Already exists
@@ -71,6 +74,9 @@  discard block
 block discarded – undo
71 74
         }
72 75
     }
73 76
 
77
+    /**
78
+     * @param string $dirname
79
+     */
74 80
     protected function requireDir($dirname)
75 81
     {
76 82
         // Directory doesn't exist, create it and mark it for deletion
Please login to merge, or discard this patch.
Unused Use Statements   -8 removed lines patch added patch discarded remove patch
@@ -2,15 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace SilverStripe\Siteconfig\Test\Behaviour;
4 4
 
5
-use Behat\Behat\Context\ClosuredContextInterface;
6
-use Behat\Behat\Context\TranslatedContextInterface;
7 5
 use Behat\Behat\Context\BehatContext;
8
-use Behat\Behat\Context\Step;
9
-use Behat\Behat\Event\StepEvent;
10
-use Behat\Behat\Exception\PendingException;
11
-use Behat\Mink\Driver\Selenium2Driver;
12
-use Behat\Gherkin\Node\PyStringNode;
13
-use Behat\Gherkin\Node\TableNode;
14 6
 
15 7
 /**
16 8
  * Context used to create fixtures in the SilverStripe ORM.
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -17,100 +17,100 @@
 block discarded – undo
17 17
  */
18 18
 class ThemeContext extends BehatContext
19 19
 {
20
-    protected $restoreFiles = array();
21
-    protected $restoreDirectories = array();
20
+	protected $restoreFiles = array();
21
+	protected $restoreDirectories = array();
22 22
 
23
-    /**
24
-     * Create a test theme
25
-     *
26
-     * @Given /^a theme "(?<theme>[^"]+)"/
27
-     */
28
-    public function stepCreateTheme($theme)
29
-    {
30
-        if (!preg_match('/^[0-9a-zA-Z_-]+$/', $theme)) {
31
-            throw new \InvalidArgumentException("Bad theme '$theme'");
32
-        }
23
+	/**
24
+	 * Create a test theme
25
+	 *
26
+	 * @Given /^a theme "(?<theme>[^"]+)"/
27
+	 */
28
+	public function stepCreateTheme($theme)
29
+	{
30
+		if (!preg_match('/^[0-9a-zA-Z_-]+$/', $theme)) {
31
+			throw new \InvalidArgumentException("Bad theme '$theme'");
32
+		}
33 33
 
34
-        $this->requireDir(BASE_PATH . '/themes');
35
-        $this->requireDir(BASE_PATH . '/themes/' . $theme);
36
-        $this->requireDir(BASE_PATH . '/themes/' . $theme . '/templates');
37
-    }
34
+		$this->requireDir(BASE_PATH . '/themes');
35
+		$this->requireDir(BASE_PATH . '/themes/' . $theme);
36
+		$this->requireDir(BASE_PATH . '/themes/' . $theme . '/templates');
37
+	}
38 38
 
39
-    /**
40
-     * Create a template within a test theme
41
-     *
42
-     * @Given /^a template "(?<template>[^"]+)" in theme "(?<theme>[^"]+)" with content "(?<content>[^"]+)"/
43
-     */
44
-    public function stepCreateTemplate($template, $theme, $content)
45
-    {
46
-        if (!preg_match('/^[0-9a-zA-Z_-]+$/', $theme)) {
47
-            throw new \InvalidArgumentException("Bad theme '$theme'");
48
-        }
49
-        if (!preg_match('/^(Layout\/)?[0-9a-zA-Z_-]+\.ss$/', $template)) {
50
-            throw new \InvalidArgumentException("Bad template '$template'");
51
-        }
39
+	/**
40
+	 * Create a template within a test theme
41
+	 *
42
+	 * @Given /^a template "(?<template>[^"]+)" in theme "(?<theme>[^"]+)" with content "(?<content>[^"]+)"/
43
+	 */
44
+	public function stepCreateTemplate($template, $theme, $content)
45
+	{
46
+		if (!preg_match('/^[0-9a-zA-Z_-]+$/', $theme)) {
47
+			throw new \InvalidArgumentException("Bad theme '$theme'");
48
+		}
49
+		if (!preg_match('/^(Layout\/)?[0-9a-zA-Z_-]+\.ss$/', $template)) {
50
+			throw new \InvalidArgumentException("Bad template '$template'");
51
+		}
52 52
 
53
-        $this->stepCreateTheme($theme);
54
-        $this->requireFile(BASE_PATH . '/themes/' . $theme . '/templates/' . $template, $content);
55
-    }
53
+		$this->stepCreateTheme($theme);
54
+		$this->requireFile(BASE_PATH . '/themes/' . $theme . '/templates/' . $template, $content);
55
+	}
56 56
 
57
-    protected function requireFile($filename, $content)
58
-    {
59
-        // Already exists
60
-        if (file_exists($filename)) {
61
-            // If the content is different, remember old content for restoration
62
-            $origContent = file_get_contents($filename);
63
-            if ($origContent != $content) {
64
-                file_put_contents($filename, $content);
65
-                $this->restoreFiles[$filename] = $origContent;
66
-            }
67
-        // Doesn't exist, mark it for deletion after test
68
-        } else {
69
-            file_put_contents($filename, $content);
70
-            $this->restoreFiles[$filename] = null;
71
-        }
72
-    }
57
+	protected function requireFile($filename, $content)
58
+	{
59
+		// Already exists
60
+		if (file_exists($filename)) {
61
+			// If the content is different, remember old content for restoration
62
+			$origContent = file_get_contents($filename);
63
+			if ($origContent != $content) {
64
+				file_put_contents($filename, $content);
65
+				$this->restoreFiles[$filename] = $origContent;
66
+			}
67
+		// Doesn't exist, mark it for deletion after test
68
+		} else {
69
+			file_put_contents($filename, $content);
70
+			$this->restoreFiles[$filename] = null;
71
+		}
72
+	}
73 73
 
74
-    protected function requireDir($dirname)
75
-    {
76
-        // Directory doesn't exist, create it and mark it for deletion
77
-        if (!file_exists($dirname)) {
78
-            mkdir($dirname);
79
-            $this->restoreDirectories[] = $dirname;
80
-        }
81
-    }
74
+	protected function requireDir($dirname)
75
+	{
76
+		// Directory doesn't exist, create it and mark it for deletion
77
+		if (!file_exists($dirname)) {
78
+			mkdir($dirname);
79
+			$this->restoreDirectories[] = $dirname;
80
+		}
81
+	}
82 82
 
83
-    /**
84
-     * Clean up any theme manipulation
85
-     *
86
-     * @AfterScenario
87
-     */
88
-    public function cleanThemesAfterScenario()
89
-    {
90
-        // Restore any created/modified files.
91
-        //  - If modified, revert then to original contnet
92
-        //  - If created, delete them
93
-        if ($this->restoreFiles) {
94
-            foreach ($this->restoreFiles as $file => $origContent) {
95
-                if ($origContent === null) {
96
-                    unlink($file);
97
-                } else {
98
-                    file_put_contents($file, $origContent);
99
-                }
100
-            }
83
+	/**
84
+	 * Clean up any theme manipulation
85
+	 *
86
+	 * @AfterScenario
87
+	 */
88
+	public function cleanThemesAfterScenario()
89
+	{
90
+		// Restore any created/modified files.
91
+		//  - If modified, revert then to original contnet
92
+		//  - If created, delete them
93
+		if ($this->restoreFiles) {
94
+			foreach ($this->restoreFiles as $file => $origContent) {
95
+				if ($origContent === null) {
96
+					unlink($file);
97
+				} else {
98
+					file_put_contents($file, $origContent);
99
+				}
100
+			}
101 101
 
102
-            $this->restoreFiles = array();
103
-        }
102
+			$this->restoreFiles = array();
103
+		}
104 104
 
105
-        // Restore any created directories: that is, delete them
106
-        if ($this->restoreDirectories) {
107
-            // Flip the order so that nested direcotires are unlinked() first
108
-            $this->restoreDirectories = array_reverse($this->restoreDirectories);
109
-            foreach ($this->restoreDirectories as $dir) {
110
-                rmdir($dir);
111
-            }
105
+		// Restore any created directories: that is, delete them
106
+		if ($this->restoreDirectories) {
107
+			// Flip the order so that nested direcotires are unlinked() first
108
+			$this->restoreDirectories = array_reverse($this->restoreDirectories);
109
+			foreach ($this->restoreDirectories as $dir) {
110
+				rmdir($dir);
111
+			}
112 112
 
113
-            $this->restoreDirectories = array();
114
-        }
115
-    }
113
+			$this->restoreDirectories = array();
114
+		}
115
+	}
116 116
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
             throw new \InvalidArgumentException("Bad theme '$theme'");
32 32
         }
33 33
 
34
-        $this->requireDir(BASE_PATH . '/themes');
35
-        $this->requireDir(BASE_PATH . '/themes/' . $theme);
36
-        $this->requireDir(BASE_PATH . '/themes/' . $theme . '/templates');
34
+        $this->requireDir(BASE_PATH.'/themes');
35
+        $this->requireDir(BASE_PATH.'/themes/'.$theme);
36
+        $this->requireDir(BASE_PATH.'/themes/'.$theme.'/templates');
37 37
     }
38 38
 
39 39
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         }
52 52
 
53 53
         $this->stepCreateTheme($theme);
54
-        $this->requireFile(BASE_PATH . '/themes/' . $theme . '/templates/' . $template, $content);
54
+        $this->requireFile(BASE_PATH.'/themes/'.$theme.'/templates/'.$template, $content);
55 55
     }
56 56
 
57 57
     protected function requireFile($filename, $content)
Please login to merge, or discard this patch.
code/model/SiteConfig.php 2 patches
Indentation   +364 added lines, -364 removed lines patch added patch discarded remove patch
@@ -18,428 +18,428 @@
 block discarded – undo
18 18
  */
19 19
 class SiteConfig extends DataObject implements PermissionProvider, TemplateGlobalProvider
20 20
 {
21
-    private static $db = array(
22
-        "Title" => "Varchar(255)",
23
-        "Tagline" => "Varchar(255)",
24
-        "Theme" => "Varchar(255)",
25
-        "CanViewType" => "Enum('Anyone, LoggedInUsers, OnlyTheseUsers', 'Anyone')",
26
-        "CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
27
-        "CanCreateTopLevelType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
28
-    );
21
+	private static $db = array(
22
+		"Title" => "Varchar(255)",
23
+		"Tagline" => "Varchar(255)",
24
+		"Theme" => "Varchar(255)",
25
+		"CanViewType" => "Enum('Anyone, LoggedInUsers, OnlyTheseUsers', 'Anyone')",
26
+		"CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
27
+		"CanCreateTopLevelType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
28
+	);
29 29
     
30
-    private static $many_many = array(
31
-        "ViewerGroups" => "Group",
32
-        "EditorGroups" => "Group",
33
-        "CreateTopLevelGroups" => "Group"
34
-    );
30
+	private static $many_many = array(
31
+		"ViewerGroups" => "Group",
32
+		"EditorGroups" => "Group",
33
+		"CreateTopLevelGroups" => "Group"
34
+	);
35 35
     
36
-    private static $defaults = array(
37
-        "CanViewType" => "Anyone",
38
-        "CanEditType" => "LoggedInUsers",
39
-        "CanCreateTopLevelType" => "LoggedInUsers",
40
-    );
36
+	private static $defaults = array(
37
+		"CanViewType" => "Anyone",
38
+		"CanEditType" => "LoggedInUsers",
39
+		"CanCreateTopLevelType" => "LoggedInUsers",
40
+	);
41 41
     
42
-    /**
43
-     * @config
44
-     *
45
-     * @var array
46
-     */
47
-    private static $disabled_themes = array();
42
+	/**
43
+	 * @config
44
+	 *
45
+	 * @var array
46
+	 */
47
+	private static $disabled_themes = array();
48 48
     
49
-    /**
50
-     * Default permission to check for 'LoggedInUsers' to create or edit pages
51
-     *
52
-     * @var array
53
-     * @config
54
-     */
55
-    private static $required_permission = array('CMS_ACCESS_CMSMain', 'CMS_ACCESS_LeftAndMain');
49
+	/**
50
+	 * Default permission to check for 'LoggedInUsers' to create or edit pages
51
+	 *
52
+	 * @var array
53
+	 * @config
54
+	 */
55
+	private static $required_permission = array('CMS_ACCESS_CMSMain', 'CMS_ACCESS_LeftAndMain');
56 56
     
57 57
 
58
-    public function populateDefaults()
59
-    {
60
-        $this->Title = _t('SiteConfig.SITENAMEDEFAULT', "Your Site Name");
61
-        $this->Tagline = _t('SiteConfig.TAGLINEDEFAULT', "your tagline here");
58
+	public function populateDefaults()
59
+	{
60
+		$this->Title = _t('SiteConfig.SITENAMEDEFAULT', "Your Site Name");
61
+		$this->Tagline = _t('SiteConfig.TAGLINEDEFAULT', "your tagline here");
62 62
         
63
-        // Allow these defaults to be overridden
64
-        parent::populateDefaults();
65
-    }
63
+		// Allow these defaults to be overridden
64
+		parent::populateDefaults();
65
+	}
66 66
 
67
-    /**
68
-     * Get the fields that are sent to the CMS. 
69
-     *
70
-     * In your extensions: updateCMSFields($fields).
71
-     *
72
-     * @return FieldList
73
-     */
74
-    public function getCMSFields()
75
-    {
76
-        $groupsMap = array();
67
+	/**
68
+	 * Get the fields that are sent to the CMS. 
69
+	 *
70
+	 * In your extensions: updateCMSFields($fields).
71
+	 *
72
+	 * @return FieldList
73
+	 */
74
+	public function getCMSFields()
75
+	{
76
+		$groupsMap = array();
77 77
 
78
-        foreach (Group::get() as $group) {
79
-            // Listboxfield values are escaped, use ASCII char instead of &raquo;
80
-            $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
81
-        }
82
-        asort($groupsMap);
78
+		foreach (Group::get() as $group) {
79
+			// Listboxfield values are escaped, use ASCII char instead of &raquo;
80
+			$groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
81
+		}
82
+		asort($groupsMap);
83 83
 
84
-        $fields = new FieldList(
85
-            new TabSet("Root",
86
-                $tabMain = new Tab('Main',
87
-                    $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")),
88
-                    $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")),
89
-                    $themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes())
90
-                ),
91
-                $tabAccess = new Tab('Access',
92
-                    $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")),
93
-                    $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))
94
-                        ->setSource($groupsMap)
95
-                        ->setAttribute(
96
-                            'data-placeholder',
97
-                            _t('SiteTree.GroupPlaceholder', 'Click to select group')
98
-                        ),
99
-                    $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")),
100
-                    $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))
101
-                        ->setSource($groupsMap)
102
-                        ->setAttribute(
103
-                            'data-placeholder',
104
-                            _t('SiteTree.GroupPlaceholder', 'Click to select group')
105
-                        ),
106
-                    $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")),
107
-                    $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))
108
-                        ->setSource($groupsMap)
109
-                        ->setAttribute(
110
-                            'data-placeholder',
111
-                            _t('SiteTree.GroupPlaceholder', 'Click to select group')
112
-                        )
113
-                )
114
-            ),
115
-            new HiddenField('ID')
116
-        );
84
+		$fields = new FieldList(
85
+			new TabSet("Root",
86
+				$tabMain = new Tab('Main',
87
+					$titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")),
88
+					$taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")),
89
+					$themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes())
90
+				),
91
+				$tabAccess = new Tab('Access',
92
+					$viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")),
93
+					$viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))
94
+						->setSource($groupsMap)
95
+						->setAttribute(
96
+							'data-placeholder',
97
+							_t('SiteTree.GroupPlaceholder', 'Click to select group')
98
+						),
99
+					$editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")),
100
+					$editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))
101
+						->setSource($groupsMap)
102
+						->setAttribute(
103
+							'data-placeholder',
104
+							_t('SiteTree.GroupPlaceholder', 'Click to select group')
105
+						),
106
+					$topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")),
107
+					$topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))
108
+						->setSource($groupsMap)
109
+						->setAttribute(
110
+							'data-placeholder',
111
+							_t('SiteTree.GroupPlaceholder', 'Click to select group')
112
+						)
113
+				)
114
+			),
115
+			new HiddenField('ID')
116
+		);
117 117
 
118
-        $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'));
118
+		$themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'));
119 119
 
120
-        $viewersOptionsSource = array();
121
-        $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
122
-        $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
123
-        $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
124
-        $viewersOptionsField->setSource($viewersOptionsSource);
120
+		$viewersOptionsSource = array();
121
+		$viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
122
+		$viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
123
+		$viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
124
+		$viewersOptionsField->setSource($viewersOptionsSource);
125 125
         
126
-        $editorsOptionsSource = array();
127
-        $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
128
-        $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
129
-        $editorsOptionsField->setSource($editorsOptionsSource);
126
+		$editorsOptionsSource = array();
127
+		$editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
128
+		$editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
129
+		$editorsOptionsField->setSource($editorsOptionsSource);
130 130
         
131
-        $topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
131
+		$topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
132 132
         
133
-        if (!Permission::check('EDIT_SITECONFIG')) {
134
-            $fields->makeFieldReadonly($viewersOptionsField);
135
-            $fields->makeFieldReadonly($viewerGroupsField);
136
-            $fields->makeFieldReadonly($editorsOptionsField);
137
-            $fields->makeFieldReadonly($editorGroupsField);
138
-            $fields->makeFieldReadonly($topLevelCreatorsOptionsField);
139
-            $fields->makeFieldReadonly($topLevelCreatorsGroupsField);
140
-            $fields->makeFieldReadonly($taglineField);
141
-            $fields->makeFieldReadonly($titleField);
142
-        }
133
+		if (!Permission::check('EDIT_SITECONFIG')) {
134
+			$fields->makeFieldReadonly($viewersOptionsField);
135
+			$fields->makeFieldReadonly($viewerGroupsField);
136
+			$fields->makeFieldReadonly($editorsOptionsField);
137
+			$fields->makeFieldReadonly($editorGroupsField);
138
+			$fields->makeFieldReadonly($topLevelCreatorsOptionsField);
139
+			$fields->makeFieldReadonly($topLevelCreatorsGroupsField);
140
+			$fields->makeFieldReadonly($taglineField);
141
+			$fields->makeFieldReadonly($titleField);
142
+		}
143 143
 
144
-        if (file_exists(BASE_PATH . '/install.php')) {
145
-            $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader",
146
-                "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING",
147
-                "Warning: You should remove install.php from this SilverStripe install for security reasons.")
148
-                . "</p>"), "Title");
149
-        }
144
+		if (file_exists(BASE_PATH . '/install.php')) {
145
+			$fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader",
146
+				"<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING",
147
+				"Warning: You should remove install.php from this SilverStripe install for security reasons.")
148
+				. "</p>"), "Title");
149
+		}
150 150
         
151
-        $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
152
-        $tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
153
-        $this->extend('updateCMSFields', $fields);
151
+		$tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
152
+		$tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
153
+		$this->extend('updateCMSFields', $fields);
154 154
         
155
-        return $fields;
156
-    }
155
+		return $fields;
156
+	}
157 157
 
158
-    /**
159
-     * Get all available themes that haven't been marked as disabled.
160
-     *
161
-     * @param string $baseDir Optional alternative theme base directory for testing
162
-     *
163
-     * @return array of theme directory names
164
-     */
165
-    public function getAvailableThemes($baseDir = null)
166
-    {
167
-        $themes = SSViewer::get_themes($baseDir);
168
-        $disabled = (array)$this->config()->disabled_themes;
158
+	/**
159
+	 * Get all available themes that haven't been marked as disabled.
160
+	 *
161
+	 * @param string $baseDir Optional alternative theme base directory for testing
162
+	 *
163
+	 * @return array of theme directory names
164
+	 */
165
+	public function getAvailableThemes($baseDir = null)
166
+	{
167
+		$themes = SSViewer::get_themes($baseDir);
168
+		$disabled = (array)$this->config()->disabled_themes;
169 169
     
170
-        foreach ($disabled as $theme) {
171
-            if (isset($themes[$theme])) {
172
-                unset($themes[$theme]);
173
-            }
174
-        }
170
+		foreach ($disabled as $theme) {
171
+			if (isset($themes[$theme])) {
172
+				unset($themes[$theme]);
173
+			}
174
+		}
175 175
     
176
-        return $themes;
177
-    }
176
+		return $themes;
177
+	}
178 178
     
179
-    /**
180
-     * Get the actions that are sent to the CMS. 
181
-     *
182
-     * In your extensions: updateEditFormActions($actions)
183
-     *
184
-     * @return FieldList
185
-     */
186
-    public function getCMSActions()
187
-    {
188
-        if (Permission::check('ADMIN') || Permission::check('EDIT_SITECONFIG')) {
189
-            $actions = new FieldList(
190
-                FormAction::create('save_siteconfig', _t('CMSMain.SAVE', 'Save'))
191
-                    ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
192
-            );
193
-        } else {
194
-            $actions = new FieldList();
195
-        }
179
+	/**
180
+	 * Get the actions that are sent to the CMS. 
181
+	 *
182
+	 * In your extensions: updateEditFormActions($actions)
183
+	 *
184
+	 * @return FieldList
185
+	 */
186
+	public function getCMSActions()
187
+	{
188
+		if (Permission::check('ADMIN') || Permission::check('EDIT_SITECONFIG')) {
189
+			$actions = new FieldList(
190
+				FormAction::create('save_siteconfig', _t('CMSMain.SAVE', 'Save'))
191
+					->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
192
+			);
193
+		} else {
194
+			$actions = new FieldList();
195
+		}
196 196
         
197
-        $this->extend('updateCMSActions', $actions);
197
+		$this->extend('updateCMSActions', $actions);
198 198
         
199
-        return $actions;
200
-    }
199
+		return $actions;
200
+	}
201 201
 
202
-    /**
203
-     * @return string
204
-     */
205
-    public function CMSEditLink()
206
-    {
207
-        return singleton('CMSSettingsController')->Link();
208
-    }
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function CMSEditLink()
206
+	{
207
+		return singleton('CMSSettingsController')->Link();
208
+	}
209 209
     
210
-    /**
211
-     * Get the current sites SiteConfig, and creates a new one through 
212
-     * {@link make_site_config()} if none is found.
213
-     *
214
-     * @return SiteConfig
215
-     */
216
-    public static function current_site_config()
217
-    {
218
-        if ($siteConfig = DataObject::get_one('SiteConfig')) {
219
-            return $siteConfig;
220
-        }
210
+	/**
211
+	 * Get the current sites SiteConfig, and creates a new one through 
212
+	 * {@link make_site_config()} if none is found.
213
+	 *
214
+	 * @return SiteConfig
215
+	 */
216
+	public static function current_site_config()
217
+	{
218
+		if ($siteConfig = DataObject::get_one('SiteConfig')) {
219
+			return $siteConfig;
220
+		}
221 221
         
222
-        return self::make_site_config();
223
-    }
222
+		return self::make_site_config();
223
+	}
224 224
 
225
-    /**
226
-     * Setup a default SiteConfig record if none exists.
227
-     */
228
-    public function requireDefaultRecords()
229
-    {
230
-        parent::requireDefaultRecords();
225
+	/**
226
+	 * Setup a default SiteConfig record if none exists.
227
+	 */
228
+	public function requireDefaultRecords()
229
+	{
230
+		parent::requireDefaultRecords();
231 231
 
232
-        $config = DataObject::get_one('SiteConfig');
232
+		$config = DataObject::get_one('SiteConfig');
233 233
         
234
-        if (!$config) {
235
-            self::make_site_config();
234
+		if (!$config) {
235
+			self::make_site_config();
236 236
 
237
-            DB::alteration_message("Added default site config", "created");
238
-        }
239
-    }
237
+			DB::alteration_message("Added default site config", "created");
238
+		}
239
+	}
240 240
     
241
-    /**
242
-     * Create SiteConfig with defaults from language file.
243
-     * 
244
-     * @return SiteConfig
245
-     */
246
-    public static function make_site_config()
247
-    {
248
-        $config = SiteConfig::create();
249
-        $config->write();
241
+	/**
242
+	 * Create SiteConfig with defaults from language file.
243
+	 * 
244
+	 * @return SiteConfig
245
+	 */
246
+	public static function make_site_config()
247
+	{
248
+		$config = SiteConfig::create();
249
+		$config->write();
250 250
 
251
-        return $config;
252
-    }
251
+		return $config;
252
+	}
253 253
 
254
-    /**
255
-     * Can a user view this SiteConfig instance?
256
-     *
257
-     * @param Member $member
258
-     * @return boolean
259
-     */
260
-    public function canView($member = null)
261
-    {
262
-        if (!$member) {
263
-            $member = Member::currentUserID();
264
-        }
265
-        if ($member && is_numeric($member)) {
266
-            $member = DataObject::get_by_id('Member', $member);
267
-        }
254
+	/**
255
+	 * Can a user view this SiteConfig instance?
256
+	 *
257
+	 * @param Member $member
258
+	 * @return boolean
259
+	 */
260
+	public function canView($member = null)
261
+	{
262
+		if (!$member) {
263
+			$member = Member::currentUserID();
264
+		}
265
+		if ($member && is_numeric($member)) {
266
+			$member = DataObject::get_by_id('Member', $member);
267
+		}
268 268
 
269
-        $extended = $this->extendedCan('canView', $member);
270
-        if ($extended !== null) {
271
-            return $extended;
272
-        }
269
+		$extended = $this->extendedCan('canView', $member);
270
+		if ($extended !== null) {
271
+			return $extended;
272
+		}
273 273
 
274
-        // Assuming all that can edit this object can also view it
275
-        return $this->canEdit($member);
276
-    }
274
+		// Assuming all that can edit this object can also view it
275
+		return $this->canEdit($member);
276
+	}
277 277
 
278
-    /**
279
-     * Can a user view pages on this site? This method is only
280
-     * called if a page is set to Inherit, but there is nothing
281
-     * to inherit from.
282
-     *
283
-     * @param Member $member
284
-     * @return boolean
285
-     */
286
-    public function canViewPages($member = null)
287
-    {
288
-        if (!$member) {
289
-            $member = Member::currentUserID();
290
-        }
291
-        if ($member && is_numeric($member)) {
292
-            $member = DataObject::get_by_id('Member', $member);
293
-        }
278
+	/**
279
+	 * Can a user view pages on this site? This method is only
280
+	 * called if a page is set to Inherit, but there is nothing
281
+	 * to inherit from.
282
+	 *
283
+	 * @param Member $member
284
+	 * @return boolean
285
+	 */
286
+	public function canViewPages($member = null)
287
+	{
288
+		if (!$member) {
289
+			$member = Member::currentUserID();
290
+		}
291
+		if ($member && is_numeric($member)) {
292
+			$member = DataObject::get_by_id('Member', $member);
293
+		}
294 294
 
295
-        if ($member && Permission::checkMember($member, "ADMIN")) {
296
-            return true;
297
-        }
295
+		if ($member && Permission::checkMember($member, "ADMIN")) {
296
+			return true;
297
+		}
298 298
 
299
-        $extended = $this->extendedCan('canViewPages', $member);
300
-        if ($extended !== null) {
301
-            return $extended;
302
-        }
299
+		$extended = $this->extendedCan('canViewPages', $member);
300
+		if ($extended !== null) {
301
+			return $extended;
302
+		}
303 303
 
304
-        if (!$this->CanViewType || $this->CanViewType == 'Anyone') {
305
-            return true;
306
-        }
304
+		if (!$this->CanViewType || $this->CanViewType == 'Anyone') {
305
+			return true;
306
+		}
307 307
                 
308
-        // check for any logged-in users
309
-        if ($this->CanViewType === 'LoggedInUsers' && $member) {
310
-            return true;
311
-        }
308
+		// check for any logged-in users
309
+		if ($this->CanViewType === 'LoggedInUsers' && $member) {
310
+			return true;
311
+		}
312 312
 
313
-        // check for specific groups
314
-        if ($this->CanViewType === 'OnlyTheseUsers' && $member && $member->inGroups($this->ViewerGroups())) {
315
-            return true;
316
-        }
313
+		// check for specific groups
314
+		if ($this->CanViewType === 'OnlyTheseUsers' && $member && $member->inGroups($this->ViewerGroups())) {
315
+			return true;
316
+		}
317 317
         
318
-        return false;
319
-    }
318
+		return false;
319
+	}
320 320
     
321
-    /**
322
-     * Can a user edit pages on this site? This method is only
323
-     * called if a page is set to Inherit, but there is nothing
324
-     * to inherit from, or on new records without a parent.
325
-     *
326
-     * @param Member $member
327
-     * @return boolean
328
-     */
329
-    public function canEditPages($member = null)
330
-    {
331
-        if (!$member) {
332
-            $member = Member::currentUserID();
333
-        }
334
-        if ($member && is_numeric($member)) {
335
-            $member = DataObject::get_by_id('Member', $member);
336
-        }
321
+	/**
322
+	 * Can a user edit pages on this site? This method is only
323
+	 * called if a page is set to Inherit, but there is nothing
324
+	 * to inherit from, or on new records without a parent.
325
+	 *
326
+	 * @param Member $member
327
+	 * @return boolean
328
+	 */
329
+	public function canEditPages($member = null)
330
+	{
331
+		if (!$member) {
332
+			$member = Member::currentUserID();
333
+		}
334
+		if ($member && is_numeric($member)) {
335
+			$member = DataObject::get_by_id('Member', $member);
336
+		}
337 337
         
338
-        if ($member && Permission::checkMember($member, "ADMIN")) {
339
-            return true;
340
-        }
338
+		if ($member && Permission::checkMember($member, "ADMIN")) {
339
+			return true;
340
+		}
341 341
 
342
-        $extended = $this->extendedCan('canEditPages', $member);
343
-        if ($extended !== null) {
344
-            return $extended;
345
-        }
342
+		$extended = $this->extendedCan('canEditPages', $member);
343
+		if ($extended !== null) {
344
+			return $extended;
345
+		}
346 346
 
347
-        // check for any logged-in users with CMS access
348
-        if ($this->CanEditType === 'LoggedInUsers'
349
-            && Permission::checkMember($member, $this->config()->required_permission)
350
-        ) {
351
-            return true;
352
-        }
347
+		// check for any logged-in users with CMS access
348
+		if ($this->CanEditType === 'LoggedInUsers'
349
+			&& Permission::checkMember($member, $this->config()->required_permission)
350
+		) {
351
+			return true;
352
+		}
353 353
 
354
-            // check for specific groups
355
-        if ($this->CanEditType === 'OnlyTheseUsers' && $member && $member->inGroups($this->EditorGroups())) {
356
-            return true;
357
-        }
354
+			// check for specific groups
355
+		if ($this->CanEditType === 'OnlyTheseUsers' && $member && $member->inGroups($this->EditorGroups())) {
356
+			return true;
357
+		}
358 358
         
359
-        return false;
360
-    }
359
+		return false;
360
+	}
361 361
 
362
-    public function canEdit($member = null)
363
-    {
364
-        if (!$member) {
365
-            $member = Member::currentUserID();
366
-        }
367
-        if ($member && is_numeric($member)) {
368
-            $member = DataObject::get_by_id('Member', $member);
369
-        }
362
+	public function canEdit($member = null)
363
+	{
364
+		if (!$member) {
365
+			$member = Member::currentUserID();
366
+		}
367
+		if ($member && is_numeric($member)) {
368
+			$member = DataObject::get_by_id('Member', $member);
369
+		}
370 370
 
371
-        $extended = $this->extendedCan('canEdit', $member);
372
-        if ($extended !== null) {
373
-            return $extended;
374
-        }
371
+		$extended = $this->extendedCan('canEdit', $member);
372
+		if ($extended !== null) {
373
+			return $extended;
374
+		}
375 375
         
376
-        return Permission::checkMember($member, "EDIT_SITECONFIG");
377
-    }
376
+		return Permission::checkMember($member, "EDIT_SITECONFIG");
377
+	}
378 378
     
379
-    /**
380
-     * @return void
381
-     */
382
-    public function providePermissions()
383
-    {
384
-        return array(
385
-            'EDIT_SITECONFIG' => array(
386
-                'name' => _t('SiteConfig.EDIT_PERMISSION', 'Manage site configuration'),
387
-                'category' => _t('Permissions.PERMISSIONS_CATEGORY', 'Roles and access permissions'),
388
-                'help' => _t('SiteConfig.EDIT_PERMISSION_HELP', 'Ability to edit global access settings/top-level page permissions.'),
389
-                'sort' => 400
390
-            )
391
-        );
392
-    }
379
+	/**
380
+	 * @return void
381
+	 */
382
+	public function providePermissions()
383
+	{
384
+		return array(
385
+			'EDIT_SITECONFIG' => array(
386
+				'name' => _t('SiteConfig.EDIT_PERMISSION', 'Manage site configuration'),
387
+				'category' => _t('Permissions.PERMISSIONS_CATEGORY', 'Roles and access permissions'),
388
+				'help' => _t('SiteConfig.EDIT_PERMISSION_HELP', 'Ability to edit global access settings/top-level page permissions.'),
389
+				'sort' => 400
390
+			)
391
+		);
392
+	}
393 393
     
394
-    /**
395
-     * Can a user create pages in the root of this site?
396
-     *
397
-     * @param Member $member
398
-     * @return boolean
399
-     */
400
-    public function canCreateTopLevel($member = null)
401
-    {
402
-        if (!$member) {
403
-            $member = Member::currentUserID();
404
-        }
405
-        if ($member && is_numeric($member)) {
406
-            $member = DataObject::get_by_id('Member', $member);
407
-        }
394
+	/**
395
+	 * Can a user create pages in the root of this site?
396
+	 *
397
+	 * @param Member $member
398
+	 * @return boolean
399
+	 */
400
+	public function canCreateTopLevel($member = null)
401
+	{
402
+		if (!$member) {
403
+			$member = Member::currentUserID();
404
+		}
405
+		if ($member && is_numeric($member)) {
406
+			$member = DataObject::get_by_id('Member', $member);
407
+		}
408 408
         
409
-        if ($member && Permission::checkMember($member, "ADMIN")) {
410
-            return true;
411
-        }
409
+		if ($member && Permission::checkMember($member, "ADMIN")) {
410
+			return true;
411
+		}
412 412
 
413
-        $extended = $this->extendedCan('canCreateTopLevel', $member);
414
-        if ($extended !== null) {
415
-            return $extended;
416
-        }
413
+		$extended = $this->extendedCan('canCreateTopLevel', $member);
414
+		if ($extended !== null) {
415
+			return $extended;
416
+		}
417 417
         
418
-        // check for any logged-in users with CMS permission
419
-        if ($this->CanCreateTopLevelType === 'LoggedInUsers'
420
-            && Permission::checkMember($member, $this->config()->required_permission)
421
-        ) {
422
-            return true;
423
-        }
418
+		// check for any logged-in users with CMS permission
419
+		if ($this->CanCreateTopLevelType === 'LoggedInUsers'
420
+			&& Permission::checkMember($member, $this->config()->required_permission)
421
+		) {
422
+			return true;
423
+		}
424 424
         
425
-        // check for specific groups
426
-        if ($this->CanCreateTopLevelType === 'OnlyTheseUsers'
427
-            && $member
428
-            && $member->inGroups($this->CreateTopLevelGroups())
429
-        ) {
430
-            return true;
431
-        }
425
+		// check for specific groups
426
+		if ($this->CanCreateTopLevelType === 'OnlyTheseUsers'
427
+			&& $member
428
+			&& $member->inGroups($this->CreateTopLevelGroups())
429
+		) {
430
+			return true;
431
+		}
432 432
 
433
-        return false;
434
-    }
433
+		return false;
434
+	}
435 435
 
436
-    /**
437
-     * Add $SiteConfig to all SSViewers
438
-     */
439
-    public static function get_template_global_variables()
440
-    {
441
-        return array(
442
-            'SiteConfig' => 'current_site_config',
443
-        );
444
-    }
436
+	/**
437
+	 * Add $SiteConfig to all SSViewers
438
+	 */
439
+	public static function get_template_global_variables()
440
+	{
441
+		return array(
442
+			'SiteConfig' => 'current_site_config',
443
+		);
444
+	}
445 445
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
             $fields->makeFieldReadonly($titleField);
142 142
         }
143 143
 
144
-        if (file_exists(BASE_PATH . '/install.php')) {
144
+        if (file_exists(BASE_PATH.'/install.php')) {
145 145
             $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader",
146
-                "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING",
146
+                "<p class=\"message warning\">"._t("SiteTree.REMOVE_INSTALL_WARNING",
147 147
                 "Warning: You should remove install.php from this SilverStripe install for security reasons.")
148 148
                 . "</p>"), "Title");
149 149
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     public function getAvailableThemes($baseDir = null)
166 166
     {
167 167
         $themes = SSViewer::get_themes($baseDir);
168
-        $disabled = (array)$this->config()->disabled_themes;
168
+        $disabled = (array) $this->config()->disabled_themes;
169 169
     
170 170
         foreach ($disabled as $theme) {
171 171
             if (isset($themes[$theme])) {
Please login to merge, or discard this patch.
tests/SiteConfigTest.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -6,92 +6,92 @@
 block discarded – undo
6 6
  */
7 7
 class SiteConfigTest extends SapphireTest
8 8
 {
9
-    protected static $fixture_file = 'SiteConfigTest.yml';
9
+	protected static $fixture_file = 'SiteConfigTest.yml';
10 10
     
11
-    protected $illegalExtensions = array(
12
-        'SiteTree' => array('SiteTreeSubsites')
13
-    );
11
+	protected $illegalExtensions = array(
12
+		'SiteTree' => array('SiteTreeSubsites')
13
+	);
14 14
 
15
-    public function setUpOnce()
16
-    {
17
-        // Fix issue with tests failing without CMS module
18
-        if (!class_exists('SiteTree')) {
19
-            unset($this->illegalExtensions['SiteTree']);
20
-        }
15
+	public function setUpOnce()
16
+	{
17
+		// Fix issue with tests failing without CMS module
18
+		if (!class_exists('SiteTree')) {
19
+			unset($this->illegalExtensions['SiteTree']);
20
+		}
21 21
 
22
-        parent::setUpOnce(); // TODO: Change the autogenerated stub
23
-    }
22
+		parent::setUpOnce(); // TODO: Change the autogenerated stub
23
+	}
24 24
 
25
-    public function testAvailableThemes()
26
-    {
27
-        $config = $this->objFromFixture('SiteConfig', 'default');
28
-        $ds = DIRECTORY_SEPARATOR;
29
-        $testThemeBaseDir = TEMP_FOLDER . $ds . 'test-themes';
25
+	public function testAvailableThemes()
26
+	{
27
+		$config = $this->objFromFixture('SiteConfig', 'default');
28
+		$ds = DIRECTORY_SEPARATOR;
29
+		$testThemeBaseDir = TEMP_FOLDER . $ds . 'test-themes';
30 30
         
31
-        if (file_exists($testThemeBaseDir)) {
32
-            Filesystem::removeFolder($testThemeBaseDir);
33
-        }
34
-        mkdir($testThemeBaseDir);
35
-        mkdir($testThemeBaseDir . $ds . 'blackcandy');
36
-        mkdir($testThemeBaseDir . $ds . 'blackcandy_blog');
37
-        mkdir($testThemeBaseDir . $ds . 'darkshades');
38
-        mkdir($testThemeBaseDir . $ds . 'darkshades_blog');
31
+		if (file_exists($testThemeBaseDir)) {
32
+			Filesystem::removeFolder($testThemeBaseDir);
33
+		}
34
+		mkdir($testThemeBaseDir);
35
+		mkdir($testThemeBaseDir . $ds . 'blackcandy');
36
+		mkdir($testThemeBaseDir . $ds . 'blackcandy_blog');
37
+		mkdir($testThemeBaseDir . $ds . 'darkshades');
38
+		mkdir($testThemeBaseDir . $ds . 'darkshades_blog');
39 39
         
40
-        $themes = $config->getAvailableThemes($testThemeBaseDir);
41
-        $this->assertContains('blackcandy', $themes, 'Test themes contain blackcandy theme');
42
-        $this->assertContains('darkshades', $themes, 'Test themes contain darkshades theme');
40
+		$themes = $config->getAvailableThemes($testThemeBaseDir);
41
+		$this->assertContains('blackcandy', $themes, 'Test themes contain blackcandy theme');
42
+		$this->assertContains('darkshades', $themes, 'Test themes contain darkshades theme');
43 43
         
44
-        SiteConfig::config()->disabled_themes = array('darkshades');
45
-        $themes = $config->getAvailableThemes($testThemeBaseDir);
46
-        $this->assertFalse(in_array('darkshades', $themes), 'Darkshades was disabled - it is no longer available');
44
+		SiteConfig::config()->disabled_themes = array('darkshades');
45
+		$themes = $config->getAvailableThemes($testThemeBaseDir);
46
+		$this->assertFalse(in_array('darkshades', $themes), 'Darkshades was disabled - it is no longer available');
47 47
         
48
-        Filesystem::removeFolder($testThemeBaseDir);
49
-    }
48
+		Filesystem::removeFolder($testThemeBaseDir);
49
+	}
50 50
 
51
-    public function testCanCreateRootPages()
52
-    {
53
-        $config = $this->objFromFixture('SiteConfig', 'default');
51
+	public function testCanCreateRootPages()
52
+	{
53
+		$config = $this->objFromFixture('SiteConfig', 'default');
54 54
 
55
-        // Log in without pages admin access
56
-        $this->logInWithPermission('CMS_ACCESS_AssetAdmin');
57
-        $this->assertFalse($config->canCreateTopLevel());
55
+		// Log in without pages admin access
56
+		$this->logInWithPermission('CMS_ACCESS_AssetAdmin');
57
+		$this->assertFalse($config->canCreateTopLevel());
58 58
 
59
-        // Login with necessary edit permission
60
-        $perms = SiteConfig::config()->required_permission;
61
-        $this->logInWithPermission(reset($perms));
62
-        $this->assertTrue($config->canCreateTopLevel());
63
-    }
59
+		// Login with necessary edit permission
60
+		$perms = SiteConfig::config()->required_permission;
61
+		$this->logInWithPermission(reset($perms));
62
+		$this->assertTrue($config->canCreateTopLevel());
63
+	}
64 64
 
65
-    public function testCanViewPages()
66
-    {
67
-        $config = $this->objFromFixture('SiteConfig', 'default');
68
-        $this->assertTrue($config->canViewPages());
69
-    }
65
+	public function testCanViewPages()
66
+	{
67
+		$config = $this->objFromFixture('SiteConfig', 'default');
68
+		$this->assertTrue($config->canViewPages());
69
+	}
70 70
 
71
-    public function testCanEdit()
72
-    {
73
-        $config = $this->objFromFixture('SiteConfig', 'default');
71
+	public function testCanEdit()
72
+	{
73
+		$config = $this->objFromFixture('SiteConfig', 'default');
74 74
         
75
-        // Unrelated permissions don't allow siteconfig
76
-        $this->logInWithPermission('CMS_ACCESS_AssetAdmin');
77
-        $this->assertFalse($config->canEdit());
75
+		// Unrelated permissions don't allow siteconfig
76
+		$this->logInWithPermission('CMS_ACCESS_AssetAdmin');
77
+		$this->assertFalse($config->canEdit());
78 78
 
79
-        // Only those with edit permission can do this
80
-        $this->logInWithPermission('EDIT_SITECONFIG');
81
-        $this->assertTrue($config->canEdit());
82
-    }
79
+		// Only those with edit permission can do this
80
+		$this->logInWithPermission('EDIT_SITECONFIG');
81
+		$this->assertTrue($config->canEdit());
82
+	}
83 83
 
84
-    public function testCanEditPages()
85
-    {
86
-        $config = $this->objFromFixture('SiteConfig', 'default');
84
+	public function testCanEditPages()
85
+	{
86
+		$config = $this->objFromFixture('SiteConfig', 'default');
87 87
         
88
-        // Log in without pages admin access
89
-        $this->logInWithPermission('CMS_ACCESS_AssetAdmin');
90
-        $this->assertFalse($config->canEditPages());
88
+		// Log in without pages admin access
89
+		$this->logInWithPermission('CMS_ACCESS_AssetAdmin');
90
+		$this->assertFalse($config->canEditPages());
91 91
 
92
-        // Login with necessary edit permission
93
-        $perms = SiteConfig::config()->required_permission;
94
-        $this->logInWithPermission(reset($perms));
95
-        $this->assertTrue($config->canEditPages());
96
-    }
92
+		// Login with necessary edit permission
93
+		$perms = SiteConfig::config()->required_permission;
94
+		$this->logInWithPermission(reset($perms));
95
+		$this->assertTrue($config->canEditPages());
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@
 block discarded – undo
26 26
     {
27 27
         $config = $this->objFromFixture('SiteConfig', 'default');
28 28
         $ds = DIRECTORY_SEPARATOR;
29
-        $testThemeBaseDir = TEMP_FOLDER . $ds . 'test-themes';
29
+        $testThemeBaseDir = TEMP_FOLDER.$ds.'test-themes';
30 30
         
31 31
         if (file_exists($testThemeBaseDir)) {
32 32
             Filesystem::removeFolder($testThemeBaseDir);
33 33
         }
34 34
         mkdir($testThemeBaseDir);
35
-        mkdir($testThemeBaseDir . $ds . 'blackcandy');
36
-        mkdir($testThemeBaseDir . $ds . 'blackcandy_blog');
37
-        mkdir($testThemeBaseDir . $ds . 'darkshades');
38
-        mkdir($testThemeBaseDir . $ds . 'darkshades_blog');
35
+        mkdir($testThemeBaseDir.$ds.'blackcandy');
36
+        mkdir($testThemeBaseDir.$ds.'blackcandy_blog');
37
+        mkdir($testThemeBaseDir.$ds.'darkshades');
38
+        mkdir($testThemeBaseDir.$ds.'darkshades_blog');
39 39
         
40 40
         $themes = $config->getAvailableThemes($testThemeBaseDir);
41 41
         $this->assertContains('blackcandy', $themes, 'Test themes contain blackcandy theme');
Please login to merge, or discard this patch.