Passed
Branch master (af9096)
by Dylan
03:47
created
code/logic/GridFieldExportAllAutomatedLinksButton.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php 
2 2
 if (!class_exists('GridFieldExportAllAutomatedLinksButton')) {
3
-	class GridFieldExportAllAutomatedLinksButton extends GridFieldExportButton {
3
+    class GridFieldExportAllAutomatedLinksButton extends GridFieldExportButton {
4 4
 /** 
5 5
 * Generate export fields for CSV. 
6 6
 * 
@@ -14,44 +14,44 @@  discard block
 block discarded – undo
14 14
 * 
15 15
 */ 
16 16
 public function generateExportFileData($gridField) { 
17
-	$separator = $this->csvSeparator; 
18
-	$csvColumns =$gridField->getColumns();
19
-	$fileData = ''; 
20
-	$columnData = array(); 
21
-	$fieldItems = new ArrayList();
22
-	if($this->csvHasHeader) {
23
-		$headers = array();
17
+    $separator = $this->csvSeparator; 
18
+    $csvColumns =$gridField->getColumns();
19
+    $fileData = ''; 
20
+    $columnData = array(); 
21
+    $fieldItems = new ArrayList();
22
+    if($this->csvHasHeader) {
23
+        $headers = array();
24 24
 // determine the CSV headers. If a field is callable (e.g. anonymous function) then use the 
25 25
 // source name as the header instead 
26
-		foreach($csvColumns as $columnSource => $columnHeader) {
27
-			$headers[] = (!is_string($columnHeader) && is_callable($columnHeader)) ? $columnSource : $columnHeader; 
28
-		}
29
-		$fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\""; 
30
-		$fileData .= "\n";
31
-	}
26
+        foreach($csvColumns as $columnSource => $columnHeader) {
27
+            $headers[] = (!is_string($columnHeader) && is_callable($columnHeader)) ? $columnSource : $columnHeader; 
28
+        }
29
+        $fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\""; 
30
+        $fileData .= "\n";
31
+    }
32 32
 // ----------------------- 
33 33
 //$items = $gridField->getManipulatedList(); 
34 34
 
35
-	$items = $gridField->getList(); 
35
+    $items = $gridField->getList(); 
36 36
 // -----------------------
37 37
 // @todo should GridFieldComponents change behaviour based on whether others are available in the config? 
38
-	foreach($gridField->getConfig()->getComponents() as $component){ 
39
-		if($component instanceof GridFieldFilterHeader || $component instanceof GridFieldSortableHeader) { 
40
-			$items = $component->getManipulatedData($gridField, $items); 
41
-		} 
42
-	}
43
-	foreach($items->limit(null) as $item) { 
44
-		$columnData = array();
45
-		foreach($csvColumns as $columnSource => $columnHeader) { 
46
-			$value = ( $item->hasMethod( $columnHeader ) ) ? $item->$columnHeader() : $item->$columnHeader;
47
-			$value = str_replace(array("\r", "\n"), "\n", $value); 
48
-			$columnData[] = '"' . str_replace('"', '\"', $value) . '"'; 
49
-		}
50
-		$fileData .= implode($separator, $columnData); 
51
-		$fileData .= "\n";
52
-		$item->destroy(); 
53
-	}
54
-	return $fileData; 
38
+    foreach($gridField->getConfig()->getComponents() as $component){ 
39
+        if($component instanceof GridFieldFilterHeader || $component instanceof GridFieldSortableHeader) { 
40
+            $items = $component->getManipulatedData($gridField, $items); 
41
+        } 
42
+    }
43
+    foreach($items->limit(null) as $item) { 
44
+        $columnData = array();
45
+        foreach($csvColumns as $columnSource => $columnHeader) { 
46
+            $value = ( $item->hasMethod( $columnHeader ) ) ? $item->$columnHeader() : $item->$columnHeader;
47
+            $value = str_replace(array("\r", "\n"), "\n", $value); 
48
+            $columnData[] = '"' . str_replace('"', '\"', $value) . '"'; 
49
+        }
50
+        $fileData .= implode($separator, $columnData); 
51
+        $fileData .= "\n";
52
+        $item->destroy(); 
53
+    }
54
+    return $fileData; 
55 55
 }
56 56
 } // end class GridFieldExportAllButton
57 57
 } 
Please login to merge, or discard this patch.
code/logic/GridFieldPrintAllAutomatedLinksButton.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php 
2 2
 if (!class_exists('GridFieldPrintAllAutomatedLinksButton')) {
3
-	class GridFieldPrintAllAutomatedLinksButton extends GridFieldPrintButton {
3
+    class GridFieldPrintAllAutomatedLinksButton extends GridFieldPrintButton {
4 4
 /** 
5 5
 * Export core. 
6 6
 * 
@@ -13,42 +13,42 @@  discard block
 block discarded – undo
13 13
 * 
14 14
 */ 
15 15
 public function generatePrintData(GridField $gridField) { 
16
-	$printColumns = $this->getPrintColumnsForGridField($gridField);
17
-	$header = null;
18
-	if($this->printHasHeader) { 
19
-		$header = new ArrayList();
20
-		foreach($printColumns as $field => $label){ 
21
-			$header->push(new ArrayData(array( 
22
-				"CellString" => $label, 
23
-				))); 
24
-		} 
25
-	}
16
+    $printColumns = $this->getPrintColumnsForGridField($gridField);
17
+    $header = null;
18
+    if($this->printHasHeader) { 
19
+        $header = new ArrayList();
20
+        foreach($printColumns as $field => $label){ 
21
+            $header->push(new ArrayData(array( 
22
+                "CellString" => $label, 
23
+                ))); 
24
+        } 
25
+    }
26 26
 // ----------------------- 
27 27
 //$items = $gridField->getManipulatedList(); 
28
-	$items = $gridField->getList(); 
28
+    $items = $gridField->getList(); 
29 29
 // -----------------------
30
-	$itemRows = new ArrayList();
31
-	foreach($items as $item) { 
32
-		$itemRow = new ArrayList();
33
-		foreach($printColumns as $field => $label) { 
34
-			$value = $gridField->getDataFieldValue($item, $field);
35
-			$itemRow->push(new ArrayData(array( 
36
-				"CellString" => $value, 
37
-				))); 
38
-		}
39
-		$itemRows->push(new ArrayData(array( 
40
-			"ItemRow" => $itemRow 
41
-			)));
42
-		$item->destroy(); 
43
-	}
44
-	$ret = new ArrayData(array( 
45
-		"Title" => $this->getTitle($gridField), 
46
-		"Header" => $header, 
47
-		"ItemRows" => $itemRows, 
48
-		"Datetime" => SS_Datetime::now(), 
49
-		"Member" => Member::currentUser(), 
50
-		));
51
-	return $ret;
30
+    $itemRows = new ArrayList();
31
+    foreach($items as $item) { 
32
+        $itemRow = new ArrayList();
33
+        foreach($printColumns as $field => $label) { 
34
+            $value = $gridField->getDataFieldValue($item, $field);
35
+            $itemRow->push(new ArrayData(array( 
36
+                "CellString" => $value, 
37
+                ))); 
38
+        }
39
+        $itemRows->push(new ArrayData(array( 
40
+            "ItemRow" => $itemRow 
41
+            )));
42
+        $item->destroy(); 
43
+    }
44
+    $ret = new ArrayData(array( 
45
+        "Title" => $this->getTitle($gridField), 
46
+        "Header" => $header, 
47
+        "ItemRows" => $itemRows, 
48
+        "Datetime" => SS_Datetime::now(), 
49
+        "Member" => Member::currentUser(), 
50
+        ));
51
+    return $ret;
52 52
 } 
53 53
 } // end class GridFieldPrintAllButton
54 54
 }
Please login to merge, or discard this patch.
code/dataobjects/GlobalAutoLinkSettings.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,20 +11,20 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class GlobalAutoLinkSettings extends DataObject{
13 13
 	
14
-	public static $enabled  = true;
14
+    public static $enabled  = true;
15 15
     public static $encoding = 'UTF-8';
16 16
 	
17
-	private static $db = array(
18
-		'MaxLinksPerPage' => 'INT',
19
-		'ExcludeTags'	  => 'VARCHAR(255)',
20
-		'IncludeIn'		  => 'Text',
21
-		'AddTo'           => 'Text',
17
+    private static $db = array(
18
+        'MaxLinksPerPage' => 'INT',
19
+        'ExcludeTags'	  => 'VARCHAR(255)',
20
+        'IncludeIn'		  => 'Text',
21
+        'AddTo'           => 'Text',
22 22
         'CrawlID'         => 'VARCHAR(15)'
23
-	);
23
+    );
24 24
 	
25
-	private static $defaults = array(
26
-		'IncludeIn' => 'Content'
27
-	);
25
+    private static $defaults = array(
26
+        'IncludeIn' => 'Content'
27
+    );
28 28
 
29 29
     public static $default_create_config = array(
30 30
         'MaxLinksPerPage' => 0,
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
         'IncludeIn'		  => 'Content'
33 33
     );
34 34
 	
35
-	public function ExcludeTags(){
36
-		return array_unique( explode( ',', str_replace( ' ', '', $this->ExcludeTags ).',a,img,iframe,video,object' ) );
37
-	}
35
+    public function ExcludeTags(){
36
+        return array_unique( explode( ',', str_replace( ' ', '', $this->ExcludeTags ).',a,img,iframe,video,object' ) );
37
+    }
38 38
 	
39
-	public function IncludeInFields(){
40
-		return explode( ',', str_replace( ' ', '', $this->IncludeIn ) );
41
-	}
39
+    public function IncludeInFields(){
40
+        return explode( ',', str_replace( ' ', '', $this->IncludeIn ) );
41
+    }
42 42
 
43 43
     public function requireDefaultRecords() {
44 44
         $hasData = self::get()->first();
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * 
77 77
      * @return array
78 78
      */
79
-     public function AllowedIn(){
79
+        public function AllowedIn(){
80 80
         $classes = array_values( ClassInfo::subclassesFor( 'SiteTree' ) );
81 81
         if( !$this->AddTo ) return $classes;
82 82
         
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         }
98 98
         
99 99
         return (array) $sanitized;
100
-     }
100
+        }
101 101
 
102 102
     /**
103 103
      * Gets the current config
Please login to merge, or discard this patch.
code/dataobjects/AutomatedLink.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -10,45 +10,45 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class AutomatedLink extends DataObject implements PermissionProvider{
12 12
 	
13
-	private static $db = array(
14
-		'Phrase'     	  => 'VARCHAR(255)',
15
-		'TitleTag'   	  => 'VARCHAR(255)',
16
-		'AnchorTag' 	  => 'VARCHAR(255)',
17
-		'NewWindow'  	  => 'Boolean',
18
-		'NoFollow'   	  => 'Boolean',
19
-		'SelfLinking'     => 'Boolean',
20
-		'CaseSensitive'   => 'Boolean',
21
-		'MaxLinksPerPage' => 'INT',
22
-		'Priority'		  => 'Int'
23
-	);
13
+    private static $db = array(
14
+        'Phrase'     	  => 'VARCHAR(255)',
15
+        'TitleTag'   	  => 'VARCHAR(255)',
16
+        'AnchorTag' 	  => 'VARCHAR(255)',
17
+        'NewWindow'  	  => 'Boolean',
18
+        'NoFollow'   	  => 'Boolean',
19
+        'SelfLinking'     => 'Boolean',
20
+        'CaseSensitive'   => 'Boolean',
21
+        'MaxLinksPerPage' => 'INT',
22
+        'Priority'		  => 'Int'
23
+    );
24 24
 	
25
-	private static $defaults = array(
26
-		'MaxLinksPerPage' => 10
27
-	);
25
+    private static $defaults = array(
26
+        'MaxLinksPerPage' => 10
27
+    );
28 28
 	
29
-	private static $default_sort = 'Priority';
29
+    private static $default_sort = 'Priority';
30 30
 	
31
-	private static $has_one = array(
32
-		'Page' => 'SiteTree'
33
-	);
31
+    private static $has_one = array(
32
+        'Page' => 'SiteTree'
33
+    );
34 34
 	
35
-	private static $summary_fields    = array( 'Phrase', 'PointsTo' );
36
-	private static $searchable_fields = array( 'Phrase' );
37
-	private static $singular_name	  = 'Automated Link';
38
-	private static $plural_name	      = 'Automated Links';
35
+    private static $summary_fields    = array( 'Phrase', 'PointsTo' );
36
+    private static $searchable_fields = array( 'Phrase' );
37
+    private static $singular_name	  = 'Automated Link';
38
+    private static $plural_name	      = 'Automated Links';
39 39
     private static $parsableFields    = array();
40 40
 
41 41
     public function PointsTo(){
42 42
         return $this->Page()->Link();
43 43
     }
44 44
 
45
-	public function Title(){
46
-		return $this->Phrase;
47
-	}
45
+    public function Title(){
46
+        return $this->Phrase;
47
+    }
48 48
 	
49
-	public function forTemplate(){
50
-		return $this->getHTML();
51
-	}
49
+    public function forTemplate(){
50
+        return $this->getHTML();
51
+    }
52 52
     
53 53
     function canView( $member = false ){
54 54
         return Permission::check('AUTOMATEDLINK_VIEW');
@@ -67,129 +67,129 @@  discard block
 block discarded – undo
67 67
     }
68 68
     
69 69
     function providePermissions() {
70
-       return array(
71
-         'AUTOMATEDLINK_VIEW'   => 'View Automated Links',
72
-         'AUTOMATEDLINK_EDIT'   => 'Edit Automated Links',
73
-         'AUTOMATEDLINK_DELETE' => 'Delete Automated Links',
74
-         'AUTOMATEDLINK_CREATE' => 'Create Automated Links',
75
-       );
76
-     }
70
+        return array(
71
+            'AUTOMATEDLINK_VIEW'   => 'View Automated Links',
72
+            'AUTOMATEDLINK_EDIT'   => 'Edit Automated Links',
73
+            'AUTOMATEDLINK_DELETE' => 'Delete Automated Links',
74
+            'AUTOMATEDLINK_CREATE' => 'Create Automated Links',
75
+        );
76
+        }
77 77
 	
78
-	public function requireDefaultRecords(){
79
-		parent::requireDefaultRecords();
78
+    public function requireDefaultRecords(){
79
+        parent::requireDefaultRecords();
80 80
 		
81
-		// Update all links to redirector pages during dev/build
82
-		foreach( self::get() as $link ) $link->CheckAndUpdateDestination( true );
83
-	}
81
+        // Update all links to redirector pages during dev/build
82
+        foreach( self::get() as $link ) $link->CheckAndUpdateDestination( true );
83
+    }
84 84
 	
85
-	/**
86
-	 * Returns the HTML Representation of this object
87
-	 * 
85
+    /**
86
+     * Returns the HTML Representation of this object
87
+     * 
88 88
      * @param  String $originalPhrase
89
-	 * @return String
90
-	 */
91
-	public function getHTML( $originalPhrase = NULL ){
92
-		$link     = ( $this->PageID )     ? $this->Page()->Link() 	    : '#';
93
-		$title    = ( $this->TitleTag )   ? "title='{$this->TitleTag}'" : '';
94
-		$nofollow = ( $this->NoFollow )   ? 'rel="nofollow"' 		    : '';
95
-		$newtab   = ( $this->NewWindow )  ? 'target="_blank"' 		    : '';
89
+     * @return String
90
+     */
91
+    public function getHTML( $originalPhrase = NULL ){
92
+        $link     = ( $this->PageID )     ? $this->Page()->Link() 	    : '#';
93
+        $title    = ( $this->TitleTag )   ? "title='{$this->TitleTag}'" : '';
94
+        $nofollow = ( $this->NoFollow )   ? 'rel="nofollow"' 		    : '';
95
+        $newtab   = ( $this->NewWindow )  ? 'target="_blank"' 		    : '';
96 96
         $anchor   = ( $originalPhrase )   ? $originalPhrase             : $this->Phrase;
97
-		$link     = ( $this->AnchorTag )  ? rtrim( $link, '#' ).'#'.$this->AnchorTag : $link;
98
-		return "<a href=\"$link\" $title $nofollow $newtab data-id=\"{$this->ID}\">{$anchor}</a>";
99
-	}
97
+        $link     = ( $this->AnchorTag )  ? rtrim( $link, '#' ).'#'.$this->AnchorTag : $link;
98
+        return "<a href=\"$link\" $title $nofollow $newtab data-id=\"{$this->ID}\">{$anchor}</a>";
99
+    }
100 100
 	
101
-	public function getCMSFields(){
102
-		$fields = FieldList::create( TabSet::create( 'Root' ) );
101
+    public function getCMSFields(){
102
+        $fields = FieldList::create( TabSet::create( 'Root' ) );
103 103
 				
104
-		$fields->addFieldsToTab( 'Root.LinkSettings', array(
105
-			TextField::create( 'Phrase', 'Phrase to search for', $this->Phrase, 255 ),
106
-			TextField::create( 'TitleTag', 'Title Tag', $this->TitleTag, 255 ),
107
-			TextField::create( 'AnchorTag', 'Anchor Tag(#)', $this->AnchorTag, 255 ),
108
-			FieldGroup::create(
109
-				CheckboxField::create( 'NoFollow' ),
110
-				CheckboxField::create( 'NewWindow' ),
111
-				CheckboxField::create( 'SelfLinking', 'Allow page to link to itself' ),
112
-				CheckboxField::create( 'CaseSensitive', 'Match the case of the phrase' )
113
-			),
114
-			NumericField::create( 'MaxLinksPerPage', 'Maximum amount of this link to be created on a single page( 0 = unlimited )' ),
115
-			TreeDropdownField::create( 'PageID', 'Page to link to', 'SiteTree' )
116
-		) );
104
+        $fields->addFieldsToTab( 'Root.LinkSettings', array(
105
+            TextField::create( 'Phrase', 'Phrase to search for', $this->Phrase, 255 ),
106
+            TextField::create( 'TitleTag', 'Title Tag', $this->TitleTag, 255 ),
107
+            TextField::create( 'AnchorTag', 'Anchor Tag(#)', $this->AnchorTag, 255 ),
108
+            FieldGroup::create(
109
+                CheckboxField::create( 'NoFollow' ),
110
+                CheckboxField::create( 'NewWindow' ),
111
+                CheckboxField::create( 'SelfLinking', 'Allow page to link to itself' ),
112
+                CheckboxField::create( 'CaseSensitive', 'Match the case of the phrase' )
113
+            ),
114
+            NumericField::create( 'MaxLinksPerPage', 'Maximum amount of this link to be created on a single page( 0 = unlimited )' ),
115
+            TreeDropdownField::create( 'PageID', 'Page to link to', 'SiteTree' )
116
+        ) );
117 117
 		
118
-		$settings = GlobalAutoLinkSettings::get_current();
119
-		if( $settings ){
120
-			$fields->addFieldsToTab( 'Root.Global', array(
121
-				NumericField::create( 
122
-					'Global_MaxLinksPerPage', 
123
-					'Maximum amount of links a single page can have ( 0 = unlimited )', 
124
-					$settings->MaxLinksPerPage 
125
-				),
126
-				TextField::create(
127
-					'Global_ExcludeTags',
128
-					'Do not include links into these HTML Tags ( comma seperated )',
129
-					$settings->ExcludeTags
130
-				),
131
-				TextField::create( 
132
-				    'Global_AddTo', 
133
-				    'Page types where links should be created in ( leave blank for all page types )',
134
-				    $settings->AddTo ),
135
-				TextField::create(
136
-					'Global_IncludeIn',
137
-					'Include Links into these fields ( comma seperated & field must support html injection )',
138
-					$settings->IncludeIn
139
-				)
140
-			) );
141
-		}
118
+        $settings = GlobalAutoLinkSettings::get_current();
119
+        if( $settings ){
120
+            $fields->addFieldsToTab( 'Root.Global', array(
121
+                NumericField::create( 
122
+                    'Global_MaxLinksPerPage', 
123
+                    'Maximum amount of links a single page can have ( 0 = unlimited )', 
124
+                    $settings->MaxLinksPerPage 
125
+                ),
126
+                TextField::create(
127
+                    'Global_ExcludeTags',
128
+                    'Do not include links into these HTML Tags ( comma seperated )',
129
+                    $settings->ExcludeTags
130
+                ),
131
+                TextField::create( 
132
+                    'Global_AddTo', 
133
+                    'Page types where links should be created in ( leave blank for all page types )',
134
+                    $settings->AddTo ),
135
+                TextField::create(
136
+                    'Global_IncludeIn',
137
+                    'Include Links into these fields ( comma seperated & field must support html injection )',
138
+                    $settings->IncludeIn
139
+                )
140
+            ) );
141
+        }
142 142
 		
143
-		return $fields;
144
-	}
143
+        return $fields;
144
+    }
145 145
 
146 146
     public function getCMSValidator(){
147 147
         return new RequiredFields( array( 'Phrase', 'PageID' ) );
148 148
     }
149 149
 	
150
-	/**
151
-	 * Save the Global Settings into the 
152
-	 * Global Auto Link Settings Object
153
-	 * 
154
-	 * @return void
155
-	 */
156
-	public function onBeforeWrite(){
157
-		parent::onBeforeWrite();
150
+    /**
151
+     * Save the Global Settings into the 
152
+     * Global Auto Link Settings Object
153
+     * 
154
+     * @return void
155
+     */
156
+    public function onBeforeWrite(){
157
+        parent::onBeforeWrite();
158 158
 		
159
-		$settings = GlobalAutoLinkSettings::get_current();
160
-		if( $settings ){
159
+        $settings = GlobalAutoLinkSettings::get_current();
160
+        if( $settings ){
161 161
 			
162
-			foreach( $this->getChangedFields() as $field => $value ){
163
-				if( strpos( $field, 'Global_' ) === 0 && isset( $value['after'] ) ){
164
-					$field = str_replace( 'Global_', '', $field );
165
-					$settings->$field = $value['after'];
166
-				}
167
-			}
162
+            foreach( $this->getChangedFields() as $field => $value ){
163
+                if( strpos( $field, 'Global_' ) === 0 && isset( $value['after'] ) ){
164
+                    $field = str_replace( 'Global_', '', $field );
165
+                    $settings->$field = $value['after'];
166
+                }
167
+            }
168 168
 
169
-			$settings->write();
170
-		}
169
+            $settings->write();
170
+        }
171 171
 		
172
-		$this->CheckAndUpdateDestination();
173
-	}
172
+        $this->CheckAndUpdateDestination();
173
+    }
174 174
     
175
-	/**
176
-	 * Checks if the destination is a redirector page if so
177
-	 * it updates it to the destination of the redirector page
178
-	 * 
179
-	 * @Boolean $write - Write the changes if any
180
-	 * @return void
181
-	 */
182
-	public function CheckAndUpdateDestination( $write = false ){
183
-		$this->extend('beforeCheckAndUpdateDestination', $write);
175
+    /**
176
+     * Checks if the destination is a redirector page if so
177
+     * it updates it to the destination of the redirector page
178
+     * 
179
+     * @Boolean $write - Write the changes if any
180
+     * @return void
181
+     */
182
+    public function CheckAndUpdateDestination( $write = false ){
183
+        $this->extend('beforeCheckAndUpdateDestination', $write);
184 184
 		
185
-		if( $this->PageID && $this->Page() && 
186
-			$this->Page()->ClassName == 'RedirectorPage' && 
187
-			$this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal' )
188
-		{
189
-			$this->PageID = $this->Page()->LinkToID;
190
-			if( $write ) $this->write();
191
-		}
192
-	}
185
+        if( $this->PageID && $this->Page() && 
186
+            $this->Page()->ClassName == 'RedirectorPage' && 
187
+            $this->Page()->LinkToID && $this->Page()->RedirectionType == 'Internal' )
188
+        {
189
+            $this->PageID = $this->Page()->LinkToID;
190
+            if( $write ) $this->write();
191
+        }
192
+    }
193 193
 	
194 194
     /**
195 195
      * Checks if the field is parable
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      *
222 222
      * @return Boolean
223 223
      */
224
-	public function canBeAdded( ContentController $controller ){
224
+    public function canBeAdded( ContentController $controller ){
225 225
         return ( $this->SelfLinking || $controller->ID != $this->PageID );
226 226
     }
227 227
 }
Please login to merge, or discard this patch.
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/extenstions/SEOToolboxControllerExtension.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -25,29 +25,29 @@  discard block
 block discarded – undo
25 25
         // Do something here
26 26
     }
27 27
 
28
-	private $maxLinksPerPage;
28
+    private $maxLinksPerPage;
29 29
     private $settings       = null;
30
-	private $linkCount      = 0;
30
+    private $linkCount      = 0;
31 31
     private $addLinks       = true;
32 32
     private $excludeTags    = array();
33 33
     private $maxLinks       = 0;
34 34
 
35
-	public function index(){
35
+    public function index(){
36 36
         $this->addAutomatedLinks();
37 37
 
38
-	    // If we have a crawl request check the CrawlID so we're sure we didn't hit another SS site running our module
39
-	    if( $crawl_id = $this->owner->request->getHeader('X-Crawl-Id') ){
40
-	        return( $crawl_id == GlobalAutoLinkSettings::get_current()->CrawlID )
38
+        // If we have a crawl request check the CrawlID so we're sure we didn't hit another SS site running our module
39
+        if( $crawl_id = $this->owner->request->getHeader('X-Crawl-Id') ){
40
+            return( $crawl_id == GlobalAutoLinkSettings::get_current()->CrawlID )
41 41
                 ? $this->crawl_response()
42 42
                 : $this->owner->redirect(SEOTestSiteTreeController::getPermissionDeniedPage()->Link());
43 43
         }
44 44
 
45
-		return array();
46
-	}
45
+        return array();
46
+    }
47 47
 
48
-	private function crawl_response(){
48
+    private function crawl_response(){
49 49
         // Encoded version to detect which fields are being used
50
-	    $customize = array();
50
+        $customize = array();
51 51
         foreach( Config::inst()->get($this->owner->ClassName, 'db') as $field => $type ){
52 52
             if( strtolower( $type ) == 'htmltext' ){
53 53
                 $data = ($this->owner->hasMethod($field)) ? $this->owner->$field() : $this->owner->$field;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 '/<!--(.*?)-->/im',
73 73
             ), '', $this->owner->customise($customize)->render())
74 74
         );
75
-	}
75
+    }
76 76
 
77 77
     /**
78 78
      * Get the global settings and check if we should be adding
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
         return $this->settings;
95 95
     }
96 96
 
97
-	/**
98
-	 * Goes through all the automated link settings and adds
99
-	 * the links where necessary
100
-	 *
101
-	 * @return void
102
-	 */
103
-	public function addAutomatedLinks(){
97
+    /**
98
+     * Goes through all the automated link settings and adds
99
+     * the links where necessary
100
+     *
101
+     * @return void
102
+     */
103
+    public function addAutomatedLinks(){
104 104
         if( GlobalAutoLinkSettings::$enabled && $this->owner->class != 'RedirectorPage' ) {
105 105
             $this->getSettings();
106 106
             if( !$this->addLinks ) return;
@@ -132,60 +132,60 @@  discard block
 block discarded – undo
132 132
                 }
133 133
             }
134 134
         }
135
-	}
135
+    }
136 136
 
137
-	/**
138
-	 * Parse the provided field and add the necessary links
139
-	 *
140
-	 * @param DOMDocument $html
137
+    /**
138
+     * Parse the provided field and add the necessary links
139
+     *
140
+     * @param DOMDocument $html
141 141
      * @param String $field
142
-	 * @return string
143
-	 */
144
-	private function parseField( DOMDocument $html, $field ){
145
-		$this->owner->extend( 'beforeParseField', $html, $field );
146
-
147
-		// Remove Tags from Content we wown't be using
148
-		$excluded = array();
149
-		foreach( $this->excludeTags as $eTag ){
150
-		    while( $tags = $html->getElementsByTagName( $eTag ) ){
151
-		        if( !$tags->length ) break 1;
152
-		        $tag	= $tags->item(0);
142
+     * @return string
143
+     */
144
+    private function parseField( DOMDocument $html, $field ){
145
+        $this->owner->extend( 'beforeParseField', $html, $field );
146
+
147
+        // Remove Tags from Content we wown't be using
148
+        $excluded = array();
149
+        foreach( $this->excludeTags as $eTag ){
150
+            while( $tags = $html->getElementsByTagName( $eTag ) ){
151
+                if( !$tags->length ) break 1;
152
+                $tag	= $tags->item(0);
153 153
                 $value  = $html->saveHTML( $tag );
154 154
                 $key    = (string) crc32( $value );
155 155
 
156
-				// Convert back children nodes of this node if they were already hashed
157
-				$excluded[$key] = str_replace( array_keys( $excluded ), array_values( $excluded ), $value );
156
+                // Convert back children nodes of this node if they were already hashed
157
+                $excluded[$key] = str_replace( array_keys( $excluded ), array_values( $excluded ), $value );
158 158
 
159 159
                 $tag->parentNode->replaceChild( $html->createTextNode( $key ), $tag );
160
-		    }
161
-		}
160
+            }
161
+        }
162 162
 
163 163
         $body    = (string)$html->saveHTML( $html->getElementsByTagName('body')->item(0) );
164 164
         $content = preg_replace( array( '/\<body\>/is', '/\<\/body\>/is' ), '', $body, 1 );
165 165
 
166
-		// Create the links
167
-		$links = AutomatedLink::get()->sort('Priority');
168
-		foreach( $links as $link ){
169
-			// Check if self-linking is allowed and if current pagetype is allowed
170
-			if( !$link->canBeAdded( $this->owner, $field ) ) continue;
166
+        // Create the links
167
+        $links = AutomatedLink::get()->sort('Priority');
168
+        foreach( $links as $link ){
169
+            // Check if self-linking is allowed and if current pagetype is allowed
170
+            if( !$link->canBeAdded( $this->owner, $field ) ) continue;
171 171
 
172
-			$max    = (int) ( $link->MaxLinksPerPage > 0 ) ? $link->MaxLinksPerPage : PHP_INT_MAX;
172
+            $max    = (int) ( $link->MaxLinksPerPage > 0 ) ? $link->MaxLinksPerPage : PHP_INT_MAX;
173 173
             $escape = (string) preg_quote( $link->Phrase, '/' );
174
-			$regex  = (string) ( $link->CaseSensitive ) ? "/(\b{$escape}\b)/" : "/(\b{$escape}\b)/i";
174
+            $regex  = (string) ( $link->CaseSensitive ) ? "/(\b{$escape}\b)/" : "/(\b{$escape}\b)/i";
175 175
 
176 176
             // Count the matches
177 177
             preg_match_all( $regex, $content, $count );
178 178
             $count = ( is_array( $count ) && isset( $count[0] ) ) ? count( $count[0] ) : 0;
179 179
             if( $count < 1 ) continue;
180 180
 
181
-			if( isset( $this->maxLinksPerPage[ $link->ID ] ) )
182
-				$max -= $this->maxLinksPerPage[ $link->ID ];
183
-			else
184
-				$this->maxLinksPerPage[ $link->ID ] = 0;
181
+            if( isset( $this->maxLinksPerPage[ $link->ID ] ) )
182
+                $max -= $this->maxLinksPerPage[ $link->ID ];
183
+            else
184
+                $this->maxLinksPerPage[ $link->ID ] = 0;
185 185
 
186
-			for( $x = 0; $x < $count; $x++ ){
187
-				// Stop adding links if we reached the link or page limit
188
-				if( $x >= $max || $this->linkCount >= $this->maxLinks ) break;
186
+            for( $x = 0; $x < $count; $x++ ){
187
+                // Stop adding links if we reached the link or page limit
188
+                if( $x >= $max || $this->linkCount >= $this->maxLinks ) break;
189 189
 
190 190
                 // Check if there is anything else to replace else stop
191 191
                 preg_match( $regex, $content, $match );
@@ -195,18 +195,18 @@  discard block
 block discarded – undo
195 195
                 $key              = (string) crc32( $html );
196 196
                 $excluded[ $key ] = (string) $html;
197 197
 
198
-				$content = preg_replace( $regex, $key, $content, 1 );
199
-				$this->linkCount++;
198
+                $content = preg_replace( $regex, $key, $content, 1 );
199
+                $this->linkCount++;
200 200
                 $this->maxLinksPerPage[ $link->ID ]++;
201 201
             }
202 202
 
203
-			// Stop Adding links if we reached the page limit
204
-			if( $this->linkCount >= $this->maxLinks ) break;
205
-		}
203
+            // Stop Adding links if we reached the page limit
204
+            if( $this->linkCount >= $this->maxLinks ) break;
205
+        }
206 206
 
207
-		// Re-add the excluded Tags
208
-		$content = str_replace( array_keys( $excluded ), array_values( $excluded ), $content );
207
+        // Re-add the excluded Tags
208
+        $content = str_replace( array_keys( $excluded ), array_values( $excluded ), $content );
209 209
 
210
-		return $content;
211
-	}
210
+        return $content;
211
+    }
212 212
 }
Please login to merge, or discard this patch.