Get chat emoticons by set

@param string $emotesets (comma-seperated list)
@throws InvalidTypeException
@return array|json
427009
public function getChatEmoticonSets($emotesets = null)
    {
        if ($emotesets && !is_string($emotesets)) {
            throw new InvalidTypeException('emotesets', 'string', gettype($emotesets));
        }

        $emotesets = trim($emotesets, ', ');

        return $this->get('chat/emoticon_images', ['emotesets' => $emotesets]);
    }
429203
public static function parseTokens(&$tokens) {
        do {
		    $typeArray = array_shift($tokens);
            if ($typeArray['token'] == "T_WHITESPACE"){
                continue;
            }
            else {
                break;
            }
        }while(true);

        if ($typeArray['token'] != 'T_TYPE') {
			throw new MoufTypeParserException("Invalid type! Expecting a type name. Got '".$typeArray['match']."'");
		}
		
		$type = new TypeDescriptor();
		$type->type = $typeArray['match'];
		
		if (empty($typeArray)) {
			return $type;
		}
		
		do {
			$continue = false;
			$nextToken = array_shift($tokens);
		
			switch ($nextToken['token']) {
				case 'T_ARRAY';
					$continue = true;
					$subType = $type;
					$type = new TypeDescriptor();
					$type->type = 'array';
					$type->subType = $subType;
					break;
				case 'T_END_ARRAY';
                    array_unshift($tokens, $nextToken);
					break;
				case 'T_START_ARRAY';
					$tok1 = self::getNthTokenWithoutWhitespace($tokens, 1);
					if ($tok1['token'] == 'T_COMA') {
						$tok0 = self::getNthTokenWithoutWhitespace($tokens, 0);
						if ($tok0['token'] != 'T_TYPE') {
							throw new MoufTypeParserException("Invalid type! Expecting a type name. Got ".$tokens['match']);
						}
						$type->keyType = $tok0['match'];
						// Let's shift twice, without counting whitespaces:
						while ($tokens[0] != $tok1) {
							array_shift($tokens);
						}
						array_shift($tokens);
						// TODO: with a state machine, we could handle whitespaces in a best way
						// TODO: develop a statemachine!
						while ($tokens[0]['token'] == 'T_WHITESPACE') {
							array_shift($tokens);
						}
						
					}
					$type->subType = TypeDescriptor::parseTokens($tokens);

                    while ($tokens[0]['token'] == 'T_WHITESPACE') {
                        array_shift($tokens);
                    }

                    if ($tokens[0]['token'] != 'T_END_ARRAY'){
                        throw new MoufTypeParserException("Invalid type! Expecting >. Got '".$tokens[0]['match']."'");
                    }

                    array_shift($tokens);

					break;
				case 'T_OR':
					break;
			}
		} while ($continue);
		
		return $type;
	}
86410
private function parseTokens(array $tokens)
    {
        return array_map(function ($token, $key) {
            return ['name' => $key, 'value' => $token];
        }, $tokens, array_keys($tokens));
    }
308666
private function parseAnnotations($annotations)
    {
        // parse array from (numeric key => 'annotation <value>') to (annotation => value)
        $methodServices = [];
        foreach ($annotations as $annotation) {
            if (!preg_match('/^(\w+)\s+\$(\w+)\s+([\w\.\@\%]+)/', $annotation, $matches)) {
                continue;
            }

            array_shift($matches);
            $tag = array_shift($matches);
            if ($tag == self::SERVICE_DOC_TAG) {
                list($argument, $service) = $matches;
                $methodServices[$argument] = $service;
            }
        }

        return $methodServices;
    }
405830
protected function render_pix_emoticon(pix_emoticon $emoticon) {
        $system = \core\output\icon_system::instance(\core\output\icon_system::STANDARD);
        return $system->render_pix_icon($this, $emoticon);
    }
970992
public function detect_emoticons()
	{
		$pattern = '';
		foreach($this->emoticons as $key => $url)
			$pattern .= ($pattern === ''? '/(?:':'|') . preg_quote($key, '/');
		$pattern .= ')/';

		$emoticons = $this->emoticons;

		$this->loop_text_nodes(function($child) use ($pattern, $emoticons) {
			preg_match_all($pattern,
				$child->get_text(),
				$matches,
				PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);

			if(count($matches[0]) == 0)
				return;

			$replacment = array();
			$last_pos   = 0;

			foreach($matches[0] as $match)
			{
				$url      = new Node_Container_Tag('img', array('alt'=>$match[0]));
				$url_text = new Node_Text($emoticons[$match[0]]);
				$url->add_child($url_text);

				$replacment[] = new Node_Text(substr($child->get_text(), $last_pos, $match[1] - $last_pos));
				$replacment[] = $url;
				$last_pos = $match[1] + strlen($match[0]);
			}

			$replacment[] = new Node_Text(substr($child->get_text(), $last_pos));
			$child->parent()->replace_child($child, $replacment);
		}, $this->get_excluded_tags(BBCode::AUTO_DETECT_EXCLUDE_EMOTICON));

		return $this;
	}
