Generate CSS styles

@param    boolean    $generateSurroundingHTML    Generate surrounding HTML tags? (&lt;style&gt; and &lt;/style&gt;)
@return    string
@throws    PHPExcel_Writer_Exception
558249
public function generateStyles($generateSurroundingHTML = true)
    {
        // PHPExcel object known?
        if (is_null($this->phpExcel)) {
            throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
        }

        // Build CSS
        $css = $this->buildCSS($generateSurroundingHTML);

        // Construct HTML
        $html = '';

        // Start styles
        if ($generateSurroundingHTML) {
            $html .= '    <style type="text/css">' . PHP_EOL;
            $html .= '      html { ' . $this->assembleCSS($css['html']) . ' }' . PHP_EOL;
        }

        // Write all other styles
        foreach ($css as $styleName => $styleDefinition) {
            if ($styleName != 'html') {
                $html .= '      ' . $styleName . ' { ' . $this->assembleCSS($styleDefinition) . ' }' . PHP_EOL;
            }
        }

        // End styles
        if ($generateSurroundingHTML) {
            $html .= '    </style>' . PHP_EOL;
        }

        // Return
        return $html;
    }
595839
public function getHtml()
    {
        $html = new Core\Tag(
            'html',
            array((isset($this->args[1]) ? $this->args[1] : null)),
            array('generate', 'start')
        );
        $html->setAttrs($this->htmlattrs);

        return $html;
    }
961015
public function generateExcel(): void
    {
        // Set Document Properties from Service values.
        $this->builder
             ->setCreator($this->getCreator())
             ->setLastModifiedBy($this->getCreator())
             ->setTitle($this->getTitle())
             ->setSubject($this->getTitle())
             ->setDescription($this->getDescription());

        if ($this->hasSheets()) {
            // Multiple sheets.
            $this->createSheets();
        } else {
            // Single sheet - these will be an array and a string.
            $headers     = $this->getHeaders();
            $reportArray = $this->getData();
            $sheetTitle  = $this->getSheetTitles();

            $this->builder->setActiveSheetIndex(0);

            $this->createSheet(
                $headers,
                $reportArray,
                $sheetTitle
            );
        }

        // Close the builder and write the file.
        $this->builder->closeAndWrite();

        return;
    }
919237
public function buildCSS($generateSurroundingHTML = true) {
		// PHPExcel object known?
		if (is_null($this->_phpExcel)) {
			throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
		}

		// Cached?
		if (!is_null($this->_cssStyles)) {
			return $this->_cssStyles;
		}

		// Ensure that spans have been calculated
		if (!$this->_spansAreCalculated) {
			$this->_calculateSpans();
		}

		// Construct CSS
		$css = array();

		// Start styles
		if ($generateSurroundingHTML) {
			// html { }
			$css['html']['font-family']	  = 'Calibri, Arial, Helvetica, sans-serif';
			$css['html']['font-size']		= '11pt';
			$css['html']['background-color'] = 'white';
		}


		// table { }
		$css['table']['border-collapse']  = 'collapse';
	    if (!$this->_isPdf) {
			$css['table']['page-break-after'] = 'always';
		}

		// .gridlines td { }
		$css['.gridlines td']['border'] = '1px dotted black';

		// .b {}
		$css['.b']['text-align'] = 'center'; // BOOL

		// .e {}
		$css['.e']['text-align'] = 'center'; // ERROR

		// .f {}
		$css['.f']['text-align'] = 'right'; // FORMULA

		// .inlineStr {}
		$css['.inlineStr']['text-align'] = 'left'; // INLINE

		// .n {}
		$css['.n']['text-align'] = 'right'; // NUMERIC

		// .s {}
		$css['.s']['text-align'] = 'left'; // STRING

		// Calculate cell style hashes
		foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) {
			$css['td.style' . $index] = $this->_createCSSStyle( $style );
		}

		// Fetch sheets
		$sheets = array();
		if (is_null($this->_sheetIndex)) {
			$sheets = $this->_phpExcel->getAllSheets();
		} else {
			$sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
		}

		// Build styles per sheet
		foreach ($sheets as $sheet) {
			// Calculate hash code
			$sheetIndex = $sheet->getParent()->getIndex($sheet);

			// Build styles
			// Calculate column widths
			$sheet->calculateColumnWidths();

			// col elements, initialize
			$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
			$column = -1;
			while($column++ < $highestColumnIndex) {
				$this->_columnWidths[$sheetIndex][$column] = 42; // approximation
				$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt';
			}

			// col elements, loop through columnDimensions and set width
			foreach ($sheet->getColumnDimensions() as $columnDimension) {
				if (($width = PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->_defaultFont)) >= 0) {
					$width = PHPExcel_Shared_Drawing::pixelsToPoints($width);
					$column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
					$this->_columnWidths[$sheetIndex][$column] = $width;
					$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = $width . 'pt';

					if ($columnDimension->getVisible() === false) {
						$css['table.sheet' . $sheetIndex . ' col.col' . $column]['visibility'] = 'collapse';
						$css['table.sheet' . $sheetIndex . ' col.col' . $column]['*display'] = 'none'; // target IE6+7
					}
				}
			}

			// Default row height
			$rowDimension = $sheet->getDefaultRowDimension();

			// table.sheetN tr { }
			$css['table.sheet' . $sheetIndex . ' tr'] = array();

			if ($rowDimension->getRowHeight() == -1) {
				$pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
			} else {
				$pt_height = $rowDimension->getRowHeight();
			}
			$css['table.sheet' . $sheetIndex . ' tr']['height'] = $pt_height . 'pt';
			if ($rowDimension->getVisible() === false) {
				$css['table.sheet' . $sheetIndex . ' tr']['display']	= 'none';
				$css['table.sheet' . $sheetIndex . ' tr']['visibility'] = 'hidden';
			}

			// Calculate row heights
			foreach ($sheet->getRowDimensions() as $rowDimension) {
				$row = $rowDimension->getRowIndex() - 1;

				// table.sheetN tr.rowYYYYYY { }
				$css['table.sheet' . $sheetIndex . ' tr.row' . $row] = array();

				if ($rowDimension->getRowHeight() == -1) {
					$pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
				} else {
					$pt_height = $rowDimension->getRowHeight();
				}
				$css['table.sheet' . $sheetIndex . ' tr.row' . $row]['height'] = $pt_height . 'pt';
				if ($rowDimension->getVisible() === false) {
					$css['table.sheet' . $sheetIndex . ' tr.row' . $row]['display'] = 'none';
					$css['table.sheet' . $sheetIndex . ' tr.row' . $row]['visibility'] = 'hidden';
				}
			}
		}

		// Cache
		if (is_null($this->_cssStyles)) {
			$this->_cssStyles = $css;
		}

		// Return
		return $css;
	}
