Skip to content

Commit

Permalink
Improved code + update some code to Cake3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Xety committed Apr 25, 2017
1 parent 6c07b77 commit 12dfd47
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 54 deletions.
2 changes: 1 addition & 1 deletion bin/cake.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

$minVersion = '5.5.9';
$minVersion = '5.6.0';
if (file_exists('composer.json')) {
$composer = json_decode(file_get_contents('composer.json'));
if (isset($composer->require->php)) {
Expand Down
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"cakephp/cakephp": "~3.0",
"cakephp/acl": "dev-master",
"cakephp/migrations": "~1.0",
"cakephp/plugin-installer": "*",
"cakephp/plugin-installer": "~1.0",
"mobiledetect/mobiledetectlib": "2.*",
"ezyang/htmlpurifier": "dev-master",
"widop/google-analytics": "dev-master",
Expand Down Expand Up @@ -69,10 +69,8 @@
"@cs-check",
"@test"
],
"cs-check": "vendor/bin/phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"cs-fix": "vendor/bin/phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"test": "vendor/bin/phpunit --colors=always"
},
"minimum-stability": "beta",
"prefer-stable": true
"cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"test": "phpunit --colors=always"
}
}
22 changes: 13 additions & 9 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
/*
* You can remove this if you are confident that your PHP version is sufficient.
*/
if (version_compare(PHP_VERSION, '5.5.9') < 0) {
trigger_error('Your PHP version must be equal or higher than 5.5.9 to use CakePHP.', E_USER_ERROR);
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
trigger_error('Your PHP version must be equal or higher than 5.6.0 to use Xeta.', E_USER_ERROR);
}

/*
* You can remove this if you are confident you have intl installed.
*/
if (!extension_loaded('intl')) {
trigger_error('You must enable the intl extension to use CakePHP.', E_USER_ERROR);
trigger_error('You must enable the intl extension to use Xeta.', E_USER_ERROR);
}

/*
* You can remove this if you are confident you have mbstring installed.
*/
if (!extension_loaded('mbstring')) {
trigger_error('You must enable the mbstring extension to use CakePHP.', E_USER_ERROR);
trigger_error('You must enable the mbstring extension to use Xeta.', E_USER_ERROR);
}

/*
Expand Down Expand Up @@ -156,22 +156,24 @@
unset($httpHost, $s);
}

Cache::config(Configure::consume('Cache'));
ConnectionManager::config(Configure::consume('Datasources'));
Email::configTransport(Configure::consume('EmailTransport'));
Email::config(Configure::consume('Email'));
Log::config(Configure::consume('Log'));
Cache::setConfig(Configure::consume('Cache'));
ConnectionManager::setConfig(Configure::consume('Datasources'));
Email::setConfigTransport(Configure::consume('EmailTransport'));
Email::setConfig(Configure::consume('Email'));
Log::setConfig(Configure::consume('Log'));
Security::salt(Configure::consume('Security.salt'));

/**
* Setup detectors for mobile and tablet.
*/
Request::addDetector('mobile', function ($request) {
$detector = new \Detection\MobileDetect();

return $detector->isMobile();
});
Request::addDetector('tablet', function ($request) {
$detector = new \Detection\MobileDetect();

return $detector->isTablet();
});

Expand All @@ -189,6 +191,8 @@
->useImmutable();
Type::build('datetime')
->useImmutable();
Type::build('timestamp')
->useImmutable();

