Transforms CSS-style selectors into an internal representation suitable for
processing by filterContent()
@return array
779580
protected function parseItemsToRemove() {
		$removals = [
			'ID' => [],
			'TAG' => [],
			'CLASS' => [],
			'TAG_CLASS' => [],
		];

		foreach ( $this->itemsToRemove as $itemToRemove ) {
			$type = '';
			$rawName = '';
			if ( $this->parseSelector( $itemToRemove, $type, $rawName ) ) {
				$removals[$type][] = $rawName;
			}
		}

		if ( $this->removeMedia ) {
			$removals['TAG'][] = 'img';
			$removals['TAG'][] = 'audio';
			$removals['TAG'][] = 'video';
		}

		return $removals;
	}
273901
private function getCssSelectorPrecedence($selector)
    {
        $selectorKey = md5($selector);
        if (!isset($this->caches[self::CACHE_KEY_SELECTOR][$selectorKey])) {
            $precedence = 0;
            $value = 100;
            // ids: worth 100, classes: worth 10, elements: worth 1
            $search = ['\\#', '\\.', ''];

            foreach ($search as $s) {
                if (trim($selector) === '') {
                    break;
                }
                $number = 0;
                $selector = preg_replace('/' . $s . '\\w+/', '', $selector, -1, $number);
                $precedence += ($value * $number);
                $value /= 10;
            }
            $this->caches[self::CACHE_KEY_SELECTOR][$selectorKey] = $precedence;
        }

        return $this->caches[self::CACHE_KEY_SELECTOR][$selectorKey];
    }
846418
public function getFilters()
    {
        return [
            new \Twig_SimpleFilter('*ize', [$this, 'inflectorFilter']),
            new \Twig_SimpleFilter('absolute_url', [$this, 'absoluteUrlFilter']),
            new \Twig_SimpleFilter('contains', [$this, 'containsFilter']),
            new \Twig_SimpleFilter('chunk_split', [$this, 'chunkSplitFilter']),
            new \Twig_SimpleFilter('nicenumber', [$this, 'niceNumberFunc']),
            new \Twig_SimpleFilter('nicefilesize', [$this, 'niceFilesizeFunc']),
            new \Twig_SimpleFilter('nicetime', [$this, 'nicetimeFunc']),
            new \Twig_SimpleFilter('defined', [$this, 'definedDefaultFilter']),
            new \Twig_SimpleFilter('ends_with', [$this, 'endsWithFilter']),
            new \Twig_SimpleFilter('fieldName', [$this, 'fieldNameFilter']),
            new \Twig_SimpleFilter('ksort', [$this, 'ksortFilter']),
            new \Twig_SimpleFilter('ltrim', [$this, 'ltrimFilter']),
            new \Twig_SimpleFilter('markdown', [$this, 'markdownFunction'], ['is_safe' => ['html']]),
            new \Twig_SimpleFilter('md5', [$this, 'md5Filter']),
            new \Twig_SimpleFilter('base32_encode', [$this, 'base32EncodeFilter']),
            new \Twig_SimpleFilter('base32_decode', [$this, 'base32DecodeFilter']),
            new \Twig_SimpleFilter('base64_encode', [$this, 'base64EncodeFilter']),
            new \Twig_SimpleFilter('base64_decode', [$this, 'base64DecodeFilter']),
            new \Twig_SimpleFilter('randomize', [$this, 'randomizeFilter']),
            new \Twig_SimpleFilter('modulus', [$this, 'modulusFilter']),
            new \Twig_SimpleFilter('rtrim', [$this, 'rtrimFilter']),
            new \Twig_SimpleFilter('pad', [$this, 'padFilter']),
            new \Twig_SimpleFilter('regex_replace', [$this, 'regexReplace']),
            new \Twig_SimpleFilter('safe_email', [$this, 'safeEmailFilter']),
            new \Twig_SimpleFilter('safe_truncate', ['\Grav\Common\Utils', 'safeTruncate']),
            new \Twig_SimpleFilter('safe_truncate_html', ['\Grav\Common\Utils', 'safeTruncateHTML']),
            new \Twig_SimpleFilter('sort_by_key', [$this, 'sortByKeyFilter']),
            new \Twig_SimpleFilter('starts_with', [$this, 'startsWithFilter']),
            new \Twig_SimpleFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
            new \Twig_SimpleFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
            new \Twig_SimpleFilter('json_decode', [$this, 'jsonDecodeFilter']),
            new \Twig_SimpleFilter('array_unique', 'array_unique'),
            new \Twig_SimpleFilter('basename', 'basename'),
            new \Twig_SimpleFilter('dirname', 'dirname'),
            new \Twig_SimpleFilter('print_r', 'print_r'),
            new \Twig_SimpleFilter('yaml_encode', [$this, 'yamlEncodeFilter']),
            new \Twig_SimpleFilter('yaml_decode', [$this, 'yamlDecodeFilter']),
            new \Twig_SimpleFilter('nicecron', [$this, 'niceCronFilter']),

            // Translations
            new \Twig_SimpleFilter('t', [$this, 'translate'], ['needs_environment' => true]),
            new \Twig_SimpleFilter('tl', [$this, 'translateLanguage']),
            new \Twig_SimpleFilter('ta', [$this, 'translateArray']),

            // Casting values
            new \Twig_SimpleFilter('string', [$this, 'stringFilter']),
            new \Twig_SimpleFilter('int', [$this, 'intFilter'], ['is_safe' => ['all']]),
            new \Twig_SimpleFilter('bool', [$this, 'boolFilter']),
            new \Twig_SimpleFilter('float', [$this, 'floatFilter'], ['is_safe' => ['all']]),
            new \Twig_SimpleFilter('array', [$this, 'arrayFilter']),

            // Object Types
            new \Twig_SimpleFilter('get_type', [$this, 'getTypeFunc']),
            new \Twig_SimpleFilter('of_type', [$this, 'ofTypeFunc'])
        ];
    }