884679
public function fetchCSS()
    {
        $string = "";

        if (empty($this->queuedCSS)) {
            return $string;
        }

        foreach ($this->queuedCSS as $sheet) {
            $string .= '<link rel="stylesheet" href="' . $sheet .'">' . "\r\n";
        }

        return $string;
    }
53465
@HtmlSafe
	public String getStylesheetHtml()
	{
		Space space = gpUtil.getSpaceManager().getSpace(getSpaceKey());
		return String.format("<style>\n%s\n</style>\n<base href=\"%s\"/>\n",
							 StyleSheetExtractorFactory.getInstance().renderStyleSheet(space), gpUtil.getBaseUrl());
	}
208399
public function replaceExternalCss($html, array $stylesheets)
    {
        foreach ($stylesheets['links'] as $key => $stylesheet) {
            if (!$this->isExternalStylesheet($stylesheet)) {
                $html = str_replace(
                    $stylesheets['tags'][$key],
                    $this->getStylesheetContent($stylesheet),
                    $html
                );
            }
        }

        return $html;
    }
1249040
public function generateCSS()
    {
        $result = '';

        $cssRaw       = '';
        $this->styles = array_unique($this->styles, SORT_REGULAR);
        foreach ($this->styles as $style) {
            if ($style[1]) {
                $cssRaw.=$style[0];
            } else {
                $result.='<link href="'.$style[0].'" rel="stylesheet" type="text/css" />';
            }
        }
        $result.=$cssRaw != '' ? '<style>'.$cssRaw.'</style>' : '';

        return $result;
    }
692553
protected function createSubHTML()
    {
        // prepare the subObject, if never prepare before
        if (self::$_subobj === null) {
            $this->_prepareSubObj();
        }

        // calculate the width to use
        if ($this->parsingCss->value['width']) {
            $marge = $this->parsingCss->value['padding']['l'] + $this->parsingCss->value['padding']['r'];
            $marge+= $this->parsingCss->value['border']['l']['width'] + $this->parsingCss->value['border']['r']['width'];
            $marge = $this->pdf->getW() - $this->parsingCss->value['width'] + $marge;
        } else {
            $marge = $this->_margeLeft+$this->_margeRight;
        }

        // BUGFIX : we have to call the method, because of a bug in php 5.1.6
        self::$_subobj->pdf->getPage();

        // clone the sub object
        $subHtml = clone self::$_subobj;
        $subHtml->parsingCss->table = $this->parsingCss->table;
        $subHtml->parsingCss->value = $this->parsingCss->value;
        $subHtml->initSubHtml(
            $this->_format,
            $this->_orientation,
            $marge,
            $this->_page,
            $this->_defList,
            $this->pdf->getMyLastPageGroup(),
            $this->pdf->getMyLastPageGroupNb()
        );

        return $subHtml;
    }
