Lookup and extract assets from a stylesheet element
@param Element $element the stylesheet element
765374
private function extractStyleSheet(Element $element){
        if($element instanceof StyleSheet){
            $href = $element->attr('href');
            $this->addAsset('css', $href);

            $parsedUrl = parse_url($href);
            if ($this->isDeepParsing() && array_key_exists('path', $parsedUrl) && !array_key_exists('host',
                    $parsedUrl)
            ) {
                $file = $this->directory->getFile($parsedUrl['path']);
                if ($file->exists()) {
                    $this->loadStyleSheetAsset($file->read());
                }
            }
        }
    }
429878
public function renderElement(Element $element) : string
    {
        // @todo - if the element implements neither HasContent or HasChildren, make it self-closing <img />
        // @todo - fix indentation - currently it adds an extra line as the middle indentation
        return $this->indent($this->depth, sprintf('<%s%s>', $element->getElement(), $this->getAttributesForElement($element))) .
            $this->indent($this->depth++, $this->getContentForElement($element)) .
            $this->indent(--$this->depth, sprintf('</%s>', $element->getElement()));
    }
946500
private function _getSectionSources(Element $element = null): array
    {
        $sources = [];
        $sections = Craft::$app->getSections()->getAllSections();
        $showSingles = false;

        foreach ($sections as $section) {
            if ($section->type === Section::TYPE_SINGLE) {
                $showSingles = true;
            } else if ($element) {
                // Does the section have URLs in the same site as the element we're editing?
                $sectionSiteSettings = $section->getSiteSettings();
                if (isset($sectionSiteSettings[$element->siteId]) && $sectionSiteSettings[$element->siteId]->hasUrls) {
                    $sources[] = 'section:'.$section->uid;
                }
            }
        }

        if ($showSingles) {
            array_unshift($sources, 'singles');
        }

        return $sources;
    }
146011
public function getElements(By $by, Element $element = null)
    {
        try {
            $obj = null === $element ? $this->getBrowser() : $element;

            return $obj->elements($by);
        } catch (ExceptionInterface $e) {
            throw new \RuntimeException(sprintf('Error while searching for element "%s" : %s (visible text: "%s").', $by->toString(), $e->getMessage(), $this->getBrowser()->getText()));
        }
    }
156746
public function getType(Element $element)
    {
        foreach (Factory::getElementAlias() as $type => $name) {
            if ($name == get_class($element)) {
                return $type;
            }
        }
        return 'hidden';
    }
911077
public function content(Form\Element\Content $element)
    {

        if ($element->isFullWith()) {
            $html = '<div class="col-md-12">' . $element->getValue() . '</div>';
        } else {
            $html = '<label class="col-md-3 control-label">' . $element->getLabel() . '</label>';
            $html .= '<div class="col-md-9">' . $element->getValue() . '</div>';
        }

        $class = Style::FORM_GROUP_CLASS;
        return html('div', compact('class'), $html);
    }
1066815
protected function getChilds(SimpleXMLElement $element)
    {
        parent::getChilds($element);
        
        $this->getChildsAsCDATAFromList($element, array(
            'nb_site_target_attributes' => 'attributes'
        ), false);
    }
158289
public static function prep_element($element) {
		if (self::containsCode($element)===false) {
			$element='"'.addslashes($element).'"';
		}
		return $element;
	}
211153
public function render(Element $element)
    {
        $method = $this->getMethodNameForClass($element);

        if (!method_exists($this, $method)) {
            throw new \Exception('Error, render method "' . $method . '" was not found');
        }

        $errorHtml = $this->renderErrorMessages($element);

        $helpHtml = $this->renderHelpText($element);

        $html = $this->$method($element);

        return $html . $helpHtml . $errorHtml;
    }
