Completed
Push — master ( bdc3e4...d48199 )
by
unknown
12s
created
src/Extension/RichLinksExtension.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -16,48 +16,48 @@
 block discarded – undo
16 16
 class RichLinksExtension extends Extension
17 17
 {
18 18
 
19
-    /**
20
-     * @var array
21
-     */
22
-    private static $casting = [
23
-        'RichLinks' => 'HTMLText'
24
-    ];
25
-
26
-    /**
27
-     * @return string
28
-     */
29
-    public function RichLinks()
30
-    {
31
-        // Note:
32
-        // Assume we can use Regexes because the link will always be formatted
33
-        // in the same way coming from the CMS.
34
-
35
-        $content = $this->owner->value;
36
-
37
-        // Find all file links for processing.
38
-        preg_match_all('/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U', $content, $matches);
39
-
40
-        // Attach the file type and size to each of the links.
41
-        for ($i = 0; $i < count($matches[0]); $i++) {
42
-            $file = DataObject::get_by_id('File', $matches[1][$i]);
43
-            if ($file) {
44
-                $size = $file->getSize();
45
-                $ext = strtoupper($file->getExtension());
46
-                // Replace the closing </a> tag with the size span (and reattach the closing tag).
47
-                $newLink = substr($matches[0][$i], 0, strlen($matches[0][$i]) - 4)
48
-                    . "<span class='fileExt'> [$ext, $size]</span></a>";
49
-                $content = str_replace($matches[0][$i], $newLink, $content);
50
-            }
51
-        }
52
-
53
-        // Inject extra attributes into the external links.
54
-        $pattern = '/(<a.*)(href=\"https?:\/\/[^\"]*\"[^>]*>.*)(<\/a>)/iU';
55
-        $replacement = sprintf(
56
-            '$1class="external" rel="external" title="%s" $2<span class="nonvisual-indicator">(external link)</span>$3',
57
-            _t(__CLASS__ . '.OpenLinkTitle', 'Open external link')
58
-        );
59
-        $content = preg_replace($pattern, $replacement, $content, -1);
60
-
61
-        return $content;
62
-    }
19
+	/**
20
+	 * @var array
21
+	 */
22
+	private static $casting = [
23
+		'RichLinks' => 'HTMLText'
24
+	];
25
+
26
+	/**
27
+	 * @return string
28
+	 */
29
+	public function RichLinks()
30
+	{
31
+		// Note:
32
+		// Assume we can use Regexes because the link will always be formatted
33
+		// in the same way coming from the CMS.
34
+
35
+		$content = $this->owner->value;
36
+
37
+		// Find all file links for processing.
38
+		preg_match_all('/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U', $content, $matches);
39
+
40
+		// Attach the file type and size to each of the links.
41
+		for ($i = 0; $i < count($matches[0]); $i++) {
42
+			$file = DataObject::get_by_id('File', $matches[1][$i]);
43
+			if ($file) {
44
+				$size = $file->getSize();
45
+				$ext = strtoupper($file->getExtension());
46
+				// Replace the closing </a> tag with the size span (and reattach the closing tag).
47
+				$newLink = substr($matches[0][$i], 0, strlen($matches[0][$i]) - 4)
48
+					. "<span class='fileExt'> [$ext, $size]</span></a>";
49
+				$content = str_replace($matches[0][$i], $newLink, $content);
50
+			}
51
+		}
52
+
53
+		// Inject extra attributes into the external links.
54
+		$pattern = '/(<a.*)(href=\"https?:\/\/[^\"]*\"[^>]*>.*)(<\/a>)/iU';
55
+		$replacement = sprintf(
56
+			'$1class="external" rel="external" title="%s" $2<span class="nonvisual-indicator">(external link)</span>$3',
57
+			_t(__CLASS__ . '.OpenLinkTitle', 'Open external link')
58
+		);
59
+		$content = preg_replace($pattern, $replacement, $content, -1);
60
+
61
+		return $content;
62
+	}
63 63
 }
Please login to merge, or discard this patch.