Back to PhocaGalleryComment class

Method bbCodeCallback

public static
bbCodeCallback
(mixed $matches)

Method bbCodeCallback - Source code

/*
 * @based based on Seb's BB-Code-Parser script by seb
 * @url http://www.traum-projekt.com/forum/54-traum-scripts/25292-sebs-bb-code-parser.html
 */
public static function bbCodeCallback($matches)
{
    $tag = trim($matches[1]);
    $bodyString = $matches[6];
    $argument = $matches[4];
    switch ($tag) {
        case 'b':
        case 'i':
        case 'u':
            $replacement = '<' . $tag . '>' . $bodyString . '</' . $tag . '>';
            break;
        default:
            // unknown tag => reconstruct and return original expression
            $replacement = '[' . $tag . ']' . $bodyString . '[/' . $tag . ']';
            break;
    }
    return $replacement;
}