Skip to content

Commit

Permalink
fixed #53 - Bug Bilder Upload Responsive backend bug
Browse files Browse the repository at this point in the history
fixed #51 - Login-Fehler backend bug
fixed #49 - Doctrine ORM Service Provider Update / Doctrine ORM-Update backend improvement
fixed #48 - Doctrine DBAL-Update auf 2.5 backend improvement
fixed #47 - Silex-Update auf 2.0 backend improvement
  • Loading branch information
areanet committed Jan 29, 2018
1 parent 20dce8c commit 7583638
Show file tree
Hide file tree
Showing 18 changed files with 737 additions and 65 deletions.
2 changes: 1 addition & 1 deletion appcms/areanet/PIM-UI/default/assets/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

if ($cookies.get('APPCMS-TOKEN') != null) {
$http.defaults.headers.common = {
'APPMCS-TOKEN': $cookies.get('APPCMS-TOKEN')
'APPCMS-TOKEN': $cookies.get('APPCMS-TOKEN')
};
}

Expand Down
6 changes: 6 additions & 0 deletions appcms/areanet/PIM/Classes/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\MappedSuperclass;
use Doctrine\ORM\Mapping\Table;
use Silex\Application;
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
Expand Down Expand Up @@ -928,6 +929,11 @@ public function getSchema(){

foreach($classAnnotations as $classAnnotation) {

if($classAnnotation instanceof MappedSuperclass){
$skipEntity = true;
break;
}

if ($classAnnotation instanceof Table) {
$settings['dbname'] = $classAnnotation->name ? $classAnnotation->name : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Areanet\PIM\Classes\Controller\Provider\BaseControllerProvider;
use Areanet\PIM\Controller\ApiController;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

Expand All @@ -15,9 +14,9 @@ class ApiControllerProvider extends BaseControllerProvider

public function connect(Application $app)
{
$app['api.controller'] = $app->share(function() use ($app) {
$app['api.controller'] = function($app) {
return new ApiController($app);
});
};

$this->setUpMiddleware($app);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class AuthControllerProvider extends BaseControllerProvider

public function connect(Application $app)
{
$app['auth.controller'] = $app->share(function() use ($app) {
$app['auth.controller'] = function($app) {
return new AuthController($app);
});
};

$this->setUpMiddleware($app);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public function __construct($basePath, $controllerName)

public function connect(Application $app)
{
$app[$this->basePath.'.controller'] = $app->share(function() use ($app) {
$app[$this->basePath.'.controller'] = function() use ($app) {
$controllerName = $this->controllerName;
return new $controllerName($app);
});
};

$this->setUpMiddleware($app);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class FileControllerProvider extends BaseControllerProvider

public function connect(Application $app)
{
$app['file.controller'] = $app->share(function() use ($app) {
$app['file.controller'] = function() use ($app) {
return new FileController($app);
});
};

$this->setUpMiddleware($app);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class PushControllerProvider extends BaseControllerProvider

public function connect(Application $app)
{
$app['push.controller'] = $app->share(function() use ($app) {
$app['push.controller'] = function($app) {
return new PushController($app);
});
};

$this->setUpMiddleware($app);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class SystemControllerProvider extends BaseControllerProvider

public function connect(Application $app)
{
$app['system.controller'] = $app->share(function() use ($app) {
$app['system.controller'] = function($app) {
return new SystemController($app);
});
};

$this->setUpMiddleware($app);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace Areanet\PIM\Classes\Controller\Provider;

use Areanet\PIM\Classes\Config\Adapter;
use Silex\Api\ControllerProviderInterface;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand Down Expand Up @@ -91,10 +91,11 @@ protected function isAuthRequiredForPath($path)

protected function checkToken(Request $request, Application $app){
$tokenString = $request->headers->get(self::TOKEN_HEADER_KEY, null);

if(empty($tokenString)){
$tokenString = $request->headers->get(self::TOKEN_HEADER_KEY_ALT, $request->get(self::TOKEN_REQUEST_KEY));
}
$headers = $request->headers->all();


if(empty($tokenString)){
return false;
Expand Down
26 changes: 16 additions & 10 deletions appcms/areanet/PIM/Classes/File/Processing/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function registerImageSize(ThumbnailSetting $thumbnailSetting)
{
$this->thumbnailSettings[$thumbnailSetting->getAlias()] = $thumbnailSetting;
}

public function getMimeTypes()
{
return array('image/jpeg', 'image/gif', 'image/png');
Expand Down Expand Up @@ -62,6 +62,7 @@ public function execute(BackendInterface $backend, File $fileObject, $fileSizeAl

foreach($this->thumbnailSettings as $thumbnailSetting){


if($fileSizeAlias && $fileSizeAlias != $thumbnailSetting->getAlias()){
continue;
}
Expand All @@ -75,7 +76,6 @@ public function execute(BackendInterface $backend, File $fileObject, $fileSizeAl
}

if(!$variant || !file_exists($imgThumbName)) {

$orig_width = imagesx($img);
$orig_height = imagesy($img);

Expand Down Expand Up @@ -131,22 +131,24 @@ public function execute(BackendInterface $backend, File $fileObject, $fileSizeAl
$quality = $this->qualityMapping['image/jpeg'];
}

$img = $loadMethodName($imgThumbName);
$thumb = $this->resizeByPercent($fileObject, $img, 2/3*100);
$imgThumb = $loadMethodName($imgThumbName);
$thumb = $this->resizeByPercent($fileObject, $imgThumb, 2/3*100);

$imgThumbNameList = explode("/", $imgThumbName);
$imgThumbNameList[count($imgThumbNameList) - 1] = "2x@" . $imgThumbNameList[count($imgThumbNameList) - 1];
$imgThumbName2x = implode('/', $imgThumbNameList);

$saveMethodName($thumb, $imgThumbName2x, $quality);

imagedestroy($thumb);

}

if($thumbnailSetting->getIsResponsive() && $variant != '2x' || $variant == '1x' ) {

$quality = $this->qualityMapping[$fileObject->getType()];
$imgThumbName = $backend->getPath($fileObject).'/'.$thumbnailSetting->getAlias().'-'.$fileObject->getName();


if($thumbnailSetting->getForceJpeg()){
$imgThumbNameList = explode('.', $imgThumbName);
$imgThumbNameList[(count($imgThumbNameList) - 1)] = 'jpg';
Expand All @@ -159,17 +161,21 @@ public function execute(BackendInterface $backend, File $fileObject, $fileSizeAl
$quality = $this->qualityMapping['image/jpeg'];
}

$img = $loadMethodName($imgThumbName);
$thumb = $this->resizeByPercent($fileObject, $img, 1/3*100);
$imgThumb = $loadMethodName($imgThumbName);
$thumb = $this->resizeByPercent($fileObject, $imgThumb, 1/3*100);

$imgThumbNameList = explode("/", $imgThumbName);
$imgThumbNameList[count($imgThumbNameList) - 1] = "1x@" . $imgThumbNameList[count($imgThumbNameList) - 1];
$imgThumbName2x = implode('/', $imgThumbNameList);

$saveMethodName($thumb, $imgThumbName2x, $quality);

imagedestroy($thumb);

}



}
}

Expand All @@ -178,7 +184,7 @@ protected function resizeByWidth($fileObject, $img, ThumbnailSetting $thumbnailS
$orig_width = imagesx($img);
$orig_height = imagesy($img);

$width = $thumbnailSetting->getWidth();
$width = $thumbnailSetting->getWidth() < $orig_width ? $thumbnailSetting->getWidth() : $orig_width;
$height = (($orig_height * $width) / $orig_width);

$thumb = imagecreatetruecolor($width, $height);
Expand Down Expand Up @@ -210,7 +216,7 @@ protected function resizeByHeight($fileObject, $img, ThumbnailSetting $thumbnail
$orig_width = imagesx($img);
$orig_height = imagesy($img);

$height = $thumbnailSetting->getHeight();
$height = $thumbnailSetting->getHeight() < $orig_height ? $thumbnailSetting->getHeight() : $orig_height;
$width = (($orig_width * $height) / $orig_height);

$thumb = imagecreatetruecolor($width, $height);
Expand Down
1 change: 1 addition & 0 deletions appcms/areanet/PIM/Classes/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function install(EntityManager $em){
}

$admin->setAlias("admin");
$admin->setLoginManager('');
$admin->setPass("admin");
$admin->setIsAdmin(true);

Expand Down
9 changes: 5 additions & 4 deletions appcms/areanet/PIM/Controller/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function executeInstallation(Request $request){
)
));

$this->app->register(new \Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), array(
$this->app->register(new \Dflydev\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), array(
'orm.proxies_dir' => ROOT_DIR . '/../data/cache/doctrine',
'orm.em.options' => array(
'connection' => 'pim',
Expand All @@ -169,9 +169,9 @@ protected function executeInstallation(Request $request){
)
));

$this->app['typeManager'] = $this->app->share(function ($app) {
$this->app['typeManager'] = function ($app) {
return new \Areanet\PIM\Classes\Manager\TypeManager($app);
});
};


foreach (Adapter::getConfig()->APP_SYSTEM_TYPES as $systemType) {
Expand All @@ -187,7 +187,8 @@ protected function executeInstallation(Request $request){
$this->app['helper']->install($this->app['orm.em']);

}catch(\Exception $e){
return array('database' => "Die Datenbank konnte nicht initialisiert werden.");

return array('database' => "Die Datenbank konnte nicht initialisiert werden: " . $e->getMessage());
}

return array();
Expand Down
2 changes: 1 addition & 1 deletion appcms/areanet/PIM/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class User extends Base
protected $salt;

/**
* @ORM\Column(type="string", length=100)
* @ORM\Column(type="string", length=100, nullable=true)
* @PIM\Config(label="Login-Manager", tab="settings", readonly=true)
*/
protected $loginManager;
Expand Down
39 changes: 20 additions & 19 deletions appcms/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile(ROOT_DIR.'/areanet/PIM/Classes/Annotations/MatrixChooser.php');



$app = new Application();
$app->register(new Silex\Provider\SessionServiceProvider());
$app['is_installed'] = (Config\Adapter::getConfig()->DB_HOST != '$SET_DB_HOST');
Expand Down Expand Up @@ -68,19 +69,19 @@
));


$app['helper'] = $app->share(function ($app) {
$app['helper'] = function () {
return new \Areanet\PIM\Classes\Helper();
});
};

$app['auth'] = $app->share(function ($app) {
$app['auth'] = function ($app) {
return new \Areanet\PIM\Classes\Auth($app);
});
};

if($app['is_installed']) {

$app['helper']->createSymlinks();

$app->register(new \Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), array(
$app->register(new \Dflydev\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), array(
'orm.proxies_dir' => ROOT_DIR . '/../data/cache/doctrine',
'orm.em.options' => array(
'connection' => 'pim',
Expand Down Expand Up @@ -130,9 +131,9 @@
}
}

$app['typeManager'] = $app->share(function ($app) {
$app['typeManager'] = function ($app) {
return new \Areanet\PIM\Classes\Manager\TypeManager($app);
});
};

foreach (Config\Adapter::getConfig()->APP_SYSTEM_TYPES as $systemType) {
$typeClass = new $systemType($app);
Expand Down Expand Up @@ -177,29 +178,29 @@

$app['debug'] = Config\Adapter::getConfig()->APP_DEBUG;

$app['consoleManager'] = $app->share(function ($app) {
$app['consoleManager'] = function ($app) {
return new \Areanet\PIM\Classes\Manager\ConsoleManager($app);
});
};

$app['uiManager'] = $app->share(function ($app) {
$app['uiManager'] = function ($app) {
return new \Areanet\PIM\Classes\Manager\UIManager($app);
});
};

$app['routeManager'] = $app->share(function ($app) {
$app['routeManager'] = function ($app) {
return new \Areanet\PIM\Classes\Manager\RouteManager($app);
});

};
/*
$app['dispatcher']->addListener(\Knp\Console\ConsoleEvents::INIT, function(\Knp\Console\ConsoleEvent $event) {
$app = $event->getApplication();
$app->add(new \Areanet\PIM\Command\SetupCommand());
});
});*/

$app['schema'] = $app->share(function ($app){
$app['schema'] = function ($app){
$api = new \Areanet\PIM\Classes\Api($app);
return $api->getSchema();
});
};

$app['database'] = $app->share(function ($app){
$app['database'] = function ($app){
$config = \Areanet\PIM\Classes\Config\Adapter::getConfig();

$connectionParams = array(
Expand All @@ -213,7 +214,7 @@
);

return \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
});
};

$app->register(new Silex\Provider\ValidatorServiceProvider());

Expand Down
14 changes: 6 additions & 8 deletions appcms/composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"require": {
"silex/silex": "1.3",
"twig/twig": "1.23",
"dflydev/doctrine-orm-service-provider": "1.0.7",
"doctrine/dbal": "2.2",
"knplabs/console-service-provider": "1.1",
"duccio/apns-php": "1.0",
"symfony/validator": "3.3"
"silex/silex": "2.2.2",
"twig/twig": "^2.4.4",
"dflydev/doctrine-orm-service-provider": "^2.0.1",
"knplabs/console-service-provider": "^2.1.0",
"doctrine/dbal": "^2.6.3",
"symfony/validator": "4.0.4"
},
"autoload": {
"psr-4": {
"Areanet\\": "areanet/",
"Plugins\\": "plugins/",
"Custom\\": "../custom/"
}
}
Expand Down
Loading

0 comments on commit 7583638

Please sign in to comment.