Inliner::getCSS()

@return
439317
private function getCSS()
    {
        $this->domCrawler->filter('style')->each(function ($crawler){$this->css .= $crawler->text();foreach ($crawler as $node){$node->parentNode->removeChild($node);}});
        $parser = new CSS\Parser($this->css);
        $css = $parser->parse();
        if(!$css){
            throw new \Exception('There are no CSS rules provided.');
        }
        return $css;
    }
1304422
static public function cssVer() {
        static $ver = '';
        if (!$ver) {
            $conf = new \Yaf_Config_Ini(ROOTPATH . '/config/env.ini');
            $ver = $conf->version->css;
        }
        return $ver;
    }
834067
public function getCss(){

		$precision = ini_get('precision');
		@ini_set('precision',16);
		$locale = setlocale(LC_NUMERIC, 0);
		setlocale(LC_NUMERIC, "C");

		try {

	 		$root = new Less_Tree_Ruleset(array(), $this->rules );
			$root->root = true;
			$root->firstRoot = true;


			$this->PreVisitors($root);

			self::$has_extends = false;
			$evaldRoot = $root->compile($this->env);



			$this->PostVisitors($evaldRoot);

			if( Less_Parser::$options['sourceMap'] ){
				$generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options );
				// will also save file
				// FIXME: should happen somewhere else?
				$css = $generator->generateCSS();
			}else{
				$css = $evaldRoot->toCSS();
			}

			if( Less_Parser::$options['compress'] ){
				$css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css);
			}

		} catch (Exception $exc) {
			// Intentional fall-through so we can reset environment
		}

		//reset php settings
		@ini_set('precision',$precision);
		setlocale(LC_NUMERIC, $locale);

		// If you previously defined $this->mb_internal_encoding
		// is required to return the encoding as it was before
		if ($this->mb_internal_encoding != '') {
			@ini_set("mbstring.internal_encoding", $this->mb_internal_encoding);
			$this->mb_internal_encoding = '';
		}

		// Rethrow exception after we handled resetting the environment
		if (!empty($exc)) {
			throw $exc;
		}



		return $css;
	}
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);
    }
591942
public function renderLegacyCss()
    {
        $cssFiles = [];
        $cssCodeLines = [];

        foreach ($this->legacyHelper->get('css_files', []) as $cssItem) {
            // List of items can contain empty elements, path to files or code
            if (!empty($cssItem)) {
                if (isset($cssItem[5]) && $this->isFile($cssItem, '.css')) {
                    $cssFiles[] = $cssItem;
                } else {
                    $cssCodeLines[] = $cssItem;
                }
            }
        }

        return $this->environment->render(
            $this->cssTemplate,
            [
                'css_files' => $cssFiles,
                'css_code_lines' => $cssCodeLines,
            ]
        );
    }
178323
public function get_css_type() {
        if (array_key_exists($this->type, $this->namedtypes)) {
            return 'type_'.$this->namedtypes[$this->type];
        }
        return 'type_unknown';
    }
936449
public function getCustomCSSAsString()
    {
        // Create CSS Array:
        
        $css = [];
        
        // Merge Custom CSS from Page Controller:
        
        if ($this->owner instanceof PageController) {
            $css = array_merge($css, $this->owner->getCustomCSS());
        }
        
        // Create CSS String:
        
        $css = implode("\n", $css);
        
        // Remove Empty Lines:
        
        $css = ViewTools::singleton()->removeEmptyLines($css);
        
        // Trim CSS String:
        
        $css = trim($css);
        
        // Minify CSS String:
        
        if (!Director::isDev()) {
            $css = ViewTools::singleton()->minifyCSS($css);
        }
        
        // Answer CSS String:
        
        return $css;
    }
453769
public function get_diff() {
		if (!$this->output_css_plain) {
			$this->formatted();
		}

		$diff = strlen($this->output_css_plain) - strlen($this->input_css);

		if ($diff > 0) {
			return '+' . $diff;
		} elseif ($diff == 0) {
			return '+-' . $diff;
		}

		return $diff;
	}
1370581
public function renderCss()
	{
		$result = "";
		$css = $this->getCss();
		if(!empty($css))
		array_walk($css, function($value) use (&$result){
			$result .= '<link href="'.$value.'" type="text/css" rel="stylesheet">';
		});
		$custom = $this->getCustomCss();
		if(!empty($custom))
		{
			$customCss = '<style type="text/css" rel="stylesheet" id="silex-assets-service-css-'.substr(md5(time()),0,5).'">';
			if($custom !== array())
				array_walk($custom, function($value) use (&$customCss){
					$customCss .= $value."\n";
				});
			$customCss .= "</style>";
			$result .= $customCss;
		}
		return $result;
	}
376573
function getInline($as_html = true) {
        if(!$as_html) {
            return $this->css_inline;
        }
        if(!count($this->css_inline)) {
            return '';
        }
        $css_inline = (implode(PHP_EOL, $this->css_inline));
        $css_inline = $this->prepare($css_inline, config('larakit.lk-staticfiles.css.inline.min'));
        if(config('larakit.lk-staticfiles.css.inline.build', false)) {
            $build_name = $this->makeFileName($css_inline, 'css/inline', 'css');
            $build_file = $this->buildFile($build_name);
            if(!file_exists($build_file)) {
                if(!file_exists(dirname($build_file))) {
                    mkdir(dirname($build_file), 0777, true);
                }
                $this->save($build_file, $css_inline);
            }
            
            return $this->getLink($this->buildUrl($build_name), 'all') . "\n        ";
        } else {
            return '<style type="text/css">' . PHP_EOL . $css_inline . PHP_EOL . '</style>';
        }
    }
