Passed
Push — master ( af9096...2fcfd9 )
by Dylan
02:48
created
code/controllers/SEOTestSiteTreeController.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -148,47 +148,47 @@
 block discarded – undo
148 148
     /**
149 149
      * @param string $data
150 150
      */
151
-    private function getHTMLFieldsData($data){
151
+    private function getHTMLFieldsData($data) {
152 152
         preg_match_all('/\[\*\*\[(.*?)\]\*\*\[(.*?)\]\*\*\]/im', $data, $matches);
153
-        foreach( $matches[2] as $key => $field_text ){
153
+        foreach ($matches[2] as $key => $field_text) {
154 154
             $matches[2][$key] = base64_decode($field_text);
155 155
             $matches[3][$key] = preg_replace('/[\s]+/mu', ' ', strip_tags($matches[2][$key]));
156 156
         }
157 157
         return $matches;
158 158
     }
159 159
 
160
-    public function loadPage($url, $agent=null){
160
+    public function loadPage($url, $agent = null) {
161 161
         $crawl_id = GlobalAutoLinkSettings::get_current()->CrawlID;
162 162
         $ch = curl_init();
163
-        curl_setopt( $ch, CURLOPT_URL, Director::absoluteBaseURL().'/'.$url );
164
-        curl_setopt( $ch, CURLOPT_HEADER, true );
165
-        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
166
-        curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
167
-        curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
168
-        curl_setopt( $ch, CURLOPT_USERAGENT, $agent );
169
-        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 );
170
-        curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
171
-        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
172
-        curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'X-Crawl-Id: '.$crawl_id ) );
173
-        $data = curl_exec( $ch );
163
+        curl_setopt($ch, CURLOPT_URL, Director::absoluteBaseURL().'/'.$url);
164
+        curl_setopt($ch, CURLOPT_HEADER, true);
165
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
166
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
167
+        curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
168
+        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
169
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
170
+        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
171
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
172
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Crawl-Id: '.$crawl_id));
173
+        $data = curl_exec($ch);
174 174
 
175 175
         $fetched        = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL), PHP_URL_PATH);
176
-        $header_size    = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
177
-        $header 	    = explode( "\r\n\r\n", substr( $data, 0, $header_size ) );
178
-        array_pop( $header ); // Remove last element as it will always be empty
179
-        $header = array_pop( $header );
180
-        $body   = preg_replace('/[\s]+/mu', ' ', substr( $data, $header_size ));
176
+        $header_size    = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
177
+        $header = explode("\r\n\r\n", substr($data, 0, $header_size));
178
+        array_pop($header); // Remove last element as it will always be empty
179
+        $header = array_pop($header);
180
+        $body   = preg_replace('/[\s]+/mu', ' ', substr($data, $header_size));
181 181
 
182
-        curl_close( $ch );
182
+        curl_close($ch);
183 183
 
184
-        if( !strpos( $header, ' 200 ' ) ) {
185
-            return array( 'headers' => false, 'body' => false );
184
+        if (!strpos($header, ' 200 ')) {
185
+            return array('headers' => false, 'body' => false);
186 186
         }
187 187
 
188 188
         $field_data = $this->getHTMLFieldsData($body);
189 189
         $body = str_replace($field_data[0], $field_data[2], $body);
190 190
 
191
-        return array( 'headers' => $header, 'body' => $body, 'field_data' => $field_data, 'url_fetched' => $fetched );
191
+        return array('headers' => $header, 'body' => $body, 'field_data' => $field_data, 'url_fetched' => $fetched);
192 192
     }
193 193
 
