Used by the PageBuilder filter functions to filter block data
@param string $content
@param string $search
@param string $type
@return bool
161985
public function filter($content, $search, $type)
    {
        switch ($type) {
            case 'in':
                return (strpos($content, $search) !== false);
                break;
            default:
                return ($content == $search);
        }
    }
1093496
public function search(SearchQuery $searchQuery, $returnType = BaseSearch::SEARCH_RESULT)
    {
        $response = static::newResponse($returnType);

        /** @var yii\db\ActiveRecord|SearchableEntity $mainEntityClassName */
        $mainEntityClassName = $searchQuery->mainEntityClassName;

        $activeQuery = $mainEntityClassName::find();

        $success = false;

        // combine query
        $e = new SearchEvent(
            $searchQuery,
            $returnType,
            $response,
            [
                'params' => [
                    'activeQuery' => &$activeQuery,
                ],
            ]
        );
        $this->trigger(self::EVENT_BEFORE_PAGINATION, $e);

        // Pagination
        $pages = $searchQuery->getPagination();
        if ($returnType !== BaseSearch::SEARCH_COUNT && $pages !== null) {
            if ($pages->totalCount === 0) {
                $pages->totalCount = (int) $activeQuery->count();
            }
            $searchQuery->limit = $pages->limit;
            $searchQuery->offset = $pages->offset;
        }

        $e = new SearchEvent(
            $searchQuery,
            $returnType,
            $response,
            [
                'params' => [
                    'activeQuery' => &$activeQuery,
                    'pages' => $pages,
                ],
            ]
        );
        $this->trigger(self::EVENT_AFTER_PAGINATION, $e);

        $response->searchQuery = $searchQuery;

        switch ($returnType) {
            case BaseSearch::SEARCH_COUNT:
                /** @var CountResponse $response */
                $response->count = (int) $activeQuery->count();
                $success = true;
                break;
            case BaseSearch::SEARCH_QUERY:
                /** @var QueryResponse $response */
                $response->query = $activeQuery;
                $success = true;
                break;
            case BaseSearch::SEARCH_RESULT_ARRAY:
            case BaseSearch::SEARCH_RESULT:
                /** @var ResultResponse $response */
                // query for debug
                $response->query = $activeQuery;
                if (is_object($pages)) {
                    $response->pages = $pages;
                }
                if ($returnType === BaseSearch::SEARCH_RESULT_ARRAY) {
                    $activeQuery->asArray(true);
                }
                $response->entities = $activeQuery->all();
                $e = new SearchEvent(
                    $searchQuery,
                    $returnType,
                    $response,
                    [
                        'params' => [
                            'activeQuery' => &$activeQuery,
                        ],
                    ]
                );
                $this->trigger(self::EVENT_AFTER_FIND, $e);
                $success = true;
                break;
            case BaseSearch::SEARCH_IDS:
                /** @var IdsResponse $response */
                $activeQuery->select(
                    array_map(
                        function ($item) use ($mainEntityClassName) {
                            return $mainEntityClassName::tableName() . '.' . $item;
                        },
                        $mainEntityClassName::primaryKey()
                    )
                );
                $response->ids = $activeQuery
                    ->distinct(true)
                    ->asArray(true)
                    ->column();
                $response->query = $activeQuery;
                $success = true;
                break;
        }

        return $response->end($success);
    }
4612
public function generateSearchText($content)
    {
        $searchText = '';
        $repeaterRows = PageBlockRepeaterData::loadRepeaterData($content, $this->_block->getVersionId());
        $repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id);

        foreach ($repeaterRows as $rowId => $repeaterRow) {
            foreach ($repeaterBlocks as $blockId => $repeaterBlock) {
                if(($blockContent = array_key_exists($blockId, $repeaterRow) ? $repeaterRow[$blockId] : null) !== null) {
                    $block = Block::preloadClone($blockId)->setRepeaterData($this->_block->getRepeaterId(), $this->_block->getRepeaterRowId())->setPageId($this->_block->getPageId());
                    if ($block->exists && $block->search_weight > 0) {
                        $blockSearchText = $block->getTypeObject()->generateSearchText($blockContent);
                        $searchText .= ($blockSearchText !== null) ? $blockSearchText . "\n" : '';
                    }
                }
            }
        }

        return parent::generateSearchText($searchText);
    }
