Completed
Branch master (5b1d5e)
by Gordon
20:19
created
tests/HtmlEditorField_ExtensionTest.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class HtmlEditorField_ExtensionTest extends SapphireTest {
4
-	public function testProcessImage() {
5
-		$this->markTestSkipped('TODO');
6
-	}
4
+    public function testProcessImage() {
5
+        $this->markTestSkipped('TODO');
6
+    }
7 7
 
8 8
 }
Please login to merge, or discard this patch.
tests/HtmlEditorField_ImageToolbarExtensionTest.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class HtmlEditorField_ImageToolbarExtensionTest extends SapphireTest {
4
-	public function testUpdateFieldsForImage() {
5
-		$this->markTestSkipped('TODO');
6
-	}
4
+    public function testUpdateFieldsForImage() {
5
+        $this->markTestSkipped('TODO');
6
+    }
7 7
 
8
-	public function testUpdateMediaForm() {
9
-		$this->markTestSkipped('TODO');
10
-	}
8
+    public function testUpdateMediaForm() {
9
+        $this->markTestSkipped('TODO');
10
+    }
11 11
 
12 12
 }
Please login to merge, or discard this patch.
tests/RemoveImageSourceAttributeTest.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class RemoveImageSourceAttributeTest extends SapphireTest {
4
-	public function testResponsiveTinyMCEImages() {
5
-		$this->markTestSkipped('TODO');
6
-	}
4
+    public function testResponsiveTinyMCEImages() {
5
+        $this->markTestSkipped('TODO');
6
+    }
7 7
 
8 8
 }
Please login to merge, or discard this patch.
code/RemoveImageSourceAttribute.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class RemoveImageSourceAttribute extends Extension {
4
-	/**
5
-	 * Remove src attributes from images, instead use foundations responsive image loader
6
-	 * @param string $html HTML content of the page
7
-	 */
8
-	public function ResponsiveTinyMCEImages($html) {
9
-		$dom = Injector::inst()->create('HTMLValue', $html);
10
-		if($images = $dom->getElementsByTagName('img')) foreach($images as $img) {
11
-			$cssclass = $img->getAttribute('class');
12
-			$pos = strpos($cssclass, 'tinymce');
13
-			if ($pos !== false) {
14
-				$img->removeAttribute('src');
15
-			}
16
-		}
17
-		return $dom->getContent();
18
-	} 	
4
+    /**
5
+     * Remove src attributes from images, instead use foundations responsive image loader
6
+     * @param string $html HTML content of the page
7
+     */
8
+    public function ResponsiveTinyMCEImages($html) {
9
+        $dom = Injector::inst()->create('HTMLValue', $html);
10
+        if($images = $dom->getElementsByTagName('img')) foreach($images as $img) {
11
+            $cssclass = $img->getAttribute('class');
12
+            $pos = strpos($cssclass, 'tinymce');
13
+            if ($pos !== false) {
14
+                $img->removeAttribute('src');
15
+            }
16
+        }
17
+        return $dom->getContent();
18
+    } 	
19 19
 }
20 20
 
