Generate CSS for Ebook JPG cover

@return string the generated CSS
487052
protected function generateCss() {
		$styles = Container::get( 'Styles' );
		$scss = $this->getScssVars();

		if ( $styles->isCurrentThemeCompatible( 1 ) ) {
			$scss .= "@import 'fonts-prince'; \n";
		} elseif ( $styles->isCurrentThemeCompatible( 2 ) ) {
			$scss .= "@import 'fonts'; \n";
		}
		$scss .= \Pressbooks\Utility\get_contents( PB_PLUGIN_DIR . 'assets/covergenerator/_jpg.scss' );

		$css = $styles->customize( 'prince', $scss );
		$css = \Pressbooks\Sanitize\normalize_css_urls( $css );

		if ( WP_DEBUG ) {
			Container::get( 'Sass' )->debug( $css, $scss, 'cover-jpg' );
		}

		return $css;
	}
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;
    }
419437
public function generateGraph()
	{
		// set the image size
		$im = @ImageCreate( $this->getOption( 'width' ), $this->getOption( 'height' ) );
		extract( $this->getOptions() );
		$imageColorBackground	= $this->setColor( $im, $this->getOption( "color_background" ) );			//  set Background Color
		$imageColorBars			= $this->setColor( $im, $this->getOption( "color_bars" ) );					//  set Color of Y-Axis Labels
		$imageColorDash			= $this->setColor( $im, $this->getOption( "color_dash" ) );					//  set Color of dashed Lines
//		$imageColorText			= $this->setColor( $im, $this->getOption( "color_text" ) );					//  set Color of Text
		$imageColorTitle		= $this->setColor( $im, $this->getOption( "color_title" ) );				//  set Color of Title Text
		if( $this->getOption( 'transparent' ) )
			ImageColorTransparent( $im, $imageColorBackground );											//  set Background Transparency
		$this->drawOutlines( $im, $imageColorBars );														//  draw Outlines of Graph Image
		// in case no maximum scale has been provided, calculate the maximum value reached by any of the lines
		if( !isset( $maxValue ) )
		{
			$maxValue	= 0;
			for( $g=0; $g<count( $this->graphs ); $g++ )
				$maxValue	= max( $maxValue, max( $this->graphs[$g]['values'] ) );
	//		if( isset( $maxAdjust ) )
	//			$maxValue	+= $maxAdjust; // so that it doesn't touch the upper margin
		}

		// determine the maximum height available for drawing
		// draw the horizontal dotted "guidelines"
		$ratio	= floor( $this->getOption( 'height' ) - $this->getOption( 'padding_top' ) - $this->getOption( 'padding_bottom' ) ) / $this->getOption( 'horizontal_bars' );
		for( $i=0; $i<$this->getOption( 'horizontal_bars' ); $i++ )
		{
			$height	= $this->getOption( 'padding_top' ) + $i * $ratio;
			if( $i )
				ImageDashedLine( $im, $this->getOption( 'padding_left' ), $height, $this->getOption( 'width' ) - $this->getOption( 'padding_right' ), $height, $imageColorDash );
			// write proper values next to the horizontal guidelines, based on their number and max value
			// FIXME: a more general approach; ability to place them on either side for example
			ImageString( $im, 1, $this->getOption( 'width' ) - $this->getOption( 'padding_left' ) - 30, $height - 3, floor( ( $this->getOption( 'horizontal_bars' ) - $i ) * $maxValue / $this->getOption( 'horizontal_bars' ) ), $imageColorTitle );
		}
		// draw the vertical dotted guidelines; these depend on how much data you have
		// FIXME: make it possible to draw only the Nth line
		$ratio	= floor( $this->getOption( 'width' ) - $this->getOption( 'padding_left' ) - $this->getOption( 'padding_right' ) ) / ( count( $this->labels ) - 1 );
		for( $i=0; $i<count( $this->labels ); $i++ )
		{
			if( $i<count( $this->labels ) -2 )
			{
				$width	=$this->getOption( 'padding_left' ) + ( $i + 1 ) * $ratio;
				ImageDashedLine( $im, $width, $this->getOption( 'padding_top' ), $width, $this->getOption( 'height' ) - $this->getOption( 'padding_bottom' ), $imageColorDash );
			}
			$width	= $this->getOption( 'padding_left' ) + $i * $ratio;
			// write the labels for each value
			ImageString( $im, 1, $width + $this->getOption( 'label_adjust_x' ), $this->getOption( 'height' ) + $this->getOption( 'label_adjust_y' ), $this->labels[$i], $imageColorTitle );
		}
		// actually output the graphs
		$this->drawGraphs( $im, $maxValue, $ratio );

		// write the title
		ImageString( $im, $this->getOption( 'title_font' ), $this->getOption( 'title_x' ), $this->getOption( 'title_y' ), $this->getOption( 'title_text' ), $imageColorTitle );
		return $im;
	}
