Passed
Pull Request — master (#6)
by
unknown
02:54
created
src/ConvertsDocumentsExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 		 */
25 25
 		$fields->findOrMakeTab(
26 26
 			'Root.Import',
27
-			_t(__CLASS__ . '.ImportTab', 'Import')
27
+			_t(__CLASS__.'.ImportTab', 'Import')
28 28
 		);
29 29
 		$fields->addFieldToTab('Root.Import', DocumentConversionField::create());
30 30
 	}
Please login to merge, or discard this patch.
src/DocumentImporterField.php 2 patches
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * Process the document immediately upon upload.
61 61
 	 */
62 62
 	public function upload(HTTPRequest $request) {
63
-		if($this->isDisabled() || $this->isReadonly()) return $this->httpError(403);
63
+		if ($this->isDisabled() || $this->isReadonly()) return $this->httpError(403);
64 64
 
65 65
 		// Protect against CSRF on destructive action
66 66
 		$token = $this->getForm()->getSecurityToken();
67
-		if(!$token->checkRequest($request)) return $this->httpError(400);
67
+		if (!$token->checkRequest($request)) return $this->httpError(400);
68 68
 
69 69
 		$name = $this->getName();
70 70
 		$tmpfile = $request->postVar($name);
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 
84 84
 		if (!$return['error']) {
85 85
 			// Get options for this import.
86
-			$splitHeader = (int)$request->postVar('SplitHeader');
87
-			$keepSource = (bool)$request->postVar('KeepSource');
88
-			$chosenFolderID = (int)$request->postVar('ChosenFolderID');
89
-			$publishPages = (bool)$request->postVar('PublishPages');
90
-			$includeTOC = (bool)$request->postVar('IncludeTOC');
86
+			$splitHeader = (int) $request->postVar('SplitHeader');
87
+			$keepSource = (bool) $request->postVar('KeepSource');
88
+			$chosenFolderID = (int) $request->postVar('ChosenFolderID');
89
+			$publishPages = (bool) $request->postVar('PublishPages');
90
+			$includeTOC = (bool) $request->postVar('IncludeTOC');
91 91
 
92 92
 			// Process the document and write the page.
93 93
 			$preservedDocument = null;
@@ -136,42 +136,42 @@  discard block
 block discarded – undo
136 136
 		$page = $this->form->getRecord();
137 137
 		$content = '<ul>';
138 138
 
139
-		if($page) {
140
-			if($page->Children()->Count() > 0) {
141
-				foreach($page->Children() as $child) {
142
-					$content .= '<li><a href="' . $child->Link() . '">' . $child->Title . '</a></li>';
139
+		if ($page) {
140
+			if ($page->Children()->Count() > 0) {
141
+				foreach ($page->Children() as $child) {
142
+					$content .= '<li><a href="'.$child->Link().'">'.$child->Title.'</a></li>';
143 143
 				}
144
-				$page->Content = $content . '</ul>';
145
-			}  else {
144
+				$page->Content = $content.'</ul>';
145
+			} else {
146 146
 				$doc = new DOMDocument();
147 147
 				$doc->loadHTML($page->Content);
148 148
 				$body = $doc->getElementsByTagName('body')->item(0);
149 149
 				$node = $body->firstChild;
150 150
 				$h1 = $h2 = 1;
151
-				while($node) {
152
-					if($node instanceof DOMElement && $node->tagName == 'h1') {
153
-						$content .= '<li><a href="#h1.' . $h1 . '">'. trim(preg_replace('/\n|\r/', '', Convert::html2raw($node->textContent))) . '</a></li>';
151
+				while ($node) {
152
+					if ($node instanceof DOMElement && $node->tagName == 'h1') {
153
+						$content .= '<li><a href="#h1.'.$h1.'">'.trim(preg_replace('/\n|\r/', '', Convert::html2raw($node->textContent))).'</a></li>';
154 154
 						$node->setAttributeNode(new DOMAttr("id", "h1.".$h1));
155 155
 						$h1++;
156
-					} elseif($node instanceof DOMElement && $node->tagName == 'h2') {
157
-						$content .= '<li class="menu-h2"><a href="#h2.' . $h2 . '">'. trim(preg_replace('/\n|\r/', '', Convert::html2raw($node->textContent))) . '</a></li>';
156
+					} elseif ($node instanceof DOMElement && $node->tagName == 'h2') {
157
+						$content .= '<li class="menu-h2"><a href="#h2.'.$h2.'">'.trim(preg_replace('/\n|\r/', '', Convert::html2raw($node->textContent))).'</a></li>';
158 158
 						$node->setAttributeNode(new DOMAttr("id", "h2.".$h2));
159 159
 						$h2++;
160 160
 					}
161 161
 					$node = $node->nextSibling;
162 162
 				}
163
-				$page->Content = $content . '</ul>' . $doc->saveHTML();
163
+				$page->Content = $content.'</ul>'.$doc->saveHTML();
164 164
 			}
165 165
 
166 166
 			// Add in the link to the original document, if provided.
167
-			if($preservedDocument) {
168
-				$page->Content = '<a href="' . $preservedDocument->Link() . '" title="download original document">download original document (' .
169
-									$preservedDocument->getSize() . ')</a>' . $page->Content;
167
+			if ($preservedDocument) {
168
+				$page->Content = '<a href="'.$preservedDocument->Link().'" title="download original document">download original document ('.
169
+									$preservedDocument->getSize().')</a>'.$page->Content;
170 170
 			}
171 171
 
172 172
 			// Store the result
173 173
 			$page->write();
174
-			if($publishPages) $page->doPublish();
174
+			if ($publishPages) $page->doPublish();
175 175
 		}
176 176
 	}
177 177
 
@@ -205,28 +205,28 @@  discard block
 block discarded – undo
205 205
 	protected function writeContent($subtitle, $subdoc, $subnode, $sort = null, $publishPages = false) {
206 206
 		$record = $this->form->getRecord();
207 207
 
208
-		if($subtitle) {
208
+		if ($subtitle) {
209 209
 			// Write the chapter page to a subpage.
210 210
 			$page = DataObject::get_one('Page', sprintf('"Title" = \'%s\' AND "ParentID" = %d', $subtitle, $record->ID));
211
-			if(!$page) {
211
+			if (!$page) {
212 212
 				$page = Page::create();
213 213
 				$page->ParentID = $record->ID;
214 214
 				$page->Title = $subtitle;
215 215
 			}
216 216
 
217 217
 			unset($this->unusedChildren[$page->ID]);
218
-			file_put_contents(ASSETS_PATH . '/index-' . $sort . '.html', $this->getBodyText($subdoc, $subnode));
218
+			file_put_contents(ASSETS_PATH.'/index-'.$sort.'.html', $this->getBodyText($subdoc, $subnode));
219 219
 
220 220
 			if ($sort) $page->Sort = $sort;
221 221
 			$page->Content = $this->getBodyText($subdoc, $subnode);
222 222
 			$page->write();
223
-			if($publishPages) $page->doPublish();
223
+			if ($publishPages) $page->doPublish();
224 224
 		} else {
225 225
 			// Write to the master page.
226 226
 			$record->Content = $this->getBodyText($subdoc, $subnode);
227 227
 			$record->write();
228 228
 
229
-			if($publishPages) $record->doPublish();
229
+			if ($publishPages) $record->doPublish();
230 230
 		}
231 231
 
232 232
 	}
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		$tidy->cleanRepair();
264 264
 
265 265
 		$fragment = [];
266
-		foreach($tidy->body()->child as $child) {
266
+		foreach ($tidy->body()->child as $child) {
267 267
 			$fragment[] = $child->value;
268 268
 		}
269 269
 
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
 
280 280
 		// make sure any images are added as Image records with a relative link to assets
281 281
 		$chosenFolder = ($this->chosenFolderID) ? DataObject::get_by_id(Folder::class, $this->chosenFolderID) : null;
282
-		$folderName = ($chosenFolder) ? '/' . $chosenFolder->Name : '';
282
+		$folderName = ($chosenFolder) ? '/'.$chosenFolder->Name : '';
283 283
 		$imgs = $xpath->query('//img');
284
-		for($i = 0; $i < $imgs->length; $i++) {
284
+		for ($i = 0; $i < $imgs->length; $i++) {
285 285
 			$img = $imgs->item($i);
286
-			$originalPath = 'assets/' . $folderName . '/' . $img->getAttribute('src');
286
+			$originalPath = 'assets/'.$folderName.'/'.$img->getAttribute('src');
287 287
 			$name = FileNameFilter::create()->filter(basename($originalPath));
288 288
 
289 289
 			$image = Image::get()->filter(array('Name' => $name, 'ParentID' => (int) $chosenFolderID))->first();
290
-			if(!($image && $image->exists())) {
290
+			if (!($image && $image->exists())) {
291 291
 				$image = Image::create();
292 292
 				$image->ParentID = (int) $chosenFolderID;
293 293
 				$image->Name = $name;
@@ -306,24 +306,24 @@  discard block
 block discarded – undo
306 306
 			'//font' // Remove any font tags
307 307
 		);
308 308
 
309
-		foreach($remove_rules as $rule => $parenttag) {
310
-			if(is_numeric($rule)) {
309
+		foreach ($remove_rules as $rule => $parenttag) {
310
+			if (is_numeric($rule)) {
311 311
 				$rule = $parenttag;
312 312
 				$parenttag = null;
313 313
 			}
314 314
 
315 315
 			$nodes = array();
316
-			foreach($xpath->query($rule) as $node) $nodes[] = $node;
316
+			foreach ($xpath->query($rule) as $node) $nodes[] = $node;
317 317
 
318
-			foreach($nodes as $node) {
318
+			foreach ($nodes as $node) {
319 319
 				$parent = $node->parentNode;
320 320
 
321
-				if($parenttag) {
321
+				if ($parenttag) {
322 322
 					$parent = $doc->createElement($parenttag);
323 323
 					$node->nextSibling ? $node->parentNode->insertBefore($parent, $node->nextSibling) : $node->parentNode->appendChild($parent);
324 324
 				}
325 325
 
326
-				while($node->firstChild) $parent->appendChild($node->firstChild);
326
+				while ($node->firstChild) $parent->appendChild($node->firstChild);
327 327
 				$node->parentNode->removeChild($node);
328 328
 			}
329 329
 		}
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 			'//br' // BR tags
348 348
 		);
349 349
 
350
-		foreach($clean as $query) {
350
+		foreach ($clean as $query) {
351 351
 			// First get all the nodes. Need to build array, as they'll disappear from the nodelist while we're deleteing them, causing the indexing
352 352
 			// to screw up.
353 353
 			$nodes = array();
354
-			foreach($xpath->query($query) as $node) $nodes[] = $node;
354
+			foreach ($xpath->query($query) as $node) $nodes[] = $node;
355 355
 
356 356
 			// Then remove them all
357 357
 			foreach ($nodes as $node) { if ($node->parentNode) $node->parentNode->removeChild($node); }
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 		$body = $doc->getElementsByTagName('body')->item(0);
362 362
 
363 363
 		$this->unusedChildren = array();
364
-		foreach($sourcePage->Children() as $child) {
364
+		foreach ($sourcePage->Children() as $child) {
365 365
 			$this->unusedChildren[$child->ID] = $child;
366 366
 		}
367 367
 
368 368
 		$documentImporterFieldError;
369 369
 
370
-		$documentImporterFieldErrorHandler = function ($errno, $errstr, $errfile, $errline) use ( $documentImporterFieldError ) {
370
+		$documentImporterFieldErrorHandler = function($errno, $errstr, $errfile, $errline) use ($documentImporterFieldError) {
371 371
 			$documentImporterFieldError = _t(
372 372
 				'SilverStripe\\DocumentConverter\\DocumentConverter.PROCESSFAILED',
373 373
 				'Could not process document, please double-check you uploaded a .doc or .docx format.',
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 		$subnode = $subdoc->createElement('body');
386 386
 		$node = $body->firstChild;
387 387
 		$sort = 1;
388
-		if($splitHeader == 1 || $splitHeader == 2) {
389
-			while($node && !$documentImporterFieldError) {
390
-				if($node instanceof DOMElement && $node->tagName == 'h' . $splitHeader) {
391
-					if($subnode->hasChildNodes()) {
388
+		if ($splitHeader == 1 || $splitHeader == 2) {
389
+			while ($node && !$documentImporterFieldError) {
390
+				if ($node instanceof DOMElement && $node->tagName == 'h'.$splitHeader) {
391
+					if ($subnode->hasChildNodes()) {
392 392
 						$this->writeContent($subtitle, $subdoc, $subnode, $sort, $publishPages);
393 393
 						$sort++;
394 394
 					}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 			$this->writeContent($subtitle, $subdoc, $body, null, $publishPages);
407 407
 		}
408 408
 
409
-		if($subnode->hasChildNodes() && !$documentImporterFieldError) {
409
+		if ($subnode->hasChildNodes() && !$documentImporterFieldError) {
410 410
 			$this->writeContent($subtitle, $subdoc, $subnode, null, $publishPages);
411 411
 		}
412 412
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 			return array('error' => $documentImporterFieldError);
416 416
 		}
417 417
 
418
-		foreach($this->unusedChildren as $child) {
418
+		foreach ($this->unusedChildren as $child) {
419 419
 			$origStage = Versioned::current_stage();
420 420
 
421 421
 			Versioned::reading_stage('Stage');
Please login to merge, or discard this patch.
Braces   +35 added lines, -12 removed lines patch added patch discarded remove patch
@@ -60,11 +60,15 @@  discard block
 block discarded – undo
60 60
 	 * Process the document immediately upon upload.
61 61
 	 */
62 62
 	public function upload(HTTPRequest $request) {
63
-		if($this->isDisabled() || $this->isReadonly()) return $this->httpError(403);
63
+		if($this->isDisabled() || $this->isReadonly()) {
64
+			return $this->httpError(403);
65
+		}
64 66
 
65 67
 		// Protect against CSRF on destructive action
66 68
 		$token = $this->getForm()->getSecurityToken();
67
-		if(!$token->checkRequest($request)) return $this->httpError(400);
69
+		if(!$token->checkRequest($request)) {
70
+			return $this->httpError(400);
71
+		}
68 72
 
69 73
 		$name = $this->getName();
70 74
 		$tmpfile = $request->postVar($name);
@@ -91,7 +95,9 @@  discard block
 block discarded – undo
91 95
 
92 96
 			// Process the document and write the page.
93 97
 			$preservedDocument = null;
94
-			if ($keepSource) $preservedDocument = $this->preserveSourceDocument($tmpfile, $chosenFolderID);
98
+			if ($keepSource) {
99
+				$preservedDocument = $this->preserveSourceDocument($tmpfile, $chosenFolderID);
100
+			}
95 101
 
96 102
 			$importResult = $this->importFromPOST($tmpfile, $splitHeader, $publishPages, $chosenFolderID);
97 103
 			if (is_array($importResult) && isset($importResult['error'])) {
@@ -142,7 +148,7 @@  discard block
 block discarded – undo
142 148
 					$content .= '<li><a href="' . $child->Link() . '">' . $child->Title . '</a></li>';
143 149
 				}
144 150
 				$page->Content = $content . '</ul>';
145
-			}  else {
151
+			} else {
146 152
 				$doc = new DOMDocument();
147 153
 				$doc->loadHTML($page->Content);
148 154
 				$body = $doc->getElementsByTagName('body')->item(0);
@@ -171,7 +177,9 @@  discard block
 block discarded – undo
171 177
 
172 178
 			// Store the result
173 179
 			$page->write();
174
-			if($publishPages) $page->doPublish();
180
+			if($publishPages) {
181
+				$page->doPublish();
182
+			}
175 183
 		}
176 184
 	}
177 185
 
@@ -217,16 +225,22 @@  discard block
 block discarded – undo
217 225
 			unset($this->unusedChildren[$page->ID]);
218 226
 			file_put_contents(ASSETS_PATH . '/index-' . $sort . '.html', $this->getBodyText($subdoc, $subnode));
219 227
 
220
-			if ($sort) $page->Sort = $sort;
228
+			if ($sort) {
229
+				$page->Sort = $sort;
230
+			}
221 231
 			$page->Content = $this->getBodyText($subdoc, $subnode);
222 232
 			$page->write();
223
-			if($publishPages) $page->doPublish();
233
+			if($publishPages) {
234
+				$page->doPublish();
235
+			}
224 236
 		} else {
225 237
 			// Write to the master page.
226 238
 			$record->Content = $this->getBodyText($subdoc, $subnode);
227 239
 			$record->write();
228 240
 
229
-			if($publishPages) $record->doPublish();
241
+			if($publishPages) {
242
+				$record->doPublish();
243
+			}
230 244
 		}
231 245
 
232 246
 	}
@@ -313,7 +327,9 @@  discard block
 block discarded – undo
313 327
 			}
314 328
 
315 329
 			$nodes = array();
316
-			foreach($xpath->query($rule) as $node) $nodes[] = $node;
330
+			foreach($xpath->query($rule) as $node) {
331
+				$nodes[] = $node;
332
+			}
317 333
 
318 334
 			foreach($nodes as $node) {
319 335
 				$parent = $node->parentNode;
@@ -323,7 +339,9 @@  discard block
 block discarded – undo
323 339
 					$node->nextSibling ? $node->parentNode->insertBefore($parent, $node->nextSibling) : $node->parentNode->appendChild($parent);
324 340
 				}
325 341
 
326
-				while($node->firstChild) $parent->appendChild($node->firstChild);
342
+				while($node->firstChild) {
343
+					$parent->appendChild($node->firstChild);
344
+				}
327 345
 				$node->parentNode->removeChild($node);
328 346
 			}
329 347
 		}
@@ -351,10 +369,15 @@  discard block
 block discarded – undo
351 369
 			// First get all the nodes. Need to build array, as they'll disappear from the nodelist while we're deleteing them, causing the indexing
352 370
 			// to screw up.
353 371
 			$nodes = array();
354
-			foreach($xpath->query($query) as $node) $nodes[] = $node;
372
+			foreach($xpath->query($query) as $node) {
373
+				$nodes[] = $node;
374
+			}
355 375
 
356 376
 			// Then remove them all
357
-			foreach ($nodes as $node) { if ($node->parentNode) $node->parentNode->removeChild($node); }
377
+			foreach ($nodes as $node) { if ($node->parentNode) {
378
+				$node->parentNode->removeChild($node);
379
+			}
380
+			}
358 381
 		}
359 382
 
360 383
 		// Now split the document into portions by H1
Please login to merge, or discard this patch.
src/DocumentConverter.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	public function __construct($fileDescriptor, $chosenFolderID = null) {
53 53
 		$this->fileDescriptor = $fileDescriptor;
54 54
 		$this->chosenFolderID = $chosenFolderID;
55
-		array_merge($this->docvertDetails, (array)$this->config()->get('docvert_details'));
55
+		array_merge($this->docvertDetails, (array) $this->config()->get('docvert_details'));
56 56
 	}
57 57
 
58
-	public function setDocvertUsername($username = null)  {
58
+	public function setDocvertUsername($username = null) {
59 59
 		$this->docvertDetails['username'] = $username;
60 60
 	}
61 61
 
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
 		$ch = curl_init();
84 84
 
85 85
 		// PHP 5.5+ introduced CURLFile which makes the '@/path/to/file' syntax deprecated.
86
-		if(class_exists('CURLFile')) {
86
+		if (class_exists('CURLFile')) {
87 87
 			$file = new CURLFile(
88 88
 				$this->fileDescriptor['path'],
89 89
 				$this->fileDescriptor['mimeType'],
90 90
 				$this->fileDescriptor['name']
91 91
 			);
92 92
 		} else {
93
-			$file = '@' . $this->fileDescriptor['path'];
93
+			$file = '@'.$this->fileDescriptor['path'];
94 94
 		}
95 95
 
96 96
 		curl_setopt_array($ch, array(
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 		));
104 104
 
105 105
 		$chosenFolder = ($this->chosenFolderID) ? DataObject::get_by_id(Folder::class, $this->chosenFolderID) : null;
106
-		$folderName = ($chosenFolder) ? '/' . $chosenFolder->Name : '';
106
+		$folderName = ($chosenFolder) ? '/'.$chosenFolder->Name : '';
107 107
 		$outname = tempnam(ASSETS_PATH, 'convert');
108
-		$outzip = $outname . '.zip';
108
+		$outzip = $outname.'.zip';
109 109
 
110 110
 		$out = fopen($outzip, 'w');
111 111
 		curl_setopt($ch, CURLOPT_FILE, $out);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 		if (!$returnValue || ($status != 200)) {
119 119
 			return array('error' => _t(
120
-				__CLASS__ . '.SERVERUNREACHABLE',
120
+				__CLASS__.'.SERVERUNREACHABLE',
121 121
 				'Could not contact document conversion server. Please try again later or contact your system administrator.',
122 122
 				'Document Converter process Word documents into HTML.'
123 123
 			));
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 		// you need php zip, i.e. port install php5-zip
128 128
 		$zip = new ZipArchive();
129 129
 
130
-		if($zip->open($outzip)) {
131
-			$zip->extractTo(ASSETS_PATH .$folderName);
130
+		if ($zip->open($outzip)) {
131
+			$zip->extractTo(ASSETS_PATH.$folderName);
132 132
 		}
133 133
 
134 134
 		// remove temporary files
135 135
 		unlink($outname);
136 136
 		unlink($outzip);
137 137
 
138
-		if (!file_exists(ASSETS_PATH . $folderName . '/index.html')) {
138
+		if (!file_exists(ASSETS_PATH.$folderName.'/index.html')) {
139 139
 			return array('error' =>  _t(
140
-				__CLASS__ . '.PROCESSFAILED',
140
+				__CLASS__.'.PROCESSFAILED',
141 141
 				'Could not process document, please double-check you uploaded a .doc or .docx format.',
142 142
 				'Document Converter processes Word documents into HTML.'
143 143
 			));
144 144
 		}
145 145
 
146
-		$content = file_get_contents(ASSETS_PATH . $folderName . '/index.html');
146
+		$content = file_get_contents(ASSETS_PATH.$folderName.'/index.html');
147 147
 
148
-		unlink(ASSETS_PATH . $folderName . '/index.html');
148
+		unlink(ASSETS_PATH.$folderName.'/index.html');
149 149
 
150 150
 		return $content;
151 151
 	}
Please login to merge, or discard this patch.
src/DocumentConversionField.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			HeaderField::create(
40 40
 				'FileWarningHeader', 
41 41
 				_t(
42
-					__CLASS__ . '.FileWarningHeader',
42
+					__CLASS__.'.FileWarningHeader',
43 43
 					'Warning: import will remove all content and subpages of this page.'
44 44
 				), 
45 45
 				4
@@ -47,41 +47,41 @@  discard block
 block discarded – undo
47 47
 			$splitHeader = DropdownField::create(
48 48
 				'DocumentConversionField-SplitHeader', 
49 49
 				_t(
50
-					__CLASS__ . '.SplitHeader',
50
+					__CLASS__.'.SplitHeader',
51 51
 					'Split document into pages'
52 52
 				), 
53 53
 				array(
54
-					0 => _t(__CLASS__ . '.No','no'), 
55
-					1 => _t(__CLASS__ . '.EachH1','for each heading 1'), 
56
-					2 => _t(__CLASS__ . '.EachH2','for each heading 2')
54
+					0 => _t(__CLASS__.'.No', 'no'), 
55
+					1 => _t(__CLASS__.'.EachH1', 'for each heading 1'), 
56
+					2 => _t(__CLASS__.'.EachH2', 'for each heading 2')
57 57
 				)
58 58
 			),
59 59
 			$keepSource = CheckboxField::create(
60 60
 				'DocumentConversionField-KeepSource', 
61 61
 				_t(
62
-					__CLASS__ . '.KeepSource',
62
+					__CLASS__.'.KeepSource',
63 63
 					'Keep the original document. Adds a link to it on TOC, if enabled.'
64 64
 				)
65 65
 			),
66 66
 			$chosenFolderID = TreeDropdownField::create(
67 67
 				'DocumentConversionField-ChosenFolderID',
68
-				_t(__CLASS__ . '.ChooseFolder', 'Choose a folder to save this file'), 
68
+				_t(__CLASS__.'.ChooseFolder', 'Choose a folder to save this file'), 
69 69
 				Folder::class
70 70
 			),
71 71
 			$includeTOC = CheckboxField::create(
72 72
 				'DocumentConversionField-IncludeTOC', 
73
-				_t(__CLASS__ . '.IncludeTOC', 'Replace this page with a Table of Contents.')
73
+				_t(__CLASS__.'.IncludeTOC', 'Replace this page with a Table of Contents.')
74 74
 			),
75 75
 			$publishPages = CheckboxField::create(
76 76
 				'DocumentConversionField-PublishPages', 
77 77
 				_t(
78
-					__CLASS__ . '.publishPages',
78
+					__CLASS__.'.publishPages',
79 79
 					'Publish modified pages (not recommended unless you are sure about the conversion outcome)'
80 80
 				)
81 81
 			),
82 82
 			$this->innerField = DocumentImporterField::create(
83 83
 				'ImportedFromFile', 
84
-				_t(__CLASS__ . '.ImportedFromFile','Import content from a word document')
84
+				_t(__CLASS__.'.ImportedFromFile', 'Import content from a word document')
85 85
 			),
86 86
 		));
87 87
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,12 @@
 block discarded – undo
29 29
 	 * @param $children FieldSet/array Any additional children.
30 30
 	 */
31 31
 	public function __construct($children = null) {
32
-		if (is_string($children)) throw new InvalidArgumentException('DocumentConversionField::__construct does not accept a name as its parameter, it defaults to "ImportedFromFile" instead. Use DocumentConversionField::getInnerField()->setName() if you want to change it.');
33
-		if ($children) throw new InvalidArgumentException('DocumentConversionField::__construct provides its own fields and does not accept additional children.');
32
+		if (is_string($children)) {
33
+			throw new InvalidArgumentException('DocumentConversionField::__construct does not accept a name as its parameter, it defaults to "ImportedFromFile" instead. Use DocumentConversionField::getInnerField()->setName() if you want to change it.');
34
+		}
35
+		if ($children) {
36
+			throw new InvalidArgumentException('DocumentConversionField::__construct provides its own fields and does not accept additional children.');
37
+		}
34 38
 
35 39
 		// Add JS specific to this field.
36 40
 		Requirements::javascript('silverstripe/documentconverter: javascript/DocumentConversionField.js');
Please login to merge, or discard this patch.
tests/DocumentConverterTest.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
 
10 10
 class DocumentConverterTest extends SapphireTest
11 11
 {
12
-    protected $usesDatabase = true;
12
+	protected $usesDatabase = true;
13 13
 
14
-    public function testExtensionAppliesAppropriateFields() {
15
-        $this->markTestIncomplete();
16
-    }
14
+	public function testExtensionAppliesAppropriateFields() {
15
+		$this->markTestIncomplete();
16
+	}
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.