310506
public function send($content = null, $type = null) 
    {
        if (!is_null($content)) {
            $this->setContents(is_array($content) ? $content : array($content));
        }
        if (!is_null($type)) {
            $this->setContentType($type);
        }
        return parent::send();
    }
195266
public static function modify($content, $type)
    {
        if (!array_key_exists($type, self::$types)) {
            throw new \LogicException(sprintf("Unsuported type `%s` of minifier.", $type));
        }

        $modifier = self::$types[$type];

        if (!$modifier['enabled']) {
            return $content;
        }

        $cacheId = md5($content);

        if (self::$cache && self::$cache->hasItem($cacheId)) {
            return self::$cache->getItem($cacheId)->get();
        }

        $content = call_user_func_array(
            [$modifier['class'], $modifier['method']],
            [$content, $modifier['options']]
        );

        self::$cache && self::$cache->save(self::$cache->getItem($cacheId)->set($content));

        return $content;
    }
812660
protected function _contentAttribute($content = '', $_attributes, $type)
    {
        $type   = strtolower($type);

        $perm   = $this->settings['attr']['perm'] ?? NULL;
        
        $return = '<'.$type.$this->attributes($_attributes).'>'.$this->stringOrCallback($content)."</$type>".EOL;

        $this->outputElement .= $this->_perm($perm, $return);

        return $this;
    }
766518
public static function decompressString( $content, $type = NULL )
	{
		if( !$type )
			return $content;
		ob_start();																					//  open a output buffer
		switch( strtolower( $type ) )
		{
			case 'deflate':
				$content	= self::inflate( $content );
				break;
			case 'gzip':
				xmp( $content );
				$content	= self::ungzip( $content );
				xmp( $content );
				break;
			default:
				ob_end_clean();
				throw new InvalidArgumentException( 'Decompression method "'.$type.'" is not supported' );
		}
		$output		= ob_get_clean();																//  close buffer for PHP error messages
		if( $content === FALSE && $output )															//  could not decompress
			throw new RuntimeException( $output );												//  throw exception and carry error message
		return $content;																				//  return decompressed response Content
	}
808358
public function scopeFilteredByType(Builder $query, $type = null)
    {
        $type = is_null($type) ? request('f', 'all') : $type;

        if (in_array($type, ['audio', 'document', 'image', 'video', 'embedded']))
        {
            $query->whereType($type);
        }

        return $query;
    }
400349
public function deleteByQuery($query, $type)
    {
        $result = $this->client->request(
            'DELETE',
            "/{$this->indexName}/{$type}/_query",
            new Message(
                array(
                    'Content-Type' => 'application/json',
                ),
                $query
            )
        );
        $this->flush();
    }
1319836
public function alert($content, $type = 'success')
    {
        if (!is_array($content)) {
            $content = [
                'body' => $content,
            ];
        }

        $content = array_merge($content, [
                'context' => 'victoire',
                'layout'  => 'growl',
                'effect'  => 'jelly',
            ]);
        $this->container->get('alertify')->alert($content, $type);
    }
