diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..592d72f
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,59 @@
+on:
+ push:
+ # Sequence of patterns matched against refs/tags
+ tags:
+ - '3*'
+
+name: create_release
+
+jobs:
+ build:
+ name: create_release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Slack Notification on Start
+ uses: rtCamp/action-slack-notify@v2.2.0
+ env:
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }}
+ SLACK_CHANNEL: notify-nc3-release
+ SLACK_TITLE: "${{ github.repository }}"
+ SLACK_COLOR: "#f0ad4e"
+ SLACK_MESSAGE: "Start Job"
+
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
+ with:
+ tag_name: ${{ github.ref }}
+ release_name: ${{ github.ref }}
+ body: |
+ NetCommons ${{ github.ref }} released.
+ draft: false
+ prerelease: false
+
+ # テスト成功時はこちらのステップが実行される
+ - name: Slack Notification on Finish
+ uses: rtCamp/action-slack-notify@v2.2.0
+ if: success()
+ env:
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }}
+ SLACK_CHANNEL: notify-nc3-release
+ SLACK_TITLE: "${{ github.repository }}"
+ SLACK_COLOR: good
+ SLACK_MESSAGE: "Job Success"
+
+ # テスト失敗時はこちらのステップが実行される
+ - name: Slack Notification on Failure
+ uses: rtCamp/action-slack-notify@v2.2.0
+ if: failure()
+ env:
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }}
+ SLACK_CHANNEL: notify-nc3-tests
+ SLACK_TITLE: "${{ github.repository }}"
+ SLACK_COLOR: danger
+ SLACK_MESSAGE: "Job Failure"
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..6da4321
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,168 @@
+on:
+ push:
+ branches:
+ - main
+ - master
+ pull_request:
+ branches:
+ - main
+ - master
+
+name: tests
+
+jobs:
+ setup:
+ name: setup
+ runs-on: ubuntu-latest
+ steps:
+ - name: Slack Notification on Start
+ uses: rtCamp/action-slack-notify@v2.2.0
+ if: env.SLACK_WEBHOOK != ''
+ env:
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }}
+ SLACK_CHANNEL: notify-nc3-tests
+ SLACK_TITLE: "${{ github.repository }}"
+ SLACK_COLOR: "#f0ad4e"
+
+ tests:
+ name: tests
+ needs: setup
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ php: [ '7.1', '7.2', '7.3', '7.4' ]
+ mysql: [ '5.7', '8.0' ]
+
+ env:
+ NC3_BUILD_DIR: "/opt/nc3"
+ NC3_DOCKER_DIR: "/opt/docker"
+ NC3_GIT_URL: "git://github.com/NetCommons3/NetCommons3.git"
+ NC3_GIT_BRANCH: "master"
+ PLUGIN_BUILD_DIR: ${{ github.workspace }}
+ PHP_VERSION: ${{ matrix.php }}
+ MYSQL_VERSION: ${{ matrix.mysql }}
+ MYSQL_ROOT_PASSWORD: root
+ MYSQL_DATABASE: cakephp_test
+ COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Fix up git URLs
+ run: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig
+
+ - name: environment
+ run: |
+ echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}"
+ echo "PLUGIN_BUILD_DIR=${PLUGIN_BUILD_DIR}"
+ echo "PHP_VERSION=${PHP_VERSION}"
+ echo "MYSQL_VERSION=${MYSQL_VERSION}"
+ ls -al ${PLUGIN_BUILD_DIR}
+
+ - name: docker-compose install
+ run: |
+ curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
+ chmod +x ~/docker-compose
+ sudo mv ~/docker-compose /usr/local/bin/docker-compose
+ docker-compose --version
+
+ - name: git clone nc3
+ run: git clone -b ${NC3_GIT_BRANCH} ${NC3_GIT_URL} ${NC3_BUILD_DIR}
+
+ - name: git clone nc3_docker
+ run: git clone https://github.com/NetCommons3/nc3app-docker.git ${NC3_DOCKER_DIR}
+
+ - name: docker-compose start
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose up -d
+ docker-compose start
+
+ - run: docker ps
+
+ - name: check libraries
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/start-on-docker.sh
+
+ - name: nc3 build
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/app-build.sh
+
+ - name: phpcs (PHP CodeSniffer)
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh
+
+ - name: phpmd (PHP Mess Detector)
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh
+
+ - name: phpcpd (PHP Copy/Paste Detector)
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh
+
+ - name: gjslint (JavaScript Style Check)
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh
+
+ - name: phpdoc (PHP Documentor)
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh
+
+ - name: phpunit (PHP UnitTest)
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh
+ sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build
+
+# - name: push coveralls
+# env:
+# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+# COVERALLS_FLAG_NAME: ${{ matrix.php }}
+# run: |
+# cd ${NC3_BUILD_DIR}
+# ls -la ${NC3_BUILD_DIR}
+# vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
+
+ - name: docker-compose remove
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose rm -f
+
+ # テスト失敗時はこちらのステップが実行される
+ - name: Slack Notification on Failure
+ uses: rtCamp/action-slack-notify@v2.2.0
+ if: env.SLACK_WEBHOOK != '' && failure()
+ env:
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }}
+ SLACK_CHANNEL: notify-nc3-tests
+ SLACK_TITLE: "${{ github.repository }}(php${{ matrix.php }}, mysql${{ matrix.mysql }})"
+ SLACK_COLOR: danger
+
+ teardown:
+ name: teardown
+ runs-on: ubuntu-latest
+ needs: tests
+ steps:
+ # テスト成功時はこちらのステップが実行される
+ - name: Slack Notification on Success
+ uses: rtCamp/action-slack-notify@v2.2.0
+ if: env.SLACK_WEBHOOK != '' && success()
+ env:
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }}
+ SLACK_CHANNEL: notify-nc3-tests
+ SLACK_TITLE: "${{ github.repository }}"
+ SLACK_COLOR: good
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 6c47da6..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-language: php
-
-php:
- - 7.0
- - 7.1
- - 7.2
- - 7.3
- - 7.4
-
-sudo: false
-dist: trusty
-
-env:
- matrix:
- - NETCOMMONS_VERSION=master DB=mysql
- global:
- - secure: "iq/xEV3mq8MBLWnumo8LOSc9cVvkrh7E+joO8ZpmZ7+CxfpFW1ESp2X552ncso9LPMH2rl24/ZR24xwwklNxpqxu+erXfmIpiO2gCa7ESFAJW3J/irN5uRL+t7Z9RWZwFq88p4jsR+2LHeVzl+jgqVNmCpjVJd40uR1DDYzODO4="
- - GIT_COMMITTER_NAME=s-nakajima
- - GIT_COMMITTER_EMAIL=nakajimashouhei@gmail.com
- - GIT_AUTHOR_NAME=s-nakajima
- - GIT_AUTHOR_EMAIL=nakajimashouhei@gmail.com
-
-before_script:
- - export NETCOMMONS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/NetCommons3
- - git clone git://github.com/NetCommons3/NetCommons3 $NETCOMMONS_BUILD_DIR
- - cd $NETCOMMONS_BUILD_DIR
- - git checkout $NETCOMMONS_VERSION
- - travis_wait . tools/build/plugins/cakephp/travis/pre.sh
- - . tools/build/plugins/cakephp/travis/environment.sh
-
-script:
- - . tools/build/plugins/cakephp/travis/main.sh
-
-after_script:
- - . tools/build/plugins/cakephp/travis/post.sh
-
-notifications:
- email:
- recipients:
- - netcommons3@googlegroups.com
- on_success: never # default: change
- on_failure: always # default: always
diff --git a/Controller/PagesEditController.php b/Controller/PagesEditController.php
index 1bf54e2..d648467 100644
--- a/Controller/PagesEditController.php
+++ b/Controller/PagesEditController.php
@@ -53,7 +53,7 @@ class PagesEditController extends PagesAppController {
public $components = array(
'NetCommons.Permission' => array(
'allow' => array(
- 'index,add,edit,delete,layout,add_m17n' => 'page_editable',
+ '*' => 'page_editable',
),
),
'Pages.PageLayout',
@@ -660,21 +660,22 @@ private function __hasDeletePage() {
* @return bool
*/
private function __hasDeleteThisPage() {
- $activeLangs = $this->Language->getLanguages();
- if (! Current::read('Space.is_m17n') && count($activeLangs) <= 1) {
- return false;
- }
-
- $hasDeletePage = $this->__hasDeletePage();
- if (! $hasDeletePage) {
- return false;
- }
-
- $activeLangIds = Hash::extract($activeLangs, '{n}.Language.id');
-
- $pageIdsM17n = $this->Page->getPageIdsWithM17n(Current::read('Page.id'));
-
- return (bool)array_diff($activeLangIds, Hash::get($pageIdsM17n, Current::read('Page.id'), []));
+ return false;
+ //$activeLangs = $this->Language->getLanguages();
+ //if (! Current::read('Space.is_m17n') && count($activeLangs) <= 1) {
+ // return false;
+ //}
+ //
+ //$hasDeletePage = $this->__hasDeletePage();
+ //if (! $hasDeletePage) {
+ // return false;
+ //}
+ //
+ //$activeLangIds = Hash::extract($activeLangs, '{n}.Language.id');
+ //
+ //$pageIdsM17n = $this->Page->getPageIdsWithM17n(Current::read('Page.id'));
+ //
+ //return (bool)array_diff($activeLangIds, Hash::get($pageIdsM17n, Current::read('Page.id'), []));
}
}
diff --git a/Model/Behavior/SavePageBehavior.php b/Model/Behavior/SavePageBehavior.php
index 1c8022f..f079e0b 100644
--- a/Model/Behavior/SavePageBehavior.php
+++ b/Model/Behavior/SavePageBehavior.php
@@ -219,6 +219,7 @@ public function saveTheme(Model $model, $data) {
* @param array $data request data
* @return bool
* @throws InternalErrorException
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function saveMove(Model $model, $data) {
//トランザクションBegin
@@ -242,7 +243,20 @@ public function saveMove(Model $model, $data) {
$childCount = $model->childCount($data[$model->alias]['parent_id'], true);
$result = $model->moveDown($model->id, $childCount);
} elseif ($data[$model->alias]['type'] === 'move') {
- $result = $model->saveField('parent_id', $data[$model->alias]['parent_id']);
+ //callbacksは必要
+ $permalink =
+ $model->getParentPermalink($data['Page']) . '/' . Current::read('Page.slug');
+ if (substr($permalink, 0, 1) === '/') {
+ $permalink = substr($permalink, 1);
+ }
+ $data[$model->alias]['permalink'] = $permalink;
+ $model->create(false);
+ $options = [
+ 'validate' => false,
+ 'fieldList' => ['parent_id', 'permalink'],
+ 'callbacks' => true
+ ];
+ $result = $model->save($data, $options);
} else {
$result = false;
}
diff --git a/Model/Page.php b/Model/Page.php
index d364210..bf5f250 100644
--- a/Model/Page.php
+++ b/Model/Page.php
@@ -344,9 +344,9 @@ public function isUniquePermalink($fields) {
*/
public function afterSave($created, $options = array()) {
if (Hash::get($this->data, 'Page.id') &&
- Hash::get($this->data, 'Page.slug') !== Current::read('Page.slug')) {
+ Hash::get($this->data, 'Page.permalink')) {
$chidren = $this->children(
- Hash::get($this->data, 'Page.id'), false, array('Page.id', 'Page.permalink')
+ Hash::get($this->data, 'Page.id'), false, array('Page.id', 'Page.permalink', 'Page.slug')
);
$data = $this->data;
@@ -354,13 +354,11 @@ public function afterSave($created, $options = array()) {
foreach ($chidren as $child) {
$this->id = $child[$this->alias]['id'];
- $pattern = '/^' . preg_quote(Current::read('Page.permalink') . '/', '/') . '/';
- $permalink = preg_replace(
- $pattern, Hash::get($data, 'Page.permalink') . '/', $child[$this->alias]['permalink']
- );
-
- if (! $this->saveField('permalink', $permalink, array('callbacks' => false))) {
- throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ $permalink = Hash::get($data, 'Page.permalink') . '/' . $child[$this->alias]['slug'];
+ if ($permalink !== $child[$this->alias]['permalink']) {
+ if (! $this->saveField('permalink', $permalink, array('callbacks' => false))) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
}
}
diff --git a/README.md b/README.md
index 0abe9f2..dfc9bb4 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,6 @@
Pages
====
-[](https://travis-ci.org/NetCommons3/Pages)
-[](https://coveralls.io/r/NetCommons3/Pages?branch=master)
-
-| dependencies | status |
-| ------------ | ------ |
-| composer.json | [](https://www.versioneye.com/user/projects/5305d1d1ec137516990000e2) |
+[](https://github.com/NetCommons3/Pages/actions/workflows/tests.yml)
+[](https://coveralls.io/r/NetCommons3/Pages?branch=master)
+[](https://packagist.org/packages/netcommons/pages)
diff --git a/VERSION.txt b/VERSION.txt
index 4772543..86fb650 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-3.3.2
+3.3.7
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 62a9213..f71af07 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -3,9 +3,6 @@
-
-
-
app/Plugin/Pages
@@ -20,5 +17,6 @@
+