658850
public function getClasses()
    {
        $classes = explode(' ', $this->cssClass);
        if ($this->style) {
            $classes[] = $this->style;
        }

        $this->extend('updateClasses', $classes);
        return Convert::raw2att(implode(' ', $classes));
    }
777857
public function getInputFilterSpecification()
    {
        $spec = array();
        foreach ($this->getElements() as $element) {
            $name = (string) $element->getName();
            $spec[$name] = array(
                'name' => $name,
            );
        }
        return $spec;
    }
943814
public function get_precompiled_css_content() {
        $configs = [$this] + $this->parent_configs;
        $css = '';

        foreach ($configs as $config) {
            if (isset($config->precompiledcsscallback)) {
                $function = $config->precompiledcsscallback;
                if (function_exists($function)) {
                    $css .= $function($this);
                }
            }
        }
        return $css;
    }
1120087
public function getCss()
    {
        $parser = new \Less_Parser(
            array(
                'cache_dir' => Config::get('concrete.cache.directory'),
                'compress' => (bool) Config::get('concrete.theme.compress_preprocessor_output'),
                'sourceMap' => !Config::get('concrete.theme.compress_preprocessor_output') && (bool) Config::get('concrete.theme.generate_less_sourcemap'),
            )
        );
        $parser = $parser->parseFile($this->file, $this->sourceUriRoot);
        if (isset($this->valueList) && $this->valueList instanceof \Concrete\Core\StyleCustomizer\Style\ValueList) {
            $variables = array();
            foreach ($this->valueList->getValues() as $value) {
                $variables = array_merge($value->toLessVariablesArray(), $variables);
            }
            $parser->ModifyVars($variables);
        }
        $css = $parser->getCss();

        return $css;
    }
80761
public function all($selector)
    {
        try {
            return $this->driver->findElements(
                WebDriverBy::cssSelector($this->format($selector))
            );
        } catch (Exception $e) {
            //
        }

        return [];
    }
