Passed
Branch master (16e4c5)
by Robbie
04:28
created
code/CwpSolrConfigStore.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
  * Uploads configuration to Solr via the PHP proxy CWP uses to filter requests
7 7
  */
8 8
 class CwpSolrConfigStore implements SolrConfigStore {
9
-       function __construct($config) {
10
-               $options = Solr::solr_options();
9
+	   function __construct($config) {
10
+			   $options = Solr::solr_options();
11 11
 
12
-               $this->url = implode('', array(
13
-                       'http://',
14
-                       isset($config['auth']) ? $config['auth'].'@' : '',
15
-                       $options['host'] . ':' . $options['port'],
16
-                       $config['path']
17
-               ));
18
-               $this->remote = $config['remotepath'];
19
-       }
12
+			   $this->url = implode('', array(
13
+					   'http://',
14
+					   isset($config['auth']) ? $config['auth'].'@' : '',
15
+					   $options['host'] . ':' . $options['port'],
16
+					   $config['path']
17
+			   ));
18
+			   $this->remote = $config['remotepath'];
19
+	   }
20 20
 
21
-       function uploadFile($index, $file) {
22
-               $this->uploadString($index, basename($file), file_get_contents($file));
23
-       }
21
+	   function uploadFile($index, $file) {
22
+			   $this->uploadString($index, basename($file), file_get_contents($file));
23
+	   }
24 24
 
25
-       function uploadString($index, $filename, $string) {
26
-               $targetDir = "{$this->url}/config/$index";
25
+	   function uploadString($index, $filename, $string) {
26
+			   $targetDir = "{$this->url}/config/$index";
27 27
 
28
-               file_get_contents($targetDir.'/'.$filename, false, stream_context_create(array('http' => array(
29
-                       'method' => 'POST',
30
-                       'header' => 'Content-type: application/octet-stream',
31
-                       'content' => (string)$string
32
-               ))));
33
-       }
28
+			   file_get_contents($targetDir.'/'.$filename, false, stream_context_create(array('http' => array(
29
+					   'method' => 'POST',
30
+					   'header' => 'Content-type: application/octet-stream',
31
+					   'content' => (string)$string
32
+			   ))));
33
+	   }
34 34
 
35
-       function instanceDir($index) {
36
-               return $this->remote ? "{$this->remote}/$index" : $index;
37
-       }
35
+	   function instanceDir($index) {
36
+			   return $this->remote ? "{$this->remote}/$index" : $index;
37
+	   }
38 38
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
                $this->url = implode('', array(
13 13
                        'http://',
14
-                       isset($config['auth']) ? $config['auth'].'@' : '',
14
+                       isset($config['auth']) ? $config['auth'] . '@' : '',
15 15
                        $options['host'] . ':' . $options['port'],
16 16
                        $config['path']
17 17
                ));
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
        function uploadString($index, $filename, $string) {
26 26
                $targetDir = "{$this->url}/config/$index";
27 27
 
28
-               file_get_contents($targetDir.'/'.$filename, false, stream_context_create(array('http' => array(
28
+               file_get_contents($targetDir . '/' . $filename, false, stream_context_create(array('http' => array(
29 29
                        'method' => 'POST',
30 30
                        'header' => 'Content-type: application/octet-stream',
31 31
                        'content' => (string)$string
Please login to merge, or discard this patch.
code/model/CwpSearchIndex.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 	public function init() {
34 34
 		// Add optional boost
35
-		if(SiteTree::has_extension('CwpSearchBoostExtension')) {
35
+		if (SiteTree::has_extension('CwpSearchBoostExtension')) {
36 36
 			$this->setFieldBoosting('SiteTree_SearchBoost', SiteTree::config()->search_boost);
37 37
 		}
38 38
 	}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 		// Upload configured synonyms {@see SynonymsSiteConfig}
49 49
 		$siteConfig = SiteConfig::current_site_config();
50
-		if($siteConfig->SearchSynonyms) {
50
+		if ($siteConfig->SearchSynonyms) {
51 51
 			$store->uploadString(
52 52
 				$this->getIndexName(),
53 53
 				'synonyms.txt',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 	public function search(SearchQuery $query, $offset = -1, $limit = -1, $params = array()) {
67 67
 		// Override dictionary if given
68
-		if($dictionary = $this->config()->dictionary) {
68
+		if ($dictionary = $this->config()->dictionary) {
69 69
 			$params["spellcheck.dictionary"] = $dictionary;
70 70
 		}
71 71
 		
Please login to merge, or discard this patch.
code/extensions/CwpSecurity.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 		// This step is necessary in cases such as automatic redirection where a user is authenticated
16 16
 		// upon landing on an SSL secured site and is automatically logged in, or some other case
17 17
 		// where the user has permissions to continue but is not given the option.
18
-		if($this->owner->getRequest()->requestVar('BackURL')
18
+		if ($this->owner->getRequest()->requestVar('BackURL')
19 19
 			&& !Session::get('Security.Message.message')
20 20
 			&& ($member = Member::currentUser())
21 21
 			&& $member->exists()
Please login to merge, or discard this patch.
code/extensions/LoginAttemptNotifications.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@
 block discarded – undo
12 12
 
13 13
 		// Exclude default admin.
14 14
 		$member = Member::currentUser();
15
-		if (!$member || !$member->ID) return;
15
+		if (!$member || !$member->ID) {
16
+			return;
17
+		}
16 18
 
17 19
 		$message = null;
18 20
 
Please login to merge, or discard this patch.
code/extensions/RichLinksExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 		preg_match_all('/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U', $content, $matches);
25 25
 
26 26
 		// Attach the file type and size to each of the links.
27
-		for ($i = 0; $i < count($matches[0]); $i++){
27
+		for ($i = 0; $i < count($matches[0]); $i++) {
28 28
 			$file = DataObject::get_by_id('File', $matches[1][$i]);
29 29
 			if ($file) {
30 30
 				$size = $file->getSize();
Please login to merge, or discard this patch.
code/extensions/CwpControllerExtension.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 
100 100
 			$relativeURL = Director::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI']));
101 101
 
102
-			foreach($allowed as $pattern) {
102
+			foreach ($allowed as $pattern) {
103 103
 				$allowWithoutAuth = $allowWithoutAuth || preg_match($pattern, $relativeURL);
104 104
 			}
105 105
 		}
106 106
 
107 107
 		// Finally if they weren't allowed to bypass Basic Auth, trigger it
108 108
 		if (!$allowWithoutAuth) {
109
-			$this->callWithSubsitesDisabled(function(){
109
+			$this->callWithSubsitesDisabled(function() {
110 110
 				BasicAuth::requireLogin(
111 111
 					_t('Cwp.LoginPrompt', "Please log in with your CMS credentials"), 
112 112
 					'ACCESS_UAT_SERVER', 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
 		if (Config::inst()->get('CwpControllerExtension', 'ssl_redirection_enabled')) {
124 124
 			// redirect some vulnerable areas to the secure domain
125
-			if(!$director::is_https()) {
125
+			if (!$director::is_https()) {
126 126
 				$forceDomain = Config::inst()->get('CwpControllerExtension', 'ssl_redirection_force_domain');
127 127
 
128 128
 				if ($forceDomain) {
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 
136 136
 		if (Config::inst()->get('CwpControllerExtension', 'test_basicauth_enabled')) {
137 137
 			// Turn on Basic Auth in testing mode
138
-			if($director::isTest()) $this->triggerBasicAuthProtection();
138
+			if ($director::isTest()) $this->triggerBasicAuthProtection();
139 139
 		}
140 140
 
141 141
 		if (Config::inst()->get('CwpControllerExtension', 'live_basicauth_enabled')) {
142 142
 			// Turn on Basic Auth in live mode
143
-			if($director::isLive()) $this->triggerBasicAuthProtection();
143
+			if ($director::isLive()) $this->triggerBasicAuthProtection();
144 144
 		}
145 145
 	}
146 146
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -43,15 +43,20 @@  discard block
 block discarded – undo
43 43
 		$rv = null;
44 44
 
45 45
 		try {
46
-			if (class_exists('Subsite')) Subsite::disable_subsite_filter(true);
46
+			if (class_exists('Subsite')) {
47
+				Subsite::disable_subsite_filter(true);
48
+			}
47 49
 			$rv = call_user_func($callback);
48
-		}
49
-		catch (Exception $e) {
50
-			if (class_exists('Subsite')) Subsite::disable_subsite_filter(false);
50
+		} catch (Exception $e) {
51
+			if (class_exists('Subsite')) {
52
+				Subsite::disable_subsite_filter(false);
53
+			}
51 54
 			throw $e;
52 55
 		}
53 56
 
54
-		if (class_exists('Subsite')) Subsite::disable_subsite_filter(false);
57
+		if (class_exists('Subsite')) {
58
+			Subsite::disable_subsite_filter(false);
59
+		}
55 60
 		return $rv;
56 61
 	}
57 62
 
@@ -77,12 +82,12 @@  discard block
 block discarded – undo
77 82
 		// First, see if we can get a member to act on, either from a changepassword token or the session
78 83
 		if (isset($_REQUEST['m']) && isset($_REQUEST['t'])) {
79 84
 			$member = Member::get()->filter('ID', (int)$_REQUEST['m'])->First();
80
-			if (!$member->validateAutoLoginToken($_REQUEST['t'])) $member = null;
81
-		}
82
-		else if (Session::get('AutoLoginHash')) {
85
+			if (!$member->validateAutoLoginToken($_REQUEST['t'])) {
86
+				$member = null;
87
+			}
88
+		} else if (Session::get('AutoLoginHash')) {
83 89
 			$member = Member::member_from_autologinhash(Session::get('AutoLoginHash'));
84
-		}
85
-		else {
90
+		} else {
86 91
 			$member = Member::currentUser();
87 92
 		}
88 93
 
@@ -135,12 +140,16 @@  discard block
 block discarded – undo
135 140
 
136 141
 		if (Config::inst()->get('CwpControllerExtension', 'test_basicauth_enabled')) {
137 142
 			// Turn on Basic Auth in testing mode
138
-			if($director::isTest()) $this->triggerBasicAuthProtection();
143
+			if($director::isTest()) {
144
+				$this->triggerBasicAuthProtection();
145
+			}
139 146
 		}
140 147
 
141 148
 		if (Config::inst()->get('CwpControllerExtension', 'live_basicauth_enabled')) {
142 149
 			// Turn on Basic Auth in live mode
143
-			if($director::isLive()) $this->triggerBasicAuthProtection();
150
+			if($director::isLive()) {
151
+				$this->triggerBasicAuthProtection();
152
+			}
144 153
 		}
145 154
 	}
146 155
 
Please login to merge, or discard this patch.
code/CwpSolr.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 	 * * 'local-4': this can be use for development using silverstripe-localsolr package, 4.x branch
19 19
 	 */
20 20
 	static function configure() {
21
-		if(!class_exists('Solr')) return;
21
+		if (!class_exists('Solr')) return;
22 22
 
23 23
 		// get options from configuration
24 24
 		$options = Config::inst()->get('CwpSolr', 'options');
25 25
 
26 26
 		// get version specific options
27
-		switch($options['version']) {
27
+		switch ($options['version']) {
28 28
 			case 'cwp-4':
29 29
 				$solrOptions = self::options_for_cwp($options);
30 30
 				break;
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 		// CAUTION: CWP does not permit usage of customised solrconfig.xml.
46 46
 		if (isset($options['extraspath']) && file_exists($options['extraspath'])) {
47 47
 			$solrOptions['extraspath'] = $options['extraspath'];
48
-		} elseif (file_exists(BASE_PATH.'/mysite/conf/extras')) {
49
-			$solrOptions['extraspath'] = BASE_PATH.'/mysite/conf/extras';
48
+		} elseif (file_exists(BASE_PATH . '/mysite/conf/extras')) {
49
+			$solrOptions['extraspath'] = BASE_PATH . '/mysite/conf/extras';
50 50
 		}
51 51
 
52 52
 		Solr::configure_server($solrOptions);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@
 block discarded – undo
18 18
 	 * * 'local-4': this can be use for development using silverstripe-localsolr package, 4.x branch
19 19
 	 */
20 20
 	static function configure() {
21
-		if(!class_exists('Solr')) return;
21
+		if(!class_exists('Solr')) {
22
+			return;
23
+		}
22 24
 
23 25
 		// get options from configuration
24 26
 		$options = Config::inst()->get('CwpSolr', 'options');
Please login to merge, or discard this patch.
code/CwpInitialisationFilter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 
27 27
 		if (Config::inst()->get('CwpInitialisationFilter', 'egress_proxy_default_enabled')) {
28 28
 
29
-			if(defined('SS_OUTBOUND_PROXY') && defined('SS_OUTBOUND_PROXY_PORT')) {
29
+			if (defined('SS_OUTBOUND_PROXY') && defined('SS_OUTBOUND_PROXY_PORT')) {
30 30
 				putenv('http_proxy=' . SS_OUTBOUND_PROXY . ':' . SS_OUTBOUND_PROXY_PORT);
31 31
 				putenv('https_proxy=' . SS_OUTBOUND_PROXY . ':' . SS_OUTBOUND_PROXY_PORT);
32 32
 			}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@
 block discarded – undo
35 35
 
36 36
 		$noProxy = Config::inst()->get('CwpInitialisationFilter', 'egress_proxy_exclude_domains');
37 37
 		if (!empty($noProxy)) {
38
-			if (!is_array($noProxy)) $noProxy = array($noProxy);
38
+			if (!is_array($noProxy)) {
39
+				$noProxy = array($noProxy);
40
+			}
39 41
 
40 42
 			// Merge with exsiting if needed.
41 43
 			if (getenv('NO_PROXY')) {
Please login to merge, or discard this patch.
code/CwpStatsReport.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 				'Versioned.stage' => 'Live'
39 39
 			);
40 40
 
41
-			if(class_exists('Translatable')) {
41
+			if (class_exists('Translatable')) {
42 42
 				$params[Translatable::QUERY_LOCALE_FILTER_ENABLED] = false;
43 43
 			}
44 44
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 				->count()
56 56
 		);
57 57
 
58
-		if(class_exists('Subsite')) {
58
+		if (class_exists('Subsite')) {
59 59
 			// Main site.
60 60
 			$records[] = array(
61 61
 				'Name' => _t('CwpStatsReport.PagesForMainSite', '- in the main site'),
Please login to merge, or discard this patch.