Completed
Branch master (e5db64)
by Schlaefer
09:02
created
app/Plugin/BbcodeParser/Test/Case/Lib/BbcodeParserTest.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 		public function testAtLinkKnownUsers() {
285 285
 			$input = '@Alice @Bob @Bobby Junior @Bobby Tables @Dr. No';
286 286
 			$expected =
287
-				"<a href='/at/Alice'>@Alice</a>" .
288
-				" @Bob " .
289
-				"<a href='/at/Bobby+Junior'>@Bobby Junior</a>" .
290
-				" @Bobby Tables " .
287
+				"<a href='/at/Alice'>@Alice</a>".
288
+				" @Bob ".
289
+				"<a href='/at/Bobby+Junior'>@Bobby Junior</a>".
290
+				" @Bobby Tables ".
291 291
 				"<a href='/at/Dr.+No'>@Dr. No</a>";
292 292
 
293 293
 			$result = $this->_Parser->parse($input);
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 
581 581
 		public function testIframe() {
582 582
 			//* test allowed domain
583
-			$input = '[iframe height=349 width=560 ' .
584
-				'src=http://www.youtube.com/embed/HdoW3t_WorU ' .
583
+			$input = '[iframe height=349 width=560 '.
584
+				'src=http://www.youtube.com/embed/HdoW3t_WorU '.
585 585
 				'frameborder=0][/iframe]';
586 586
 			$expected = [
587 587
 				['iframe' => [
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
 			$this->assertTags($result, $expected);
597 597
 
598 598
 			//* test forbidden domains
599
-			$input = '[iframe height=349 width=560 ' .
600
-				'src=http://www.youtubescam.com/embed/HdoW3t_WorU ' .
599
+			$input = '[iframe height=349 width=560 '.
600
+				'src=http://www.youtubescam.com/embed/HdoW3t_WorU '.
601 601
 				'frameborder=0][/iframe]';
602 602
 			$expected = '/src/i';
603 603
 			$result = $this->_Parser->parse($input, ['video_domains_allowed' => 'youtube | vimeo']);
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
 		}
606 606
 
607 607
 		public function testIframeAllDomainsAllowed() {
608
-			$input = '[iframe height=349 width=560 ' .
609
-				'src=http://www.youtubescam.com/embed/HdoW3t_WorU ' .
608
+			$input = '[iframe height=349 width=560 '.
609
+				'src=http://www.youtubescam.com/embed/HdoW3t_WorU '.
610 610
 				'][/iframe]';
611 611
 			$expected = 'src="http://www.youtubescam.com/embed/HdoW3t_WorU';
612 612
 			$result = $this->_Parser->parse($input, ['video_domains_allowed' => '*']);
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
 		}
615 615
 
616 616
 		public function testIframeNoDomainAllowed() {
617
-			$input = '[iframe height=349 width=560 ' .
618
-				'src=http://www.youtubescam.com/embed/HdoW3t_WorU ' .
617
+			$input = '[iframe height=349 width=560 '.
618
+				'src=http://www.youtubescam.com/embed/HdoW3t_WorU '.
619 619
 				'][/iframe]';
620 620
 			$expected = '/src/i';
621 621
 			$result = $this->_Parser->parse($input, ['video_domains_allowed' => '']);
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 
635 635
 			// test for URIs without protocol
636 636
 			$input = '[img]/somewhere/macnemo.png[/img]';
637
-			$expected = '<img src="' . $this->_Helper->webroot . 'somewhere/macnemo.png" alt=""/>';
637
+			$expected = '<img src="'.$this->_Helper->webroot.'somewhere/macnemo.png" alt=""/>';
638 638
 			$result = $this->_Parser->parse($input);
639 639
 			$this->assertEquals($expected, $result);
640 640
 
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 		public function testCodeNoCitationMark() {
818 818
 			// [code]<citation mark>[/code] should not be cited
819 819
 			$input = h(
820
-				"[code]\n" . $this->_Helper->settings['quote_symbol'] . "\n[/code]"
820
+				"[code]\n".$this->_Helper->settings['quote_symbol']."\n[/code]"
821 821
 			);
822 822
 			$expected = '`span class=.*?richtext-citation`';
823 823
 			$result = $this->_Parser->parse($input);
@@ -832,11 +832,11 @@  discard block
 block discarded – undo
832 832
 
833 833
 		public function testQuote() {
834 834
 			$_qs = h($this->_Helper->settings['quote_symbol']);
835
-			$input = $_qs . ' fo [b]test[/b] ba';
835
+			$input = $_qs.' fo [b]test[/b] ba';
836 836
 			$result = $this->_Parser->parse($input);
837 837
 			$expected = [
838 838
 				'span' => ['class' => 'richtext-citation'],
839
-				$_qs . ' fo ',
839
+				$_qs.' fo ',
840 840
 				'strong' => [],
841 841
 				'test',
842 842
 				'/strong',
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 			//* test autoconversion for audio files
865 865
 			$html5AudioExtensions = array('m4a', 'ogg', 'mp3', 'wav', 'opus');
866 866
 			foreach ($html5AudioExtensions as $extension) {
867
-				$url = 'http://example.com/audio.' . $extension;
867
+				$url = 'http://example.com/audio.'.$extension;
868 868
 				$input = "[video]{$url}[/video]";
869 869
 				$result = $this->_Parser->parse($input);
870 870
 				$expected = array(
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 			$input = "[audio]{$url}[/audio]";
928 928
 			$result = $this->_Parser->parse($input);
929 929
 			$expected = array(
930
-					'audio' => array( 'src' => $url, 'controls' => 'controls' ),
930
+					'audio' => array('src' => $url, 'controls' => 'controls'),
931 931
 			);
932 932
 			$this->assertTags($result, $expected);
933 933
 
Please login to merge, or discard this patch.
app/Plugin/BbcodeParser/Lib/Parser.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$options = array_merge($this->_cSettings, $options);
218 218
 
219 219
 			// serializing complex objects kills PHP
220
-			$serializable = array_filter($options, function ($value) {
220
+			$serializable = array_filter($options, function($value) {
221 221
 				return !is_object($value);
222 222
 			});
223 223
 			$parserId = md5(serialize($serializable));
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 						$this->_Parser->addCodeDefinition($builder->build());
259 259
 						break;
260 260
 					case 'class':
261
-						require_once (\CakePlugin::path('BbcodeParser') . DS . 'Lib' . DS . 'jBBCode' . DS . 'Definitions' . DS . 'JbbCodeDefinitions.php');
262
-						$class = '\Plugin\BbcodeParser\Lib\jBBCode\Definitions\\' . ucfirst($title);
261
+						require_once (\CakePlugin::path('BbcodeParser').DS.'Lib'.DS.'jBBCode'.DS.'Definitions'.DS.'JbbCodeDefinitions.php');
262
+						$class = '\Plugin\BbcodeParser\Lib\jBBCode\Definitions\\'.ucfirst($title);
263 263
 						$this->_Parser->addCodeDefinition(new $class($this->_Helper, $options));
264 264
 						break;
265 265
 					default:
Please login to merge, or discard this patch.
app/Plugin/BbcodeParser/Lib/Helper/UrlParserTrait.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 				// use Cakes Validation class to detect valid URL
21 21
 				\App::uses('Validation', 'Utility');
22 22
 				if (\Validation::url($url)) {
23
-					$url = 'http://' . $url;
23
+					$url = 'http://'.$url;
24 24
 				}
25 25
 			}
26 26
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				if (!empty($url) && preg_match('/\<img\s*?src=/', $text) !== 1) {
37 37
 					$host = DomainParser::domainAndTld($url);
38 38
 					if ($host !== false && $host !== env('SERVER_NAME')) {
39
-						$out .= ' <span class=\'richtext-linkInfo\'>[' . $host . ']</span>';
39
+						$out .= ' <span class=\'richtext-linkInfo\'>['.$host.']</span>';
40 40
 					}
41 41
 				}
42 42
 			}
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 			}
65 65
 
66 66
 			$_placeholder = ' … ';
67
-			$leftMargin = (int)floor($_textWordMaxLength / 2);
68
-			$rightMargin = (int)(-1 * ($_textWordMaxLength - $leftMargin - mb_strlen($_placeholder)));
67
+			$leftMargin = (int) floor($_textWordMaxLength / 2);
68
+			$rightMargin = (int) (-1 * ($_textWordMaxLength - $leftMargin - mb_strlen($_placeholder)));
69 69
 
70
-			$string = mb_substr($string, 0, $leftMargin) . $_placeholder .
70
+			$string = mb_substr($string, 0, $leftMargin).$_placeholder.
71 71
 				mb_substr($string, $rightMargin);
72 72
 			return $string;
73 73
 		}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		 * @return string
80 80
 		 */
81 81
 		protected function _decorateTarget($string) {
82
-			$decorator = function ($matches) {
82
+			$decorator = function($matches) {
83 83
 				$out = '';
84 84
 				$url = $matches[1];
85 85
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 				$parsedUrl = @parse_url($url);
91 91
 
92 92
 				if (isset($parsedUrl['host'])) {
93
-					if ($parsedUrl['host'] !== env('SERVER_NAME') && $parsedUrl['host'] !== "www." . env('SERVER_NAME')) {
93
+					if ($parsedUrl['host'] !== env('SERVER_NAME') && $parsedUrl['host'] !== "www.".env('SERVER_NAME')) {
94 94
 						$out = " rel='external' target='_blank'";
95 95
 					}
96 96
 				}
97
-				return $matches[0] . $out;
97
+				return $matches[0].$out;
98 98
 			};
99 99
 
100 100
 			return preg_replace_callback('#href=["\'](.*?)["\']#is',
Please login to merge, or discard this patch.
app/Plugin/BbcodeParser/Lib/jBBCode/Visitors/JbbCodeAutolinkVisitor.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 				}
61 61
 			}
62 62
 			krsort($names);
63
-			$baseUrl = $this->_sOptions['webroot'] . $this->_sOptions['atBaseUrl'];
63
+			$baseUrl = $this->_sOptions['webroot'].$this->_sOptions['atBaseUrl'];
64 64
 			foreach ($names as $name => $v) {
65 65
 				$title = urlencode($name);
66
-				$link = $this->_url($baseUrl . $title, "@$name",
66
+				$link = $this->_url($baseUrl.$title, "@$name",
67 67
 					false);
68 68
 				$string = str_replace("@$name", $link, $string);
69 69
 			}
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 
74 74
 		protected function _autolink($string) {
75
-			$replace = function ($matches) {
75
+			$replace = function($matches) {
76 76
 				// exclude punctuation at end of sentence from URLs
77 77
 				$ignoredEndChars = implode('|', [',', '\?', ',', '\.', '\)', '!']);
78 78
 				preg_match(
79
-					'/(?P<element>.*?)(?P<suffix>' . $ignoredEndChars . ')?$/',
79
+					'/(?P<element>.*?)(?P<suffix>'.$ignoredEndChars.')?$/',
80 80
 					$matches['element'],
81 81
 					$m
82 82
 				);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 				$matches = $m + $matches;
85 85
 
86 86
 				if (strpos($matches['element'], '://') === false) {
87
-					$matches['element'] = 'http://' . $matches['element'];
87
+					$matches['element'] = 'http://'.$matches['element'];
88 88
 				}
89 89
 				$matches += [
90 90
 					'prefix' => '',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 				$url = $this->_url($matches['element'], $matches['element'], false,
95 95
 					true);
96
-				return $matches['prefix'] . $url . $matches['suffix'];
96
+				return $matches['prefix'].$url.$matches['suffix'];
97 97
 			};
98 98
 
99 99
 			//# autolink http://urls
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			//# autolink email
114 114
 			$string = preg_replace_callback(
115 115
 				"#(?<=^|[\n ])(?P<content>([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+))#i",
116
-				function ($matches) {
116
+				function($matches) {
117 117
 					return $this->_email($matches['content']);
118 118
 				}, $string
119 119
 			);
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 		}
123 123
 
124 124
 		protected function _hashLink($string) {
125
-			$baseUrl = $this->_sOptions['webroot'] . $this->_sOptions['hashBaseUrl'];
125
+			$baseUrl = $this->_sOptions['webroot'].$this->_sOptions['hashBaseUrl'];
126 126
 			$string = preg_replace_callback(
127 127
 				'/(?<=\s|^|])(?<tag>#)(?<element>\d+)(?!\w)/',
128
-				function ($m) use ($baseUrl) {
128
+				function($m) use ($baseUrl) {
129 129
 					$hash = $m['element'];
130
-					return $this->_url($baseUrl . $hash, '#' . $hash);
130
+					return $this->_url($baseUrl.$hash, '#'.$hash);
131 131
 				},
132 132
 				$string
133 133
 			);
Please login to merge, or discard this patch.
Plugin/BbcodeParser/Lib/jBBCode/Definitions/JbbHtml5MediaCodeDefinition.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		protected function _audio($content) {
20 20
 			$out = "<audio src='$content' controls='controls'>";
21 21
 			$out .= Message::format(__(
22
-				'Your browser does not support HTML5 audio. Please updgrade to a modern ' .
22
+				'Your browser does not support HTML5 audio. Please updgrade to a modern '.
23 23
 				'browser. In order to watch this stream you need an HTML5 capable browser.',
24 24
 				true));
25 25
 			$out .= "</audio>";
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 		protected function _video($content) {
30 30
 			// fix audio files mistakenly wrapped into an [video] tag
31
-			if (preg_match('/(' . implode('|', self::$_html5AudioExtensions) . ')$/i',
31
+			if (preg_match('/('.implode('|', self::$_html5AudioExtensions).')$/i',
32 32
 					$content) === 1
33 33
 			) {
34 34
 				return $this->_audio($content);
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 			$out = "<video src='$content' controls='controls' x-webkit-airplay='allow'>";
38 38
 			$out .= Message::format(__(
39
-				'Your browser does not support HTML5 video. Please updgrade to a modern ' .
39
+				'Your browser does not support HTML5 video. Please updgrade to a modern '.
40 40
 				'browser. In order to watch this stream you need an HTML5 capable browser.',
41 41
 				true));
42 42
 			$out .= '</video>';
Please login to merge, or discard this patch.
app/Plugin/BbcodeParser/Lib/jBBCode/Definitions/JbbCodeCodeDefinition.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 			// load config from app/Config/geshi.php
21 21
 			$this->Geshi->features = false;
22 22
 
23
-			$string = '<div class="geshi-wrapper"><pre lang="' . $type . '">' . $content . '</pre></div>';
23
+			$string = '<div class="geshi-wrapper"><pre lang="'.$type.'">'.$content.'</pre></div>';
24 24
 
25 25
 			$string = $this->Geshi->highlight($string);
26 26
 			return $string;
Please login to merge, or discard this patch.
app/Plugin/BbcodeParser/Lib/jBBCode/Definitions/JbbCodeDefinitions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
 			// @todo should be done in Setting model
125 125
 			$ad = explode('|', $this->_sOptions['video_domains_allowed']);
126
-			$trim = function ($v) {
126
+			$trim = function($v) {
127 127
 				return trim($v);
128 128
 			};
129 129
 			$this->_allowedVideoDomains = array_fill_keys(array_map($trim, $ad), 1);
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 				}
194 194
 			}
195 195
 
196
-			$out = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="' . $width . '" height="' . $height . '">
197
-									<param name="movie" value="' . $url . '"></param>
198
-									<embed src="' . $url . '" width="' . $width . '" height="' . $height . '" type="application/x-shockwave-flash" wmode="opaque" style="width:' . $width . 'px; height:' . $height . 'px;" id="VideoPlayback" flashvars=""> </embed> </object>';
196
+			$out = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'.$width.'" height="'.$height.'">
197
+									<param name="movie" value="' . $url.'"></param>
198
+									<embed src="' . $url.'" width="'.$width.'" height="'.$height.'" type="application/x-shockwave-flash" wmode="opaque" style="width:'.$width.'px; height:'.$height.'px;" id="VideoPlayback" flashvars=""> </embed> </object>';
199 199
 			return $out;
200 200
 		}
201 201
 
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
 		protected function _parse($content, $attributes) {
259 259
 			$listPieces = explode('[*]', $content);
260 260
 			unset($listPieces[0]);
261
-			$listPieceProcessor = function ($li) {
262
-				return '<li>' . $li . '</li>' . "\n";
261
+			$listPieceProcessor = function($li) {
262
+				return '<li>'.$li.'</li>'."\n";
263 263
 			};
264 264
 			$listPieces = array_map($listPieceProcessor, $listPieces);
265 265
 
266
-			return '<ul>' . implode('', $listPieces) . '</ul>';
266
+			return '<ul>'.implode('', $listPieces).'</ul>';
267 267
 		}
268 268
 
269 269
 	}
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
 			}
281 281
 
282 282
 			$title = $this->_mbStrpad(
283
-				' ' . __('Spoiler') . ' ',
283
+				' '.__('Spoiler').' ',
284 284
 				$length,
285 285
 				'▇',
286 286
 				STR_PAD_BOTH
287 287
 			);
288 288
 
289 289
 			$json = json_encode(['string' => $content]);
290
-			$id = 'spoiler_' . rand(0, 9999999999999);
290
+			$id = 'spoiler_'.rand(0, 9999999999999);
291 291
 
292 292
 			$out = <<<EOF
293 293
 <div class="richtext-spoiler" style="display: inline;">
@@ -320,19 +320,19 @@  discard block
 block discarded – undo
320 320
 			$result = null;
321 321
 			$repeat = ceil($strLen - $padStrLen + $padLen);
322 322
 			if ($dir == STR_PAD_RIGHT) {
323
-				$result = $str . str_repeat($padStr, $repeat);
323
+				$result = $str.str_repeat($padStr, $repeat);
324 324
 				$result = mb_substr($result, 0, $padLen);
325 325
 			} else {
326 326
 				if ($dir == STR_PAD_LEFT) {
327
-					$result = str_repeat($padStr, $repeat) . $str;
327
+					$result = str_repeat($padStr, $repeat).$str;
328 328
 					$result = mb_substr($result, -$padLen);
329 329
 				} else {
330 330
 					if ($dir == STR_PAD_BOTH) {
331 331
 						$length = ($padLen - $strLen) / 2;
332 332
 						$repeat = ceil($length / $padStrLen);
333 333
 						$result = mb_substr(str_repeat($padStr, $repeat), 0,
334
-								floor($length)) .
335
-							$str .
334
+								floor($length)).
335
+							$str.
336 336
 							mb_substr(str_repeat($padStr, $repeat), 0, ceil($length));
337 337
 					}
338 338
 				}
Please login to merge, or discard this patch.
app/Plugin/BbcodeParser/Lib/Editor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
 					'className' => 'btn-markItUp-Link',
71 71
 					'key' => 'L',
72 72
 					'openWith' =>
73
-						'[url=[![' . __('geshi_link_popup') . ']!]]',
73
+						'[url=[!['.__('geshi_link_popup').']!]]',
74 74
 					'closeWith' => '[/url]',
75 75
 					'placeHolder' => __('geshi_link_placeholder'),
76 76
 				),
Please login to merge, or discard this patch.
app/Plugin/BbcodeParser/Lib/Processors/BbcodeQuotePostprocessor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
 			$quoteSymbolSanitized = h($this->_sOptions['quote_symbol']);
9 9
 			$string = preg_replace(
10 10
 			// Begin of the text or a new line in the text, maybe one space afterwards
11
-				'/(^|\n\r\s?)' .
12
-				$quoteSymbolSanitized .
11
+				'/(^|\n\r\s?)'.
12
+				$quoteSymbolSanitized.
13 13
 				'\s(.*)(?!\<br)/m',
14
-				"\\1<span class=\"richtext-citation\">" . $quoteSymbolSanitized . " \\2</span>",
14
+				"\\1<span class=\"richtext-citation\">".$quoteSymbolSanitized." \\2</span>",
15 15
 				$string
16 16
 			);
17 17
 			return $string;
Please login to merge, or discard this patch.