658943
public function getChatClassString($type) {
        /** @var EntityManager $em */
        $em = $this->container->get('doctrine')->getManager();

        $chatClass = "Sopinet\ChatBundle\Entity\Chat";

        $cmf = $em->getMetadataFactory();
        $meta = $cmf->getMetadataFor($chatClass);

        $config = $this->container->getParameter('sopinet_chat.config');
        foreach($meta->discriminatorMap as $typeString => $typeClass) {
            if ($typeString == $type) {
                return $typeClass;
            }
        }

        // Type unknow
        return null;
    }
1142029
private function doParseTokens()
    {
        $tokens = array();

        while ($this->valid()) {
            while (ctype_space($this->current)) {
                // Skip spaces
                $this->next();
            }

            if ($this->valid()) {
                $tokens[] = $this->parseToken();
            }
        }

        return $tokens;
    }
114759
public function refreshCharactersetCollation($characterSet, $collation)
    {
        $this->executeQuery('SET NAMES ' . $this->quote($characterSet) . ' COLLATE ' . $this->quote($collation));
        $this->overriddenParams['character_set'] = $characterSet;
        $this->overriddenParams['collation'] = $collation;
    }
529711
public static function GetMimeTypeCharsetByCharset ($charset) {
		$charset_map = static::GetCharsetMapForMimeType();
		return isset($charset_map[$charset]) ? $charset_map[$charset] : null;
	}
1291974
public function checkTexts(array $texts, array $params = [])
    {
        $mergedParams = $this->mergeParams($this->getDefaultParams(), $params);

        $query = [];
        foreach ($texts as $text) {
            $query[] = 'text=' . rawurlencode($text);
        }

        foreach ($mergedParams as $key => $value) {
            if (!empty($value)) {
                $query[] = $key . '=' . rawurlencode($value);
            }
        }

        $response = $this->sendRequest(
            'POST',
            '/services/spellservice.json/checkTexts',
            [
                'headers' => [
                    'Content-Type' => 'application/x-www-form-urlencoded'
                ],
                'body' => join('&', $query)
            ]
        );

        if (!empty($mergedParams['callback'])) {
            return (string) $response->getBody();
        }

        return $this->getDecodedBody($response->getBody());
    }
782547
protected function getTokens()
    {
        if ($this->tokens === null) {
            $this->tokens = $this->parsePattern($this->pattern);
        }

        return $this->tokens;
    }
788801
public function setCharacterSet($characterSet)
    {
        if ($characterSet !== null) {
            $characterSet = $this->normalizeCharacterSet($characterSet);
        }
        $this->characterSet = $characterSet;

        return $this;
    }
467522
public function getTemplate()
	{
		// Build the <xsl:choose> node
		$xsl = '<xsl:choose>';

		// First, test whether the emoticon should be rendered as text if applicable
		if (!empty($this->notIfCondition))
		{
			$xsl .= '<xsl:when test="' . htmlspecialchars($this->notIfCondition) . '">'
			      . '<xsl:value-of select="."/>'
			      . '</xsl:when>'
			      . '<xsl:otherwise>'
			      . '<xsl:choose>';
		}

		// Iterate over codes, create an <xsl:when> for each emote
		foreach ($this->collection as $code => $template)
		{
			$xsl .= '<xsl:when test=".=' . htmlspecialchars(XPath::export($code)) . '">'
			      . $template
			      . '</xsl:when>';
		}

		// Finish it with an <xsl:otherwise> that displays the unknown codes as text
		$xsl .= '<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>';

		// Close the emote switch
		$xsl .= '</xsl:choose>';

		// Close the "notIf" condition if applicable
		if (!empty($this->notIfCondition))
		{
			$xsl .= '</xsl:otherwise></xsl:choose>';
		}

		return $xsl;
	}
997651
public function add_emoticons(Array $emoticons, $replace=true)
	{
		foreach($emoticons as $key => $url)
			$this->add_emoticon($key, $url, $replace);
	}
1202158
public function createMessage($deviceTokens = [])
    {
        $message = new Message();
        if (is_string($deviceTokens)) {
            $deviceTokens = [$deviceTokens];
        }
        if (!is_array($deviceTokens)) {
            throw new InvalidParamException("\$deviceTokens must be string or array");
        }
        foreach ($deviceTokens as $token) {
            $message->addRecipient($this->createDevice($token));
        }
        return $message;
    }
347010
protected function getSolidityTypes($types)
    {
        if (!is_array($types)) {
            throw new InvalidArgumentException('Types must be array');
        }
        $solidityTypes = array_fill(0, count($types), 0);

        foreach ($types as $key => $type) {
            $match = [];

            if (preg_match('/^([a-zA-Z]+)/', $type, $match) === 1) {
                if (isset($this->types[$match[0]])) {
                    $className = $this->types[$match[0]];

                    if (call_user_func([$this->types[$match[0]], 'isType'], $type) === false) {
                        // check dynamic bytes
                        if ($match[0] === 'bytes') {
                            $className = $this->types['dynamicBytes'];
                        } else {
                            throw new InvalidArgumentException('Unsupport solidity parameter type: ' . $type);
                        }
                    }
                    $solidityTypes[$key] = $className;
                }
            }
        }
        return $solidityTypes;
    }