325890
private function extractMediaQueriesFromCss($css)
    {
        preg_match_all('/@media\\b[^{]*({((?:[^{}]+|(?1))*)})/', $css, $rawMediaQueries, PREG_SET_ORDER);
        $parsedQueries = [];

        /** @var string[][] $rawMediaQueries */
        foreach ($rawMediaQueries as $mediaQuery) {
            if ($mediaQuery[2] !== '') {
                $parsedQueries[] = [
                    'css' => $mediaQuery[2],
                    'query' => $mediaQuery[0],
                ];
            }
        }

        return $parsedQueries;
    }
338854
public function getAllAttachmentParts()
    {
        $parts = $this->getAllParts(
            $this->partFilterFactory->newFilterFromArray([
                'multipart' => PartFilter::FILTER_EXCLUDE
            ])
        );
        return array_values(array_filter(
            $parts,
            function ($part) {
                return !(
                    $part->isTextPart()
                    && $part->getContentDisposition() === 'inline'
                );
            }
        ));
    }
1245245
public function extract()
    {
        return [
            'name' => $this->getName(),
            'ordering' => $this->getOrdering(),
            'type' => $this->getType(),
            'include_pattern' => $this->getIncludePattern(),
            'exclude_pattern' => $this->getExcludePattern(),
            'classes' => $this->dump(),
        ];
    }
114997
private function _styleToArray($style)
    {
        $styles = array();
        $style = trim(trim($style), ";");
        if($style) {
            foreach(explode(";", $style) as $props) {
                $props = trim(trim($props), ";");
                //Don't parse empty props
                if(!trim($props))continue;
                //Only match valid CSS rules
                if (preg_match('#^([-a-z0-9\*]+):(.*)$#i', $props, $matches) && isset($matches[0], $matches[1], $matches[2])) {
                    list(, $prop, $val) = $matches;
                    $styles[$prop] = $val;
                }
            }
        }

        return $styles;
    }
415487
public function getAllElementClassContentClassnames()
    {
        $classnames = array_filter(
            $this->getAllClassContentClassnames(),
            function ($classname) {
                return false !== strpos(
                    $classname,
                    AbstractClassContent::CLASSCONTENT_BASE_NAMESPACE.'Element\\'
                );
            }
        );

        $classnames[] = AbstractClassContent::CLASSCONTENT_BASE_NAMESPACE.'ContentSet';

        return $classnames;
    }
889606
public function getSelectors(){
		$list	= array();
		foreach( $this->rules as $rule )
			$list[]	= $rule->getSelector();
		return $list;
	}
102129
protected function getCurrentCssSelector()
    {
        $cssSelector = '';
        if (isset($this->parser->tagAttributes['id'])) {
            $cssSelector .= '#' . $this->decode($this->parser->tagAttributes['id']);
        }
        if (isset($this->parser->tagAttributes['class'])) {
            $classes = explode(' ', $this->decode($this->parser->tagAttributes['class']));
            $classes = array_filter($classes);
            $cssSelector .= '.' . join('.', $classes);
        }
        return $cssSelector;
    }
783071
protected function getAddonCssClass()
	{
		$classes = array();
		if (isset($this->prependText))
			$classes[] = 'input-prepend';
		if (isset($this->appendText))
			$classes[] = 'input-append';

		return implode(' ', $classes);
	}
312621
public function getErrorContainerDisplayCss()
    {
        $cssBlocks = [];
        $formConfiguration = $this->getFormObject()->getConfiguration();

        foreach ($formConfiguration->getFields() as $fieldName => $field) {
            $formName = $this->getFormObject()->getName();
            $errorSelector = DataAttributesAssetHandler::getFieldDataMessageKey($fieldName, 'error');
            $warningSelector = DataAttributesAssetHandler::getFieldDataMessageKey($fieldName, 'warning');
            $noticeSelector = DataAttributesAssetHandler::getFieldDataMessageKey($fieldName, 'notice');
            $errorContainerCss = $field->getSettings()->getMessageContainerSelector();

            $cssBlocks[] = <<<CSS
form[name="$formName"]:not([$errorSelector="1"]):not([$warningSelector="1"]):not([$noticeSelector="1"]) $errorContainerCss {
    display: none!important;
}
CSS;
        }

        return implode(CRLF, $cssBlocks);
    }