2 namespace wcf\system\message\embedded\object;
3 use wcf\data\object\type\ObjectType;
4 use wcf\data\DatabaseObjectDecorator;
5 use wcf\util\ArrayUtil;
8 * Provides default implementations for message embedded object handlers.
11 * @copyright 2001-2016 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.message.embedded.object
15 * @category Community Framework
17 * @method ObjectType getDecoratedObject()
20 abstract class AbstractMessageEmbeddedObjectHandler extends DatabaseObjectDecorator implements IMessageEmbeddedObjectHandler {
24 protected static $baseClass = ObjectType::class;
27 * Parses given message for specific bbcode parameters.
29 * @param string $message
30 * @param string $bbcode bbcode name
33 public static function getTextParameters($message, $bbcode) {
34 if (preg_match_all('~\['.$bbcode.'\](.*?)\[/'.$bbcode.'\]~i', $message, $matches)) {
35 $results = ArrayUtil::trim($matches[1]);
36 $results = array_unique($results);
45 * Parses given message for specific bbcode parameters.
47 * @param string $message
48 * @param string $bbcode bbcode name
51 public static function getFirstParameters($message, $bbcode) {
52 $pattern = '~\['.$bbcode.'=
53 (\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|(?:[^,\]]*))
54 (?:,(?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\]]*))*
57 if (preg_match_all($pattern, $message, $matches)) {
58 foreach ($matches[1] as &$value) {
60 if (mb_substr($value, 0, 1) == "'" && mb_substr($value, -1) == "'") {
61 $value = str_replace("\'", "'", $value);
62 $value = str_replace("\\\\", "\\", $value);
64 $value = mb_substr($value, 1, -1);
68 $results = ArrayUtil::trim($matches[1]);
69 $results = array_unique($results);