Skip to content

Commit ec1e38c

Browse files
committed
Merge branch '5.1.x' of github.com:baserproject/basercms into 5.1.x
2 parents f77b016 + 9e63e41 commit ec1e38c

76 files changed

Lines changed: 1336 additions & 322 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
test:
2121
name: Unit Test
2222

23-
runs-on: ubuntu-20.04
23+
runs-on: ubuntu-22.04
2424

2525
strategy:
2626
matrix:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</a>
1313
</p>
1414

15-
baserCMS is a website development framework with WebAPI that runs on PHP8 and CakePHP4.
15+
baserCMS is a website development framework with WebAPI that runs on PHP8 and CakePHP5.
1616

1717
The plugins such as "Mail Forms" and "Blogs", which are the minimum required for the Website, are equipped from the beginning as "Core Plugins", and a mechanism is provided to centrally manage those "Contents". The management system also has a tree-like display that makes it easy to understand the site structure, and intuitive operation is possible. It also has a REST API and "Custom Content", and can also be used as a "Headless CMS".
1818

plugins/baser-core/src/Controller/AppController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ public function beforeFilter(EventInterface $event)
178178
}
179179
$url = Configure::read("BcPrefixAuth.{$prefix}.loginRedirect");
180180
} else {
181-
$url = Router::url(Configure::read("BcPrefixAuth.{$prefix}.loginAction"))
182-
. '?redirect=' . urlencode(Router::url());
181+
$url = Router::url(Configure::read("BcPrefixAuth.{$prefix}.loginAction"), true)
182+
. '?redirect=' . rawurlencode($this->getRequest()->getPath());
183183
}
184184
return $this->redirect($url);
185185
}

plugins/baser-core/src/Controller/UploadsController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ protected function output($args, $funcNum)
102102
unlink($path);
103103
}
104104

105-
if ($ext !== 'gif' && $ext !== 'jpg' && $ext !== 'png') {
106-
Header("Content-disposition: attachment; filename=" . $name);
105+
$response = $this->getResponse()
106+
->withHeader('Content-type', sprintf('%s; name=%s', $type, $name))
107+
->withStringBody($data);
108+
if($ext !== 'gif' && $ext !== 'jpg' && $ext !== 'png') {
109+
$response = $response->withHeader('Content-disposition', sprintf('attachment; filename=%s', $name));
107110
}
108-
Header("Content-type: " . $type . "; name=" . $name);
111+
$this->setResponse($response);
109112
return $data;
110113
}
111114