/**
* Custom Type map.
Expand Down
4 changes: 2 additions & 2 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function middleware($middleware)
{
$middleware
// Handle plugin/theme assets like CakePHP normally does.
->add(new AssetMiddleware())
->add(AssetMiddleware::class)

// Apply routing
->add(new RoutingMiddleware())
->add(RoutingMiddleware::class)

// Handle the language switching from the Accept-Language header
->add(new LocaleSelectorMiddleware(['locales' => ['en_US', 'en', 'fr_FR', 'fr']]));
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ErrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function beforeRender(Event $event)
{
parent::beforeRender($event);

$this->viewBuilder()->templatePath('Error');
$this->viewBuilder()->setTemplatePath('Error');
}

/**
Expand Down
18 changes: 3 additions & 15 deletions src/Template/Element/Admin/header.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,9 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<?= $this->Html->link(
$this->Html->image('logo_and_name_white_inversed.png', ['class' => 'navbar-brand', 'alt' => \Cake\Core\Configure::read('Site.name')]),
['controller' => 'pages', 'action' => 'home', 'prefix' => false],
['escape' => false, 'class' => 'hidden-xs hidden-sm']
) ?>
<svg class='navbar-brand logo hidden-md hidden-lg' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400.1 360.1" xml:space="preserve">
<g class='icon'>
<path class="T" d="m 280.5,71.336441 0,-26.4 41.4,-45.30000034 0,71.70000034 0,47.099999 0,171.6 c 0.1,0.1 -41.4,51 -41.4,50.9 l 0,-222.5 z" />
<path class="F" d="m 56.5,71.336441 195.8,0 28.2,0 41.4,0 77.2,0 -43.3,47.099999 c 0,0 -33.9,0.1 -33.9,0 l -41.4,0 -146.8,0 -33.9,0 z" />
<path class="M" d="m 267.4,144.83644 -47.1,41.5 c -3.3,0.1 -26.4,0 -26.4,0 l -47.1,1.9 c 0.3,0.1 -47,0.1 -47.1,0 l -43.3,0 c -0.1,-0.1 -9.4,0 -9.4,0 0,-0.1 -46.90000002,-43 -47.10000002,-43.4 13.80000002,0 56.50000002,-0.3 56.50000002,0 70.20503,-0.71993 140.69199,0 211,0 z" />
<path class="M3" d="m 56.5,71.336441 43.3,47.099999 0,26.4 -0.1,43.4 0,101.8 c 0.2,-0.2 -43.3,52.8 -43.3,52.8 -0.1,0.1 0,-154.6 0,-154.6 l 0,-43.4 c 0.1,-9.6 0.1,-73.499999 0.1,-73.499999 z" />
<path class="M2" d="m 193.9,186.33644 0,84.9 c 0,28.2 0.3,45.5 0,45.3 0.3,0.1 -47.1,-43.3 -47.1,-43.4 l 0,-84.9 z" />
<path class="M1" d="m 267.4,144.83644 0,128.2 c -16.4,14.8 -47,43.3 -47.1,43.4 0,-16.3 -0.1,-130.1 0,-130.1 z" />
</g>
</svg>
<?= $this->Html->image('logo50x50.png', ['class' => 'navbar-brand hidden-xs hidden-sm', 'alt' => \Cake\Core\Configure::read('Site.name')]) ?>
<?= $this->Html->link(\Cake\Core\Configure::read('Site.name'), ['controller' => 'pages', 'action' => 'home', 'prefix' => false], ['class' => 'navbar-brand hidden-xs hidden-sm', 'data-hover' => \Cake\Core\Configure::read('Site.name')]) ?>
<?= $this->Html->image('logo50x50.png', ['class' => 'navbar-brand hidden-md hidden-lg', 'alt' => \Cake\Core\Configure::read('Site.name')]) ?>
</div>
<nav class="collapse navbar-collapse">
<ul class="nav navbar-nav">
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Controller/BlogControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function testArticleLike()
$this->get(['controller' => 'blog', 'action' => 'articleLike', 1]);
$this->assertJson($this->_response->body());
$this->assertResponseContains('Thanks for');
$this->assertResponseContains('"error": false');
$this->assertResponseContains('"error":false');
}

/**
Expand Down Expand Up @@ -385,7 +385,7 @@ public function testArticleLikeAlreadyLiked()
$this->get(['controller' => 'blog', 'action' => 'articleLike', 1]);
$this->assertJson($this->_response->body());
$this->assertResponseContains('You already like this article !');
$this->assertResponseContains('"error": true');
$this->assertResponseContains('"error":true');
}

/**
Expand All @@ -405,7 +405,7 @@ public function testArticleLikeNotFound()
$this->get(['controller' => 'blog', 'action' => 'articleLike', 1337]);
$this->assertJson($this->_response->body());
$this->assertResponseContains('This article doesn\u0027t exist !');
$this->assertResponseContains('"error": true');
$this->assertResponseContains('"error":true');
}

/**
Expand All @@ -424,7 +424,7 @@ public function testArticleUnlike()

$this->get(['controller' => 'blog', 'action' => 'articleUnlike', 1]);
$this->assertJson($this->_response->body());
$this->assertResponseContains('"error": false');
$this->assertResponseContains('"error":false');
}

/**
Expand Down Expand Up @@ -455,7 +455,7 @@ public function testArticleUnlikeNotFound()
$this->get(['controller' => 'blog', 'action' => 'articleUnlike', 1337]);
$this->assertJson($this->_response->body());
$this->assertResponseContains('You don\u0027t like this article !');
$this->assertResponseContains('"error": true');
$this->assertResponseContains('"error":true');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Controller/ConversationsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function testQuote()
$this->get(['controller' => 'conversations', 'action' => 'quote', 1]);
$this->assertResponseOk();
$this->assertJson($this->_response->body());
$this->assertResponseContains('"error": false');
$this->assertResponseContains('"error":false');
}

/**
Expand All @@ -359,7 +359,7 @@ public function testQuoteNotExist()
$this->get(['controller' => 'conversations', 'action' => 'quote', 2]);
$this->assertResponseOk();
$this->assertJson($this->_response->body());
$this->assertResponseContains('"error": true');
$this->assertResponseContains('"error":true');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Controller/NotificationsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testMarkAsRead()

$this->post(['controller' => 'notifications', 'action' => 'markAsRead'], $data);
$this->assertJson($this->_response->body());
$this->assertResponseContains('"error": false');
$this->assertResponseContains('"error":false');

$this->configRequest([
'headers' => [
Expand All @@ -92,7 +92,7 @@ public function testMarkAsRead()
//Test markAsRead when the notif is already readed
$this->post(['controller' => 'notifications', 'action' => 'markAsRead'], $data);
$this->assertJson($this->_response->body());
$this->assertResponseContains('"error": false', 'Should not throw an error.');
$this->assertResponseContains('"error":false', 'Should not throw an error.');
}

/**
Expand Down Expand Up @@ -137,7 +137,7 @@ public function testMarkAsReadUnauthorized()

$this->post(['controller' => 'notifications', 'action' => 'markAsRead'], $data);
$this->assertJson($this->_response->body());
$this->assertResponseContains('"error": true');
$this->assertResponseContains('"error":true');
}

/**
Expand All @@ -161,6 +161,6 @@ public function testMarkAsReadNotFound()

$this->post(['controller' => 'notifications', 'action' => 'markAsRead'], $data);
$this->assertJson($this->_response->body());
$this->assertResponseContains('"error": true');
$this->assertResponseContains('"error":true');
}
}
2 changes: 1 addition & 1 deletion webroot/css/admin.min.css

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions webroot/css/adminless/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
.navbar-header {
width: 195px;
border-right: 1px solid #3F5061;
padding-left: 35.5px;

.navbar-brand {
width: initial;
margin-left: 35px;
padding: 11px 0;
}
}

Expand Down Expand Up @@ -52,12 +50,22 @@
.navbar-admin {
.navbar-header {
width: inherit;
padding-left: 0px;

.navbar-brand {
outline: none;
fill: #ffffff;
height: 38px;
height: 40px;
margin: 6px 9px 6px -6px;
padding: 5px;
}
}
}
}

@media (min-width: 992px) {
.navbar-admin {
.navbar-header {
.navbar-brand {
margin-left: -15px;
}
}
}
Expand All @@ -72,7 +80,7 @@
margin: 0;
border-right: 1px solid #3f5061;
height: 50px;
padding: 6px 9px;
padding: 6px 10px;
}
}

Expand Down

0 comments on commit 12dfd47

Please sign in to comment.