IMPR: Website Domain QR-Code
This commit is contained in:
parent
c0d3d6fafa
commit
fb362cddd4
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
Name: app-mimeuploadvalidator
|
||||
After: '#mimeuploadvalidator'
|
||||
Only:
|
||||
moduleexists: 'silverstripe/mimevalidator'
|
||||
---
|
||||
SilverStripe\Core\Injector\Injector:
|
||||
SilverStripe\Assets\Upload_Validator:
|
||||
class: SilverStripe\MimeValidator\MimeUploadValidator
|
|
@ -44,6 +44,16 @@ class SiteConfigExtension extends DataExtension
|
|||
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$img = Image::get()->filter([
|
||||
'ParentID' => 0,
|
||||
'FileFilename' => 'qrcode.png',
|
||||
])->first();
|
||||
if ($img) {
|
||||
$fields->addFieldsToTab('Root.Main', [
|
||||
LiteralField::create('QRCode', '<img src="'.$img->Link().'" alt="QR code" width="200" style="float:left" />'),
|
||||
]);
|
||||
}
|
||||
|
||||
$fields->addFieldsToTab('Root.Main', [
|
||||
TreeMultiselectField::create(
|
||||
'Navigation',
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Site\Tasks;
|
||||
|
||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||
use Endroid\QrCode\LabelAlignment;
|
||||
use Endroid\QrCode\QrCode;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Image;
|
||||
use SilverStripe\Assets\Storage\AssetStore;
|
||||
use SilverStripe\Assets\Upload;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
|
||||
|
||||
class QRCodeTask extends BuildTask
|
||||
{
|
||||
protected $title = 'Generate website QR-code';
|
||||
|
||||
protected $description = 'Generate website QR-code';
|
||||
|
||||
protected $enabled = true;
|
||||
|
||||
public function run($request)
|
||||
{
|
||||
echo '<h1>'.$this->Title().'</h1>';
|
||||
|
||||
echo self::generateQR();
|
||||
|
||||
die('Done!');
|
||||
}
|
||||
|
||||
public static function generateQR()
|
||||
{
|
||||
$qrCode = new QrCode(Director::absoluteBaseURL());
|
||||
$qrCode->setSize(600);
|
||||
$qrCode->setMargin(10);
|
||||
|
||||
$qrCode->setWriterByName('png');
|
||||
$qrCode->setEncoding('UTF-8');
|
||||
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH());
|
||||
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
||||
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
||||
$qrCode->setLabel(Director::absoluteBaseURL(), 16, null, LabelAlignment::CENTER());
|
||||
/*$qrCode->setLogoPath('/'.File::join_paths(
|
||||
PUBLIC_PATH,
|
||||
RESOURCES_DIR,
|
||||
project(),
|
||||
'client', 'dist', 'icons',
|
||||
'apple-touch-icon-152x152.png'
|
||||
));
|
||||
$qrCode->setLogoSize(152, 152);*/
|
||||
$qrCode->setValidateResult(true);
|
||||
|
||||
|
||||
// Round block sizes to improve readability and make the blocks sharper in pixel based outputs (like png).
|
||||
// There are three approaches:
|
||||
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN); // The size of the qr code is shrinked, if necessary, but the size of the final image remains unchanged due to additional margin being added (default)
|
||||
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_ENLARGE); // The size of the qr code and the final image is enlarged, if necessary
|
||||
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_SHRINK); // The size of the qr code and the final image is shrinked, if necessary
|
||||
|
||||
// Set additional writer options (SvgWriter example)
|
||||
$qrCode->setWriterOptions(['exclude_xml_declaration' => true]);
|
||||
|
||||
// Directly output the QR code
|
||||
/*header('Content-Type: '.$qrCode->getContentType());
|
||||
echo $qrCode->writeString();
|
||||
die();*/
|
||||
|
||||
// Save it to a file
|
||||
$qrCode->writeFile(TEMP_PATH.'/qrcode.png');
|
||||
$res = self::getAssetStore()->setFromLocalFile(
|
||||
TEMP_PATH.'/qrcode.png',
|
||||
'qrcode.png', null, null,
|
||||
[
|
||||
'conflict' => AssetStore::CONFLICT_OVERWRITE,
|
||||
'visibility' => AssetStore::VISIBILITY_PUBLIC,
|
||||
]
|
||||
);
|
||||
|
||||
$img = Image::get()->filter([
|
||||
'ParentID' => 0,
|
||||
'FileFilename' => $res['Filename'],
|
||||
])->first();
|
||||
if(!$img) {
|
||||
$img = Image::create();
|
||||
}
|
||||
|
||||
$res['FileHash'] = $res['Hash'];
|
||||
$res['FileFilename'] = $res['Filename'];
|
||||
$res['ParentID'] = 0;
|
||||
|
||||
$img = $img->update($res);
|
||||
$img->write();
|
||||
$img->publishFile();
|
||||
|
||||
return '<img src="'.$qrCode->writeDataUri().'" width="300" alt="QR-code" /><br/>';
|
||||
}
|
||||
|
||||
protected static function getAssetStore()
|
||||
{
|
||||
return Injector::inst()->get(AssetStore::class);
|
||||
}
|
||||
}
|
170
composer.json
170
composer.json
|
@ -1,88 +1,90 @@
|
|||
{
|
||||
"name": "a2nt/silverstripe-webpack",
|
||||
"type": "silverstripe-recipe",
|
||||
"version": "2.2.1",
|
||||
"description": "SilverStripe WebPack boilerplate + Basics of JS/CSS UI",
|
||||
"keywords": [
|
||||
"silverstripe",
|
||||
"webpack",
|
||||
"bootstrap",
|
||||
"boilerplate"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"require": {
|
||||
"php": ">=7.1.0",
|
||||
"ext-json": "*",
|
||||
"silverstripe/recipe-cms": "^4",
|
||||
"wilr/silverstripe-googlesitemaps": "*",
|
||||
"silverstripe/userforms": "*",
|
||||
"undefinedoffset/sortablegridfield": "*",
|
||||
"silverstripe/spamprotection": "*",
|
||||
"silverstripe/recaptcha": "*",
|
||||
"jonom/silverstripe-betternavigator": "*",
|
||||
"silverstripe/externallinks": "*",
|
||||
"symbiote/silverstripe-gridfieldextensions": "*",
|
||||
"colymba/gridfield-bulk-editing-tools": "^3",
|
||||
"dnadesign/silverstripe-elemental-list": "*",
|
||||
"dnadesign/silverstripe-elemental-virtual": "*",
|
||||
"dnadesign/silverstripe-elemental-userforms": "*",
|
||||
"dynamic/silverstripe-elemental-blocks": "*",
|
||||
"drmartingonzo/ss-tinymce-charcount": "*",
|
||||
"axllent/silverstripe-version-truncator": "*",
|
||||
"gorriecoe/silverstripe-dataobjecthistory": "*",
|
||||
"axllent/silverstripe-bootstrap-forms": "*",
|
||||
"silverstripe/redirectedurls": "*",
|
||||
"undefinedoffset/silverstripe-nocaptcha": "*",
|
||||
"stevie-mayhew/silverstripe-svg": "*",
|
||||
"betterbrief/silverstripe-googlemapfield": "*",
|
||||
"innoweb/silverstripe-sitemap": "*",
|
||||
"silverstripe/multiuser-editing-alert": "*",
|
||||
"gorriecoe/silverstripe-link": "*",
|
||||
"gorriecoe/silverstripe-linkfield": "*",
|
||||
"silverstripe/environmentcheck": "*",
|
||||
"silverstripe/widgets": "^2.0",
|
||||
"a2nt/silverstripe-font-awesome-field": "dev-master",
|
||||
"a2nt/silverstripe-mapboxfield": "dev-master",
|
||||
"a2nt/silverstripe-progressivewebapp": "dev-master",
|
||||
"bummzack/sortablefile": "*",
|
||||
"showpro/silverstripe-seo-images": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"lekoala/silverstripe-debugbar": "dev-master"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/a2nt/silverstripe-font-awesome"
|
||||
"name": "a2nt/silverstripe-webpack",
|
||||
"type": "silverstripe-recipe",
|
||||
"description": "SilverStripe WebPack boilerplate + Basics of JS/CSS UI",
|
||||
"keywords": [
|
||||
"silverstripe",
|
||||
"webpack"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"require": {
|
||||
"php": ">=7.1.0",
|
||||
"ext-json": "*",
|
||||
"silverstripe/recipe-cms": "^4",
|
||||
"wilr/silverstripe-googlesitemaps": "*",
|
||||
"silverstripe/userforms": "*",
|
||||
"undefinedoffset/sortablegridfield": "*",
|
||||
"silverstripe/spamprotection": "*",
|
||||
"silverstripe/recaptcha": "*",
|
||||
"jonom/silverstripe-betternavigator": "*",
|
||||
"silverstripe/externallinks": "*",
|
||||
"symbiote/silverstripe-gridfieldextensions": "*",
|
||||
"colymba/gridfield-bulk-editing-tools": "*",
|
||||
"dnadesign/silverstripe-elemental-list": "*",
|
||||
"dnadesign/silverstripe-elemental-virtual": "*",
|
||||
"dnadesign/silverstripe-elemental-userforms": "*",
|
||||
"dynamic/silverstripe-elemental-blocks": "*",
|
||||
"drmartingonzo/ss-tinymce-charcount": "*",
|
||||
"axllent/silverstripe-version-truncator": "*",
|
||||
"gorriecoe/silverstripe-dataobjecthistory": "*",
|
||||
"axllent/silverstripe-bootstrap-forms": "*",
|
||||
"silverstripe/redirectedurls": "*",
|
||||
"undefinedoffset/silverstripe-nocaptcha": "*",
|
||||
"stevie-mayhew/silverstripe-svg": "*",
|
||||
"betterbrief/silverstripe-googlemapfield": "*",
|
||||
"innoweb/silverstripe-sitemap": "*",
|
||||
"silverstripe/multiuser-editing-alert": "*",
|
||||
"gorriecoe/silverstripe-link": "*",
|
||||
"gorriecoe/silverstripe-linkfield": "*",
|
||||
"silverstripe/environmentcheck": "*",
|
||||
"silverstripe/widgets": "^2.0",
|
||||
"a2nt/silverstripe-font-awesome-field": "dev-master",
|
||||
"a2nt/silverstripe-mapboxfield": "dev-master",
|
||||
"a2nt/silverstripe-progressivewebapp": "dev-master",
|
||||
"bummzack/sortablefile": "*",
|
||||
"barryvdh/composer-cleanup-plugin": "0.2.x",
|
||||
"eluceo/ical": "^0.16.0",
|
||||
"ezyang/htmlpurifier": "^4.13",
|
||||
"showpro/silverstripe-seo-images": "^1.0",
|
||||
"endroid/qr-code": "^3.9"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/a2nt/silverstripe-mapboxfield"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"expose": [
|
||||
"app/client/dist"
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"lekoala/silverstripe-debugbar": "dev-master"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/a2nt/silverstripe-font-awesome"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/a2nt/silverstripe-mapboxfield"
|
||||
}
|
||||
],
|
||||
"project-files-installed": [
|
||||
"app/.htaccess",
|
||||
"app/_config.php",
|
||||
"app/_config/mysite.yml",
|
||||
"app/src/Page.php",
|
||||
"app/src/PageController.php"
|
||||
],
|
||||
"public-files-installed": [
|
||||
".htaccess",
|
||||
"index.php",
|
||||
"install-frameworkmissing.html",
|
||||
"install.php",
|
||||
"web.config"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"process-timeout": 600
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"minimum-stability": "dev"
|
||||
"extra": {
|
||||
"expose": [
|
||||
"app/client/dist"
|
||||
],
|
||||
"project-files-installed": [
|
||||
"app/.htaccess",
|
||||
"app/_config.php",
|
||||
"app/_config/mimevalidator.yml",
|
||||
"app/_config/mysite.yml",
|
||||
"app/src/Page.php",
|
||||
"app/src/PageController.php"
|
||||
],
|
||||
"public-files-installed": [
|
||||
".htaccess",
|
||||
"index.php",
|
||||
"install-frameworkmissing.html",
|
||||
"install.php",
|
||||
"web.config"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"process-timeout": 600
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
|
12
package.json
12
package.json
|
@ -32,13 +32,13 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"@a2nt/meta-lightbox": "^2.2.1",
|
||||
"@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^2.3.1",
|
||||
"@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^2.3.5",
|
||||
"bootbox": "^4.4.0",
|
||||
"bootstrap": "^4.5.0",
|
||||
"bootstrap-confirmation2": "^4.1.0",
|
||||
"bootstrap-datepicker": "^1.9.0",
|
||||
"bootstrap-offcanvas": "^1.0.0",
|
||||
"bootstrap-table": "^1.16.0",
|
||||
"bootstrap-table": "^1.17.1",
|
||||
"bootstrap-timepicker": "^0.5.2",
|
||||
"exif-js": "^2.3.0",
|
||||
"font-awesome": "^4.7.0",
|
||||
|
@ -49,7 +49,7 @@
|
|||
"jquery-hoverintent": "*",
|
||||
"jquery-zoom": "^1.7.21",
|
||||
"jquery.appear": "^1.0.1",
|
||||
"mapbox-gl": "^1.11.0",
|
||||
"mapbox-gl": "^1.11.1",
|
||||
"material-design-color": "^2.3.2",
|
||||
"moment": "^2.27.0",
|
||||
"offcanvas-bootstrap": "^2.5.2",
|
||||
|
@ -63,13 +63,13 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@a2nt/image-sprite-webpack-plugin": "^0.2.5",
|
||||
"@babel/core": "^7.10.4",
|
||||
"@babel/core": "^7.10.5",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.10.4",
|
||||
"@babel/plugin-transform-react-jsx": "^7.10.4",
|
||||
"@babel/preset-env": "^7.10.4",
|
||||
"@google/markerclusterer": "^1.0.3",
|
||||
"animate.css": "^3.7.2",
|
||||
"autoprefixer": "^9.8.4",
|
||||
"autoprefixer": "^9.8.5",
|
||||
"babel-eslint": "^8.2.6",
|
||||
"babel-loader": "^8.1.0",
|
||||
"copy-webpack-plugin": "^4.6.0",
|
||||
|
@ -110,7 +110,7 @@
|
|||
"svg-url-loader": "^2.3.3",
|
||||
"terser-webpack-plugin": "^2.3.7",
|
||||
"url-loader": "^0.6.2",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack": "^4.44.0",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"webpack-dev-server": "^3.11.0",
|
||||
"webpack-manifest-plugin": "^1.3.2",
|
||||
|
|
Loading…
Reference in New Issue