Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-10-25 12:57:27 +0300
committerJulius Härtl <jus@bitgrid.net>2018-10-25 13:16:10 +0300
commitd21ded67a70672cfa56a48051fa752b431118604 (patch)
tree5f29256f45dbb761f5cc1ea80dd7d9802114196b /core/Controller
parent0b2ef7e60873fbb2036a85a934bf1af23ebb5bc9 (diff)
Keep list of icons in a separate file for use in the accessibility app
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core/Controller')
-rw-r--r--core/Controller/SvgController.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php
index f7159dd9fe1..bbf4e61c60c 100644
--- a/core/Controller/SvgController.php
+++ b/core/Controller/SvgController.php
@@ -31,6 +31,7 @@ use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\App\IAppManager;
use OCP\IRequest;
+use OC\Template\IconsCacher;
class SvgController extends Controller {
@@ -43,15 +44,20 @@ class SvgController extends Controller {
/** @var IAppManager */
protected $appManager;
+ /** @var IconsCacher */
+ private $iconsCacher;
+
public function __construct(string $appName,
IRequest $request,
ITimeFactory $timeFactory,
- IAppManager $appManager) {
+ IAppManager $appManager,
+ IconsCacher $iconsCacher) {
parent::__construct($appName, $request);
$this->serverRoot = \OC::$SERVERROOT;
$this->timeFactory = $timeFactory;
$this->appManager = $appManager;
+ $this->iconsCacher = $iconsCacher;
}
/**
@@ -114,17 +120,11 @@ class SvgController extends Controller {
$svg = file_get_contents($path);
- if (is_null($svg)) {
+ if ($svg === null) {
return new NotFoundResponse();
}
- // add fill (fill is not present on black elements)
- $fillRe = '/<((circle|rect|path)((?!fill)[a-z0-9 =".\-#():;])+)\/>/mi';
- $svg = preg_replace($fillRe, '<$1 fill="#' . $color . '"/>', $svg);
-
- // replace any fill or stroke colors
- $svg = preg_replace('/stroke="#([a-z0-9]{3,6})"/mi', 'stroke="#' . $color . '"', $svg);
- $svg = preg_replace('/fill="#([a-z0-9]{3,6})"/mi', 'fill="#' . $color . '"', $svg);
+ $svg = $this->iconsCacher->colorizeSvg($svg, $color);
$response = new DataDisplayResponse($svg, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']);