Passed
Push — develop ( 09225f...2749c8 )
by Dylan
02:47
created
code/admin/SEOToolboxAdmin.php 1 patch
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.
code/dataobjects/AutomatedLink.php 2 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.
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 2 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.
code/controllers/SEOTestSiteTreeController.php 1 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/controllers/AutomatedLinkReportTask.php 1 patch
Braces   +43 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
     private static $exclude_classes = array('RedirectorPage', 'VirtualPage');
9 9
 
10 10
     public function index() {
11
-        if (!Director::is_cli()) return 'Please run this controller in CLI';
11
+        if (!Director::is_cli()) {
12
+            return 'Please run this controller in CLI';
13
+        }
12 14
 
13 15
         libxml_use_internal_errors(true);
14 16
         set_time_limit(600);
@@ -44,15 +46,23 @@  discard block
 block discarded – undo
44 46
         $exclude = Config::inst()->get($this->class, 'exclude_classes');
45 47
         $exclude = ($exclude) ? "'".implode("','", $exclude)."'" : '';
46 48
         foreach (SiteTree::get()->where("ClassName NOT IN($exclude)") as $page) {
47
-            if (!$this->checkForPossibleLinks($page, $includeInFields)) continue;
49
+            if (!$this->checkForPossibleLinks($page, $includeInFields)) {
50
+                continue;
51
+            }
48 52
             $page = $this->getLinkData($page, $includeInFields);
49
-            if (!$page) continue;
53
+            if (!$page) {
54
+                continue;
55
+            }
50 56
 
51
-            if (!$run_in_realtime) AutomatedLinkPageResult::add_or_update($page);
57
+            if (!$run_in_realtime) {
58
+                AutomatedLinkPageResult::add_or_update($page);
59
+            }
52 60
             $data->push($page);
53 61
         }
54 62
 
55
-        if (!$run_in_realtime) AutomatedLinkPageResult::remove_old_data();
63
+        if (!$run_in_realtime) {
64
+            AutomatedLinkPageResult::remove_old_data();
65
+        }
56 66
 
57 67
         return $data;
58 68
     }
@@ -70,15 +80,18 @@  discard block
 block discarded – undo
70 80
         // Set a list of all fields that can have autolinks created in them
71 81
         $page->AutomateableFields = ArrayList::create();
72 82
 