194 194
     /**
Please login to merge, or discard this patch.
code/logic/GridFieldExportAllAutomatedLinksButton.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,29 +3,29 @@
 block discarded – undo
3 3
     class GridFieldExportAllAutomatedLinksButton extends GridFieldExportButton {
4 4
         public function generateExportFileData($gridField) {
5 5
             $separator = $this->csvSeparator;
6
-            $csvColumns =$gridField->getColumns();
6
+            $csvColumns = $gridField->getColumns();
7 7
             $fileData = '';
8
-            if($this->csvHasHeader) {
8
+            if ($this->csvHasHeader) {
9 9
                 $headers = array();
10
-                foreach($csvColumns as $columnSource => $columnHeader) {
10
+                foreach ($csvColumns as $columnSource => $columnHeader) {
11 11
                     $headers[] = (!is_string($columnHeader) && is_callable($columnHeader)) ? $columnSource : $columnHeader;
12 12
                 }
13
-                $fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
13
+                $fileData .= "\"".implode("\"{$separator}\"", array_values($headers))."\"";
14 14
                 $fileData .= "\n";
15 15
             }
16 16
             $items = $gridField->getList();
17 17
 
18
-            foreach($gridField->getConfig()->getComponents() as $component){
19
-                if($component instanceof GridFieldFilterHeader || $component instanceof GridFieldSortableHeader) {
18
+            foreach ($gridField->getConfig()->getComponents() as $component) {
19
+                if ($component instanceof GridFieldFilterHeader || $component instanceof GridFieldSortableHeader) {
20 20
                     $items = $component->getManipulatedData($gridField, $items);
21 21
                 }
22 22
             }
23
-            foreach($items->limit(null) as $item) {
23
+            foreach ($items->limit(null) as $item) {
24 24
                 $columnData = array();
25
-                foreach($csvColumns as $columnSource => $columnHeader) {
26
-                    $value = ( $item->hasMethod( $columnHeader ) ) ? $item->$columnHeader() : $item->$columnHeader;
25
+                foreach ($csvColumns as $columnSource => $columnHeader) {
26
+                    $value = ($item->hasMethod($columnHeader)) ? $item->$columnHeader() : $item->$columnHeader;
27 27
                     $value = str_replace(array("\r", "\n"), "\n", $value);
28
-                    $columnData[] = '"' . str_replace('"', '\"', $value) . '"';
28
+                    $columnData[] = '"'.str_replace('"', '\"', $value).'"';
29 29
                 }
30 30
                 $fileData .= implode($separator, $columnData);
31 31
                 $fileData .= "\n";
Please login to merge, or discard this patch.
code/logic/GridFieldPrintAllAutomatedLinksButton.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
         public function generatePrintData(GridField $gridField) {
5 5
             $printColumns = $this->getPrintColumnsForGridField($gridField);
6 6
             $header = null;
7
-            if($this->printHasHeader) {
7
+            if ($this->printHasHeader) {
8 8
                 $header = new ArrayList();
9
-                foreach($printColumns as $field => $label){
9
+                foreach ($printColumns as $field => $label) {
10 10
                     $header->push(new ArrayData(array(
11 11
                         "CellString" => $label,
12 12
                         )));
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
             $items = $gridField->getList();
17 17
             $itemRows = new ArrayList();
18
-            foreach($items as $item) {
18
+            foreach ($items as $item) {
19 19
                 $itemRow = new ArrayList();
20
-                foreach($printColumns as $field => $label) {
20
+                foreach ($printColumns as $field => $label) {
21 21
                     $value = $gridField->getDataFieldValue($item, $field);
22 22
                     $itemRow->push(new ArrayData(array(
23 23
                         "CellString" => $value,
Please login to merge, or discard this patch.
code/extenstions/SEOToolboxControllerExtension.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
     private $excludeTags    = array();
19 19
     private $maxLinks       = 0;
20 20
 
21
-    public function index(){
21
+    public function index() {
22 22
         $this->addAutomatedLinks();
23 23
 
24 24
         // If we have a crawl request check the CrawlID so we're sure we didn't hit another SS site running our module
25
-        if( $crawl_id = $this->owner->request->getHeader('X-Crawl-Id') ){
26
-            return( $crawl_id == GlobalAutoLinkSettings::get_current()->CrawlID )
25
+        if ($crawl_id = $this->owner->request->getHeader('X-Crawl-Id')) {
26
+            return($crawl_id == GlobalAutoLinkSettings::get_current()->CrawlID)
27 27
                 ? $this->crawl_response()
28 28
                 : $this->owner->redirect(SEOTestSiteTreeController::getPermissionDeniedPage()->Link());
29 29
         }
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
         return array();
32 32
     }
33 33
 
34
-    private function crawl_response(){
34
+    private function crawl_response() {
35 35
         // Encoded version to detect which fields are being used
36 36
         $customize = array();
37 37
         $dbFields  = Config::inst()->get($this->owner->ClassName, 'db');
38
-        if(is_array($dbFields)) {
39
-            foreach ( $dbFields as $field => $type) {
38
+        if (is_array($dbFields)) {
39
+            foreach ($dbFields as $field => $type) {
40 40
                 if (strtolower($type) == 'htmltext') {
41 41
                     $data = ($this->owner->hasMethod($field)) ? $this->owner->$field() : $this->owner->$field;
42
-                    if($data){
42
+                    if ($data) {
43 43
                         $tmp = new HTMLText('tmp');
44 44
                         $tmp->setValue($data);
45 45
                         $data = base64_encode($tmp->forTemplate());
@@ -90,31 +90,31 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return void
92 92
      */