902760
public function getCss()
	{
		$css = $this->css;
		$options = $this->options;
		if($this->isCombineEnabled())
			$this->combine('css', $css);

		// avoiding duplicate assets
		$css = array_flip(array_flip($css));

		array_walk($css, function(&$value) use($options){
			if(!empty($options['baseUrl'])&&strpos($value,'http://')===false)
				$value = $options['baseUrl'].$value;
		});
		return $css;
	}
335580
public function getCss()
    {
        if(!$this->includeAssets())
        {
            return '';
        }
        $libraries = $this->getLibrariesInUse();
        $code = '';
        foreach($libraries as $library)
        {
            $code .= $library->getCss() . "\n";
        }
        return $code;
    }
533310
public function includeGeneratedCss()
    {
        $filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath() . '.css';

        $this->assetHandlerConnectorManager->createFileInTemporaryDirectory(
            $filePath,
            function () {
                /** @var MessageContainerDisplayCssAssetHandler $errorContainerDisplayCssAssetHandler */
                $errorContainerDisplayCssAssetHandler = $this->assetHandlerConnectorManager
                    ->getAssetHandlerFactory()
                    ->getAssetHandler(MessageContainerDisplayCssAssetHandler::class);

                /** @var FieldsActivationCssAssetHandler $fieldsActivationCssAssetHandler */
                $fieldsActivationCssAssetHandler = $this->assetHandlerConnectorManager
                    ->getAssetHandlerFactory()
                    ->getAssetHandler(FieldsActivationCssAssetHandler::class);

                $css = $errorContainerDisplayCssAssetHandler->getErrorContainerDisplayCss() . LF;
                $css .= $fieldsActivationCssAssetHandler->getFieldsActivationCss();

                return $css;
            }
        );

        $this->assetHandlerConnectorManager
            ->getPageRenderer()
            ->addCssFile(StringService::get()->getResourceRelativePath($filePath));

        return $this;
    }
386755
public function get_inline_css() {
		if ( $this->get_pre_selectors() ) {
			$inline_css = sprintf(
				'%1$s { %2$s }',
				implode( ',', $this->get_selectors() ),
				$this->get_properties()
			);
			foreach ( $this->get_pre_selectors() as $pre_selector ) {
				$inline_css = sprintf(
					'%1$s { %2$s }',
					$pre_selector,
					$inline_css
				);
			}
			return $inline_css;
		}

		return sprintf(
			'%1$s { %2$s }',
			implode( ',', $this->get_selectors() ),
			$this->get_properties()
		);
	}
872166
public function getStyle()
    {
        $style = '';

        // Always add fixed height as a fallback if autosetting or JS fails.
        $height = $this->FixedHeight;
        if (!$height) {
            $height = 800;
        }
        $style .= "height: {$height}px; ";

        if ($this->AutoWidth) {
            $style .= "width: 100%; ";
        } elseif ($this->FixedWidth) {
            $style .= "width: {$this->FixedWidth}px; ";
        }

        return $style;
    }
