3 namespace Friendica\Content\Text\BBCode;
6 * Video specific BBCode util class
11 * Transforms video BBCode tagged links to youtube/vimeo tagged links
13 * @param string $bbCodeString The input BBCode styled string
15 * @return string The transformed text
17 public function transform(string $bbCodeString)
20 $found = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$bbCodeString,$matches,PREG_SET_ORDER);
22 foreach ($matches as $match) {
23 if ((stristr($match[1], 'youtube')) || (stristr($match[1], 'youtu.be'))) {
24 $bbCodeString = str_replace($match[0], '[youtube]' . $match[1] . '[/youtube]', $bbCodeString);
25 } elseif (stristr($match[1], 'vimeo')) {
26 $bbCodeString = str_replace($match[0], '[vimeo]' . $match[1] . '[/vimeo]', $bbCodeString);