828239
protected function processingElementsResult($element)
    {
        $arElement = $element;

        if ($this->arParams['RESULT_PROCESSING_MODE'] === 'EXTENDED')
        {
            $arElement = $element->GetFields();
            $arElement['PROPS'] = $element->GetProperties();
        }
        elseif (!empty($this->arParams['SELECT_PROPS']))
        {
            foreach ($this->arParams['SELECT_PROPS'] as $propCode)
            {
                if (trim($propCode))
                {
                    $arProp = explode('.', $propCode);
                    $propCode = array_shift($arProp);
                    $propValue = $element['PROPERTY_'.$propCode.'_VALUE'];
                    $propDescr = $element['PROPERTY_'.$propCode.'_DESCRIPTION'];

                    if ($propValue)
                    {
                        $arElement['PROPS'][$propCode]['VALUE'] = $propValue;
                    }

                    if ($propDescr)
                    {
                        $arElement['PROPS'][$propCode]['DESCRIPTION'] = $propDescr;
                    }

                    if (!empty($arElement['PROPS'][$propCode]))
                    {
                        foreach ($arProp as $field)
                        {
                            $arElement['PROPS'][$propCode]['LINKED'][$field] = $element['PROPERTY_'.$propCode.'_'.$field];
                        }
                    }
                }
            }
        }

        if ($arElement = $this->prepareElementsResult($arElement))
        {
            return $arElement;
        }
        else
        {
            return false;
        }
    }
391932
protected function extractMediasFromElement($element)
    {
        $references = array();
        if ($this->isMediaAttribute($element)) {
            $references[] = $element['id'];

        } elseif (is_string($element) && $this->hasMediaBBcode($element)) {
            $references = array_merge($references, $this->extractMediaFromBBCode($element));

        } elseif (is_array($element)) {
            foreach ($element as $item) {
                $references = array_merge($references, $this->extractMediasFromElement($item));
            }
        }

        return $references;
    }
127166
protected function _getElementHtml(AbstractElement $element)
    {
        $element->addData([
            'wysiwyg' => true,
            'config'  => $this->wysiwygConfig->getConfig($element)
        ]);
        return parent::_getElementHtml($element);
    }
902
private function loadStyleSheetAsset($css){

        $imageRe = "/url\\s*\\(['|\"]?([^)]*\.(png|jpg|jpeg|gif|svg))['|\"]?\\)/mi";
        $importRe = "/@import\\s*(url\\s*\\()?['\"]?([^;]*)['\"]/mi";
        $fontFaceRe = "/@font-face\\s*\\{(.*)?\\}/mi";
        $fontRe = "/url\\s*\\(['|\"]?([^)'|\"]*)['|\"]?\\)/i";

        //extract images
        preg_match_all($imageRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $match){
                $this->addAsset('img', $match);
            }
        }

        //extract @import
        preg_match_all($importRe, $css, $matches);
        if(isset($matches[2])){
            foreach($matches[2] as $match){
                $this->addAsset('css', $match);
            }
        }

        //extract fonts
        preg_match_all($fontFaceRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $faceMatch){
                preg_match_all($fontRe, $faceMatch, $fontMatches);
                if(isset($fontMatches[1])){
                    foreach($fontMatches[1] as $fontMatch){
                        $this->addAsset('font', $fontMatch);
                    }
                }
            }
        }
    }
215423
protected function prepareElement($element)
    {
        $options    = $this->getOptions();
        $currClass  = $element->getAttribute('class');
        $class      = $currClass . (null !== $currClass ? ' ' : '') . $options['class'];

        $element->setAttributes(array(
            'class'             => $class,
            'data-color'        => $options['color'],
            'data-color-format' => $options['format'],
        ));

        return $element;
    }
27291
public function render(AbstractElement $element) {
        $pattern    = '<div id="checkout_com_adminhtml_logo"><a href="%s" target="_blank"><img src="%s" alt="Checkout.com Logo"></a></div>';
        $url        = 'https://checkout.com';
        $src        = 'https://cdn.checkout.com/img/checkout-logo-online-payments.jpg';

        return sprintf($pattern, $url, $src);
    }
120366
public function resolveElement(Element $element)
    {
        $elementtype = $this->elementService->findElementtype($element);

        return $this->resolveElementtype($elementtype);
    }
368267
private function renderElement(Element $element) : string
    {
        $label = $element->getLabel();

        if ($label->isEmpty()) {
            return $element->render();
        }

        return $label->render() . $element->render();
    }