Passed
Pull Request — master (#6)
by
unknown
02:54
created
src/DocumentImporterField.php 1 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/DocumentConversionField.php 1 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.