Passed
Push — develop ( 09225f...2749c8 )
by Dylan
02:47
created
code/admin/SEOToolboxAdmin.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class SEOToolboxAdmin extends ModelAdmin{
13 13
 	
14
-	private static $menu_title      = 'SEO Tool box';
15
-	private static $url_segment     = 'seo-tool-box';
16
-	private static $managed_models  = array( 'AutomatedLink' );
14
+    private static $menu_title      = 'SEO Tool box';
15
+    private static $url_segment     = 'seo-tool-box';
16
+    private static $managed_models  = array( 'AutomatedLink' );
17 17
     private static $menu_priority   = 10;
18 18
 
19 19
 
20
-	public function getEditForm($id = null, $fields = null) {
21
-		$form = parent::getEditForm( $id, $fields );
22
-		$class = $this->sanitiseClassName($this->modelClass);
23
-		$grid   = $form->Fields()->fieldByName($class);
24
-		$grid->getConfig()->addComponent( new GridFieldSortableRows( 'Priority' ) );
20
+    public function getEditForm($id = null, $fields = null) {
21
+        $form = parent::getEditForm( $id, $fields );
22
+        $class = $this->sanitiseClassName($this->modelClass);
23
+        $grid   = $form->Fields()->fieldByName($class);
24
+        $grid->getConfig()->addComponent( new GridFieldSortableRows( 'Priority' ) );
25 25
 		
26
-		return $form;
27
-	}
26
+        return $form;
27
+    }
28 28
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@
 block discarded – undo
9 9
  * all the automated links and automated link global settings
10 10
  * for this site
11 11
  */
12
-class SEOToolboxAdmin extends ModelAdmin{
12
+class SEOToolboxAdmin extends ModelAdmin {
13 13
 	
14 14
 	private static $menu_title      = 'SEO Tool box';
15 15
 	private static $url_segment     = 'seo-tool-box';
16
-	private static $managed_models  = array( 'AutomatedLink' );
17
-    private static $menu_priority   = 10;
16
+	private static $managed_models  = array('AutomatedLink');
17
+    private static $menu_priority = 10;
18 18
 
19 19
 
20 20
 	public function getEditForm($id = null, $fields = null) {
21
-		$form = parent::getEditForm( $id, $fields );
21
+		$form = parent::getEditForm($id, $fields);
22 22
 		$class = $this->sanitiseClassName($this->modelClass);
23
-		$grid   = $form->Fields()->fieldByName($class);
24
-		$grid->getConfig()->addComponent( new GridFieldSortableRows( 'Priority' ) );
23
+		$grid = $form->Fields()->fieldByName($class);
24
+		$grid->getConfig()->addComponent(new GridFieldSortableRows('Priority'));
25 25
 		
26 26
 		return $form;
27 27
 	}
Please login to merge, or discard this patch.
_config.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@
 block discarded – undo
33 33
  * to view this report.
34 34
  */
35 35
 
36
-define( 'SEOTOOLBOX_DIR', str_replace( Director::baseFolder().'/', '', __DIR__ ) );
36
+define('SEOTOOLBOX_DIR', str_replace(Director::baseFolder().'/', '', __DIR__));
37 37
 
38 38
 Config::inst()->update('SEOToolboxAdmin', 'menu_icon', SEOTOOLBOX_DIR.'/code/admin/icon/seotoolbox-icon.png');
39
-Config::inst()->update('LeftAndMain','extra_requirements_javascript', array(SEOTOOLBOX_DIR.'/js/seo_page_analyzer.js'));
40
-Config::inst()->update('LeftAndMain','extra_requirements_css', array(SEOTOOLBOX_DIR.'/css/seo_page_analyzer.css'));
39
+Config::inst()->update('LeftAndMain', 'extra_requirements_javascript', array(SEOTOOLBOX_DIR.'/js/seo_page_analyzer.js'));
40
+Config::inst()->update('LeftAndMain', 'extra_requirements_css', array(SEOTOOLBOX_DIR.'/css/seo_page_analyzer.css'));
41 41
 
42 42
 CMSMenu::add_link('seotest', 'Run Crawler', '/seotest', 9, array('target' => '_blank'));
43 43
 Requirements::customCSS('.icon.icon-16.icon-seotest{background:url('.SEOTOOLBOX_DIR.'/code/admin/icon/crawl-icon.png)}');
Please login to merge, or discard this patch.
code/dataobjects/AutomatedLink.php 3 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -66,133 +66,133 @@
 block discarded – undo
66 66
     }
67 67
 
68 68
     function providePermissions() {
69
-       return array(
70
-         'AUTOMATEDLINK_VIEW'   => 'View Automated Links',
71
-         'AUTOMATEDLINK_EDIT'   => 'Edit Automated Links',
72
-         'AUTOMATEDLINK_DELETE' => 'Delete Automated Links',
73
-         'AUTOMATEDLINK_CREATE' => 'Create Automated Links',
74
-       );
75
-     }
76
-
77
-	public function requireDefaultRecords(){
78
-		parent::requireDefaultRecords();
79
-
80
-		// Update all links to redirector pages during dev/build
81
-		foreach( self::get() as $link ) {
82
-		    $link->CheckAndUpdateDestination( true );
83
-		}
84
-	}
85
-
86
-	/**
87
-	 * Returns the HTML Representation of this object
88
-	 *
69
+        return array(
70
+            'AUTOMATEDLINK_VIEW'   => 'View Automated Links',
71
+            'AUTOMATEDLINK_EDIT'   => 'Edit Automated Links',
72
+            'AUTOMATEDLINK_DELETE' => 'Delete Automated Links',
73
+            'AUTOMATEDLINK_CREATE' => 'Create Automated Links',
74
+        );
75
+        }
76
+
77
+    public function requireDefaultRecords(){
78
+        parent::requireDefaultRecords();
79
+
80
+        // Update all links to redirector pages during dev/build
81
+        foreach( self::get() as $link ) {
82
+            $link->CheckAndUpdateDestination( true );
83
+        }
84
+    }
85
+
86
+    /**
87
+     * Returns the HTML Representation of this object
88
+     *
89 89
      * @param  String $originalPhrase
90
-	 * @return String
91
-	 */
92
-	public function getHTML($originalPhrase = NULL) {
93
-		$link     = ($this->PageID) ? $this->Page()->Link() : '#';
94
-		$title    = ($this->TitleTag) ? "title='{$this->TitleTag}'" : '';
95
-		$nofollow = ($this->NoFollow) ? 'rel="nofollow"' : '';
96
-		$newtab   = ($this->NewWindow) ? 'target="_blank"' : '';
90
+     * @return String
91
+     */
92
+    public function getHTML($originalPhrase = NULL) {
93
+        $link     = ($this->PageID) ? $this->Page()->Link() : '#';
94
+        $title    = ($this->TitleTag) ? "title='{$this->TitleTag}'" : '';
95
+        $nofollow = ($this->NoFollow) ? 'rel="nofollow"' : '';
96
+        $newtab   = ($this->NewWindow) ? 'target="_blank"' : '';
97 97
         $anchor = ($originalPhrase) ? $originalPhrase : $this->Phrase;
98
-		$link     = ($this->AnchorTag) ? rtrim($link, '#').'#'.$this->AnchorTag : $link;
99
-		return "<a href=\"$link\" $title $nofollow $newtab data-id=\"{$this->ID}\">{$anchor}</a>";
100
-	}
101
-
102
-	public function getCMSFields() {
103
-		$fields = FieldList::create(TabSet::create('Root'));
104
-
105
-		$fields->addFieldsToTab('Root.LinkSettings', array(
106
-			TextField::create('Phrase', 'Phrase to search for', $this->Phrase, 255),
107
-			TextField::create('TitleTag', 'Title Tag', $this->TitleTag, 255),
108
-			TextField::create('AnchorTag', 'Anchor Tag(#)', $this->AnchorTag, 255),
109
-			FieldGroup::create(
110
-				CheckboxField::create('NoFollow'),
111
-				CheckboxField::create('NewWindow'),
112
-				CheckboxField::create('SelfLinking', 'Allow page to link to itself'),
113
-				CheckboxField::create('CaseSensitive', 'Match the case of the phrase')
114
-			),
115
-			NumericField::create('MaxLinksPerPage', 'Maximum amount of this link to be created on a single page( 0 = unlimited )'),
116
-			TreeDropdownField::create('PageID', 'Page to link to', 'SiteTree')
117
-		));
118
-
119
-		$settings = GlobalAutoLinkSettings::get_current();
120
-		if ($settings) {
121
-			$fields->addFieldsToTab('Root.Global', array(
122
-				NumericField::create(
123
-					'Global_MaxLinksPerPage',
124
-					'Maximum amount of links a single page can have ( 0 = unlimited )',
125
-					$settings->MaxLinksPerPage
126
-				),
127
-				TextField::create(
128
-					'Global_ExcludeTags',
129
-					'Do not include links into these HTML Tags ( comma seperated )',
130
-					$settings->ExcludeTags
131
-				),
132
-				TextField::create(
133
-				    'Global_AddTo',
134
-				    'Page types where links should be created in ( leave blank for all page types )',
135
-				    $settings->AddTo ),
136
-				TextField::create(
137
-					'Global_IncludeIn',
138
-					'Include Links into these fields ( comma seperated & field must support html injection )',
139
-					$settings->IncludeIn
140
-				)
141
-			));
142
-		}
143
-
144
-		return $fields;
145
-	}
98
+        $link     = ($this->AnchorTag) ? rtrim($link, '#').'#'.$this->AnchorTag : $link;
99
+        return "<a href=\"$link\" $title $nofollow $newtab data-id=\"{$this->ID}\">{$anchor}</a>";
100
+    }
101
+
102
+    public function getCMSFields() {
103
+        $fields = FieldList::create(TabSet::create('Root'));
104
+
105
+        $fields->addFieldsToTab('Root.LinkSettings', array(
106
+            TextField::create('Phrase', 'Phrase to search for', $this->Phrase, 255),
107
+            TextField::create('TitleTag', 'Title Tag', $this->TitleTag, 255),
108
+            TextField::create('AnchorTag', 'Anchor Tag(#)', $this->AnchorTag, 255),
109
+            FieldGroup::create(
110
+                CheckboxField::create('NoFollow'),
111
+                CheckboxField::create('NewWindow'),
112
+                CheckboxField::create('SelfLinking', 'Allow page to link to itself'),
113
+                CheckboxField::create('CaseSensitive', 'Match the case of the phrase')
114
+            ),
115
+            NumericField::create('MaxLinksPerPage', 'Maximum amount of this link to be created on a single page( 0 = unlimited )'),
116
+            TreeDropdownField::create('PageID', 'Page to link to', 'SiteTree')
117
+        ));
118
+
119
+        $settings = GlobalAutoLinkSettings::get_current();
120
+        if ($settings) {
121
+            $fields->addFieldsToTab('Root.Global', array(
122
+                NumericField::create(
123
+                    'Global_MaxLinksPerPage',
124
+                    'Maximum amount of links a single page can have ( 0 = unlimited )',
125
+                    $settings->MaxLinksPerPage
126
+                ),
127
+                TextField::create(
128
+                    'Global_ExcludeTags',
129
+                    'Do not include links into these HTML Tags ( comma seperated )',
130
+                    $settings->ExcludeTags
131
+                ),
132
+                TextField::create(
133
+                    'Global_AddTo',
134
+                    'Page types where links should be created in ( leave blank for all page types )',
135
+                    $settings->AddTo ),
136
+                TextField::create(
137
+                    'Global_IncludeIn',
138
+                    'Include Links into these fields ( comma seperated & field must support html injection )',
139
+                    $settings->IncludeIn
140
+                )
141
+            ));
142
+        }
143
+
144
+        return $fields;
145
+    }
146 146
 
147 147
     public function getCMSValidator() {
148 148
         return new RequiredFields(array('Phrase', 'PageID'));
149 149
     }
150 150
 
151
-	/**
152
-	 * Save the Global Settings into the
153
-	 * Global Auto Link Settings Object
154
-	 *
155
-	 * @return void
156
-	 */
157
-	public function onBeforeWrite() {
158
-		parent::onBeforeWrite();
159
-
160
-		$settings = GlobalAutoLinkSettings::get_current();
161
-		if ($settings) {
162
-
163
-			foreach ($this->getChangedFields() as $field => $value) {
164
-				if (strpos($field, 'Global_') === 0 && isset($value['after'])) {
165
-					$field = str_replace('Global_', '', $field);
166
-					$settings->$field = $value['after'];
167
-				}
168
-			}
169
-
170
-			$settings->write();
171
-		}
172
-
173
-		$this->CheckAndUpdateDestination();
174
-	}
175
-
176
-	/**
177
-	 * Checks if the destination is a redirector page if so
178
-	 * it updates it to the destination of the redirector page
179
-	 *
180
-	 * @Boolean $write - Write the changes if any
181
-	 * @return void
182
-	 */
183
-	public function CheckAndUpdateDestination( $write = false ){
184
-		$this->extend('beforeCheckAndUpdateDestination', $write);
185
-
186
-		if( $this->PageID && $this->Page() &&
187
-			$this->Page()->ClassName == 'RedirectorPage' &&
188
-			$this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal' )
189
-		{
190
-			$this->PageID = $this->Page()->LinkToID;
191
-			if( $write ) {
192
-			    $this->write();
193
-			}
194
-		}
195
-	}
151
+    /**
152
+     * Save the Global Settings into the
153
+     * Global Auto Link Settings Object
154
+     *
155
+     * @return void
156
+     */
157
+    public function onBeforeWrite() {
158
+        parent::onBeforeWrite();
159
+
160
+        $settings = GlobalAutoLinkSettings::get_current();
161
+        if ($settings) {
162
+
163
+            foreach ($this->getChangedFields() as $field => $value) {
164
+                if (strpos($field, 'Global_') === 0 && isset($value['after'])) {
165
+                    $field = str_replace('Global_', '', $field);
166
+                    $settings->$field = $value['after'];
167
+                }
168
+            }
169
+
170
+            $settings->write();
171
+        }
172
+
173
+        $this->CheckAndUpdateDestination();
174
+    }
175
+
176
+    /**
177
+     * Checks if the destination is a redirector page if so
178
+     * it updates it to the destination of the redirector page
179
+     *
180
+     * @Boolean $write - Write the changes if any
181
+     * @return void
182
+     */
183
+    public function CheckAndUpdateDestination( $write = false ){
184
+        $this->extend('beforeCheckAndUpdateDestination', $write);
185
+
186
+        if( $this->PageID && $this->Page() &&
187
+            $this->Page()->ClassName == 'RedirectorPage' &&
188
+            $this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal' )
189
+        {
190
+            $this->PageID = $this->Page()->LinkToID;
191
+            if( $write ) {
192
+                $this->write();
193
+            }
194
+        }
195
+    }
196 196
 
197 197
     /**
198 198
      * Checks if the field is parable
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -31,37 +31,37 @@  discard block
 block discarded – undo
31 31
         'Page' => 'SiteTree'
32 32
     );
33 33
 
34
-    private static $summary_fields    = array( 'Phrase', 'PointsTo' );
35
-    private static $searchable_fields = array( 'Phrase' );
36
-    private static $singular_name	  = 'Automated Link';
34
+    private static $summary_fields    = array('Phrase', 'PointsTo');
35
+    private static $searchable_fields = array('Phrase');
36
+    private static $singular_name = 'Automated Link';
37 37
     private static $plural_name	      = 'Automated Links';
38 38
     private static $parsableFields    = array();
39 39
 
40
-    public function PointsTo(){
40
+    public function PointsTo() {
41 41
         return $this->Page()->Link();
42 42
     }
43 43
 
44
-    public function Title(){
44
+    public function Title() {
45 45
         return $this->Phrase;
46 46
     }
47 47
 
48
-    public function forTemplate(){
48
+    public function forTemplate() {
49 49
         return $this->getHTML();
50 50
     }
51 51
 
52
-    function canView( $member = false ){
52
+    function canView($member = false) {
53 53
         return Permission::check('AUTOMATEDLINK_VIEW');
54 54
     }
55 55
 
56
-    function canEdit( $member = false ){
56
+    function canEdit($member = false) {
57 57
         return Permission::check('AUTOMATEDLINK_EDIT');
58 58
     }
59 59
 
60
-    function canDelete( $member = false ){
60
+    function canDelete($member = false) {
61 61
         return Permission::check('AUTOMATEDLINK_DELETE');
62 62
     }
63 63
 
64
-    function canCreate( $member = false ){
64
+    function canCreate($member = false) {
65 65
         return Permission::check('AUTOMATEDLINK_CREATE');
66 66
     }
67 67
 
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
        );
75 75
      }
76 76
 
77
-	public function requireDefaultRecords(){
77
+	public function requireDefaultRecords() {
78 78
 		parent::requireDefaultRecords();
79 79
 
80 80
 		// Update all links to redirector pages during dev/build
81
-		foreach( self::get() as $link ) {
82
-		    $link->CheckAndUpdateDestination( true );
81
+		foreach (self::get() as $link) {
82
+		    $link->CheckAndUpdateDestination(true);
83 83
 		}
84 84
 	}
85 85
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 	 * @Boolean $write - Write the changes if any
181 181
 	 * @return void
182 182
 	 */
183
-	public function CheckAndUpdateDestination( $write = false ){
183
+	public function CheckAndUpdateDestination($write = false) {
184 184
 		$this->extend('beforeCheckAndUpdateDestination', $write);
185 185
 
186
-		if( $this->PageID && $this->Page() &&
186
+		if ($this->PageID && $this->Page() &&
187 187
 			$this->Page()->ClassName == 'RedirectorPage' &&
188
-			$this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal' )
188
+			$this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal')
189 189
 		{
190 190
 			$this->PageID = $this->Page()->LinkToID;
191
-			if( $write ) {
191
+			if ($write) {
192 192
 			    $this->write();
193 193
 			}
194 194
 		}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      *
225 225
      * @return Boolean
226 226
      */
227
-    public function canBeAdded( ContentController $controller ){
228
-        return ( $this->SelfLinking || $controller->ID != $this->PageID );
227
+    public function canBeAdded(ContentController $controller) {
228
+        return ($this->SelfLinking || $controller->ID != $this->PageID);
229 229
     }
230 230
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -206,8 +206,9 @@
 block discarded – undo
206 206
         if (!isset(self::$parsableFields[$page->ID]) || !isset(self::$parsableFields[$page->ID][$field])) {
207 207
             $fields = array();
208 208
 
209
-            foreach (ClassInfo::ancestry($page->ClassName, true) as $class)
210
-                $fields = array_merge($fields, (array) DataObject::database_fields($class));
209
+            foreach (ClassInfo::ancestry($page->ClassName, true) as $class) {
210
+                            $fields = array_merge($fields, (array) DataObject::database_fields($class));
211
+            }
211 212
 
212 213
             self::$parsableFields[$page->ID][$field] =
213 214
                 (Boolean) array_key_exists($field, $fields) && strtolower($fields[$field]) === 'htmltext' && $page->$field;
Please login to merge, or discard this patch.
code/dataobjects/AutomatedLinkPageResult.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public static function add_or_update(SiteTree $page) {
54 54
         $obj = self::get()->find('PageID', $page->ID);
55
-        if (!$obj) $obj = self::create(array('PageID' => $page->ID));
55
+        if (!$obj) {
56
+            $obj = self::create(array('PageID' => $page->ID));
57
+        }
56 58
 
57 59
         $obj->OriginalLinkCount = $page->OriginalLinkCount;
58 60
         $obj->LinksCreatedCount = $page->LinkCount;
@@ -68,6 +70,8 @@  discard block
 block discarded – undo
68 70
      * @return void
69 71
      */
70 72
     public static function remove_old_data() {
71
-        foreach (self::get() as $obj) if (!SiteTree::get()->byID($obj->PageID)) $obj->delete();
73
+        foreach (self::get() as $obj) {
74
+            if (!SiteTree::get()->byID($obj->PageID)) $obj->delete();
75
+        }
72 76
     }
73 77
 }
Please login to merge, or discard this patch.
code/dataobjects/GlobalAutoLinkSettings.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class GlobalAutoLinkSettings extends DataObject{
12 12
 
13
-	public static $enabled  = true;
13
+    public static $enabled  = true;
14 14
     public static $encoding = 'UTF-8';
15 15
 
16
-	private static $db = array(
17
-		'MaxLinksPerPage' => 'INT',
18
-		'ExcludeTags'	  => 'VARCHAR(255)',
19
-		'IncludeIn'		  => 'Text',
20
-		'AddTo'           => 'Text',
16
+    private static $db = array(
17
+        'MaxLinksPerPage' => 'INT',
18
+        'ExcludeTags'	  => 'VARCHAR(255)',
19
+        'IncludeIn'		  => 'Text',
20
+        'AddTo'           => 'Text',
21 21
         'CrawlID'         => 'VARCHAR(15)'
22
-	);
22
+    );
23 23
 
24
-	private static $defaults = array(
25
-		'IncludeIn' => 'Content'
26
-	);
24
+    private static $defaults = array(
25
+        'IncludeIn' => 'Content'
26
+    );
27 27
 
28 28
     public static $default_create_config = array(
29 29
         'MaxLinksPerPage' => 0,
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
         'IncludeIn'		  => 'Content'
32 32
     );
33 33
 
34
-	public function ExcludeTags(){
35
-		return array_unique( explode( ',', str_replace( ' ', '', $this->ExcludeTags ).',a,img,iframe,video,object' ) );
36
-	}
34
+    public function ExcludeTags(){
35
+        return array_unique( explode( ',', str_replace( ' ', '', $this->ExcludeTags ).',a,img,iframe,video,object' ) );
36
+    }
37 37
 
38
-	public function IncludeInFields(){
39
-		return explode( ',', str_replace( ' ', '', $this->IncludeIn ) );
40
-	}
38
+    public function IncludeInFields(){
39
+        return explode( ',', str_replace( ' ', '', $this->IncludeIn ) );
40
+    }
41 41
 
42 42
     public function requireDefaultRecords() {
43 43
         $hasData = self::get()->first();
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@  discard block
 block discarded – undo
61 61
         $alpha = 'abcdefghijklm[)0123456789(]nopqrstuvwxyz';
62 62
         $alpha_len = strlen($alpha);
63 63
 
64
-        while (strlen($ret) < 14)
65
-            $ret .= (rand(0, 1) == 0) ? strtoupper($alpha[rand(0, $alpha_len-1)]) : $alpha[rand(0, $alpha_len-1)];
64
+        while (strlen($ret) < 14) {
65
+                    $ret .= (rand(0, 1) == 0) ? strtoupper($alpha[rand(0, $alpha_len-1)]) : $alpha[rand(0, $alpha_len-1)];
66
+        }
66 67
 
67 68
         return $ret;
68 69
     }
@@ -77,7 +78,9 @@  discard block
 block discarded – undo
77 78
      */
78 79
         public function AllowedIn(){
79 80
         $classes = array_values( ClassInfo::subclassesFor( 'SiteTree' ) );
80
-        if( !$this->AddTo ) return $classes;
81
+        if( !$this->AddTo ) {
82
+            return $classes;
83
+        }
81 84
 
82 85
         $sanitized = explode( ',', str_replace( ' ', '', strtolower( $this->AddTo ) ) );
83 86
 
@@ -92,7 +95,9 @@  discard block
 block discarded – undo
92 95
                 }
93 96
             }
94 97
 
95
-            if( !$found ) unset( $sanitized[$x] );
98
+            if( !$found ) {
99
+                unset( $sanitized[$x] );
100
+            }
96 101
         }
97 102
 
98 103
         return (array) $sanitized;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
  * on dev/build and contains all the global settings for the
9 9
  * automated links
10 10
  */
11
-class GlobalAutoLinkSettings extends DataObject{
11
+class GlobalAutoLinkSettings extends DataObject {
12 12
 
13
-	public static $enabled  = true;
13
+	public static $enabled = true;
14 14
     public static $encoding = 'UTF-8';
15 15
 
16 16
 	private static $db = array(
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return array
38 38
      */
39
-	public function ExcludeTags(){
40
-		return array_unique( explode( ',', str_replace( ' ', '', $this->ExcludeTags ).',a,img,iframe,video,object' ) );
39
+	public function ExcludeTags() {
40
+		return array_unique(explode(',', str_replace(' ', '', $this->ExcludeTags).',a,img,iframe,video,object'));
41 41
 	}
42 42
 
43 43
     /**
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @return array
47 47
      */
48
-	public function IncludeInFields(){
49
-		return explode( ',', str_replace( ' ', '', $this->IncludeIn ) );
48
+	public function IncludeInFields() {
49
+		return explode(',', str_replace(' ', '', $this->IncludeIn));
50 50
 	}
51 51
 
52 52
     public function requireDefaultRecords() {
53 53
         $hasData = self::get()->first();
54
-        if(!$hasData) {
54
+        if (!$hasData) {
55 55
             $obj = self::create(self::$default_create_config);
56 56
             $obj->CrawlID = $this->createCrawlID();
57 57
             $obj->write();
58
-            DB::alteration_message("Added default Global Auto Link Settings","created");
59
-        } else{
60
-            if(!$hasData->CrawlID){
58
+            DB::alteration_message("Added default Global Auto Link Settings", "created");
59
+        }else {
60
+            if (!$hasData->CrawlID) {
61 61
                 $hasData->CrawlID = $this->createCrawlID();
62 62
                 $hasData->write();
63 63
             }
@@ -90,24 +90,24 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return array
92 92
      */
93
-        public function AllowedIn(){
94
-        $classes = array_values( ClassInfo::subclassesFor( 'SiteTree' ) );
95
-        if( !$this->AddTo ) return $classes;
93
+        public function AllowedIn() {
94
+        $classes = array_values(ClassInfo::subclassesFor('SiteTree'));
95
+        if (!$this->AddTo) return $classes;
96 96
 
97
-        $sanitized = explode( ',', str_replace( ' ', '', strtolower( $this->AddTo ) ) );
97
+        $sanitized = explode(',', str_replace(' ', '', strtolower($this->AddTo)));
98 98
 
99
-        for( $x = 0; $x < count( $sanitized ); $x++ ){
99
+        for ($x = 0; $x < count($sanitized); $x++) {
100 100
             $found = false;
101 101
 
102
-            foreach( $classes as $class ){
103
-                if( strtolower( $class ) === $sanitized[$x] ){
102
+            foreach ($classes as $class) {
103
+                if (strtolower($class) === $sanitized[$x]) {
104 104
                     $sanitized[$x] = $class;
105 105
                     $found = true;
106 106
                     break 1;
107 107
                 }
108 108
             }
109 109
 
110
-            if( !$found ) unset( $sanitized[$x] );
110
+            if (!$found) unset($sanitized[$x]);
111 111
         }
112 112
 
113 113
         return (array) $sanitized;
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( $params, $sort, $limit ){
37
-        if( !Config::inst()->get( $this->class, 'run_in_realtime' ) ) {
36
+    public function sourceRecords($params, $sort, $limit) {
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/controllers/SEOTestSiteTreeController.php 2 patches
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.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,21 +17,29 @@  discard block
 block discarded – undo
17 17
         parent::init();
18 18
 
19 19
         // Check user is logged in and has permission to access to SEO Toolbox Admin
20
-        if (!Member::currentUser()) return $this->redirect(Security::login_url().'?BackURL=/seotest');
21
-        if (!Permission::check('CMS_ACCESS_SEOToolboxAdmin')) return $this->redirect(self::getPermissionDeniedPage()->Link());
20
+        if (!Member::currentUser()) {
21
+            return $this->redirect(Security::login_url().'?BackURL=/seotest');
22
+        }
23
+        if (!Permission::check('CMS_ACCESS_SEOToolboxAdmin')) {
24
+            return $this->redirect(self::getPermissionDeniedPage()->Link());
25
+        }
22 26
 
23 27
         Requirements::clear();
24 28
 
25 29
         // Sprite Location needs to be dynamic as devs can install module in different locations
26 30
         $sprite_path = $this->config()->get('sprite_path');
27
-        if ($sprite_path === null) $sprite_path = SEOTOOLBOX_DIR.'/css/icons/icon_sprite.png';
31
+        if ($sprite_path === null) {
32
+            $sprite_path = SEOTOOLBOX_DIR.'/css/icons/icon_sprite.png';
33
+        }
28 34
         Requirements::customCSS(".icon{width:16px;height: 16px;cursor:pointer;background: url(/{$sprite_path});}");
29 35
 
30 36
         // CSS can be replaced by devs if they desire to change styling
31 37
         Requirements::css(SEOTOOLBOX_DIR.'/third-party/bootstrap/css/bootstrap.min.css');
32 38
         Requirements::css(SEOTOOLBOX_DIR.'/third-party/bootstrap/css/bootstrap-theme.min.css');
33 39
         $css = $this->config()->get('css');
34
-        if ($css === null) $css = array(SEOTOOLBOX_DIR.'/fonts/lato/lato.css', SEOTOOLBOX_DIR.'/css/seotest.css');
40
+        if ($css === null) {
41
+            $css = array(SEOTOOLBOX_DIR.'/fonts/lato/lato.css', SEOTOOLBOX_DIR.'/css/seotest.css');
42
+        }
35 43
         Requirements::combine_files('seotest.css', $css);
36 44
 
37 45
         Requirements::combine_files('seotest.js', array(
@@ -120,8 +128,9 @@  discard block
 block discarded – undo
120 128
                 $phrases = array_merge($phrases, $matches[$commands['find_pos']]);
121 129
             }
122 130
 
123
-            if (isset($commands['replace']))
124
-                $html = preg_replace($commands['replace'], ' ', $html);
131
+            if (isset($commands['replace'])) {
132
+                            $html = preg_replace($commands['replace'], ' ', $html);
133
+            }
125 134
         }
126 135
 
127 136
         // Remove the empty elements
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.