1114254
public function check($content, $type, $additionalArgs = array(), $user = false)
    {
        if ($this->controller) {
            if (!$user) {
                $user = new User();
            }
            $wlg = $this->getWhitelistGroup();
            if ($wlg instanceof Group && $user->inGroup($wlg)) {
                // Never spam if user is in the whitelist
                return true;
            }

            /** @var \Concrete\Core\Permission\IPService $iph */
            $iph = Core::make('helper/validation/ip');
            $ip = $iph->getRequestIP();
            $args['ip_address'] = ($ip === false) ? ('') : ($ip->getIp($ip::FORMAT_IP_STRING));
            $args['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
            $args['content'] = $content;
            foreach ($additionalArgs as $key => $value) {
                $args[$key] = $value;
            }
            if (isset($args['user']) && is_object($args['user'])) {
                $u = $args['user'];
            } else {
                $u = new User();
            }
            if (!isset($args['email']) && $u->isRegistered()) {
                $ui = UserInfo::getByID($u->getUserID());
                $args['email'] = $ui->getUserEmail();
            }
            $r = $this->controller->check($args);
            if ($r) {
                return true;
            } else {
                $logText = '';
                $c = Page::getCurrentPage();
                if (is_object($c)) {
                    $logText .= t('URL: %s', Loader::helper('navigation')->getLinkToCollection($c, true));
                    $logText .= "\n";
                }
                if ($u->isRegistered()) {
                    $logText .= t('User: %s (ID %s)', $u->getUserName(), $u->getUserID());
                    $logText .= "\n";
                }
                $logText .= t('Type: %s', Loader::helper('text')->unhandle($type));
                $logText .= "\n";
                foreach ($args as $key => $value) {
                    $logText .= Loader::helper('text')->unhandle($key) . ': ' . $value . "\n";
                }

                if (Config::get('concrete.log.spam')) {
                    $logger = \Core::make('log/factory')->createLogger(Channels::CHANNEL_SPAM);
                    $logger->warning($logText);
                }
                if (Config::get('concrete.spam.notify_email') != '') {
                    $mh = Loader::helper('mail');
                    $mh->to(Config::get('concrete.spam.notify_email'));
                    $mh->addParameter('content', $logText);
                    $mh->addParameter('siteName', tc('SiteName', \Core::make('site')->getSite()->getSiteName()));
                    $mh->load('spam_detected');
                    $mh->sendMail();
                }

                return false;
            }
        } else {
            return true; // return true if it passes the test
        }
    }
498835
public function _compare($tag,$content,$type='eq') {
        $name       =   $tag['name'];
        $value      =   $tag['value'];
        $type       =   isset($tag['type'])?$tag['type']:$type;
        $type       =   $this->parseCondition(' '.$type.' ');
        $varArray   =   explode('|',$name);
        $name       =   array_shift($varArray);
        $name       =   $this->autoBuildVar($name);
        if(count($varArray)>0)
            $name = $this->tpl->parseVarFunction($name,$varArray);
        if('$' == substr($value,0,1)) {
            $value  =  $this->autoBuildVar(substr($value,1));
        }else {
            $value  =   '"'.$value.'"';
        }
        $parseStr   =   '<?php if(('.$name.') '.$type.' '.$value.'): ?>'.$content.'<?php endif; ?>';
        return $parseStr;
    }
1316060
public function generateSearchText($content)
    {
        $content = $this->_defaultData($content);
        $searchText = $this->_generateSearchText($content->selected, $content->price);
        return parent::generateSearchText($searchText);
    }
134657
protected function _compile($content, $type = self::TPL_COMPILE_ALL) {
        switch ($type) {
            case self::TPL_COMPILE_ALL:
                return $this->_parser->parse($content);
                break;

            case self::TPL_COMPILE_INCLUDE:
                return $this->_parser->parseNoTemplate($content);
                break;

            case self::TPL_COMPILE_LANG:
                return $this->_parser->parseLang($content);
                break;
        }

        return '';
    }
779452
public function filter($content, $search, $type)
    {
        $search = is_array($search) ? $search : [$search];
        $search = array_map(function($searchValue) {return is_a($searchValue, Carbon::class) ? $searchValue : new Carbon($searchValue);}, $search);
        $current = (new Carbon($content));
        switch ($type) {
            case 'in':
                return ($current->gte($search[0]) && $current->lt($search[1]));
                break;
            default:
                return $current->eq($search[0]);
        }
    }
1156457
public function setSearchType($search_type)
    {
        switch ($search_type) {
            case self::RECORD_RECORD:
            default:
                $this->search_type = self::RECORD_RECORD;
                break;
            case self::RECORD_GROUPING:
            case self::RECORD_STORY:
                $this->search_type = self::RECORD_GROUPING;
                break;
        }

        return $this;
    }
218699
public function moveContent($content, $type, $page)
    {
        $contenType = $this->contentType->findOneBy(array('type' => $type, 'content' => $content));

        $contenType->detach();
        $contenType->setType($page);
        $contenType->setFirst($this->contentType->findOneBy(array('type' => $page, 'back' => null)));

        $this->manager->persist($contenType);
        $this->manager->flush();
    }