plugins/baser-core/src/Service/Admin/ContentsAdminService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function _isAvailablePreview($content)
7979
protected function _isAvailableDelete($content)
8080
{
8181
if(!BcUtil::loginUser()->user_groups) return false;
82-
$path = BcUtil::getPrefix() . 'baser-core/contents/delete';
82+
$path = BcUtil::getPrefix() . '/baser-core/contents/delete';
8383
$userGroupIds = Hash::extract(BcUtil::loginUser()->user_groups, '{n}.id');
8484
$service = $this->getService(PermissionsServiceInterface::class);
8585
return ($content->id && $service->check($path, $userGroupIds) && !$content->site_root);

plugins/baser-core/src/TestSuite/BcTestCase.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,14 @@ public function setUp(): void
165165
public function classMethod()
166166
{
167167
$test = $this->provides()[0];
168+
$contents = ob_get_contents();
169+
if (ob_get_level() > 0) {
170+
ob_end_clean();
171+
}
168172
echo "\n" . $test->getTarget() . ' ';
169-
ob_end_flush();
173+
if($contents) {
174+
echo $contents;
175+
}
170176
ob_start();
171177
}
172178

plugins/baser-core/src/Utility/BcUtil.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Cake\Core\Plugin;
2626
use Cake\Core\Configure;
2727
use Cake\Database\Exception\MissingConnectionException;
28-
use Cake\Event\EventListenerInterface;
2928
use Cake\Event\EventManagerInterface;
3029
use Cake\Http\ServerRequest;
3130
use Cake\Http\UriFactory;

plugins/baser-core/src/View/Helper/BcBaserHelper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,18 +1281,18 @@ public function pagination($name = 'default', $data = [], $options = [])
12811281
public function content()
12821282
{
12831283
/*** contentHeader ***/
1284-
$this->dispatchLayerEvent('contentHeader', null, ['layer' => 'View', 'class' => '', 'plugin' => '']);
1284+
$this->dispatchLayerEvent('contentHeader', [], ['layer' => 'View', 'class' => '', 'plugin' => '']);
12851285

12861286
/*** Controller.contentHeader ***/
1287-
$this->dispatchLayerEvent('contentHeader', null, ['layer' => 'View', 'class' => $this->getView()->getName()]);
1287+
$this->dispatchLayerEvent('contentHeader', [], ['layer' => 'View', 'class' => $this->getView()->getName()]);
12881288

12891289
echo $this->getView()->fetch('content');
12901290

12911291
/*** contentFooter ***/
1292-
$this->dispatchLayerEvent('contentFooter', null, ['layer' => 'View', 'class' => '', 'plugin' => '']);
1292+
$this->dispatchLayerEvent('contentFooter', [], ['layer' => 'View', 'class' => '', 'plugin' => '']);
12931293

12941294
/*** Controller.contentFooter ***/
1295-
$this->dispatchLayerEvent('contentFooter', null, ['layer' => 'View', 'class' => $this->getView()->getName()]);
1295+
$this->dispatchLayerEvent('contentFooter', [], ['layer' => 'View', 'class' => $this->getView()->getName()]);
12961296
}
12971297

12981298
/**

plugins/baser-core/src/View/Helper/BcContentsHelper.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ public function setup()
141141
if (!empty($item['routes'][$method])) {
142142
$route = $item['routes'][$method];
143143
$item['url'][$method] = Router::url($route);
144+
$item['permissionCheckUrl'][$method] = Router::url([...$route, '_base' => false]);
144145
}
145146
}
146147
// disabled
147148
if (!empty($item['url']['add'])) {
148-
$item['addDisabled'] = !($this->PermissionsService->check($item['url']['add'], Hash::extract($user->user_groups, '{n}.id')));
149+
$item['addDisabled'] = !($this->PermissionsService->check($item['permissionCheckUrl']['add'],
150+
Hash::extract($user->user_groups, '{n}.id')));
149151
} else {
150152
$item['addDisabled'] = true;
151153
}
@@ -167,10 +169,10 @@ public function setup()
167169
public function isActionAvailable($type, $action, $entityId): bool
168170
{
169171
$user = BcUtil::loginUser();
170-
if (!isset($this->getConfig('items')[$type]['url'][$action])) {
172+
if (!isset($this->getConfig('items')[$type]['permissionCheckUrl'][$action])) {
171173
return false;
172174
}
173-
$url = $this->getConfig('items')[$type]['url'][$action] . '/' . $entityId;
175+
$url = $this->getConfig('items')[$type]['permissionCheckUrl'][$action] . '/' . $entityId;
174176
if (isset($user->user_groups)) {
175177
$userGroups = $user->user_groups;
176178
$userGroupIds = [];

plugins/baser-core/src/View/Helper/BcCsvHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace BaserCore\View\Helper;
1313

1414
use BaserCore\Event\BcEventDispatcherTrait;
15+
use BaserCore\Utility\BcUtil;
1516
use Cake\View\Helper;
1617
use BaserCore\Annotation\UnitTest;
1718
use BaserCore\Annotation\NoTodo;
@@ -209,7 +210,7 @@ protected function _perseValue($data)
209210
*/
210211
public function download($fileName, $debug = false)
211212
{
212-
if (!$debug) {
213+
if (!$debug && !BcUtil::isTest()) {
213214
for($i = 0; $i < ob_get_level(); $i++) {
214215
ob_end_flush();
215216
}

0 commit comments

Comments
 (0)