/** * Get Stylecow\Css object from a string. * @param string $cssString * @param string $file * * @return Stylecow\Css */ protected function getCss($cssString, $file) { $css = Stylecow\Parser::parseString($cssString); $this->checkCssImport($css, $file); return $css; }
/** * @param string $buffer * @return string */ private function optimize($buffer) { $plugins = array('Color' => true, 'Grid' => true, 'IeBackgroundAlpha' => true, 'IeClip' => true, 'IeFloat' => true, 'IeInlineBlock' => true, 'IeLinearGradient' => true, 'IeMinHeight' => true, 'IeOpacity' => true, 'Initial' => true, 'Matches' => true, 'Math' => true, 'MediaQuery' => false, 'NestedRules' => false, 'Rem' => true, 'IeTransform' => true, 'Variables' => false, 'VendorPrefixes' => true, 'BaseUrl' => \App::get('home')); $stylecow = \Stylecow\Parser::parseString($buffer); $stylecow->applyPlugins($plugins); return (string) $stylecow; }
<?php include 'Stylecow/autoloader.php'; use Stylecow\Parser; $plugins = array('Color' => array('checked' => false, 'options' => array()), 'Grid' => array('checked' => false, 'options' => array()), 'IeBackgroundAlpha' => array('checked' => false, 'options' => array()), 'IeClip' => array('checked' => false, 'options' => array()), 'IeFloat' => array('checked' => false, 'options' => array()), 'IeInlineBlock' => array('checked' => false, 'options' => array()), 'IeLinearGradient' => array('checked' => false, 'options' => array()), 'IeMinHeight' => array('checked' => false, 'options' => array()), 'IeOpacity' => array('checked' => false, 'options' => array()), 'Initial' => array('checked' => false, 'options' => array()), 'Matches' => array('checked' => true, 'options' => array()), 'Math' => array('checked' => false, 'options' => array()), 'MediaQuery' => array('checked' => false, 'options' => array('width' => array('string', ''), 'type' => array('string', 'all'))), 'NestedRules' => array('checked' => true, 'options' => array()), 'Rem' => array('checked' => true, 'options' => array()), 'IeTransform' => array('checked' => false, 'options' => array()), 'Variables' => array('checked' => true, 'options' => array()), 'VendorPrefixes' => array('checked' => true, 'options' => array())); $input_code = $output_code = ''; //If the form has been send if (isset($_POST['send'])) { //Initialize stylecow $input_code = $_POST['code']; $css = Parser::parseString($input_code); //Load the plugin configuration $applyPlugins = array(); foreach ($plugins as $plugin => $settings) { if (isset($_POST['plugin'][$plugin])) { $applyPlugins[$plugin] = array(); $plugins[$plugin]['checked'] = true; foreach ($settings['options'] as $name => $value) { $valuePost = isset($_POST['pluginOptions'][$plugin][$name]) ? $_POST['pluginOptions'][$plugin][$name] : ''; if ($valuePost === '') { switch ($value[0]) { case 'bool': $plugins[$plugin]['options'][$name][1] = false; break; default: $plugins[$plugin]['options'][$name][1] = null; break; } } else { $plugins[$plugin]['options'][$name][1] = $valuePost; }