73
-        foreach ($this->getAllDatabaseFields($page->class) as $field => $type)
74
-            if (in_array($field, $includeIn) &&
83
+        foreach ($this->getAllDatabaseFields($page->class) as $field => $type) {
84
+                    if (in_array($field, $includeIn) &&
75 85
                 !$page->AutomateableFields->find('DataField', $field) &&
76 86
                 AutomatedLink::isFieldParsable($page, $field)
77 87
             ) $page->AutomateableFields->push(DataObject::create(array('DataField' => $field)));
88
+        }
78 89
 
79 90
         // Get data Pre-Automated Links creation
80 91
         $withLinks = $this->getPageDOM($page, true);
81
-        if (!$withLinks) return false;
92
+        if (!$withLinks) {
93
+            return false;
94
+        }
82 95
 
83 96
         $links = $withLinks->getElementsByTagName('a');
84 97
 
@@ -88,10 +101,11 @@  discard block
 block discarded – undo
88 101
 
89 102
         // List all automated links that were created in this $page
90 103
         $linksUsed = array();
91
-        foreach ($this->Links as $autolink)
92
-            foreach ($links as $link) {
104
+        foreach ($this->Links as $autolink) {
105
+                    foreach ($links as $link) {
93 106
                 if ($link->getAttribute('data-id') == $autolink->ID) {
94 107
                     $linksUsed[$autolink->ID] = $autolink->Phrase;
108
+        }
95 109
                     $page->OriginalLinkCount--;
96 110
                     $page->LinkCount++;
97 111
                 }
@@ -99,7 +113,9 @@  discard block
 block discarded – undo
99 113
 
100 114
         $page->Links = implode(', ', $linksUsed);
101 115
 
102
-        if ($page->LinkCount < 1) return false;
116
+        if ($page->LinkCount < 1) {
117
+            return false;
118
+        }
103 119
 
104 120
         return $page;
105 121
     }
@@ -113,8 +129,9 @@  discard block
 block discarded – undo
113 129
      */
114 130
     private function getAllDatabaseFields($class) {
115 131
         $fields = array();
116
-        foreach (ClassInfo::ancestry($class, true) as $cls)
117
-            $fields = array_merge($fields, (array) DataObject::database_fields($cls));
132
+        foreach (ClassInfo::ancestry($class, true) as $cls) {
133
+                    $fields = array_merge($fields, (array) DataObject::database_fields($cls));
134
+        }
118 135
 
119 136
         return $fields;
120 137
     }
@@ -129,8 +146,12 @@  discard block
 block discarded – undo
129 146
      */
130 147
     private function getPageDOM(SiteTree $page) {
131 148
         $controllerClass = $page->class.'_Controller';
132
-        if (!class_exists($controllerClass))  $controller = $page->class.'Controller';
133
-        if (!class_exists($controllerClass)) return false;
149
+        if (!class_exists($controllerClass)) {
150
+            $controller = $page->class.'Controller';
151
+        }
152
+        if (!class_exists($controllerClass)) {
153
+            return false;
154
+        }
134 155
 
135 156
         $controller = $controllerClass::create($page);
136 157
         $controller->invokeWithExtensions('addAutomatedLinks');
@@ -149,7 +170,9 @@  discard block
 block discarded – undo
149 170
             GlobalAutoLinkSettings::$encoding
150 171
         );
151 172
 
152
-        if (!$content) return false;
173
+        if (!$content) {
174
+            return false;
175
+        }
153 176
 
154 177
         if( class_exists( 'HTML5_Parser' ) ){
155 178
             $html5 = HTML5_Parser::parse( $content );
@@ -158,7 +181,7 @@  discard block
 block discarded – undo
158 181
                 while($html5->length > 0) {
159 182
                     $dom->appendChild($html5->item(0));
160 183
                 }
161
-            }else{
184
+            } else{
162 185
                 $dom = $html5;
163 186
             }
164 187
         } else{
@@ -178,9 +201,10 @@  discard block
 block discarded – undo
178 201
      * @return Boolean
179 202
      */
180 203
     private function checkForPossibleLinks(SiteTree $page, array $includeIn) {
181
-        foreach ($this->Links as $link)
182
-            foreach ($includeIn as $possibleField)
204
+        foreach ($this->Links as $link) {
205
+                    foreach ($includeIn as $possibleField)
183 206
                 if (isset($page->$possibleField) && preg_match("/\b{$link->Phrase}\b/i", $page->$possibleField)) return true;
207
+        }
184 208
 
185 209
         return false;
186 210
     }
Please login to merge, or discard this patch.
code/extenstions/SEOToolboxControllerExtension.php 1 patch
Braces   +33 added lines, -14 removed lines patch added patch discarded remove patch
@@ -73,12 +73,16 @@  discard block
 block discarded – undo
73 73
     private function getSettings() {
74 74
         if ($this->settings === null) {
75 75
             $this->settings = GlobalAutoLinkSettings::get_current();
76
-            if (!$this->settings) return $this->addLinks = false;
76
+            if (!$this->settings) {
77
+                return $this->addLinks = false;
78
+            }
77 79
 
78 80
             $this->excludeTags = (array) $this->settings->ExcludeTags();
79 81
             $this->maxLinks = (int) ($this->settings->MaxLinksPerPage) ? $this->settings->MaxLinksPerPage : PHP_INT_MAX;
80 82
 
81
-            if (!in_array($this->owner->ClassName, $this->settings->AllowedIn())) $this->addLinks = false;
83
+            if (!in_array($this->owner->ClassName, $this->settings->AllowedIn())) {
84
+                $this->addLinks = false;
85
+            }
82 86
         }
83 87
 
84 88
         return $this->settings;
@@ -114,7 +118,7 @@  discard block
 block discarded – undo
114 118
                             while($html5->length > 0) {
115 119
                                 $dom->appendChild($html5->item(0));
116 120
                             }
117
-                        }else{
121
+                        } else{
118 122
                             $dom = $html5;
119 123
                         }
120 124
                     } else{
@@ -150,7 +154,9 @@  discard block
 block discarded – undo
150 154
         $excluded = array();
151 155
         foreach( $this->excludeTags as $eTag ){
152 156
             while( $tags = $html->getElementsByTagName( $eTag ) ){
153
-                if( !$tags->length ) break 1;
157
+                if( !$tags->length ) {
158
+                    break 1;
159
+                }
154 160
                 $tag	= $tags->item(0);
155 161
                 $value  = $html->saveHTML( $tag );
156 162
                 $key    = (string) crc32( $value );
@@ -169,7 +175,9 @@  discard block
 block discarded – undo
169 175
         $links = AutomatedLink::get()->sort('Priority');
170 176
         foreach( $links as $link ){
171 177
             // Check if self-linking is allowed and if current pagetype is allowed
172
-            if( !$link->canBeAdded( $this->owner, $field ) ) continue;
178
+            if( !$link->canBeAdded( $this->owner, $field ) ) {
179
+                continue;
180
+            }
173 181
 
174 182
             $max    = (int) ( $link->MaxLinksPerPage > 0 ) ? $link->MaxLinksPerPage : PHP_INT_MAX;
175 183
             $escape = (string) preg_quote( $link->Phrase, '/' );
@@ -178,22 +186,31 @@  discard block
 block discarded – undo
178 186
             // Count the matches
179 187
             preg_match_all( $regex, $content, $count );
180 188
             $count = ( is_array( $count ) && isset( $count[0] ) ) ? count( $count[0] ) : 0;
181
-            if( $count < 1 ) continue;
189
+            if( $count < 1 ) {
190
+                continue;
191
+            }
182 192
 
183
-            if( isset( $this->maxLinksPerPage[ $link->ID ] ) )
184
-                $max -= $this->maxLinksPerPage[ $link->ID ];
185
-            else
186
-                $this->maxLinksPerPage[ $link->ID ] = 0;
193
+            if( isset( $this->maxLinksPerPage[ $link->ID ] ) ) {
194
+                            $max -= $this->maxLinksPerPage[ $link->ID ];
195
+            } else {
196
+                            $this->maxLinksPerPage[ $link->ID ] = 0;
197
+            }
187 198
 
188 199
             for( $x = 0; $x < $count; $x++ ){
189 200
                 // Stop adding links if we reached the link or page limit
190
-                if( $x >= $max || $this->linkCount >= $this->maxLinks ) break;
201
+                if( $x >= $max || $this->linkCount >= $this->maxLinks ) {
202
+                    break;
203
+                }
191 204
 
192 205
                 // Check if there is anything else to replace else stop
193 206
                 preg_match( $regex, $content, $match );
194
-                if( !is_array( $match ) || !count( $match ) ) break;
207
+                if( !is_array( $match ) || !count( $match ) ) {
208
+                    break;
209
+                }
195 210
 
196
-                if( !$html = (string) $link->getHTML( $match[0] ) ) continue;
211
+                if( !$html = (string) $link->getHTML( $match[0] ) ) {
212
+                    continue;
213
+                }
197 214
                 $key              = (string) crc32( $html );
198 215
                 $excluded[ $key ] = (string) $html;
199 216
 
@@ -203,7 +220,9 @@  discard block
 block discarded – undo
203 220
             }
204 221
 
205 222
             // Stop Adding links if we reached the page limit
206
-            if( $this->linkCount >= $this->maxLinks ) break;
223
+            if( $this->linkCount >= $this->maxLinks ) {
224
+                break;
225
+            }
207 226
         }
208 227
 
209 228
         // Re-add the excluded Tags
Please login to merge, or discard this patch.