add: router.controller.svg (now manage svg recoloring)
This commit is contained in:
parent
2653f896f2
commit
c5fae9e7ce
|
@ -0,0 +1,60 @@
|
|||
<?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(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
"routes": {
|
||||
|
||||
"/js/bundle.js": {
|
||||
"/{path}{color}": {
|
||||
"methods": ["GET"],
|
||||
"controller": "js:bundle",
|
||||
"arguments": {}
|
||||
"controller": "svg:color",
|
||||
"arguments": {
|
||||
"path": ".+\\.svg",
|
||||
"color": "@[a-fA-F0-9]{6}"
|
||||
}
|
||||
},
|
||||
|
||||
"/js/_SERVER.js": {
|
||||
|
@ -17,6 +20,12 @@
|
|||
"arguments": {}
|
||||
},
|
||||
|
||||
"/js/bundle.js": {
|
||||
"methods": ["GET"],
|
||||
"controller": "js:bundle",
|
||||
"arguments": {}
|
||||
},
|
||||
|
||||
"/{page}/": {
|
||||
"methods": ["GET"],
|
||||
"controller": "page:load",
|
||||
|
|
Loading…
Reference in New Issue