/var/www/vhosts/ihelp.ro/httpdocs/vendor/mirko-pagliai/me-tools/src/Utility
NameSizeModeActions
BBCode.php44280644editdlrm
Youtube.php17300644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/mirko-pagliai/me-tools/src/Utility/BBCode.php (4428B)
'/\[hr\s*\/?]/', 'image' => '/\[img](.+?)\[\/img]/', 'readmore' => '/(|.*?[^?]>))?\[read-?more\s*\/?\s*](<\/p>)?/', 'url' => '/\[url=[\'"](.+?)[\'"]](.+?)\[\/url]/', 'youtube' => '/(|.*?[^?]>))?\[youtube](.+?)\[\/youtube](<\/p>)?/', ]; /** * Constructor * @param \MeTools\View\Helper\HtmlHelper|null $HtmlHelper An `HtmlHelper` instance */ public function __construct(?HtmlHelper $HtmlHelper = null) { $this->Html = $HtmlHelper ?: new HtmlHelper(new View()); } /** * Executes all parsers * @param string $text Text * @return string */ public function parser(string $text): string { //Gets all class methods, except for `parser()` and `remove()` $methods = array_diff(get_class_methods(__CLASS__), ['__construct', 'parser', 'remove']); //Calls dynamically each method foreach ($methods as $method) { $callable = [$this, $method]; if (is_callable($callable)) { $text = call_user_func($callable, $text); } } return $text; } /** * Removes all BBCode * @param string $text Text * @return string */ public function remove(string $text): string { return trim(preg_replace($this->pattern, '', $text) ?: ''); } /** * Parses horizontal rule code * @param string $text Text * @return string * @since 2.22.1 */ public function hr(string $text): string { return preg_replace($this->pattern['hr'], '
', $text) ?: ''; } /** * Parses image code. * * [img]my_pic.gif[/img] * * @param string $text Text * @return string */ public function image(string $text): string { return preg_replace_callback($this->pattern['image'], fn($matches): string => $this->Html->image($matches[1]), $text) ?: ''; } /** * Parses "read mode" code. Example: * * [read-more /] * * @param string $text Text * @return string */ public function readMore(string $text): string { return preg_replace($this->pattern['readmore'], '', $text) ?: ''; } /** * Parses url code. * * [url="http://example"]my link[/url] * * @param string $text Text * @return string */ public function url(string $text): string { return preg_replace_callback($this->pattern['url'], fn($matches): string => $this->Html->link($matches[2], $matches[1]), $text) ?: ''; } /** * Parses Youtube code. * You can use video ID or video url. * * Examples: * * [youtube]bL_CJKq9rIw[/youtube] * * * * [youtube]http://youtube.com/watch?v=bL_CJKq9rIw[/youtube] * * @param string $text Text * @return string */ public function youtube(string $text): string { return preg_replace_callback($this->pattern['youtube'], function (array $matches): string { if (is_url($matches[3])) { $id = Youtube::getId($matches[3]) ?: ''; parse_str(parse_url($matches[3], PHP_URL_QUERY) ?: '', $query); if (isset($query['t']) && is_string($query['t'])) { $id .= '?start=' . $query['t']; } } return $this->Html->youtube($id ?? $matches[3]); }, $text) ?: ''; } }