312688
protected function formStylesOutput($styles)
    {
        $preparedStyles = [];
        $template = '<link rel="stylesheet" type="text/css" href="%s" />';
        foreach ($styles as $style) {
            $preparedStyles[] = sprintf($template, $style);
        }

        return implode(PHP_EOL, $preparedStyles);
    }
1128212
protected function generateStyleguide() {

		// set-up the dispatcher
		$dispatcherInstance = Dispatcher::getInstance();

		// note the beginning of the operation
		$dispatcherInstance->dispatch("builder.generateStyleguideStart");

		// default var
		$publicDir = Config::getOption("publicDir");

		// load the pattern loader
		$ppdExporter             = new PatternPathSrcExporter();
		$patternPathSrc          = $ppdExporter->run();
		$options                 = array();
		$options["patternPaths"] = $patternPathSrc;
		$patternEngineBasePath   = PatternEngine::getInstance()->getBasePath();
		$patternLoaderClass      = $patternEngineBasePath."\Loaders\PatternLoader";
		$patternLoader           = new $patternLoaderClass($options);

		// check directories i need
		if (!is_dir($publicDir."/styleguide/")) {
			mkdir($publicDir."/styleguide/");
		}

		if (!is_dir($publicDir."/styleguide/html/")) {
			mkdir($publicDir."/styleguide/html/");
		}

		// grab the partials into a data object for the style guide
		$ppExporter                   = new PatternPartialsExporter();
		$partials                     = $ppExporter->run();

		// add the pattern data so it can be exported
		$patternData = array();

		// add the pattern lab specific mark-up
		$filesystemLoader             = Template::getFilesystemLoader();
		$stringLoader                 = Template::getStringLoader();

		$globalData                   = Data::get();
		$globalData["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"])));
		$globalData["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData))));
		$globalData["viewall"]        = true;

		$header                       = $patternLoader->render(array("pattern" => Template::getPatternHead(), "data" => $globalData));
		$code                         = $filesystemLoader->render(array("template" => "viewall", "data" => $partials));
		$footer                       = $patternLoader->render(array("pattern" => Template::getPatternFoot(), "data" => $globalData));

		$styleGuidePage               = $header.$code.$footer;

		file_put_contents($publicDir."/styleguide/html/styleguide.html",$styleGuidePage);

		// note the end of the operation
		$dispatcherInstance->dispatch("builder.generateStyleguideEnd");

	}
919571
public function getCssFromStyleTags($html)
    {
        $css = '';
        $matches = array();
        preg_match_all('|<style(?:\s.*)?>(.*)</style>|isU', $html, $matches);

        if (!empty($matches[1])) {
            foreach ($matches[1] as $match) {
                $css .= trim($match) . "\n";
            }
        }

        return $css;
    }
1306442
final public function generateClass()
    {
        static $docBlock;
        if (empty($docBlock)) {
            $writer = new Writer();
            $writer
                ->writeln('/**')
                ->writeln(' * CG library enhanced proxy class.')
                ->writeln(' *')
                ->writeln(' * This code was generated automatically by the CG library, manual changes to it')
                ->writeln(' * will be lost upon next generation.')
                ->write(' */')
            ;
            $docBlock = $writer->getContent();
        }

        $this->generatedClass = PhpClass::create()
            ->setDocblock($docBlock)
            ->setParentClassName($this->class->name)
        ;

        $proxyClassName = $this->getClassName($this->class);
        if (false === strpos($proxyClassName, NamingStrategyInterface::SEPARATOR)) {
            throw new \RuntimeException(sprintf('The proxy class name must be suffixed with "%s" and an optional string, but got "%s".', NamingStrategyInterface::SEPARATOR, $proxyClassName));
        }
        $this->generatedClass->setName($proxyClassName);

        if (!empty($this->interfaces)) {
            $this->generatedClass->setInterfaceNames(array_map(function($v) { return '\\'.$v; }, $this->interfaces));

            foreach ($this->getInterfaceMethods() as $method) {
                $method = PhpMethod::fromReflection($method);
                $method->setAbstract(false);

                $this->generatedClass->setMethod($method);
            }
        }

        if (!empty($this->generators)) {
            foreach ($this->generators as $generator) {
                $generator->generate($this->class, $this->generatedClass);
            }
        }

        return $this->generateCode($this->generatedClass);
    }
