Ejemplo n.º 1
0
 /**
  * Shortcode to to quicker format text as HTML.
  *
  * @param string $text text to be converted.
  *
  * @return string the formatted text.
  */
 public function shortCode($text)
 {
     $patterns = ['/\\[(FIGURE)[\\s+](.+)\\]/', '/\\[(BASEURL)\\]/', '/\\[(RELURL)\\]/', '/\\[(ASSET)\\]/'];
     return preg_replace_callback($patterns, function ($matches) {
         switch ($matches[1]) {
             case 'FIGURE':
                 return CTextFilter::ShortCodeFigure($matches[2]);
                 break;
             case 'BASEURL':
                 return CTextFilter::ShortCodeBaseurl();
                 break;
             case 'RELURL':
                 return CTextFilter::ShortCodeRelurl();
                 break;
             case 'ASSET':
                 return CTextFilter::ShortCodeAsset();
                 break;
             default:
                 return "{$matches[1]} is unknown shortcode.";
         }
     }, $text);
 }