mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 11:27:03 +00:00
Squashed commit
Always execute migration 9999 (can be used to fix things manually) Optimized meal plan navigation / date range filtering Prepared next release Pulled translations from Transifex Various code optimizations
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use Grocy\Helpers\Grocycode;
|
||||
use jucksearm\barcode\lib\BarcodeFactory;
|
||||
use jucksearm\barcode\lib\DatamatrixFactory;
|
||||
|
||||
class ChoresController extends BaseController
|
||||
{
|
||||
use GrocycodeTrait;
|
||||
|
||||
public function ChoreEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$usersService = $this->getUsersService();
|
||||
@@ -115,40 +115,7 @@ class ChoresController extends BaseController
|
||||
|
||||
public function ChoreGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$size = $request->getQueryParam('size', null);
|
||||
$gc = new Grocycode(Grocycode::CHORE, $args['choreId']);
|
||||
|
||||
if (GROCY_GROCYCODE_TYPE == '2D')
|
||||
{
|
||||
$png = (new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData();
|
||||
}
|
||||
else
|
||||
{
|
||||
$png = (new BarcodeFactory())->setType('C128')->setCode((string) $gc)->setHeight($size)->getBarcodePngData();
|
||||
}
|
||||
|
||||
$isDownload = $request->getQueryParam('download', false);
|
||||
if ($isDownload)
|
||||
{
|
||||
$response = $response->withHeader('Content-Type', 'application/octet-stream')
|
||||
->withHeader('Content-Disposition', 'attachment; filename=grocycode.png')
|
||||
->withHeader('Content-Length', strlen($png))
|
||||
->withHeader('Cache-Control', 'no-cache')
|
||||
->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = $response->withHeader('Content-Type', 'image/png')
|
||||
->withHeader('Content-Length', strlen($png))
|
||||
->withHeader('Cache-Control', 'no-cache')
|
||||
->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
}
|
||||
$response->getBody()->write($png);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function __construct(\DI\Container $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
return $this->ServeGrocycodeImage($request, $response, $gc);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user