234927
public function generate(): string
    {
        $fieldId = $this->controllData['field-id'];
        $label = $this->controllData['label'];
        $label = $label != Tags::NBSP ? $label.':' : $label;
        $icons = '';
        $class = ['controll'];
        $ret = [];

        if ($this->controllData['required'] == 1) {
            $class[] = 'is-required';
        }
        if ($this->controllData['help'] != '') {
            $icons .= Tags::i($this->controllData['help'], ['class' => 'icon-help']);
            $class[] = 'has-help';
        }
        if ($this->controllData['error'] != '') {
            $icons .= Tags::i($this->controllData['error'], ['class' => 'icon-error']);
            $class[] = 'has-error';
        }

        $ctrl = Tags::div($label, ['class' => 'label']);
        $ctrl .= Tags::div($this->controllData['controll'], ['class' => 'html-controll']);
        $ctrl .= Tags::div($icons, ['class' => 'icons']);
        $ret[] = Tags::div($ctrl, ['class' => \implode(' ', $class), 'data-field-id' => $fieldId]);

        if ($this->controllData['script'] != '') {
            $ret[] = Tags::script(\str_replace(Tags::CRLF, ' ', $this->controllData['script']));
        }

        return \implode(Tags::CRLF, $ret);
    }
613354
public function generate()
	{
		if ($this->arrData['space'][0] != '')
		{
			$this->arrStyle[] = 'margin-top:'.$this->arrData['space'][0].'px;';
		}

		if ($this->arrData['space'][1] != '')
		{
			$this->arrStyle[] = 'margin-bottom:'.$this->arrData['space'][1].'px;';
		}

		$this->Template = new \FrontendTemplate($this->strTemplate);
		$this->Template->setData(clone $this->arrData);

		$this->compile();

		$this->Template->inColumn = $this->strColumn;
		$this->Template->style = !empty($this->arrStyle) ? implode(' ', $this->arrStyle) : '';
		$this->Template->class = trim('mod_' . $this->type . ' ' . $this->cssID[1]);
		$this->Template->cssID = ($this->cssID[0] != '') ? ' id="' . $this->cssID[0] . '"' : '';

		if ($this->Template->headline == '')
		{
			$this->Template->headline = $this->headline;
		}

		if ($this->Template->hl == '')
		{
			$this->Template->hl = $this->hl;
		}

		return $this->Template->parse();
	}
711274
public function generateHtml( $withOutput = false ) {

        $th = [
            'Name/ID',
            'Execution Time',
            'Total Execution Time',
            'Memory',
            'Total Memory',
            'Memory Peak',
            'Avg. Memory Peak',
            'Real Memory',
            'Total Real Memory',
            'Real Memory Peak',
            'Avg. Real Memory Peak'
        ];

        $m = new Manipulator( 'div' );

        $tbl = $m->setCss( [ 'font-family' => 'monospace', 'font-size' => '8px', 'color' => '#333' ] )
                 ->table
                     ->tableCols( $th );

        foreach( $this->_records as $record ) {

            $fromStart = $record->getAbsoluteResult();
            $fromLast = $record->getResult();

            if( !$fromLast )
                $fromLast = $fromStart;

            $tr = $tbl->append( 'tr' );
            $tr->append( 'th' )
                   ->setText( $record->getName() );

            foreach( [ $fromLast->getTime(), $fromStart->getTime() ] as $time ) {

                $time = $time * 1000;

                $tr->append( 'td' )
                        ->append( 'label[title="'.$time.' ms"]' )
                            ->setText( StringUtil::timify( $time ) );
            }

            foreach( [ 
                $fromLast->getMemoryUsage(), 
                $fromStart->getMemoryUsage(),
                $fromLast->getMemoryUsagePeak(), 
                $fromStart->getMemoryUsagePeak(),
                $fromLast->getRealMemoryUsage(),
                $fromStart->getRealMemoryUsage(),
                $fromLast->getRealMemoryUsagePeak(),
                $fromStart->getRealMemoryUsagePeak()
            ] as $bytes )
                $tr->append( 'td' )
                        ->append( 'label[title="'.$bytes.' Byte"]' )
                            ->setText( StringUtil::bytify( $bytes ) );

        }

        $m->find( 'table' )->setCss( [ 'width' => '100%' ] );
        $m->find( 'td, th' )->setCss( [ 'border' => '1px solid #ccc' ] );
        $m->find( 'td' )->setCss( [ 'text-align' => 'right' ] );
        $m->find( 'tr:even, tbody th' )->setCss( [ 'background' => '#efefef' ] );

        return $m;
    }
495438
public function getStylesheets()
    {
        $parse_stylesheets = function ($params, $stylesheets) {
            foreach ($params as $css) {
                if (is_string($css)) {
                    $css = array(
                        'path'  => $css,
                        'media' => 'all',
                    );
                }

                $stylesheets[] = $css;
            }

            return $stylesheets;
        };

        // From config.yml
        $stylesheets = $parse_stylesheets(
            $this->getGenerator()->getContainer()
                 ->getParameter('admingenerator.stylesheets', array()), array()
        );

        // From generator.yml
        $stylesheets = $parse_stylesheets(
            $this->getVariable('stylesheets', array()), $stylesheets
        );

        return $stylesheets;
    }