A bare bones front-end for knockout designed for maximum compatibility with "obsolete" browsers
25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?php
-
- namespace App\BbCode\Tag;
-
- use Knockout\BbCode\Tag\TagInterface;
- use Knockout\BbCode\Tokenizer\Tag as TokenTag;
-
- class Link implements TagInterface
- {
-
- const REG_EXP_VALID_URL = '~https?://[a-zA-Z0-9_\-.:/#?]+~';
-
- public function format(TokenTag $tokenTag): string
- {
- $args = $tokenTag->parseArgument();
- $url = $args['href'] ?? null;
-
- if (!preg_match(self::REG_EXP_VALID_URL, $url)) {
- $simpleTag = new Unknown();
- return $simpleTag->format($tokenTag);
- }
-
- return "<a href=\"{$url}\" target=\"_blank\">{$tokenTag->getText()}</a>";
- }
-
- public function getName(): string
- {
- return 'url';
- }
-
- public function getOriginalText(TokenTag $tokenTag) : string
- {
- return "[url={$tokenTag->getArgument()}]{$tokenTag->getText()}[/url]";
- }
- }
|