21
-  
22 21
\ No newline at end of file
22
+    
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 	 */
8 8
 	public function ResponsiveTinyMCEImages($html) {
9 9
 		$dom = Injector::inst()->create('HTMLValue', $html);
10
-		if($images = $dom->getElementsByTagName('img')) foreach($images as $img) {
10
+		if ($images = $dom->getElementsByTagName('img')) foreach ($images as $img) {
11 11
 			$cssclass = $img->getAttribute('class');
12 12
 			$pos = strpos($cssclass, 'tinymce');
13 13
 			if ($pos !== false) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,8 +7,10 @@
 block discarded – undo
7 7
 	 */
8 8
 	public function ResponsiveTinyMCEImages($html) {
9 9
 		$dom = Injector::inst()->create('HTMLValue', $html);
10
-		if($images = $dom->getElementsByTagName('img')) foreach($images as $img) {
10
+		if($images = $dom->getElementsByTagName('img')) {
11
+		    foreach($images as $img) {
11 12
 			$cssclass = $img->getAttribute('class');
13
+		}
12 14
 			$pos = strpos($cssclass, 'tinymce');
13 15
 			if ($pos !== false) {
14 16
 				$img->removeAttribute('src');
Please login to merge, or discard this patch.
code/HtmlEditorField_Extension.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Add 'no alignment' option when inserting images through 'Insert Media' form
4
- */
3
+     * Add 'no alignment' option when inserting images through 'Insert Media' form
4
+     */
5 5
 class HtmlEditorField_Extension extends Extension {
6 6
 
7
-	public function processImage($image, &$imageDom) {
8
-		error_log('**** Processing saved image '.$image);
7
+    public function processImage($image, &$imageDom) {
8
+        error_log('**** Processing saved image '.$image);
9 9
 
10
-		error_log('IMAGE DOM:'.get_class($imageDom));
10
+        error_log('IMAGE DOM:'.get_class($imageDom));
11 11
 		
12
-		// create the sizes of responsive images to be shown
13
-		$resized640=$image->SetWidth(640);
14
-		$resized720=$image->SetWidth(720);
12
+        // create the sizes of responsive images to be shown
13
+        $resized640=$image->SetWidth(640);
14
+        $resized720=$image->SetWidth(720);
15 15
 
16
-		$imageDom->setAttribute('data-src-640', $resized640->URL);
17
-		$imageDom->setAttribute('data-src-720', $resized720->URL);
16
+        $imageDom->setAttribute('data-src-640', $resized640->URL);
17
+        $imageDom->setAttribute('data-src-720', $resized720->URL);
18 18
 
19
-		// remove width and height attributes as they break the view in the editor
20
-		$imageDom->removeAttribute('width');
21
-		$imageDom->removeAttribute('height');
19
+        // remove width and height attributes as they break the view in the editor
20
+        $imageDom->removeAttribute('width');
21
+        $imageDom->removeAttribute('height');
22 22
 
23
-		$parent = $imageDom->parentNode;
24
-		$parentClass = $parent->getAttribute('class');
25
-		error_log('PARENT CLASS:'.$parentClass);
23
+        $parent = $imageDom->parentNode;
24
+        $parentClass = $parent->getAttribute('class');
25
+        error_log('PARENT CLASS:'.$parentClass);
26 26
 
27
-		if (strpos($parentClass, 'captionImage') !== false) {
28
-			$parent->removeAttribute('style');
29
-		}
27
+        if (strpos($parentClass, 'captionImage') !== false) {
28
+            $parent->removeAttribute('style');
29
+        }
30 30
 
31 31
 /*
32 32
 	not winning with this other than attribute tweaking
@@ -43,6 +43,6 @@  discard block
 block discarded – undo
43 43
 		//$imageDom = $htmlDom;
44 44
 		$imageDom->appendChild($htmlDom);
45 45
 		*/
46
-	}
46
+    }
47 47
  
48 48
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@  discard block
 block discarded – undo
5 5
 class HtmlEditorField_Extension extends Extension {
6 6
 
7 7
 	public function processImage($image, &$imageDom) {
8
-		error_log('**** Processing saved image '.$image);
8
+		error_log('**** Processing saved image ' . $image);
9 9
 
10
-		error_log('IMAGE DOM:'.get_class($imageDom));
10
+		error_log('IMAGE DOM:' . get_class($imageDom));
11 11
 		
12 12
 		// create the sizes of responsive images to be shown
13
-		$resized640=$image->SetWidth(640);
14
-		$resized720=$image->SetWidth(720);
13
+		$resized640 = $image->SetWidth(640);
14
+		$resized720 = $image->SetWidth(720);
15 15
 
16 16
 		$imageDom->setAttribute('data-src-640', $resized640->URL);
17 17
 		$imageDom->setAttribute('data-src-720', $resized720->URL);
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 		$parent = $imageDom->parentNode;
24 24
 		$parentClass = $parent->getAttribute('class');
25
-		error_log('PARENT CLASS:'.$parentClass);
25
+		error_log('PARENT CLASS:' . $parentClass);
26 26
 
27 27
 		if (strpos($parentClass, 'captionImage') !== false) {
28 28
 			$parent->removeAttribute('style');
Please login to merge, or discard this patch.
code/HtmlEditorField_ImageToolbarExtension.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,40 +4,40 @@
 block discarded – undo
4 4
  */
5 5
 class HtmlEditorField_ImageToolbarExtension extends Extension {
6 6
  
7
-	public function updateFieldsForImage(&$fields, $url, $file) {
8
-		foreach ($fields as $field) {
9
-			error_log('FIELD -> NAME: '.$field->Name);
10
-		}
11
-		//error_log('UPDATE FIELDS FOR IMAGE:'.print_r($fields,1));
12
-		$className = $fields->fieldByName('CSSClass');
13
-		$classes = $className->getSource();
7
+    public function updateFieldsForImage(&$fields, $url, $file) {
8
+        foreach ($fields as $field) {
9
+            error_log('FIELD -> NAME: '.$field->Name);
10
+        }
11
+        //error_log('UPDATE FIELDS FOR IMAGE:'.print_r($fields,1));
12
+        $className = $fields->fieldByName('CSSClass');
13
+        $classes = $className->getSource();
14 14
 
15
-		error_log(print_r($classes,1));
15
+        error_log(print_r($classes,1));
16 16
 
17
-		$markedclasses = array();
17
+        $markedclasses = array();
18 18
 
19
-		error_log("CLASSES:".$classes);
19
+        error_log("CLASSES:".$classes);
20 20
 
21
-		// prepend 'tinymce' onto the CSS class names
22
-		foreach (array_keys($classes) as $key) {
23
-			$markedclasses['tinymce '.$key] = $classes[$key];
24
-		}
21
+        // prepend 'tinymce' onto the CSS class names
22
+        foreach (array_keys($classes) as $key) {
23
+            $markedclasses['tinymce '.$key] = $classes[$key];
24
+        }
25 25
 
26
-		//$markedclasses = array_merge(array('tinymce' => _t('HtmlEditorField.CSSCLASSNONE', 'No alignment.')), $markedclasses);
26
+        //$markedclasses = array_merge(array('tinymce' => _t('HtmlEditorField.CSSCLASSNONE', 'No alignment.')), $markedclasses);
27 27
 
28
-		error_log('set marked classes');
29
-		$className->setSource($markedclasses);
30
-		error_log('MARKED CLASSES:'.print_r($markedclasses,1));
28
+        error_log('set marked classes');
29
+        $className->setSource($markedclasses);
30
+        error_log('MARKED CLASSES:'.print_r($markedclasses,1));
31 31
 
32 32
 
33
-		return $fields;
34
-	}
33
+        return $fields;
34
+    }
35 35
 
36
-	public function updateMediaForm(&$fields) {
37
-		error_log('UPDATE MEDIA FORM');
38
-		foreach ($fields as $field) {
39
-			error_log('Media form: FIELD -> NAME: '.$field->Name);
40
-		}
41
-	}
36
+    public function updateMediaForm(&$fields) {
37
+        error_log('UPDATE MEDIA FORM');
38
+        foreach ($fields as $field) {
39
+            error_log('Media form: FIELD -> NAME: '.$field->Name);
40
+        }
41
+    }
42 42
  
43 43
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@  discard block
 block discarded – undo
6 6
  
7 7
 	public function updateFieldsForImage(&$fields, $url, $file) {
8 8
 		foreach ($fields as $field) {
9
-			error_log('FIELD -> NAME: '.$field->Name);
9
+			error_log('FIELD -> NAME: ' . $field->Name);
10 10
 		}
11 11
 		//error_log('UPDATE FIELDS FOR IMAGE:'.print_r($fields,1));
12 12
 		$className = $fields->fieldByName('CSSClass');
13 13
 		$classes = $className->getSource();
14 14
 
15
-		error_log(print_r($classes,1));
15
+		error_log(print_r($classes, 1));
16 16
 
17 17
 		$markedclasses = array();
18 18
 
19
-		error_log("CLASSES:".$classes);
19
+		error_log("CLASSES:" . $classes);
20 20
 
21 21
 		// prepend 'tinymce' onto the CSS class names
22 22
 		foreach (array_keys($classes) as $key) {
23
-			$markedclasses['tinymce '.$key] = $classes[$key];
23
+			$markedclasses['tinymce ' . $key] = $classes[$key];
24 24
 		}
25 25
 
26 26
 		//$markedclasses = array_merge(array('tinymce' => _t('HtmlEditorField.CSSCLASSNONE', 'No alignment.')), $markedclasses);
27 27
 
28 28
 		error_log('set marked classes');
29 29
 		$className->setSource($markedclasses);
30
-		error_log('MARKED CLASSES:'.print_r($markedclasses,1));
30
+		error_log('MARKED CLASSES:' . print_r($markedclasses, 1));
31 31
 
32 32
 
33 33
 		return $fields;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	public function updateMediaForm(&$fields) {
37 37
 		error_log('UPDATE MEDIA FORM');
38 38
 		foreach ($fields as $field) {
39
-			error_log('Media form: FIELD -> NAME: '.$field->Name);
39
+			error_log('Media form: FIELD -> NAME: ' . $field->Name);
40 40
 		}
41 41
 	}
42 42
  
Please login to merge, or discard this patch.