93
-    public function addAutomatedLinks(){
94
-        if( GlobalAutoLinkSettings::$enabled && $this->owner->class != 'RedirectorPage' ) {
93
+    public function addAutomatedLinks() {
94
+        if (GlobalAutoLinkSettings::$enabled && $this->owner->class != 'RedirectorPage') {
95 95
             $this->getSettings();
96
-            if( !$this->addLinks ) {
96
+            if (!$this->addLinks) {
97 97
                 return;
98 98
             }
99 99
 
100
-            foreach( $this->getSettings()->IncludeInFields() as $field ){
100
+            foreach ($this->getSettings()->IncludeInFields() as $field) {
101 101
                 // Check that the field provided by user exists in this object, is of type HTMLText and has content
102
-                if( AutomatedLink::isFieldParsable( $this->owner->data(), $field ) ){
102
+                if (AutomatedLink::isFieldParsable($this->owner->data(), $field)) {
103 103
 
104 104
                     // Create dummy object so we can parse the HTML
105
-                    $dummy = new HTMLText( $field );
106
-                    $dummy->setValue( $this->owner->$field );
105
+                    $dummy = new HTMLText($field);
106
+                    $dummy->setValue($this->owner->$field);
107 107
                     // Create DOMDocument Object
108
-                    $content = mb_convert_encoding( $dummy->forTemplate(), 'html-entities', GlobalAutoLinkSettings::$encoding );
108
+                    $content = mb_convert_encoding($dummy->forTemplate(), 'html-entities', GlobalAutoLinkSettings::$encoding);
109 109
                     $dom = AutomatedLink::constructDOMDocument($content);
110 110
 
111 111
                     // Check current link count and if it's already exceeded do nothing
112
-                    $this->linkCount += (int) $dom->getElementsByTagName( 'a' )->length;
113
-                    if( $this->linkCount >= $this->maxLinks ) {
112
+                    $this->linkCount += (int) $dom->getElementsByTagName('a')->length;
113
+                    if ($this->linkCount >= $this->maxLinks) {
114 114
                         return;
115 115
                     }
116 116
 
117
-                    $parsed = $this->parseField( $dom, $field );
117
+                    $parsed = $this->parseField($dom, $field);
118 118
                     $this->owner->data()->$field = $parsed;
119 119
                     $this->owner->$field         = $parsed;
120 120
                 }
@@ -129,71 +129,71 @@  discard block
 block discarded – undo
129 129
      * @param String $field
130 130
      * @return string
131 131
      */
132
-    private function parseField( DOMDocument $html, $field ){
133
-        $this->owner->extend( 'beforeParseField', $html, $field );
132
+    private function parseField(DOMDocument $html, $field) {
133
+        $this->owner->extend('beforeParseField', $html, $field);
134 134
 
135 135
         // Remove Tags from Content we wown't be using
136 136
         $excluded = array();
137
-        foreach( $this->excludeTags as $eTag ){
138
-            while( $tags = $html->getElementsByTagName( $eTag ) ){
139
-                if( !$tags->length ) break 1;
140
-                $tag	= $tags->item(0);
141
-                $value  = $html->saveHTML( $tag );
142
-                $key    = (string) crc32( $value );
137
+        foreach ($this->excludeTags as $eTag) {
138
+            while ($tags = $html->getElementsByTagName($eTag)) {
139
+                if (!$tags->length) break 1;
140
+                $tag = $tags->item(0);
141
+                $value  = $html->saveHTML($tag);
142
+                $key    = (string) crc32($value);
143 143
 
144 144
                 // Convert back children nodes of this node if they were already hashed
145
-                $excluded[$key] = str_replace( array_keys( $excluded ), array_values( $excluded ), $value );
145
+                $excluded[$key] = str_replace(array_keys($excluded), array_values($excluded), $value);
146 146
 
147
-                $tag->parentNode->replaceChild( $html->createTextNode( $key ), $tag );
147
+                $tag->parentNode->replaceChild($html->createTextNode($key), $tag);
148 148
             }
149 149
         }
150 150
 
151
-        $body    = (string)$html->saveHTML( $html->getElementsByTagName('body')->item(0) );
152
-        $content = preg_replace( array( '/\<body\>/is', '/\<\/body\>/is' ), '', $body, 1 );
151
+        $body    = (string) $html->saveHTML($html->getElementsByTagName('body')->item(0));
152
+        $content = preg_replace(array('/\<body\>/is', '/\<\/body\>/is'), '', $body, 1);
153 153
 
154 154
         // Create the links
155 155
         $links = AutomatedLink::get()->sort('Priority');
156
-        foreach( $links as $link ){
156
+        foreach ($links as $link) {
157 157
             // Check if self-linking is allowed and if current pagetype is allowed
158
-            if( !$link->canBeAdded( $this->owner, $field ) ) continue;
158
+            if (!$link->canBeAdded($this->owner, $field)) continue;
159 159
 
160
-            $max    = (int) ( $link->MaxLinksPerPage > 0 ) ? $link->MaxLinksPerPage : PHP_INT_MAX;
161
-            $escape = (string) preg_quote( $link->Phrase, '/' );
162
-            $regex  = (string) ( $link->CaseSensitive ) ? "/(\b{$escape}\b)/" : "/(\b{$escape}\b)/i";
160
+            $max    = (int) ($link->MaxLinksPerPage > 0) ? $link->MaxLinksPerPage : PHP_INT_MAX;
161
+            $escape = (string) preg_quote($link->Phrase, '/');
162
+            $regex  = (string) ($link->CaseSensitive) ? "/(\b{$escape}\b)/" : "/(\b{$escape}\b)/i";
163 163
 
164 164
             // Count the matches
165
-            preg_match_all( $regex, $content, $count );
166
-            $count = ( is_array( $count ) && isset( $count[0] ) ) ? count( $count[0] ) : 0;
167
-            if( $count < 1 ) continue;
165
+            preg_match_all($regex, $content, $count);
166
+            $count = (is_array($count) && isset($count[0])) ? count($count[0]) : 0;
167
+            if ($count < 1) continue;
168 168
 
169
-            if( isset( $this->maxLinksPerPage[ $link->ID ] ) )
170
-                $max -= $this->maxLinksPerPage[ $link->ID ];
169
+            if (isset($this->maxLinksPerPage[$link->ID]))
170
+                $max -= $this->maxLinksPerPage[$link->ID];
171 171
             else
172
-                $this->maxLinksPerPage[ $link->ID ] = 0;
172
+                $this->maxLinksPerPage[$link->ID] = 0;
173 173
 
174
-            for( $x = 0; $x < $count; $x++ ){
174
+            for ($x = 0; $x < $count; $x++) {
175 175
                 // Stop adding links if we reached the link or page limit
176
-                if( $x >= $max || $this->linkCount >= $this->maxLinks ) break;
176
+                if ($x >= $max || $this->linkCount >= $this->maxLinks) break;
177 177
 
178 178
                 // Check if there is anything else to replace else stop
179
-                preg_match( $regex, $content, $match );
180
-                if( !is_array( $match ) || !count( $match ) ) break;
179
+                preg_match($regex, $content, $match);
180
+                if (!is_array($match) || !count($match)) break;
181 181
 
182
-                if( !$html = (string) $link->getHTML( $match[0] ) ) continue;
183
-                $key              = (string) crc32( $html );
184
-                $excluded[ $key ] = (string) $html;
182
+                if (!$html = (string) $link->getHTML($match[0])) continue;
183
+                $key              = (string) crc32($html);
184
+                $excluded[$key] = (string) $html;
185 185
 
186
-                $content = preg_replace( $regex, $key, $content, 1 );
186
+                $content = preg_replace($regex, $key, $content, 1);
187 187
                 $this->linkCount++;
188
-                $this->maxLinksPerPage[ $link->ID ]++;
188
+                $this->maxLinksPerPage[$link->ID]++;
189 189
             }
190 190
 
191 191
             // Stop Adding links if we reached the page limit
192
-            if( $this->linkCount >= $this->maxLinks ) break;
192
+            if ($this->linkCount >= $this->maxLinks) break;
193 193
         }
194 194
 
195 195
         // Re-add the excluded Tags
196
-        $content = str_replace( array_keys( $excluded ), array_values( $excluded ), $content );
196
+        $content = str_replace(array_keys($excluded), array_values($excluded), $content);
197 197
 
198 198
         return $content;
199 199
     }
Please login to merge, or discard this patch.
code/dataobjects/AutomatedLink.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
         'Page' => 'SiteTree'
44 44
     );
45 45
 
46
-    private static $summary_fields    = array( 'Phrase', 'PointsTo' );
47
-    private static $searchable_fields = array( 'Phrase' );
48
-    private static $singular_name	  = 'Automated Link';
46
+    private static $summary_fields    = array('Phrase', 'PointsTo');
47
+    private static $searchable_fields = array('Phrase');
48
+    private static $singular_name = 'Automated Link';
49 49
     private static $plural_name	      = 'Automated Links';
50 50
     private static $parsableFields    = array();
51 51
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @return string
56 56
      */
57
-    public function PointsTo(){
57
+    public function PointsTo() {
58 58
         return $this->Page()->Link();
59 59
     }
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      *
64 64
      * @return string
65 65
      */
66
-    public function Title(){
66
+    public function Title() {
67 67
         return $this->Phrase;
68 68
     }
69 69
 
@@ -72,23 +72,23 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return String
74 74
      */
75
-    public function forTemplate(){
75
+    public function forTemplate() {
76 76
         return $this->getHTML();
77 77
     }
78 78
 
79
-    public function canView( $member = false ){
79
+    public function canView($member = false) {
80 80
         return Permission::check('AUTOMATEDLINK_VIEW');
81 81
     }
82 82
 
83
-    public function canEdit( $member = false ){
83
+    public function canEdit($member = false) {
84 84
         return Permission::check('AUTOMATEDLINK_EDIT');
85 85
     }
86 86
 
87
-    public function canDelete( $member = false ){
87
+    public function canDelete($member = false) {
88 88
         return Permission::check('AUTOMATEDLINK_DELETE');
89 89
     }
90 90
 
91
-    public function canCreate( $member = false ){
91
+    public function canCreate($member = false) {
92 92
         return Permission::check('AUTOMATEDLINK_CREATE');
93 93
     }
94 94
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
        );
102 102
      }
103 103
 
104
-	public function requireDefaultRecords(){
104
+	public function requireDefaultRecords() {
105 105
 		parent::requireDefaultRecords();
106 106
 
107 107
 		// Update all links to redirector pages during dev/build
108
-		foreach( self::get() as $link ) {
109
-		    $link->CheckAndUpdateDestination( true );
108
+		foreach (self::get() as $link) {
109
+		    $link->CheckAndUpdateDestination(true);
110 110
 		}
111 111
 	}
112 112
 
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
 	 * @Boolean $write - Write the changes if any
208 208
 	 * @return void
209 209
 	 */
210
-	public function CheckAndUpdateDestination( $write = false ){
210
+	public function CheckAndUpdateDestination($write = false) {
211 211
 		$this->extend('beforeCheckAndUpdateDestination', $write);
212 212
 
213
-		if( $this->PageID && $this->Page() &&
213
+		if ($this->PageID && $this->Page() &&
214 214
 			$this->Page()->ClassName == 'RedirectorPage' &&
215
-			$this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal' )
215
+			$this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal')
216 216
 		{
217 217
 			$this->PageID = $this->Page()->LinkToID;
218
-			if( $write ) {
218
+			if ($write) {
219 219
 			    $this->write();
220 220
 			}
221 221
 		}
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
      * @param ContentController $controller
246 246
      * @return Boolean
247 247
      */
248
-    public function canBeAdded( ContentController $controller ){
249
-        return ( $this->SelfLinking || $controller->ID != $this->PageID );
248
+    public function canBeAdded(ContentController $controller) {
249
+        return ($this->SelfLinking || $controller->ID != $this->PageID);
250 250
     }
251 251
 
252 252
     /**
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
      * @param string $html
256 256
      * @return DOMDocument
257 257
      */
258
-    public static function constructDOMDocument($html){
259
-        if( class_exists( 'HTML5_Parser' ) ){
260
-            $html5 = HTML5_Parser::parse( $html );
261
-            if($html5 instanceof DOMNodeList){
258
+    public static function constructDOMDocument($html) {
259
+        if (class_exists('HTML5_Parser')) {
260
+            $html5 = HTML5_Parser::parse($html);
261
+            if ($html5 instanceof DOMNodeList) {
262 262
                 $dom = new DOMDocument();
263
-                while($html5->length > 0) {
263
+                while ($html5->length > 0) {
264 264
                     $dom->appendChild($html5->item(0));
265 265
                 }
266
-            }else{
266
+            }else {
267 267
                 $dom = $html5;
268 268
             }
269
-        } else{
269
+        }else {
270 270
             $dom = new DOMDocument();
271
-            $dom->loadHTML( $html );
271
+            $dom->loadHTML($html);
272 272
         }
273 273
 
274 274
         return $dom;
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
      * @param string $class
281 281
      * @return array
282 282
      */
283
-    public static function getAllDatabaseFields($class){
283
+    public static function getAllDatabaseFields($class) {
284 284
         $fields = array();
285
-        foreach (ClassInfo::ancestry($class, true) as $ancestor){
285
+        foreach (ClassInfo::ancestry($class, true) as $ancestor) {
286 286
             $fields = array_merge($fields, (array) DataObject::database_fields($ancestor));
287 287
         }
288 288
         return $fields;
Please login to merge, or discard this patch.
code/reports/AutomatedLinkReport.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * Automated Link Report is a report that lists all automated
8 8
  * links and how they affect the website
9 9
  */
10
-class AutomatedLinkReport extends SS_Report{
10
+class AutomatedLinkReport extends SS_Report {
11 11
 
12 12
     protected $title       = 'Automated Link Report';
13 13
     protected $description = 'Shows a list of all automated links and how they affect the site';
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
         );
34 34
     }
35 35
 
36
-    public function sourceRecords(){
37
-        if( !Config::inst()->get( $this->class, 'run_in_realtime' ) ) {
36
+    public function sourceRecords() {
37
+        if (!Config::inst()->get($this->class, 'run_in_realtime')) {
38 38
             return AutomatedLinkPageResult::get();
39 39
         }
40 40
 
Please login to merge, or discard this patch.
code/dataobjects/GlobalAutoLinkSettings.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @property string AddTo
15 15
  * @property string CrawlID
16 16
  */
17
-class GlobalAutoLinkSettings extends DataObject{
17
+class GlobalAutoLinkSettings extends DataObject {
18 18
 
19
-	public static $enabled  = true;
19
+	public static $enabled = true;
20 20
     public static $encoding = 'UTF-8';
21 21
 
22 22
 	private static $db = array(
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
      *
43 43
      * @return array
44 44
      */
45
-	public function ExcludeTags(){
46
-		return array_unique( explode( ',', str_replace( ' ', '', $this->ExcludeTags ).',a,img,iframe,video,object' ) );
45
+	public function ExcludeTags() {
46
+		return array_unique(explode(',', str_replace(' ', '', $this->ExcludeTags).',a,img,iframe,video,object'));
47 47
 	}
48 48
 
49 49
     /**
@@ -51,19 +51,19 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @return array
53 53
      */
54
-	public function IncludeInFields(){
55
-		return explode( ',', str_replace( ' ', '', $this->IncludeIn ) );
54
+	public function IncludeInFields() {
55
+		return explode(',', str_replace(' ', '', $this->IncludeIn));
56 56
 	}
57 57
 
58 58
     public function requireDefaultRecords() {
59 59
         $hasData = self::get()->first();
60
-        if(!$hasData) {
60
+        if (!$hasData) {
61 61
             $obj = self::create(self::$default_create_config);
62 62
             $obj->CrawlID = $this->createCrawlID();
63 63
             $obj->write();
64
-            DB::alteration_message("Added default Global Auto Link Settings","created");
65
-        } else{
66
-            if(!$hasData->CrawlID){
64
+            DB::alteration_message("Added default Global Auto Link Settings", "created");
65
+        }else {
66
+            if (!$hasData->CrawlID) {
67 67
                 $hasData->CrawlID = $this->createCrawlID();
68 68
                 $hasData->write();
69 69
             }
@@ -96,25 +96,25 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @return array
98 98
      */
99
-        public function AllowedIn(){
100
-        $classes = array_values( ClassInfo::subclassesFor( 'SiteTree' ) );
101
-        if( !$this->AddTo ) return $classes;
99
+        public function AllowedIn() {
100
+        $classes = array_values(ClassInfo::subclassesFor('SiteTree'));
101
+        if (!$this->AddTo) return $classes;
102 102
 
103
-        $sanitized = explode( ',', str_replace( ' ', '', strtolower( $this->AddTo ) ) );
103
+        $sanitized = explode(',', str_replace(' ', '', strtolower($this->AddTo)));
104 104
         $len       = count($sanitized);
105 105
 
106
-        for( $x = 0; $x < $len; $x++ ){
106
+        for ($x = 0; $x < $len; $x++) {
107 107
             $found = false;
108 108
 
109
-            foreach( $classes as $class ){
110
-                if( strtolower( $class ) === $sanitized[$x] ){
109
+            foreach ($classes as $class) {
110
+                if (strtolower($class) === $sanitized[$x]) {
111 111
                     $sanitized[$x] = $class;
112 112
                     $found = true;
113 113
                     break 1;
114 114
                 }
115 115
             }
116 116
 
117
-            if( !$found ) unset( $sanitized[$x] );
117
+            if (!$found) unset($sanitized[$x]);
118 118
         }
119 119
 
120 120
         return (array) $sanitized;
Please login to merge, or discard this patch.