diff --git a/code/Icon.php b/code/Icon.php index 46b8d49..af47bb5 100755 --- a/code/Icon.php +++ b/code/Icon.php @@ -1,14 +1,22 @@ tableName, $this->name, 'Varchar(1024)'); } + + public function wrapSvg() { + return true; + } private static $casting = array( 'URL' => 'HTMLFragment', @@ -22,7 +30,8 @@ function requireField() { * * @return string */ - public function forTemplate() { + public function forTemplate() : string + { return $this->getTag(); } @@ -84,14 +93,24 @@ public function SVG(){ } $svg = file_get_contents($filePath); - return ''.$svg.''; + + + $wrapSVG = $this->wrapSvg(); + $this->extend('updateWrapSVG', $wrapSVG); + + if($wrapSVG){ + $svg =''.$svg.''; + } + + return $svg; } /** * (non-PHPdoc) * @see DBField::scaffoldFormField() */ - public function scaffoldFormField($title = null, $params = null) { + public function scaffoldFormField(?string $title = null, array $params = []) : FormField + { return IconField::create($this->name, $title); } -} \ No newline at end of file +} diff --git a/code/IconField.php b/code/IconField.php index 491d2d7..56d225e 100755 --- a/code/IconField.php +++ b/code/IconField.php @@ -2,6 +2,8 @@ namespace Jaedb\IconField; use DirectoryIterator; +use SilverStripe\Control\Director; +use SilverStripe\Core\Path; use SilverStripe\View\Requirements; use SilverStripe\View\ArrayData; use SilverStripe\ORM\ArrayList; @@ -28,7 +30,7 @@ public function __construct($name, $title = null, $sourceFolder = null){ } $icons = array(); - $sourcePath = BASE_PATH.$sourceFolder; + $sourcePath = Path::join(Director::publicFolder(), $sourceFolder); $extensions = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg'); // Scan each directory for files @@ -48,7 +50,7 @@ public function __construct($name, $title = null, $sourceFolder = null){ } $this->source = $icons; - Requirements::css('/resources/jaedb/iconfield/css/IconField.css'); + Requirements::css('/_resources/jaedb/iconfield/css/IconField.css'); } diff --git a/composer.json b/composer.json index 3c070e2..5180581 100755 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "jaedb/iconfield", + "name": "toastnz/iconfield", "type": "silverstripe-vendormodule", "description": "Icon field for SilverStripe", "homepage": "http://jamesbarnsley.co.nz",