152857
public String inlineCSS() {
    StringBuilder buf = new StringBuilder();
    for (Pair<String, String> pair : statements) {
      buf.append(pair.getFirst());
      buf.append(':');
      buf.append(pair.getSecond());
      buf.append(';');
    }
    return buf.toString();
  }
1330172
public static function baseCss($css = null)
    {
        if (!is_null($css)) {
            return static::$baseCss = $css;
        }

        $skin = config('admin.skin', 'skin-blue-light');

        array_unshift(static::$baseCss, "vendor/laravel-admin/AdminLTE/dist/css/skins/{$skin}.min.css");

        return static::$baseCss;
    }
120626
protected function stripExistingCssCharsets($css)
    {
        if (!($css = (string) $css)) {
            return $css; // Nothing to do.
        }
        $css        = preg_replace('/@(?:\-(?:'.$this->regex_vendor_css_prefixes.')\-)?charset(?:\s+[^;]*?)?;/ui', '', $css);
        return $css = $css ? trim($css) : $css;
    }
192995
public function generateCSS(){
		$output = new Less_Output_Mapped($this->contentsMap, $this);

		// catch the output
		$this->root->genCSS($output);


		$sourceMapUrl				= $this->getOption('sourceMapURL');
		$sourceMapFilename			= $this->getOption('sourceMapFilename');
		$sourceMapContent			= $this->generateJson();
		$sourceMapWriteTo			= $this->getOption('sourceMapWriteTo');

		if( !$sourceMapUrl && $sourceMapFilename ){
			$sourceMapUrl = $this->normalizeFilename($sourceMapFilename);
		}

		// write map to a file
		if( $sourceMapWriteTo ){
			$this->saveMap($sourceMapWriteTo, $sourceMapContent);
		}

		// inline the map
		if( !$sourceMapUrl ){
			$sourceMapUrl = sprintf('data:application/json,%s', Less_Functions::encodeURIComponent($sourceMapContent));
		}

		if( $sourceMapUrl ){
			$output->add( sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl) );
		}

		return $output->toString();
	}
526489
protected String getCSS()
    {
        // The default styles to use
        String retVal =
            "body {\n" + "	font-family: Arial, Helvetica, sans-serif;\n" + "}\n" + "h1 {\n" + "	font-size: 1.5em;\n" + "}\n" + "th {\n"
                + "	background-color: #9DACBF;\n" + "}\n" + "table {\n" + "	border-top-style: solid;\n" + "	border-right-style: solid;\n"
                + "	border-bottom-style: solid;\n" + "	border-left-style: solid;\n" + "}\n" + "td {\n" + "	margin: 0px;\n" + "	padding-top: 2px;\n"
                + "	padding-right: 5px;\n" + "	padding-bottom: 2px;\n" + "	padding-left: 5px;\n" + "}\n" + "tr.even {\n"
                + "	background-color: #CCCCCC;\n" + "}\n" + "tr.odd {\n" + "	background-color: #FFFFFF;\n" + "}\n" + "";
        try
        {
            // Try loading one via class loader and use that one instead
            final ClassLoader cl = getClass().getClassLoader();
            final InputStream iStream = cl.getResourceAsStream( "webdav.css" );
            if ( iStream != null )
            {
                // Found css via class loader, use that one
                final StringBuilder out = new StringBuilder();
                final byte[] b = new byte[4096];
                for ( int n; ( n = iStream.read( b ) ) != -1; )
                {
                    out.append( new String( b, 0, n ) );
                }
                retVal = out.toString();
            }
        }
        catch ( final Exception ex )
        {
            LOG.error( "Error in reading webdav.css", ex );
        }

        return retVal;
    }
1167313
public function getFieldsActivationCss()
    {
        $cssBlocks = [];
        $formConfiguration = $this->getFormObject()->getConfiguration();

        foreach ($formConfiguration->getFields() as $field) {
            $formName = $this->getFormObject()->getName();
            $fieldContainerSelector = $field->getSettings()->getFieldContainerSelector();

            $cssTree = $this->getConditionTreeForField($field)->getCssConditions();

            if (false === empty($cssTree)) {
                $fullNodeData = [];

                foreach ($cssTree as $node) {
                    $fullNodeData[] = 'form[name="' . $formName . '"]' . $node . ' ' . $fieldContainerSelector;
                }

                $nodesSelector = implode(',' . CRLF, $fullNodeData);

                $cssBlocks[] = $this->getSingleFieldCssBlock($formName, $field, $fieldContainerSelector, $nodesSelector);
            }
        }

        return implode(CRLF, $cssBlocks);
    }
1308585
function get_inline($as_html = true) {
        if (!$as_html) {
            return $this->css_inline;
        }
        if (!count($this->css_inline)) {
            return '';
        }
        $css_inline = (implode("\n", $this->css_inline));
        $css_inline = $this->prepare($css_inline, $this->get_need_min_inline());
        if ($this->get_need_build_inline()) {
            $build_name = $this->make_file_name($css_inline, 'css/inline', 'css');
            $build_file = Helper::build_file($build_name);
            if (!file_exists($build_file)) {
                if (!file_exists(dirname($build_file))) {
                    mkdir(dirname($build_file), 0777, true);
                }
                $this->save($build_file, $css_inline);
            }
            return $this->get_link(Helper::build_url($build_name), 'all') . "\n        ";
        } else {
            return '<style type="text/css">
' . $css_inline . '
</style>';
        }
    }