1039457
public function getStylesXMLFileContent()
    {
        $content = <<<EOD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
EOD;

        $content .= $this->getFontsSectionContent();
        $content .= $this->getFillsSectionContent();
        $content .= $this->getBordersSectionContent();
        $content .= $this->getCellStyleXfsSectionContent();
        $content .= $this->getCellXfsSectionContent();
        $content .= $this->getCellStylesSectionContent();

        $content .= <<<EOD
</styleSheet>
EOD;

        return $content;
    }
1327152
public function getStyle(): string
    {
        $values = $this->options;
        if ($this->bgColor > 0) {
            array_unshift($values, $this->bgColor);
        }

        if ($this->fgColor > 0) {
            array_unshift($values, $this->fgColor);
        }

        return implode(';', $values);
    }
1083349
public function getStyleSheetsHtml()
    {
        $styleSheets = '';
        if (!isset($this->styles)) {
            return $styleSheets;
        }

        foreach ($this->styles as $s) {
            $styleSheets .= '<link rel="stylesheet" type="text/css" href="' . $s . '"/>' . "\n";
        }

        return $styleSheets;
    }
335298
public function get_css_content_editor() {
        $css = '';
        $cssfiles = $this->editor_css_files();

        // If editor has static CSS, include it.
        foreach ($cssfiles as $file) {
            $css .= file_get_contents($file)."\n";
        }

        // If editor has SCSS, compile and include it.
        if (($convertedscss = $this->editor_scss_to_css())) {
            $css .= $convertedscss;
        }

        $output = $this->post_process($css);

        return $output;
    }
92794
private function generateResponsiveCss()
  {
    if (static::$responsiveMediaQuery===null) return;

    Abc::$assets->cssAppendLine(static::$responsiveMediaQuery);
    Abc::$assets->cssAppendLine('{');
    $id     = $this->getAttribute('id');
    $format = '#%s tr.%s > td:nth-of-type(%d):before {content: %s;}';
    foreach ($this->columns as $index => $column)
    {
      $text = $column->getHeaderText();
      for ($i=0; $i<$column->getColSpan(); $i++)
      {
        Abc::$assets->cssAppendLine(sprintf($format, $id, static::$class, $index + $i, Css::txt2CssString($text)));
      }
    }
    Abc::$assets->cssAppendLine('}');
  }
535182
protected function generateTheme()
    {
        $nodes = $this->xpath->query('/x:webspace/x:theme/x:key');
        if ($nodes->length > 0) {
            return $nodes->item(0)->nodeValue;
        }

        $nodes = $this->xpath->query('/x:webspace/x:theme');
        if (0 === $nodes->length) {
            return;
        }

        return $nodes->item(0)->nodeValue;
    }
744598
public function getCustomCSSPrefix()
    {
        if ($parent = $this->getParent()) {
            return sprintf('%s %s', $parent->CSSID, $this->CSSID);
        }
        
        return $this->CSSID;
    }
523783
public function imageToHtml()
    {
        if (empty($this->data['file.url'])) {
            return '';
        }

        $text = $this->data['text'] ?? '';

        if (!empty($text)) {
            $text = $this->parser->toHtml($text);
        }

        $url = $this->data['file.url'] ?? '';

        try {
            $size = getimagesize($url);
        } catch (Exception $e) {
            $size = [
                $this->config['image.width'] ?? 520,
                $this->config['image.height'] ?? 200,
            ];
        }

        return $this->view('image.image', [
            'url' => $url,
            'text' => $text,
            'width' => $size[0],
            'height' => $size[1],
        ]);
    }
58005
public function getStylesContent(): string
    {
        $content = '';
        if(isset($this->styles))
            foreach($this->styles as $style)
                if(isset($style['content']))
                    $content .= $style['content'].PHP_EOL;

        return $content;
    }