| 1 |
<?php |
| 2 |
|
| 3 |
namespace Depicter\Document\Models\Elements; |
| 4 |
|
| 5 |
use Depicter\Document\Models\Common\Styles; |
| 6 |
|
| 7 |
class Vector extends Svg |
| 8 |
{ |
| 9 |
|
| 10 |
public function getSelectorAndCssList() { |
| 11 |
parent::getSelectorAndCssList(); |
| 12 |
|
| 13 |
if ( empty( $this->options->customColors ) ) { |
| 14 |
return $this->selectorCssList; |
| 15 |
} |
| 16 |
$innerStyles = $this->prepare()->innerStyles; |
| 17 |
if ( !empty( $innerStyles ) ) { |
| 18 |
|
| 19 |
foreach( $innerStyles as $cssSelector => $styles ){ |
| 20 |
if ( empty( $styles ) || ! $styles instanceof Styles ) { |
| 21 |
continue; |
| 22 |
} |
| 23 |
|
| 24 |
$generalCss = $innerStyles->{$cssSelector}->getSvgCss('svg'); |
| 25 |
|
| 26 |
$this->selectorCssList[ '.' . $this->getStyleSelector() . ' .' . $this->removeCommonStrings( $cssSelector ) ] = $generalCss; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
return $this->selectorCssList; |
| 31 |
} |
| 32 |
|
| 33 |
public function removeCommonStrings( $selector ) { |
| 34 |
$commonStrings = [ |
| 35 |
'depicter', |
| 36 |
'fill', |
| 37 |
'stroke', |
| 38 |
'stopColor', |
| 39 |
'color' |
| 40 |
]; |
| 41 |
|
| 42 |
$selector = strtolower( $selector ); |
| 43 |
foreach( $commonStrings as $commonString ){ |
| 44 |
if ( $commonString == 'color') { |
| 45 |
if ( stripos( $selector, 'stopColor' ) === false ) { |
| 46 |
$selector = $commonString == 'depicter' ? str_ireplace( $commonString, $commonString . '-' , $selector ) : str_ireplace( $commonString, '-' . $commonString , $selector ); |
| 47 |
} |
| 48 |
} else { |
| 49 |
$selector = $commonString == 'depicter' ? str_ireplace( $commonString, $commonString . '-' , $selector ) : str_ireplace( $commonString, '-' . $commonString , $selector ); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
return str_replace( 'stopcolor', 'stopColor', $selector ); |
| 54 |
} |
| 55 |
} |
| 56 |
|