This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/app/BBCode/Tags/Box.php

41 lines
1,001 B
PHP

<?php
/**
* Holds the box tag.
* @package Sakura
*/
namespace Sakura\BBCode\Tags;
use Sakura\BBCode\TagBase;
use Sakura\User;
/**
* Box tag.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Box extends TagBase
{
/**
* Parses the bbcode.
* @param string $text
* @param User $poster
* @return string
*/
public static function parse(string $text, User $poster): string
{
return preg_replace_callback(
'/\[box(?:\=(.*?))?\](.*?)\[\/box\]/s',
function ($matches) {
$title = strlen($matches[1]) ? $matches[1] : 'Click to open';
return "<div class='bbcode__box'>"
. "<div class='bbcode__box-title' onclick='alert(\"implement the toggle system\");'>{$title}</div>"
. "<div class='bbcode__box-content bbcode__box-content--hidden'>{$matches[2]}</div>"
. "</div>";
},
$text
);
}
}