Replace/push the toolbars

@param string $text Block of text to parse
@return ComKoowaTemplateFilterToolbar
357037
public function filter(&$text)
    {
        $matches = array();

        if(preg_match_all('#<ktml:toolbar([^>]*)>#siU', $text, $matches))
        {
            foreach($matches[0] as $key => $match)
            {
                $attributes = $this->parseAttributes($matches[1][$key]);

                //Create attributes array
                $config = new KObjectConfig($attributes);
                $config->append(array(
                    'type'  => 'actionbar',
                ));

                $helper = $this->getTemplate()->createHelper($config->type);

                $html = '';
                if($toolbar = $this->getToolbar($helper->getToolbarType()))
                {
                    $config->toolbar = $toolbar; //set the toolbar in the config

                    $html = $helper->render($config);
                }

                //Remove placeholder
                $text = str_replace($match, $html, $text);
            }
        }

        return $this;
    }
749707
public function prependEmpty($text=NULL) {
		
		$t = Translator::getInstance();
		
		$option			= new \stdClass();
		$option->value	= '';
		$option->text	= is_null($text) ? $t->get('SELECT_NULL_VALUE') : $text;

		$this->list = array_merge(array($option), $this->list);
		
		return $this;
		
	}
1291230
public function text($text = '')
    {
        $msg = array(
            'ToUserName'   => $this->getRevFrom(),
            'FromUserName' => $this->getRevTo(),
            'MsgType'      => self::MSGTYPE_TEXT,
            'Content'      => $this->_auto_text_filter($text),
            'CreateTime'   => time(),
        );
        $this->Message($msg);
        return $this;
    }
649384
public function censorText($text)
	{
		return preg_replace_callback(
			$this->regexp,
			function ($m)
			{
				return $this->getReplacement($m[0]);
			},
			$text
		);
	}
242549
public function placeholder($text)
    {
        return $this->prependChild(
            Option::create()
                ->value(null)
                ->text($text)
                ->selectedIf(! $this->hasSelection())
        );
    }
391546
public function setText(string $text): self
    {
        return $this->addPart(Part::create($text, 'text/plain'), true);
    }
978586
public static function convert($text)
    {
        static $parser;

        if (empty($parser)) {
            $parser = new MarkdownExtraExtended();
        }

        return $parser->transform($text);
    }
541092
public function purge($text)
    {
        foreach ($this->parsers as $parser) {
            $text = $parser->purge($text);
        }

        return $text;
    }
1007413
public function text($text) {

        if(false === is_string($text)) {
            return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($text)), E_USER_ERROR);
        }

    	$this -> text = $text;

    	return $this;
    }
966071
public static function replaceLinksInTextsWithHrefs(string $text): string
    {
        $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);

        $ret = ' ' . $text;

        // Replace links with http://
        $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret);

        // Replace links without http://
        $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret);

        // Replace email addresses
        $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
        $ret = substr($ret, 1);

        return $ret;
    }
623660
public function setText(string $text)
    {
        PregHelper::assertValidUTF8(
            $text,
            RegExpException::class,
            "Regular expression error on checking source text"
        );
        $this->text = $text;
        $this->textAtCursor = null;
        $this->cursor = 0;
        return $this;
    }
536167
public function clean($text)
    {
        if (!$this->type) {
            return $text;
        }

        return static::$filter->clean($text, $this->type);
    }
925955
public function read(&$text)
    {
        $text = str_replace(
            array_keys($this->_alias_read),
            array_values($this->_alias_read),
            $text);

        return $this;
    }
325549
public function addParagraph($text)
    {
        $this->content .= isset($this->app)
            ? $this->app->getTag('p', $text)
            : '<p>'.htmlspecialchars($text).'</p>';

        return $this;
    }
273609
public function replaceTokens($text) {
    $tokens = $this->macro->search($text);
    if (empty($tokens)) {
      return $text;
    }

    static $last = [];
    $replacements = [];
    foreach ($tokens as $type => $typeTokens) {
      foreach ($typeTokens as $name => $token) {
        if ($type == "any") {
          $value = $this->faker->{$name};
          $replacements[$token] = $value;
          $last[$name] = $value;
        } elseif ($type == "last") {
          $replacements[$token] = $last[$name];
        }
      }
    }

    $search = array_keys($replacements);
    $replace = array_values($replacements);
    return str_replace($search, $replace, $text);
  }
53510
public function filter(&$text)
    {
        $pattern = '~
            <ktml:(?:script|style) # match ktml:script and ktml:style tags
            [^(?:src=)]+           # anything before src=
            src="                  # match the link
              ((?:media://|assets://)           # starts with media:// or assets://
              (?:koowa/)?            # may or may not be in koowa/ folder
              (?:com_([^/]+)/|js/|css/|scss/) # either has package name (com_foo) or in framework
              [^"]+)"                # match the rest of the link
             (.*)/>
        ~siUx';

        // Hold a list of already processed URLs
        $processed = array();

        if(preg_match_all($pattern, $text, $matches, PREG_SET_ORDER))
        {
            foreach ($matches as $match)
            {
                $version = $this->_getVersion(!empty($match[2]) ? $match[2] : 'koowa');

                if ($version)
                {
                    $url = $match[1];

                    if (!in_array($url, $processed))
                    {
                        $processed[] = $url;

                        $version = substr(md5($version), 0, 8);
                        $suffix  = strpos($url, '?') === false ? '?'.$version : '&'.$version;
                        $text    = str_replace($url, $url.$suffix, $text);
                    }


                }
            }
        }
    }
1089580
public function replace($text)
    {
        preg_match_all($this->pattern, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
        $delta = 0;
        foreach ($matches as $match)
        {
            $stringsOnly = array();
            foreach ($match as $info)
            {
                $stringsOnly []= $info[0];
            }
            $replace = call_user_func($this->callback, $stringsOnly);
            if (false === $replace || null === $replace)
            {
                continue;
            }

            $text = substr_replace($text, $replace, $match[0][1] + $delta, strlen($match[0][0]));
            $delta += strlen($replace) - strlen($match[0][0]);
        }

        return $text;
    }