61 lines
1.1 KiB
PHP
61 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace router\controller;
|
|
|
|
|
|
class svg{
|
|
|
|
|
|
private $path;
|
|
private $color;
|
|
|
|
/* PRE-CALL
|
|
*
|
|
* @url<String> Calling URI
|
|
*
|
|
*/
|
|
public function __construct($url){
|
|
$this->path = $url['path'];
|
|
$this->color = substr($url['color'], 1);
|
|
}
|
|
|
|
|
|
/* Colorate svg
|
|
*
|
|
*/
|
|
public function color(){
|
|
header('Content-Type: image/svg+xml');
|
|
|
|
// On crée la partie ajoutée
|
|
$stylesheet = "\n<style type='text/css'>\n";
|
|
$stylesheet .= "\t#fill-edit{\n";
|
|
$stylesheet .= "\t\tfill: #".$this->color." !important;\n";
|
|
$stylesheet .= "\t\tfill-opacity: 1 !important;\n";
|
|
$stylesheet .= "\t}\n";
|
|
$stylesheet .= "\t#stroke-edit{\n";
|
|
$stylesheet .= "\t\tstroke: #".$this->color." !important;\n";
|
|
$stylesheet .= "\t\tstroke-opacity: 1 !important;\n";
|
|
$stylesheet .= "\t}\n";
|
|
$stylesheet .= "</style></svg>";
|
|
|
|
// On récupère le fichier
|
|
$file = file_get_contents(__PUBLIC__.'/'.$this->path);
|
|
|
|
// On ajoute le style
|
|
$file = str_replace('</svg>', $stylesheet, $file);
|
|
|
|
echo $file;
|
|
|
|
}
|
|
|
|
/* POST-CALL
|
|
*
|
|
*/
|
|
public function __destruct(){
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|