Filters mentions in a text.

@param string $text
The text containing the possible mentions.

@return string
The processed text.
557140
public function filterMentions($text) {
    $mentions = $this->getMentions($text);

    foreach ($mentions as $match) {
      $mention = $this->mentionsManager->createInstance($match['type']);

      if ($mention instanceof MentionsPluginInterface) {
        $output_settings = $this->outputSettings[$match['config_name']];
        $output = $mention->outputCallback($match, $output_settings);
        $build = [
          '#theme' => 'mention_link',
          '#mention_id' => $match['target']['entity_id'],
          '#link' => $output['link'],
          '#render_link' => $output_settings['renderlink'],
          '#render_value' => $output['value'],
        ];
        $mentions = $this->renderer->render($build);
        $text = str_replace($match['source']['string'], $mentions, $text);
      }
    }

    return $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);
                    }


                }
            }
        }
    }
243742
public function read(&$text)
    {
        /**
         * We could make a better effort at only finding @ between <?php ?>
         * but that's probably not necessary as @ doesn't occur much in the wild
         * and there's a significant performance gain by using str_replace().
         */

        // Replace \@ with \$
        $text = str_replace('\@', '\$', $text);

        // Now replace non-eescaped @'s
         $text = str_replace(array('@$'), '$', $text);

        // Replace \$ with @
        $text = str_replace('\$', '@', $text);

        return $this;
    }
275231
private function stripContent($text)
    {
        if ($this->convertBrToNewlines()) {
            $text = $this->brToNewline($text);
        }
        if ($this->stripTags()) {
            $text = strip_tags($text);
        }
        return $text;
    }
5861
public function clean($text)
    {
        $len = $this->utf8 ? mb_strlen($text) : strlen($text);

        if ($len <= $this->max) {
            return $text;
        }

        return $this->utf8 ? mb_substr($text, 0, $this->max) : substr($text, 0, $this->max);
    }
577338
public function text( $text )
	{
		if( !empty( $text ) )
		{
			$langid = $this->getContext()->getLocale()->getLanguageId();
			$func = $this->filter->createFunction( 'index.text:relevance', [$langid, $text] );

			$this->conditions[] = $this->filter->compare( '>', $func, 0 );
		}

		return $this;
	}
1192532
protected function doHardBreaks($text) {
		if ($this->hard_wrap) {
			return preg_replace_callback('/ *\n/', 
				array($this, '_doHardBreaks_callback'), $text);
		} else {
			return preg_replace_callback('/ {2,}\n/', 
				array($this, '_doHardBreaks_callback'), $text);
		}
	}
1276893
function filterText( $text )
    {
        $text = str_replace('\\','\\\\',$text);
        $text = str_replace('(','\(',$text);
        $text = str_replace(')','\)',$text);
        $text = str_replace('&lt;','<',$text);
        $text = str_replace('&gt;','>',$text);
        $text = str_replace('&#039;','\'',$text);
        $text = str_replace('&quot;','"',$text);
        $text = str_replace('&amp;','&',$text);

        return $text;
    }
1283465
public function lookup($text)
    {
        $url = $this->getLookupUrl($text);
        $response = $this->sendRequest(
            'GET',
            $url,
            [
                'version' => $this->serviceProtocolVersion
            ]
        );
        if ($response->getStatusCode() === 200) {
            $definitions = $this->parseLookupResponse($response);
            return $definitions;
        }
        return false;
    }
445928
public function extractHashtagTerms($text)
    {
        $matches = array();

        if (preg_match_all(ComHashtagsDomainEntityHashtag::PATTERN_HASHTAG, $text, $matches)) {
            return array_unique($matches[1]);
        } else {
            return array();
        }
    }
1121763
public function filterCamelCaseToUpper($text)
    {
        $text = StaticFilter::execute($text, 'Word\CamelCaseToUnderScore');
        $text = StaticFilter::execute($text, 'StringToUpper');

        return $text;
    }
1313010
protected function sanitize_text( $text ) {
		// not fancy
		$text = strip_tags( $text );
		$text = esc_html( $text );
		$text = trim( $text );

		return $text;
	}
633509
private function _checkReplacements($text) {
		if ($this->_isActive('checkReplacements')) {
			$key = strtolower($text);
			if (array_key_exists($key, $this->_replacements)) {
				$msg = $this->_getMessage('REPLACED', $this->_replacements[$key]['old'], $this->_replacements[$key]['new']);
				$this->_writeError('checkReplacements', $msg);
			}
		}
	}
275081
protected static function _removeLastWord($text)
    {
        $spacepos = mb_strrpos($text, ' ');

        if ($spacepos !== false) {
            $lastWord = mb_strrpos($text, $spacepos);

            // Some languages are written without word separation.
            // We recognize a string as a word if it doesn't contain any full-width characters.
            if (mb_strwidth($lastWord) === mb_strlen($lastWord)) {
                $text = mb_substr($text, 0, $spacepos);
            }

            return $text;
        }

        return '';
    }
249018
public function filter(&$text)
    {
        $name = $this->getIdentifier()->package . '_' . $this->getIdentifier()->name;

        //Create a module object
        $module   	       = new KObject(new KObjectConfig());
        $module->id        = uniqid();
        $module->module    = 'mod_'.$name;
        $module->content   = $text;
        $module->position  = $name;
        $module->params    = 'moduleclass_sfx='.$this->_class;
        $module->showtitle = (bool) $this->_title;
        $module->title     = $this->_title;
        $module->user      = 0;

        $text = $this->getObject('mod://admin/koowa.html')->module($module)->attribs($this->_attribs)->styles($this->_styles)->render();

        return $this;
    }
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;
    }
670267
public static function humanize($text)
    {
        preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $text, $matches);
        $ret = $matches[0];

        foreach ($ret as &$match) {
            $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
        }

        return ucfirst(implode(' ', $ret));
    }