2 namespace wcf\system\message\embedded\object;
3 use wcf\data\DatabaseObjectDecorator;
4 use wcf\util\ArrayUtil;
7 * Provides default implementations for message embedded object handlers.
10 * @copyright 2001-2015 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package com.woltlab.wcf
13 * @subpackage system.message.embedded.object
14 * @category Community Framework
16 abstract class AbstractMessageEmbeddedObjectHandler extends DatabaseObjectDecorator implements IMessageEmbeddedObjectHandler {
18 * @see \wcf\data\DatabaseObjectDecorator::$baseClass
20 protected static $baseClass = 'wcf\data\object\type\ObjectType';
23 * Parses given message for specific bbcode parameters.
25 * @param string $message
26 * @param string $bbcode bbcode name
29 public static function getTextParameters($message, $bbcode) {
30 if (preg_match_all('~\['.$bbcode.'\](.*?)\[/'.$bbcode.'\]~i', $message, $matches)) {
31 $results = ArrayUtil::trim($matches[1]);
32 $results = array_unique($results);
41 * Parses given message for specific bbcode parameters.
43 * @param string $message
44 * @param string $bbcode bbcode name
47 public static function getFirstParameters($message, $bbcode) {
48 $pattern = '~\['.$bbcode.'=
49 (?:\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|([^,\]]*))
50 (?:,(?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\]]*))*
53 if (preg_match_all($pattern, $message, $matches)) {
54 $results = ArrayUtil::trim($matches[1]);
55 $results = array_merge($results, ArrayUtil::trim($matches[2]));
56 $results = array_unique($results);