From 081c6062b1d373c7330fa560d89e4ff20566e270 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Tue, 5 May 2015 19:12:10 +0900
Subject: [PATCH 001/274] Fix for specification changes
---
.travis.yml | 31 +++++++++++++++++++++++++++++++
README.md | 11 +++++++++++
composer.json | 38 ++++++++++++++++++++++++++++++++++++++
phpunit.xml.dist | 39 +++++++++++++++++++++++++++++++++++++++
4 files changed, 119 insertions(+)
create mode 100644 .travis.yml
create mode 100644 README.md
create mode 100644 composer.json
create mode 100644 phpunit.xml.dist
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..adbdf21
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,31 @@
+language: php
+
+php:
+ - 5.4
+ - 5.5
+ - 5.6
+
+sudo: required
+
+env:
+ - NETCOMMONS_VERSION=master DB=mysql
+
+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
+ - . tools/build/plugins/cakephp/travis/pre.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/README.md b/README.md
new file mode 100644
index 0000000..5a55682
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+Links
+==============
+
+Links for NetComomns3
+
+[](https://travis-ci.org/NetCommons3/Links)
+[](https://coveralls.io/r/NetCommons3/Links?branch=master)
+
+| dependencies | status |
+| ------------- | ------ |
+| composer.json | [/badge.png)](https://www.versioneye.com/user/projects/(versioneye_project_ID)) |
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..aa52a89
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,38 @@
+{
+ "name": "netcommons/links",
+ "description": "Links for NetCommons Plugin",
+ "homepage": "http://www.netcommons.org/",
+ "extra": {
+ "installer-paths": {
+ "app/Plugin/{$name}": ["type:cakephp-plugin"]
+ }
+ },
+ "require": {
+ "cakephp/cakephp": "~2.4",
+ "cakephp/debug_kit": "~2.2",
+ "cakedc/migrations": "~2.2",
+ "twbs/bootstrap": "~3.1",
+ "components/jquery": "~2.1"
+ },
+ "require-dev": {
+ "mustangostang/spyc": "dev-master",
+ "satooshi/php-coveralls": "dev-master",
+ "netcommons/net-commons": "dev-master",
+ "netcommons/frames": "dev-master",
+ "netcommons/pages": "dev-master",
+ "netcommons/users": "dev-master"
+ },
+ "license": "NetCommons License",
+ "authors": [
+ {
+ "name": "NetCommons Community",
+ "homepage": "https://github.com/NetCommons3/Links/graphs/contributors"
+ }
+ ],
+ "type": "cakephp-plugin",
+ "keywords": ["cakephp", "links"],
+ "config": {
+ "vendor-dir": "vendors"
+ }
+}
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..41acbf2
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,39 @@
+
+
+
+
+ app/Config
+ app/Controller
+ app/Console
+ app/Lib
+ app/Locale
+ app/Model
+ app/Vendor
+ app/View
+ app/Test
+ app/Plugin/Auth
+ app/Plugin/AuthGeneral
+ app/Plugin/Blocks
+ app/Plugin/Boxes
+ app/Plugin/Categories
+ app/Plugin/Comments
+ app/Plugin/DebugKit
+ app/Plugin/DebugKit
+ app/Plugin/Frames
+ app/Plugin/Migration
+ app/Plugin/MobileDetect
+ app/Plugin/NetCommons
+ app/Plugin/NetCommons
+ app/Plugin/Pages
+ app/Plugin/TinyMCE
+ app/Plugin/Users
+ lib/Cake
+ vendors
+ app/Plugin
+
+
+
+
+
+
+
\ No newline at end of file
From c094ddaf9372d068af7c83458b26e725ca99c49c Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Tue, 5 May 2015 19:20:51 +0900
Subject: [PATCH 002/274] Fix for specification changes
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 5a55682..cf192d7 100644
--- a/README.md
+++ b/README.md
@@ -8,4 +8,4 @@ Links for NetComomns3
| dependencies | status |
| ------------- | ------ |
-| composer.json | [/badge.png)](https://www.versioneye.com/user/projects/(versioneye_project_ID)) |
+| composer.json | [](https://www.versioneye.com/user/projects/554899ac240549af5300005c) |
From 3ddd52a778743753bdea16404d47fe6222c6e5bb Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Tue, 5 May 2015 19:25:32 +0900
Subject: [PATCH 003/274] Fix for specification changes
---
Config/Migration/1430464483_initial.php | 191 ++++++++
Config/Schema/schema.php | 139 ++++++
Controller/BlockRolePermissionsController.php | 118 +++++
Controller/BlocksController.php | 233 +++++++++
Controller/CategoriesController.php | 78 ++++
Controller/Component/empty | 1 +
Controller/LinkFrameSettingsController.php | 101 ++++
Controller/LinkListsAppController.php | 7 -
Controller/LinkListsCategoriesController.php | 113 -----
Controller/LinkListsController.php | 117 -----
Controller/LinkOrdersController.php | 95 ++++
Controller/LinksAppController.php | 154 ++++++
Controller/LinksController.php | 442 ++++++++++++++++++
Model/Link.php | 364 +++++++++++++++
Model/LinkBlock.php | 212 +++++++++
Model/LinkFrameSetting.php | 338 ++++++++++++++
Model/LinkListsAppModel.php | 7 -
Model/LinkOrder.php | 230 +++++++++
Model/LinkSetting.php | 145 ++++++
Model/Linklist.php | 139 ------
Model/LinklistPartSetting.php | 118 -----
Model/LinklistSetting.php | 60 ---
Model/LinklistsBlock.php | 97 ----
Model/LinklistsCategory.php | 121 -----
Model/LinksAppModel.php | 23 +
Test/Case/AllLinksTest.php | 32 ++
.../LinkListsCategoriesControllerTest.php | 71 ---
.../Controller/LinkListsControllerTest.php | 73 ---
Test/Case/Model/LinkBlockTest.php | 55 +++
Test/Case/Model/LinklistPartSettingTest.php | 51 --
Test/Case/Model/LinklistSettingTest.php | 48 --
Test/Case/Model/LinklistTest.php | 52 ---
Test/Case/Model/LinklistsBlockTest.php | 52 ---
Test/Case/Model/LinklistsCategoryTest.php | 50 --
Test/Case/Model/LinksBaseModel.php | 132 ++++++
Test/Fixture/LinkFixture.php | 68 +++
Test/Fixture/LinkFrameSettingFixture.php | 64 +++
Test/Fixture/LinkOrderFixture.php | 60 +++
Test/Fixture/LinkSettingFixture.php | 56 +++
Test/Fixture/LinklistFixture.php | 65 ---
Test/Fixture/LinklistPartSettingFixture.php | 59 ---
Test/Fixture/LinklistSettingFixture.php | 49 --
Test/Fixture/LinklistsBlockFixture.php | 49 --
Test/Fixture/LinklistsCategoryFixture.php | 59 ---
View/BlockRolePermissions/edit.ctp | 28 ++
View/Blocks/edit.ctp | 34 ++
View/Blocks/index.ctp | 101 ++++
View/Blocks/not_found.ctp | 28 ++
View/Categories/edit.ctp | 25 +
.../BlockRolePermissions/edit_form.ctp | 32 ++
View/Elements/Blocks/delete_form.ctp | 26 ++
View/Elements/Blocks/edit_form.ctp | 71 +++
View/Elements/LinkFrameSettings/edit_form.ctp | 149 ++++++
View/Elements/Links/delete_form.ctp | 40 ++
View/Elements/Links/edit_form.ctp | 136 ++++++
View/Elements/Links/edit_link.ctp | 28 ++
View/Elements/Links/index_dropdown.ctp | 50 ++
View/Elements/Links/index_list_only_title.ctp | 36 ++
.../Links/index_list_with_description.ctp | 39 ++
View/Elements/Links/link.ctp | 31 ++
View/LinkFrameSettings/edit.ctp | 42 ++
View/LinkOrders/edit.ctp | 95 ++++
View/Links/edit.ctp | 53 +++
View/Links/index.ctp | 59 +++
View/Links/view.ctp | 67 +++
webroot/css/style.css | 41 ++
webroot/img/line/line_a1.gif | Bin 0 -> 49 bytes
webroot/img/line/line_a2.gif | Bin 0 -> 49 bytes
webroot/img/line/line_a3.gif | Bin 0 -> 49 bytes
webroot/img/line/line_a4.gif | Bin 0 -> 49 bytes
webroot/img/line/line_b1.gif | Bin 0 -> 54 bytes
webroot/img/line/line_b2.gif | Bin 0 -> 54 bytes
webroot/img/line/line_b3.gif | Bin 0 -> 54 bytes
webroot/img/line/line_b4.gif | Bin 0 -> 54 bytes
webroot/img/line/line_b5.gif | Bin 0 -> 54 bytes
webroot/img/line/line_b6.gif | Bin 0 -> 54 bytes
webroot/img/line/line_c1.gif | Bin 0 -> 56 bytes
webroot/img/line/line_c2.gif | Bin 0 -> 56 bytes
webroot/img/line/line_c3.gif | Bin 0 -> 56 bytes
webroot/img/line/line_c4.gif | Bin 0 -> 56 bytes
webroot/img/mark/mark_a1.gif | Bin 0 -> 60 bytes
webroot/img/mark/mark_a2.gif | Bin 0 -> 60 bytes
webroot/img/mark/mark_a3.gif | Bin 0 -> 60 bytes
webroot/img/mark/mark_a4.gif | Bin 0 -> 60 bytes
webroot/img/mark/mark_a5.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_b1.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_b2.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_b3.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_c1.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_c2.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_c3.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_c4.gif | Bin 0 -> 53 bytes
webroot/img/mark/mark_d1.gif | Bin 0 -> 102 bytes
webroot/img/mark/mark_d2.gif | Bin 0 -> 102 bytes
webroot/img/mark/mark_d3.gif | Bin 0 -> 98 bytes
webroot/img/mark/mark_d4.gif | Bin 0 -> 98 bytes
webroot/img/mark/mark_d5.gif | Bin 0 -> 98 bytes
webroot/img/mark/mark_e1.gif | Bin 0 -> 196 bytes
webroot/img/mark/mark_e2.gif | Bin 0 -> 196 bytes
webroot/img/mark/mark_e3.gif | Bin 0 -> 196 bytes
webroot/img/mark/mark_e4.gif | Bin 0 -> 196 bytes
webroot/img/mark/mark_e5.gif | Bin 0 -> 196 bytes
webroot/js/links.js | 224 +++++++++
103 files changed, 4766 insertions(+), 1457 deletions(-)
create mode 100644 Config/Migration/1430464483_initial.php
create mode 100644 Config/Schema/schema.php
create mode 100644 Controller/BlockRolePermissionsController.php
create mode 100644 Controller/BlocksController.php
create mode 100644 Controller/CategoriesController.php
create mode 100644 Controller/LinkFrameSettingsController.php
delete mode 100644 Controller/LinkListsAppController.php
delete mode 100644 Controller/LinkListsCategoriesController.php
delete mode 100644 Controller/LinkListsController.php
create mode 100644 Controller/LinkOrdersController.php
create mode 100644 Controller/LinksAppController.php
create mode 100644 Controller/LinksController.php
create mode 100644 Model/Link.php
create mode 100644 Model/LinkBlock.php
create mode 100644 Model/LinkFrameSetting.php
delete mode 100644 Model/LinkListsAppModel.php
create mode 100644 Model/LinkOrder.php
create mode 100644 Model/LinkSetting.php
delete mode 100644 Model/Linklist.php
delete mode 100644 Model/LinklistPartSetting.php
delete mode 100644 Model/LinklistSetting.php
delete mode 100644 Model/LinklistsBlock.php
delete mode 100644 Model/LinklistsCategory.php
create mode 100644 Model/LinksAppModel.php
create mode 100644 Test/Case/AllLinksTest.php
delete mode 100644 Test/Case/Controller/LinkListsCategoriesControllerTest.php
delete mode 100644 Test/Case/Controller/LinkListsControllerTest.php
create mode 100644 Test/Case/Model/LinkBlockTest.php
delete mode 100644 Test/Case/Model/LinklistPartSettingTest.php
delete mode 100644 Test/Case/Model/LinklistSettingTest.php
delete mode 100644 Test/Case/Model/LinklistTest.php
delete mode 100644 Test/Case/Model/LinklistsBlockTest.php
delete mode 100644 Test/Case/Model/LinklistsCategoryTest.php
create mode 100644 Test/Case/Model/LinksBaseModel.php
create mode 100644 Test/Fixture/LinkFixture.php
create mode 100644 Test/Fixture/LinkFrameSettingFixture.php
create mode 100644 Test/Fixture/LinkOrderFixture.php
create mode 100644 Test/Fixture/LinkSettingFixture.php
delete mode 100644 Test/Fixture/LinklistFixture.php
delete mode 100644 Test/Fixture/LinklistPartSettingFixture.php
delete mode 100644 Test/Fixture/LinklistSettingFixture.php
delete mode 100644 Test/Fixture/LinklistsBlockFixture.php
delete mode 100644 Test/Fixture/LinklistsCategoryFixture.php
create mode 100644 View/BlockRolePermissions/edit.ctp
create mode 100644 View/Blocks/edit.ctp
create mode 100644 View/Blocks/index.ctp
create mode 100644 View/Blocks/not_found.ctp
create mode 100644 View/Categories/edit.ctp
create mode 100644 View/Elements/BlockRolePermissions/edit_form.ctp
create mode 100644 View/Elements/Blocks/delete_form.ctp
create mode 100644 View/Elements/Blocks/edit_form.ctp
create mode 100644 View/Elements/LinkFrameSettings/edit_form.ctp
create mode 100644 View/Elements/Links/delete_form.ctp
create mode 100644 View/Elements/Links/edit_form.ctp
create mode 100644 View/Elements/Links/edit_link.ctp
create mode 100644 View/Elements/Links/index_dropdown.ctp
create mode 100644 View/Elements/Links/index_list_only_title.ctp
create mode 100644 View/Elements/Links/index_list_with_description.ctp
create mode 100644 View/Elements/Links/link.ctp
create mode 100644 View/LinkFrameSettings/edit.ctp
create mode 100644 View/LinkOrders/edit.ctp
create mode 100644 View/Links/edit.ctp
create mode 100644 View/Links/index.ctp
create mode 100644 View/Links/view.ctp
create mode 100644 webroot/css/style.css
create mode 100644 webroot/img/line/line_a1.gif
create mode 100644 webroot/img/line/line_a2.gif
create mode 100644 webroot/img/line/line_a3.gif
create mode 100644 webroot/img/line/line_a4.gif
create mode 100644 webroot/img/line/line_b1.gif
create mode 100644 webroot/img/line/line_b2.gif
create mode 100644 webroot/img/line/line_b3.gif
create mode 100644 webroot/img/line/line_b4.gif
create mode 100644 webroot/img/line/line_b5.gif
create mode 100644 webroot/img/line/line_b6.gif
create mode 100644 webroot/img/line/line_c1.gif
create mode 100644 webroot/img/line/line_c2.gif
create mode 100644 webroot/img/line/line_c3.gif
create mode 100644 webroot/img/line/line_c4.gif
create mode 100644 webroot/img/mark/mark_a1.gif
create mode 100644 webroot/img/mark/mark_a2.gif
create mode 100644 webroot/img/mark/mark_a3.gif
create mode 100644 webroot/img/mark/mark_a4.gif
create mode 100644 webroot/img/mark/mark_a5.gif
create mode 100644 webroot/img/mark/mark_b1.gif
create mode 100644 webroot/img/mark/mark_b2.gif
create mode 100644 webroot/img/mark/mark_b3.gif
create mode 100644 webroot/img/mark/mark_c1.gif
create mode 100644 webroot/img/mark/mark_c2.gif
create mode 100644 webroot/img/mark/mark_c3.gif
create mode 100644 webroot/img/mark/mark_c4.gif
create mode 100644 webroot/img/mark/mark_d1.gif
create mode 100644 webroot/img/mark/mark_d2.gif
create mode 100644 webroot/img/mark/mark_d3.gif
create mode 100644 webroot/img/mark/mark_d4.gif
create mode 100644 webroot/img/mark/mark_d5.gif
create mode 100644 webroot/img/mark/mark_e1.gif
create mode 100644 webroot/img/mark/mark_e2.gif
create mode 100644 webroot/img/mark/mark_e3.gif
create mode 100644 webroot/img/mark/mark_e4.gif
create mode 100644 webroot/img/mark/mark_e5.gif
create mode 100644 webroot/js/links.js
diff --git a/Config/Migration/1430464483_initial.php b/Config/Migration/1430464483_initial.php
new file mode 100644
index 0000000..fc6bd09
--- /dev/null
+++ b/Config/Migration/1430464483_initial.php
@@ -0,0 +1,191 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+/**
+ * Migration file
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Faqs\Config\Migration
+ */
+class Initial extends CakeMigration {
+
+/**
+ * Migration description
+ *
+ * @var string
+ */
+ public $description = 'initial';
+
+/**
+ * Actions to be performed
+ *
+ * @var array $migration
+ */
+ public $migration = array(
+ 'up' => array(
+ 'create_table' => array(
+ 'link_frame_settings' => array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'frame_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'frame key | フレームKey | frames.key | ', 'charset' => 'utf8'),
+ 'display_type' => array('type' => 'integer', 'null' => false, 'default' => '1', 'length' => 4, 'comment' => 'display type, 1: dropdown type, 2: list type (no explanation), 3: list type (with explanation) | 表示方法種別 1: ドロップダウン型、2:リスト型(説明なし)、3:リスト型(説明あり) | | '),
+ 'open_new_tab' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'open new tab, 1: new tab or 0: same window | リンクの開き方 0:同じウィンドウ内、1:新しいタブ | | '),
+ 'display_click_count' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'display of click count, 1: display or 0: no display | リンクのクリック数の表示 0:表示しない、1:表示する | | '),
+ 'category_separator_line' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'separator line between the categories | カテゴリ間の区切り線 | | ', 'charset' => 'utf8'),
+ 'list_style' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'list mark | リストマーク | | ', 'charset' => 'utf8'),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1),
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB'),
+ ),
+ 'link_orders' => array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'block key | ブロックKey | blocks.key | ', 'charset' => 'utf8'),
+ 'category_key' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'category key | カテゴリKey | categories.key | ', 'charset' => 'utf8'),
+ 'link_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link key | リンクKey | links.key | ', 'charset' => 'utf8'),
+ 'weight' => array('type' => 'integer', 'null' => false, 'default' => '0', 'comment' => 'The weight of the display(display order) | 表示の重み(表示順序) | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1),
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB'),
+ ),
+ 'link_settings' => array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Block key | ブロックキー | Hash値 | ', 'charset' => 'utf8'),
+ 'use_workflow' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'Use workflow, 0:Unused 1:Use | コンテンツの承認機能 0:使わない 1:使う | | '),
+ //'use_comment' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'Use omments, 0:Unused 1:Use | コメント機能 0:使わない 1:使う | | '),
+ //'is_comment_auto_approval' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'Use of comments auto approval, 0:Unused 1:Use | コメントの承認機能 0:使わない 1:使う | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1),
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB'),
+ ),
+ 'links' => array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'comment' => 'block id | ブロックID | blocks.id | '),
+ 'category_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'category id | カテゴリーID | link_categories.id | '),
+ 'language_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 6, 'comment' => 'language id | 言語ID | languages.id | '),
+ 'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link key | リンクキー | Hash値 | ', 'charset' => 'utf8'),
+ 'status' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 4, 'comment' => 'public status, 1: public, 2: public pending, 3: draft during 4: remand | 公開状況 1:公開中、2:公開申請中、3:下書き中、4:差し戻し | | '),
+ 'is_active' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'Is active, 0:deactive 1:acive | アクティブなコンテンツかどうか 0:アクティブでない 1:アクティブ | | '),
+ 'is_latest' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'Is latest, 0:not latest 1:latest | 最新コンテンツかどうか 0:最新でない 1:最新 | | '),
+ 'url' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link url | リンク先URL | | ', 'charset' => 'utf8'),
+ 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'title | タイトル | | ', 'charset' => 'utf8'),
+ 'description' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'description | 説明 | | ', 'charset' => 'utf8'),
+ 'click_count' => array('type' => 'integer', 'null' => false, 'default' => '0', 'comment' => 'link click count | クリック数 | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1),
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB'),
+ ),
+ ),
+ ),
+ 'down' => array(
+ 'drop_table' => array(
+ 'link_frame_settings', 'link_orders', 'link_settings', 'links'
+ ),
+ ),
+ );
+
+/**
+ * recodes
+ *
+ * @var array $migration
+ */
+ public $records = array(
+ 'Plugin' => array(
+ array(
+ 'language_id' => 2,
+ 'key' => 'links',
+ 'namespace' => 'netcommons/links',
+ 'name' => 'リンクリスト',
+ 'type' => 1,
+ ),
+ ),
+
+ 'PluginsRole' => array(
+ array(
+ 'role_key' => 'room_administrator',
+ 'plugin_key' => 'links'
+ ),
+ ),
+
+ 'PluginsRoom' => array(
+ array(
+ 'room_id' => '1',
+ 'plugin_key' => 'links'
+ ),
+ ),
+ );
+
+/**
+ * Before migration callback
+ *
+ * @param string $direction Direction of migration process (up or down)
+ * @return bool Should process continue
+ */
+ public function before($direction) {
+ return true;
+ }
+
+/**
+ * After migration callback
+ *
+ * @param string $direction Direction of migration process (up or down)
+ * @return bool Should process continue
+ */
+ public function after($direction) {
+ if ($direction === 'down') {
+ return true;
+ }
+
+ foreach ($this->records as $model => $records) {
+ if (!$this->updateRecords($model, $records)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+/**
+ * Update model records
+ *
+ * @param string $model model name to update
+ * @param string $records records to be stored
+ * @return bool Should process continue
+ */
+ public function updateRecords($model, $records) {
+ $Model = $this->generateModel($model);
+ foreach ($records as $record) {
+ $Model->create();
+ if (!$Model->save($record, false)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/Config/Schema/schema.php b/Config/Schema/schema.php
new file mode 100644
index 0000000..c66169c
--- /dev/null
+++ b/Config/Schema/schema.php
@@ -0,0 +1,139 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+/**
+ * AppSchema file
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Faqs\Config\Schema
+ * @SuppressWarnings(PHPMD.LongVariable)
+ */
+class AppSchema extends CakeSchema {
+
+/**
+ * Database connection
+ *
+ * @var string
+ */
+ public $connection = 'master';
+
+/**
+ * before
+ *
+ * @param array $event savent
+ * @return bool
+ */
+ public function before($event = array()) {
+ return true;
+ }
+
+/**
+ * after
+ *
+ * @param array $event savent
+ * @return void
+ */
+ public function after($event = array()) {
+ }
+
+/**
+ * link_frame_settings table
+ *
+ * @var array
+ */
+ public $link_frame_settings = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'frame_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'frame key | フレームKey | frames.key | ', 'charset' => 'utf8'),
+ 'display_type' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 4, 'comment' => 'display type, 1: dropdown type, 2: list type (no explanation), 3: list type (with explanation) | 表示方法種別 1: ドロップダウン型、2:リスト型(説明なし)、3:リスト型(説明あり) | | '),
+ 'open_new_tab' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'open new tab, 1: new tab or 0: same window | リンクの開き方 0:同じウィンドウ内、1:新しいタブ | | '),
+ 'display_click_count' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'display of click count, 1: display or 0: no display | リンクのクリック数の表示 0:表示しない、1:表示する | | '),
+ 'category_separator_line' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'separator line between the categories | カテゴリ間の区切り線 | | ', 'charset' => 'utf8'),
+ 'list_style' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'list mark | リストマーク | | ', 'charset' => 'utf8'),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1)
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+
+/**
+ * link_orders table
+ *
+ * @var array
+ */
+ public $link_orders = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'block key | ブロックKey | blocks.key | ', 'charset' => 'utf8'),
+ 'category_key' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'category key | カテゴリKey | categories.key | ', 'charset' => 'utf8'),
+ 'link_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link key | リンクKey | links.key | ', 'charset' => 'utf8'),
+ 'weight' => array('type' => 'integer', 'null' => false, 'default' => '0', 'comment' => 'The weight of the display(display order) | 表示の重み(表示順序) | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1)
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+
+/**
+ * link_settings table
+ *
+ * @var array
+ */
+ public $link_settings = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Block key | ブロックキー | Hash値 | ', 'charset' => 'utf8'),
+ 'use_workflow' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'Use workflow, 0:Unused 1:Use | コンテンツの承認機能 0:使わない 1:使う | | '),
+ //'use_comment' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'Use omments, 0:Unused 1:Use | コメント機能 0:使わない 1:使う | | '),
+ //'is_comment_auto_approval' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'Use of comments auto approval, 0:Unused 1:Use | コメントの承認機能 0:使わない 1:使う | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1),
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB'),
+ );
+
+/**
+ * links table
+ *
+ * @var array
+ */
+ public $links = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'comment' => 'block id | ブロックID | blocks.id | '),
+ 'category_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'category id | カテゴリーID | link_categories.id | '),
+ 'language_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 6, 'comment' => 'language id | 言語ID | languages.id | '),
+ 'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link key | リンクキー | Hash値 | ', 'charset' => 'utf8'),
+ 'status' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 4, 'comment' => 'public status, 1: public, 2: public pending, 3: draft during 4: remand | 公開状況 1:公開中、2:公開申請中、3:下書き中、4:差し戻し | | '),
+ 'is_active' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'Is active, 0:deactive 1:acive | アクティブなコンテンツかどうか 0:アクティブでない 1:アクティブ | | '),
+ 'is_latest' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'Is latest, 0:not latest 1:latest | 最新コンテンツかどうか 0:最新でない 1:最新 | | '),
+ 'url' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link url | リンク先URL | | ', 'charset' => 'utf8'),
+ 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'title | タイトル | | ', 'charset' => 'utf8'),
+ 'description' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'description | 説明 | | ', 'charset' => 'utf8'),
+ 'click_count' => array('type' => 'integer', 'null' => false, 'default' => '0', 'comment' => 'link click count | クリック数 | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1)
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+}
diff --git a/Controller/BlockRolePermissionsController.php b/Controller/BlockRolePermissionsController.php
new file mode 100644
index 0000000..f59165d
--- /dev/null
+++ b/Controller/BlockRolePermissionsController.php
@@ -0,0 +1,118 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppController', 'Links.Controller');
+
+/**
+ * BlockRolePermissions Controller
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Controller
+ */
+class BlockRolePermissionsController extends LinksAppController {
+
+/**
+ * use models
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Roles.Role',
+ 'Roles.DefaultRolePermission',
+ 'Blocks.Block',
+ 'Blocks.BlockRolePermission',
+ 'Rooms.RolesRoom',
+ 'Links.LinkSetting'
+ );
+
+/**
+ * use components
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsBlock',
+ 'NetCommons.NetCommonsRoomRole' => array(
+ //コンテンツの権限設定
+ 'allowedActions' => array(
+ 'permissionEditable' => array('edit')
+ ),
+ ),
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+
+ $this->layout = 'NetCommons.setting';
+ $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
+ $this->set($results);
+
+ //タブの設定
+ $this->initTabs('block_index', 'role_permissions');
+ }
+
+/**
+ * edit
+ *
+ * @return void
+ */
+ public function edit() {
+ if (! $this->NetCommonsBlock->validateBlockId()) {
+ $this->throwBadRequest();
+ return false;
+ }
+ $this->set('blockId', (int)$this->params['pass'][1]);
+ if (! $this->initLink(['linkSetting'])) {
+ return;
+ }
+
+ if (! $block = $this->Block->find('first', array(
+ 'recursive' => -1,
+ 'conditions' => array(
+ 'Block.id' => $this->viewVars['blockId'],
+ ),
+ ))) {
+ $this->throwBadRequest();
+ return false;
+ };
+ $this->set('blockId', $block['Block']['id']);
+ $this->set('blockKey', $block['Block']['key']);
+
+ $permissions = $this->NetCommonsBlock->getBlockRolePermissions(
+ $this->viewVars['blockKey'],
+ ['content_creatable', 'content_publishable']
+ );
+
+ if ($this->request->isPost()) {
+ $data = $this->data;
+ $this->LinkSetting->saveLinkSetting($data);
+ if ($this->handleValidationError($this->LinkSetting->validationErrors)) {
+ if (! $this->request->is('ajax')) {
+ $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ }
+ return;
+ }
+ }
+
+ $results = array(
+ 'BlockRolePermissions' => $permissions['BlockRolePermissions'],
+ 'roles' => $permissions['Roles'],
+ );
+ $results = $this->camelizeKeyRecursive($results);
+ $this->set($results);
+ }
+}
diff --git a/Controller/BlocksController.php b/Controller/BlocksController.php
new file mode 100644
index 0000000..7156f07
--- /dev/null
+++ b/Controller/BlocksController.php
@@ -0,0 +1,233 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppController', 'Links.Controller');
+
+/**
+ * BlocksController
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Controller
+ */
+class BlocksController extends LinksAppController {
+
+/**
+ * use models
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Blocks.Block',
+ 'Frames.Frame',
+ 'Links.LinkSetting',
+ 'Categories.Category',
+ );
+
+/**
+ * use components
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsBlock',
+ 'NetCommons.NetCommonsRoomRole' => array(
+ //コンテンツの権限設定
+ 'allowedActions' => array(
+ 'blockEditable' => array('index', 'add', 'edit', 'delete')
+ ),
+ ),
+ 'Paginator',
+ 'Categories.Categories',
+ );
+
+/**
+ * use helpers
+ *
+ * @var array
+ */
+ public $helpers = array(
+ 'NetCommons.Date',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->deny('index');
+
+ $this->layout = 'NetCommons.setting';
+ $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
+ $this->set($results);
+
+ //タブの設定
+ $this->initTabs('block_index', 'block_settings');
+ }
+
+/**
+ * index
+ *
+ * @return void
+ * @throws Exception
+ */
+ public function index() {
+ $this->Paginator->settings = array(
+ 'LinkBlock' => array(
+ 'order' => array('Block.id' => 'desc'),
+ 'conditions' => array(
+ 'Block.language_id' => $this->viewVars['languageId'],
+ 'Block.room_id' => $this->viewVars['roomId'],
+ 'Block.plugin_key ' => $this->params['plugin'],
+ ),
+ //'limit' => 1
+ )
+ );
+ try {
+ $linkBlocks = $this->Paginator->paginate('LinkBlock');
+ } catch (Exception $ex) {
+ if (isset($this->request['paging']) && $this->params['named']) {
+ $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ return;
+ }
+ CakeLog::error($ex);
+ throw $ex;
+ }
+ if (! $linkBlocks) {
+ $this->view = 'Blocks/not_found';
+ return;
+ }
+
+ $results = array(
+ 'linkBlocks' => $linkBlocks
+ );
+ $results = $this->camelizeKeyRecursive($results);
+ $this->set($results);
+ }
+
+/**
+ * add
+ *
+ * @return void
+ */
+ public function add() {
+ $this->view = 'Blocks/edit';
+
+ $this->set('blockId', null);
+ $block = $this->Block->create(
+ array(
+ 'id' => null,
+ 'key' => null,
+ 'name' => __d('links', 'New Bookmark List %s', date('YmdHis')),
+ )
+ );
+
+ $data = array();
+ if ($this->request->isPost()) {
+ $data = $this->__parseRequestData();
+
+ $this->LinkBlock->saveLinkBlock($data);
+ if ($this->handleValidationError($this->LinkBlock->validationErrors)) {
+ if (! $this->request->is('ajax')) {
+ $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ }
+ return;
+ }
+ $data['Block']['id'] = null;
+ $data['Block']['key'] = null;
+ }
+
+ $results = $this->camelizeKeyRecursive(Hash::merge($block, $data));
+ $this->set($results);
+ }
+
+/**
+ * edit
+ *
+ * @return void
+ */
+ public function edit() {
+ if (! $this->NetCommonsBlock->validateBlockId()) {
+ $this->throwBadRequest();
+ return false;
+ }
+ $this->set('blockId', (int)$this->params['pass'][1]);
+
+ if (! $this->initLink(['linkSetting'])) {
+ return;
+ }
+ $this->Categories->initCategories();
+
+ if ($this->request->isPost()) {
+ $data = $this->__parseRequestData();
+ $data['LinkSetting']['block_key'] = $data['Block']['key'];
+
+ $this->LinkBlock->saveLinkBlock($data);
+ if ($this->handleValidationError($this->LinkBlock->validationErrors)) {
+ if (! $this->request->is('ajax')) {
+ $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ }
+ return;
+ }
+
+ $results = $this->camelizeKeyRecursive($data);
+ $this->set($results);
+ }
+ }
+
+/**
+ * delete
+ *
+ * @return void
+ */
+ public function delete() {
+ if (! $this->NetCommonsBlock->validateBlockId()) {
+ $this->throwBadRequest();
+ return false;
+ }
+ $this->set('blockId', (int)$this->params['pass'][1]);
+
+ if (! $this->initLink()) {
+ return;
+ }
+
+ if ($this->request->isDelete()) {
+ if ($this->LinkBlock->deleteLinkBlock($this->data)) {
+ if (! $this->request->is('ajax')) {
+ $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ }
+ return;
+ }
+ }
+
+ $this->throwBadRequest();
+ }
+
+/**
+ * Parse data from request
+ *
+ * @return array
+ */
+ private function __parseRequestData() {
+ $data = $this->data;
+ if ($data['Block']['public_type'] === Block::TYPE_LIMITED) {
+ //$data['Block']['from'] = implode('-', $data['Block']['from']);
+ //$data['Block']['to'] = implode('-', $data['Block']['to']);
+ } else {
+ unset($data['Block']['from'], $data['Block']['to']);
+ }
+
+ return $data;
+ }
+
+}
diff --git a/Controller/CategoriesController.php b/Controller/CategoriesController.php
new file mode 100644
index 0000000..84ddb4e
--- /dev/null
+++ b/Controller/CategoriesController.php
@@ -0,0 +1,78 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppController', 'Links.Controller');
+
+/**
+ * Categories Controller
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Controller
+ */
+class CategoriesController extends LinksAppController {
+
+/**
+ * use model
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Categories.Category',
+ );
+
+/**
+ * use components
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsBlock',
+ 'NetCommons.NetCommonsRoomRole' => array(
+ //コンテンツの権限設定
+ 'allowedActions' => array(
+ 'blockEditable' => array('edit')
+ ),
+ ),
+ 'Categories.Categories',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+
+ $this->layout = 'NetCommons.setting';
+ $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
+ $this->set($results);
+
+ //タブの設定
+ $this->initTabs('block_index', 'block_settings');
+ }
+
+/**
+ * edit
+ *
+ * @return void
+ */
+ public function edit() {
+ //blockId取得
+ if (! $this->NetCommonsBlock->validateBlockId()) {
+ $this->throwBadRequest();
+ return false;
+ }
+ $this->set('blockId', (int)$this->params['pass'][1]);
+ $this->Categories->edit();
+ }
+}
diff --git a/Controller/Component/empty b/Controller/Component/empty
index e69de29..7b4d68d 100644
--- a/Controller/Component/empty
+++ b/Controller/Component/empty
@@ -0,0 +1 @@
+empty
\ No newline at end of file
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
new file mode 100644
index 0000000..209f62d
--- /dev/null
+++ b/Controller/LinkFrameSettingsController.php
@@ -0,0 +1,101 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppController', 'Links.Controller');
+
+/**
+ * LinkFrameSettingsController Controller
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Controller
+ */
+class LinkFrameSettingsController extends LinksAppController {
+
+/**
+ * use models
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Links.LinkFrameSetting'
+ );
+
+/**
+ * use components
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole' => array(
+ //コンテンツの権限設定
+ 'allowedActions' => array(
+ 'pageEditable' => array('edit')
+ ),
+ ),
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+
+ $this->layout = 'NetCommons.setting';
+ $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
+ $this->set($results);
+
+ //タブの設定
+ $this->initTabs('frame_settings', '');
+ }
+
+/**
+ * edit
+ *
+ * @return void
+ */
+ public function edit() {
+ if (! $this->NetCommonsFrame->validateFrameId()) {
+ $this->throwBadRequest();
+ return false;
+ }
+ if (! $linkFrameSetting = $this->LinkFrameSetting->getLinkFrameSetting($this->viewVars['frameKey'])) {
+ $linkFrameSetting = $this->LinkFrameSetting->create(array(
+ 'id' => null,
+ 'display_type' => LinkFrameSetting::TYPE_DROPDOWN,
+ 'frame_key' => $this->viewVars['frameKey'],
+ 'category_separator_line' => null,
+ 'list_style' => null,
+ ));
+ }
+ $linkFrameSetting = $this->camelizeKeyRecursive($linkFrameSetting);
+
+ $data = array();
+ if ($this->request->isPost()) {
+ $data = $this->data;
+ $this->LinkFrameSetting->saveLinkFrameSetting($data);
+ if ($this->handleValidationError($this->LinkFrameSetting->validationErrors)) {
+ if (! $this->request->is('ajax')) {
+ $this->redirect('/' . $this->viewVars['cancelUrl']);
+ }
+ return;
+ }
+ }
+
+ $data = Hash::merge(
+ $linkFrameSetting, $data
+ );
+ $results = $this->camelizeKeyRecursive($data);
+ $this->set($results);
+ }
+}
diff --git a/Controller/LinkListsAppController.php b/Controller/LinkListsAppController.php
deleted file mode 100644
index 1a01fb3..0000000
--- a/Controller/LinkListsAppController.php
+++ /dev/null
@@ -1,7 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-class LinkListsCategoriesController extends LinkListsAppController {
-
-/**
- * Components
- *
- * @var array
- */
- public $components = array('Paginator');
-
-/**
- * index method
- *
- * @return void
- */
- public function index() {
- $this->LinkListsCategory->recursive = 0;
- $this->set('linkListsCategories', $this->Paginator->paginate());
- }
-
-/**
- * view method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function view($id = null) {
- if (!$this->LinkListsCategory->exists($id)) {
- throw new NotFoundException(__('Invalid link lists category'));
- }
- $options = array('conditions' => array('LinkListsCategory.' . $this->LinkListsCategory->primaryKey => $id));
- $this->set('linkListsCategory', $this->LinkListsCategory->find('first', $options));
- }
-
-/**
- * add method
- *
- * @return void
- */
- public function add() {
- if ($this->request->is('post')) {
- $this->LinkListsCategory->create();
- if ($this->LinkListsCategory->save($this->request->data)) {
- $this->Session->setFlash(__('The link lists category has been saved.'));
- return $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The link lists category could not be saved. Please, try again.'));
- }
- }
- $linklistsBlocks = $this->LinkListsCategory->LinklistsBlock->find('list');
- $languages = $this->LinkListsCategory->Language->find('list');
- $this->set(compact('linklistsBlocks', 'languages'));
- }
-
-/**
- * edit method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function edit($id = null) {
- if (!$this->LinkListsCategory->exists($id)) {
- throw new NotFoundException(__('Invalid link lists category'));
- }
- if ($this->request->is(array('post', 'put'))) {
- if ($this->LinkListsCategory->save($this->request->data)) {
- $this->Session->setFlash(__('The link lists category has been saved.'));
- return $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The link lists category could not be saved. Please, try again.'));
- }
- } else {
- $options = array('conditions' => array('LinkListsCategory.' . $this->LinkListsCategory->primaryKey => $id));
- $this->request->data = $this->LinkListsCategory->find('first', $options);
- }
- $linklistsBlocks = $this->LinkListsCategory->LinklistsBlock->find('list');
- $languages = $this->LinkListsCategory->Language->find('list');
- $this->set(compact('linklistsBlocks', 'languages'));
- }
-
-/**
- * delete method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function delete($id = null) {
- $this->LinkListsCategory->id = $id;
- if (!$this->LinkListsCategory->exists()) {
- throw new NotFoundException(__('Invalid link lists category'));
- }
- $this->request->onlyAllow('post', 'delete');
- if ($this->LinkListsCategory->delete()) {
- $this->Session->setFlash(__('The link lists category has been deleted.'));
- } else {
- $this->Session->setFlash(__('The link lists category could not be deleted. Please, try again.'));
- }
- return $this->redirect(array('action' => 'index'));
- }}
diff --git a/Controller/LinkListsController.php b/Controller/LinkListsController.php
deleted file mode 100644
index fc5b237..0000000
--- a/Controller/LinkListsController.php
+++ /dev/null
@@ -1,117 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-class LinkListsController extends LinkListsAppController {
-
-/**
- * Components
- *
- * @var array
- */
- public $components = array('Paginator');
-
-/**
- * index method
- *
- * @return void
- */
- public function index() {
- $this->LinkList->recursive = 0;
- $this->set('linkLists', $this->Paginator->paginate());
- }
-
-/**
- * view method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function view($id = null) {
- if (!$this->LinkList->exists($id)) {
- throw new NotFoundException(__('Invalid link list'));
- }
- $options = array('conditions' => array('LinkList.' . $this->LinkList->primaryKey => $id));
- $this->set('linkList', $this->LinkList->find('first', $options));
- }
-
-/**
- * add method
- *
- * @return void
- */
- public function add() {
- if ($this->request->is('post')) {
- $this->LinkList->create();
- if ($this->LinkList->save($this->request->data)) {
- $this->Session->setFlash(__('The link list has been saved.'));
- return $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The link list could not be saved. Please, try again.'));
- }
- }
- $linklistsBlocks = $this->LinkList->LinklistsBlock->find('list');
- $languages = $this->LinkList->Language->find('list');
- $linklistsCategories = $this->LinkList->LinklistsCategory->find('list');
- $blocks = $this->LinkList->Block->find('list');
- $this->set(compact('linklistsBlocks', 'languages', 'linklistsCategories', 'blocks'));
- }
-
-/**
- * edit method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function edit($id = null) {
- if (!$this->LinkList->exists($id)) {
- throw new NotFoundException(__('Invalid link list'));
- }
- if ($this->request->is(array('post', 'put'))) {
- if ($this->LinkList->save($this->request->data)) {
- $this->Session->setFlash(__('The link list has been saved.'));
- return $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The link list could not be saved. Please, try again.'));
- }
- } else {
- $options = array('conditions' => array('LinkList.' . $this->LinkList->primaryKey => $id));
- $this->request->data = $this->LinkList->find('first', $options);
- }
- $linklistsBlocks = $this->LinkList->LinklistsBlock->find('list');
- $languages = $this->LinkList->Language->find('list');
- $linklistsCategories = $this->LinkList->LinklistsCategory->find('list');
- $blocks = $this->LinkList->Block->find('list');
- $this->set(compact('linklistsBlocks', 'languages', 'linklistsCategories', 'blocks'));
- }
-
-/**
- * delete method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function delete($id = null) {
- $this->LinkList->id = $id;
- if (!$this->LinkList->exists()) {
- throw new NotFoundException(__('Invalid link list'));
- }
- $this->request->onlyAllow('post', 'delete');
- if ($this->LinkList->delete()) {
- $this->Session->setFlash(__('The link list has been deleted.'));
- } else {
- $this->Session->setFlash(__('The link list could not be deleted. Please, try again.'));
- }
- return $this->redirect(array('action' => 'index'));
- }}
diff --git a/Controller/LinkOrdersController.php b/Controller/LinkOrdersController.php
new file mode 100644
index 0000000..71e8dd0
--- /dev/null
+++ b/Controller/LinkOrdersController.php
@@ -0,0 +1,95 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppController', 'Links.Controller');
+
+/**
+ * LinkOrders Controller
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Controller
+ */
+class LinkOrdersController extends LinksAppController {
+
+/**
+ * use models
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Links.Link',
+ 'Links.LinkOrder',
+ 'Links.LinkFrameSetting',
+ 'Categories.Category',
+ );
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsBlock',
+ 'NetCommons.NetCommonsRoomRole' => array(
+ //コンテンツの権限設定
+ 'allowedActions' => array(
+ 'contentEditable' => array('edit'),
+ ),
+ ),
+ 'Categories.Categories',
+ 'Paginator',
+ );
+
+/**
+ * edit
+ *
+ * @return void
+ */
+ public function edit() {
+ if (! $this->initLink()) {
+ return;
+ }
+ $this->Categories->initCategories(true);
+
+ $this->Paginator->settings = array(
+ 'Link' => array(
+ 'order' => array('LinkOrder.weight' => 'asc'),
+ 'conditions' => array(
+ 'Link.block_id' => $this->viewVars['blockId'],
+ 'Link.is_latest' => true,
+ ),
+ 'limit' => -1
+ )
+ );
+ $links = $this->Paginator->paginate('Link');
+ $links = Hash::combine($links, '{n}.LinkOrder.weight', '{n}', '{n}.Category.id');
+
+ //POST処理
+ $data = array();
+ if ($this->request->isPost()) {
+ //登録処理
+ $data = $this->data;
+
+ $this->LinkOrder->saveLinkOrders($data);
+ //validationError
+ if ($this->handleValidationError($this->LinkOrder->validationErrors)) {
+ //リダイレクト
+ $this->redirectByFrameId();
+ return;
+ }
+ }
+
+ $data = Hash::merge(array('links' => $links), $data);
+ $results = $this->camelizeKeyRecursive($data);
+ $this->set($results);
+ }
+
+}
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
new file mode 100644
index 0000000..b92b644
--- /dev/null
+++ b/Controller/LinksAppController.php
@@ -0,0 +1,154 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('AppController', 'Controller');
+
+/**
+ * LinksApp Controller
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Controller
+ */
+class LinksAppController extends AppController {
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'Security',
+ 'NetCommons.NetCommonsFrame',
+ );
+
+/**
+ * use models
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Links.LinkBlock',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $results = $this->camelizeKeyRecursive(['current' => $this->current]);
+ $this->set($results);
+ }
+
+/**
+ * initLink
+ *
+ * @param array $contains Optional result sets
+ * @return bool True on success, False on failure
+ */
+ public function initLink($contains = []) {
+ if (! $linkBlock = $this->LinkBlock->getLinkBlock($this->viewVars['blockId'], $this->viewVars['roomId'])) {
+ $this->throwBadRequest();
+ return false;
+ }
+ $linkBlock = $this->camelizeKeyRecursive($linkBlock);
+ $this->set($linkBlock);
+
+ if (in_array('linkSetting', $contains, true)) {
+ if (! $linkSetting = $this->LinkSetting->getLinkSetting($linkBlock['linkBlock']['key'])) {
+ $linkSetting = $this->LinkSetting->create(
+ array('id' => null)
+ );
+ }
+ $linkSetting = $this->camelizeKeyRecursive($linkSetting);
+ $this->set($linkSetting);
+ }
+
+ if (in_array('linkFrameSetting', $contains, true)) {
+ if (! $linkFrameSetting = $this->LinkFrameSetting->getLinkFrameSetting($this->viewVars['frameKey'])) {
+ $linkFrameSetting = $this->LinkFrameSetting->create(array(
+ 'id' => null,
+ 'display_type' => LinkFrameSetting::TYPE_DROPDOWN,
+ 'category_separator_line' => LinkFrameSetting::CATEGORY_SEPARATOR_DEFAULT,
+ 'list_style' => LinkFrameSetting::LINE_STYLE_DISC,
+ ));
+ }
+
+ //カテゴリ間の区切り線
+ $separatorLine = $linkFrameSetting['LinkFrameSetting']['category_separator_line'];
+ $linkFrameSetting['LinkFrameSetting']['category_separator_line_css'] =
+ $this->LinkFrameSetting->getCategorySeparatorLineCss($separatorLine);
+
+ //リストマーク
+ $listStyle = $linkFrameSetting['LinkFrameSetting']['list_style'];
+ $linkFrameSetting['LinkFrameSetting']['list_style_css'] = $this->LinkFrameSetting->getLineStyleCss($listStyle);
+
+ $linkFrameSetting = $this->camelizeKeyRecursive($linkFrameSetting);
+ $this->set($linkFrameSetting);
+ }
+
+ $this->set('userId', (int)$this->Auth->user('id'));
+
+ return true;
+ }
+
+/**
+ * initTabs
+ *
+ * @param string $mainActiveTab Main active tab
+ * @param string $blockActiveTab Block active tab
+ * @return void
+ */
+ public function initTabs($mainActiveTab, $blockActiveTab) {
+ //タブの設定
+ $settingTabs = array(
+ 'tabs' => array(
+ 'block_index' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'blocks',
+ 'action' => 'index',
+ $this->viewVars['frameId'],
+ ),
+ 'frame_settings' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'link_frame_settings',
+ 'action' => 'edit',
+ $this->viewVars['frameId'],
+ ),
+ ),
+ 'active' => $mainActiveTab
+ );
+ $this->set('settingTabs', $settingTabs);
+
+ $blockSettingTabs = array(
+ 'tabs' => array(
+ 'block_settings' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'blocks',
+ 'action' => $this->params['action'],
+ $this->viewVars['frameId'],
+ $this->viewVars['blockId']
+ ),
+ 'role_permissions' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'block_role_permissions',
+ 'action' => 'edit',
+ $this->viewVars['frameId'],
+ $this->viewVars['blockId']
+ ),
+ ),
+ 'active' => $blockActiveTab
+ );
+ $this->set('blockSettingTabs', $blockSettingTabs);
+ }
+
+}
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
new file mode 100644
index 0000000..ac4438f
--- /dev/null
+++ b/Controller/LinksController.php
@@ -0,0 +1,442 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppController', 'Links.Controller');
+App::uses('HttpSocket', 'Network/Http');
+
+/**
+ * Links Controller
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Controller
+ */
+class LinksController extends LinksAppController {
+
+/**
+ * use model
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Blocks.Block',
+ 'Links.Link',
+ 'Links.LinkOrder',
+ 'Links.LinkFrameSetting',
+ 'Categories.Category',
+ 'Comments.Comment',
+ );
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsBlock',
+ 'NetCommons.NetCommonsWorkflow',
+ 'NetCommons.NetCommonsRoomRole' => array(
+ //コンテンツの権限設定
+ 'allowedActions' => array(
+ 'contentCreatable' => array('add', 'edit', 'delete'),
+ ),
+ ),
+ 'Categories.Categories',
+ );
+
+/**
+ * use helpers
+ *
+ * @var array
+ */
+ public $helpers = array(
+ 'NetCommons.Token'
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow('index', 'view', 'link');
+ }
+
+/**
+ * index
+ *
+ * @return void
+ */
+ public function index() {
+ if (! $this->viewVars['blockId']) {
+ $this->autoRender = false;
+ return;
+ }
+ if (! $this->initLink(['linkFrameSetting'])) {
+ return;
+ }
+ $this->Categories->initCategories(true, '{n}.Category.id');
+
+ //条件
+ $conditions = $this->__setConditions();
+
+ //取得
+ $links = $this->Link->getLinks($conditions);
+ $links = Hash::combine($links, '{n}.Link.id', '{n}', '{n}.Category.id');
+
+ //Viewにセット
+ $results = array(
+ 'links' => $links
+ );
+ $results = $this->camelizeKeyRecursive($results);
+ $this->set($results);
+
+ //Tokenセット
+ $this->request->data = array(
+ 'Frame' => array(
+ 'id' => $this->viewVars['frameId']
+ ),
+ 'Link' => array(
+ 'id' => null
+ ),
+ );
+ $tokenFields = Hash::flatten($this->request->data);
+ $hiddenFields = array('Frame.id');
+ $this->set('tokenFields', $tokenFields);
+ $this->set('hiddenFields', $hiddenFields);
+ }
+
+/**
+ * view
+ *
+ * @return void
+ */
+ public function view() {
+ $linkKey = null;
+ if (isset($this->params['pass'][1])) {
+ $linkKey = $this->params['pass'][1];
+ }
+ $this->set('linkKey', $linkKey);
+
+ //データ取得
+ if (! $this->__initLink(['linkFrameSetting'])) {
+ return;
+ }
+ $this->Categories->initCategories();
+ }
+
+/**
+ * Get url
+ *
+ * @return void
+ */
+ public function get() {
+ $url = Hash::get($this->request->query, 'url');
+ if (! $url) {
+ return false;
+ }
+ try {
+ $socket = new HttpSocket(array('request' => array('redirect' => 10)));
+ $response = $socket->get($url);
+ if (! $response->isOk()) {
+ $this->throwBadRequest(__d('links', 'Failed to obtain the title for this page.'));
+ return;
+ }
+ } catch (SocketException $ex) {
+ CakeLog::error($ex);
+ $this->throwBadRequest(__d('links', 'Failed to obtain the title for this page.'));
+ return;
+ }
+
+ $results = array(
+ 'title' => null,
+ 'description' => null,
+ );
+
+ $body = $response->body;
+ $pattern = '/(.*)<\/title>/i';
+ $matches = array();
+ if (preg_match($pattern, $body, $matches)) {
+ $results['title'] = mb_convert_encoding($matches[1], 'utf-8', 'auto');
+ }
+ $pattern = '/\]]*name=([\'"]?)description\\1[^"\'<>\]]*content=([\'"]?)([^"\'<>\]]*)\\2[^"\'<>\]]*>/i';
+ $matches = array();
+ if (preg_match($pattern, $body, $matches)) {
+ $results['description'] = mb_convert_encoding($matches[3], 'utf-8', 'auto');
+ }
+
+ $this->renderJson($results);
+ }
+
+/**
+ * add
+ *
+ * @return void
+ */
+ public function add() {
+ $this->view = 'edit';
+
+ //データ取得
+ if (! $this->initLink()) {
+ return;
+ }
+ $this->Categories->initCategories(false, '{n}.Category.id');
+
+ $link = $this->Link->create(
+ array(
+ 'id' => null,
+ 'key' => null,
+ 'block_id' => $this->viewVars['blockId'],
+ 'category_id' => null,
+ )
+ );
+ $linkOrder = $this->LinkOrder->create(
+ array(
+ 'id' => null,
+ 'block_key' => $this->viewVars['blockKey'],
+ 'link_key' => null,
+ )
+ );
+
+ //POSTの場合、登録処理
+ $data = array();
+ if ($this->request->isPost()) {
+ if (! $status = $this->NetCommonsWorkflow->parseStatus()) {
+ return;
+ }
+ if (isset($this->viewVars['categories'][$this->data['Link']['category_id']])) {
+ $category['Category'] = $this->viewVars['categories'][$this->data['Link']['category_id']]['category'];
+ } else {
+ $category = $this->Category->create(array('key' => null));
+ }
+ $data = Hash::merge(
+ $this->data, array(
+ 'Link' => array('status' => $status),
+ ),
+ $category
+ );
+ unset($data['LinkOrder']['weight']);
+
+ $this->Link->saveLink($data);
+ if ($this->handleValidationError($this->Link->validationErrors)) {
+ $this->redirectByFrameId();
+ return;
+ }
+ }
+
+ //Viewにセット
+ $data = Hash::merge(
+ $link, $linkOrder, $data,
+ ['contentStatus' => null, 'comments' => []]
+ );
+ $results = $this->camelizeKeyRecursive($data);
+ $this->set($results);
+ }
+
+/**
+ * edit
+ *
+ * @return void
+ */
+ public function edit() {
+ $linkKey = null;
+ if (isset($this->params['pass'][1])) {
+ $linkKey = $this->params['pass'][1];
+ }
+ $this->set('linkKey', $linkKey);
+
+ //データ取得
+ if (! $this->__initLink(['comments'])) {
+ return;
+ }
+ $this->Categories->initCategories(false, '{n}.Category.id');
+
+ //POSTの場合、登録処理
+ $data = array();
+ if ($this->request->isPost()) {
+ if (! $status = $this->NetCommonsWorkflow->parseStatus()) {
+ return;
+ }
+
+ $data = $this->data;
+
+ $categoryId = $data['Link']['category_id'];
+ $category = array();
+ if (isset($this->viewVars['categories'][$categoryId])) {
+ $category['Category'] = $this->viewVars['categories'][$categoryId]['category'];
+ } else {
+ $category = $this->Category->create(array('key' => null));
+ }
+
+ $data = Hash::merge(
+ $data, $category,
+ array('Link' => array(
+ 'status' => $status,
+ 'click_count' => $this->viewVars['link']['clickCount'],
+ 'created_user' => $this->viewVars['link']['createdUser']
+ ))
+ );
+ unset($data['Link']['id'], $data['LinkOrder']['weight']);
+
+ $this->Link->saveLink($data);
+
+ if ($this->handleValidationError($this->Link->validationErrors)) {
+ $this->redirectByFrameId();
+ return;
+ }
+
+ $data['contentStatus'] = null;
+ $data['comments'] = null;
+ }
+
+ $data = Hash::merge(
+ $this->viewVars, $data,
+ ['contentStatus' => $this->viewVars['link']['status']]
+ );
+ $results = $this->camelizeKeyRecursive($data);
+ $this->set($results);
+ }
+
+/**
+ * delete
+ *
+ * @return void
+ */
+ public function delete() {
+ $linkKey = null;
+ if (isset($this->params['pass'][1])) {
+ $linkKey = $this->params['pass'][1];
+ }
+ $this->set('linkKey', $linkKey);
+
+ //データ取得
+ if (! $this->__initLink()) {
+ return;
+ }
+
+ if (! $this->request->isDelete()) {
+ $this->throwBadRequest();
+ return;
+ }
+
+ if (! $this->Link->deleteLink($this->data)) {
+ $this->throwBadRequest();
+ return;
+ }
+
+ $this->redirectByFrameId();
+ }
+
+/**
+ * link
+ *
+ * @return void
+ */
+ public function link() {
+ $linkKey = null;
+ if (isset($this->params['pass'][1])) {
+ $linkKey = $this->params['pass'][1];
+ }
+ $this->set('linkKey', $linkKey);
+
+ //データ取得
+ if (! $this->__initLink()) {
+ return;
+ }
+
+ if (! $this->request->isPost()) {
+ $this->throwBadRequest();
+ return;
+ }
+
+ if (! $this->Link->updateCount($this->data['Link']['id'], $this->viewVars['blockId'])) {
+ $this->throwBadRequest();
+ return;
+ }
+
+ $this->redirectByFrameId();
+ }
+
+/**
+ * Get conditions function for getting the Link data.
+ *
+ * @return array Conditions data
+ */
+ private function __setConditions() {
+ //言語の指定
+ $activeConditions = array(
+ 'Link.is_active' => true,
+ );
+ $latestConditons = array();
+
+ if ($this->viewVars['contentEditable']) {
+ $activeConditions = array();
+ $latestConditons = array(
+ 'Link.is_latest' => true,
+ );
+ } elseif ($this->viewVars['contentCreatable']) {
+ $activeConditions = array(
+ 'Link.is_active' => true,
+ 'Link.created_user !=' => (int)$this->viewVars['userId'],
+ );
+ $latestConditons = array(
+ 'Link.is_active' => false,
+ 'Link.is_latest' => true,
+ 'Link.created_user' => (int)$this->viewVars['userId'],
+ );
+ }
+
+ $conditions = array(
+ 'Link.block_id' => $this->viewVars['blockId'],
+ 'OR' => array($activeConditions, $latestConditons)
+ );
+
+ return $conditions;
+ }
+
+/**
+ * Function do set into view with getting the Link data.
+ *
+ * @param array $contains Optional result sets
+ * @return bool True on success, False on failure
+ */
+ private function __initLink($contains = []) {
+ if (! $this->initLink($contains)) {
+ return false;
+ }
+
+ $conditions = $this->__setConditions();
+ if (! $link = $this->Link->getLink(
+ $this->viewVars['blockId'],
+ $this->viewVars['linkKey'],
+ $conditions
+ )) {
+ $this->throwBadRequest();
+ return false;
+ }
+ $link = $this->camelizeKeyRecursive($link);
+ $this->set($link);
+
+ if (in_array('comments', $contains, true)) {
+ $comments = $this->Comment->getComments(
+ array(
+ 'plugin_key' => $this->params['plugin'],
+ 'content_key' => $this->viewVars['linkKey'],
+ )
+ );
+ $comments = $this->camelizeKeyRecursive($comments);
+ $this->set(['comments' => $comments]);
+ }
+
+ return true;
+ }
+
+}
diff --git a/Model/Link.php b/Model/Link.php
new file mode 100644
index 0000000..d73af80
--- /dev/null
+++ b/Model/Link.php
@@ -0,0 +1,364 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * Link Model
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Model
+ */
+class Link extends LinksAppModel {
+
+/**
+ * use behaviors
+ *
+ * @var array
+ */
+ public $actsAs = array(
+ 'NetCommons.Publishable',
+ 'NetCommons.OriginalKey',
+ );
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array();
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+
+/**
+ * belongsTo associations
+ *
+ * @var array
+ */
+ public $belongsTo = array(
+ 'LinkOrder' => array(
+ 'className' => 'Links.LinkOrder',
+ 'foreignKey' => false,
+ 'conditions' => 'LinkOrder.link_key=Link.key',
+ 'fields' => '',
+ 'order' => array('LinkOrder.weight' => 'asc')
+ ),
+ 'Block' => array(
+ 'className' => 'Block',
+ 'foreignKey' => 'block_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'Category' => array(
+ 'className' => 'Categories.Category',
+ 'foreignKey' => 'category_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'CategoryOrder' => array(
+ 'className' => 'Categories.CategoryOrder',
+ 'foreignKey' => false,
+ 'conditions' => 'CategoryOrder.category_key=Category.key',
+ 'fields' => '',
+ 'order' => array('CategoryOrder.weight' => 'asc')
+ )
+ );
+
+/**
+ * Called during validation operations, before validation. Please note that custom
+ * validation rules can be defined in $validate.
+ *
+ * @param array $options Options passed from Model::save().
+ * @return bool True if validate operation should continue, false to abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
+ * @see Model::save()
+ */
+ public function beforeValidate($options = array()) {
+ $this->validate = Hash::merge($this->validate, array(
+ 'block_id' => array(
+ 'numeric' => array(
+ 'rule' => array('numeric'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ 'required' => true,
+ 'on' => 'update', // Limit validation to 'create' or 'update' operations
+ ),
+ ),
+ 'key' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ 'required' => true,
+ 'on' => 'update', // Limit validation to 'create' or 'update' operations
+ ),
+ ),
+
+ //status to set in PublishableBehavior.
+
+ 'click_count' => array(
+ 'numeric' => array(
+ 'rule' => array('numeric'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => true,
+ ),
+ ),
+
+ //status to set in PublishableBehavior.
+
+ 'url' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'URL')),
+ 'allowEmpty' => false,
+ 'required' => true,
+ ),
+ 'url' => array(
+ 'rule' => array('url'),
+ 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('links', 'URL'), __d('links', 'URL')),
+ 'allowEmpty' => false,
+ 'required' => true,
+ ),
+ ),
+ 'title' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'Title')),
+ 'allowEmpty' => false,
+ 'required' => true,
+ ),
+ ),
+ ));
+
+ return parent::beforeValidate($options);
+ }
+
+/**
+ * Get Links
+ *
+ * @param array $conditions findAll conditions
+ * @return array Links
+ */
+ public function getLinks($conditions) {
+ $links = $this->find('all', array(
+ 'recursive' => 0,
+ 'conditions' => $conditions,
+ 'order' => array(
+ 'CategoryOrder.weight' => 'asc',
+ 'LinkOrder.weight' => 'asc',
+ ),
+ ));
+ return $links;
+ }
+
+/**
+ * Get Link
+ *
+ * @param int $blockId blocks.id
+ * @param string $linkKey links.key
+ * @param array $conditions find conditions
+ * @return array Link
+ */
+ public function getLink($blockId, $linkKey, $conditions = []) {
+ $conditions[$this->alias . '.block_id'] = $blockId;
+ $conditions[$this->alias . '.key'] = $linkKey;
+
+ $link = $this->find('first', array(
+ 'recursive' => 0,
+ 'conditions' => $conditions,
+ )
+ );
+
+ return $link;
+ }
+
+/**
+ * Save Link
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on validation errors
+ * @throws InternalErrorException
+ */
+ public function saveLink($data) {
+ $this->loadModels([
+ 'Link' => 'Links.Link',
+ 'LinkOrder' => 'Links.LinkOrder',
+ 'Comment' => 'Comments.Comment',
+ ]);
+
+ //トランザクションBegin
+ $this->setDataSource('master');
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ try {
+ //バリデーション
+ if (! $this->validateLink($data, ['linkOrder', 'comment'])) {
+ return false;
+ }
+
+ //Link登録
+ if (! $link = $this->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ //LinkOrder登録
+ $this->LinkOrder->data['LinkOrder']['category_key'] = $data['Category']['key'];
+ if (! $data['LinkOrder']['link_key']) {
+ $this->LinkOrder->data['LinkOrder']['link_key'] = $link[$this->alias]['key'];
+ }
+ if (! $this->LinkOrder->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+ //Comment登録
+ if (isset($data['Comment']) && $this->Comment->data) {
+ $this->Comment->data[$this->Comment->name]['content_key'] = $link[$this->name]['key'];
+ if (! $this->Comment->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+ }
+
+ //トランザクションCommit
+ $dataSource->commit();
+
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return $link;
+ }
+
+/**
+ * validate of Link
+ *
+ * @param array $data received post data
+ * @param array $contains Optional validate sets
+ * @return bool True on success, false on validation errors
+ */
+ public function validateLink($data, $contains = []) {
+ $this->set($data);
+ $this->validates();
+ if ($this->validationErrors) {
+ return false;
+ }
+ if (in_array('linkOrder', $contains, true)) {
+ if (! $this->LinkOrder->validateLinkOrder($data)) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->LinkOrder->validationErrors);
+ return false;
+ }
+ }
+ if (in_array('comment', $contains, true) && isset($data['Comment'])) {
+ if (! $this->Comment->validateByStatus($data, array('plugin' => $this->plugin, 'caller' => $this->name))) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->Comment->validationErrors);
+ return false;
+ }
+ }
+ return true;
+ }
+
+/**
+ * Delete Link
+ *
+ * @param array $data received post data
+ * @return mixed On success Model::$data if its not empty or true, false on failure
+ * @throws InternalErrorException
+ */
+ public function deleteLink($data) {
+ $this->loadModels([
+ 'Link' => 'Links.Link',
+ 'LinkOrder' => 'Links.LinkOrder',
+ 'Comment' => 'Comments.Comment',
+ ]);
+
+ //トランザクションBegin
+ $this->setDataSource('master');
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ try {
+ if (! $this->deleteAll(array($this->alias . '.key' => $data['Link']['key']), false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ $this->LinkOrder->data = array(
+ $this->LinkOrder->name => array(
+ 'link_key' => $data['Link']['key'],
+ )
+ );
+ if (! $this->LinkOrder->deleteAll(
+ $this->LinkOrder->data[$this->LinkOrder->name], false
+ )) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ //トランザクションCommit
+ $dataSource->commit();
+
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ //エラー出力
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return true;
+ }
+
+/**
+ * Update count
+ *
+ * @param int $id links.id
+ * @param int $blockId blocks.id
+ * @return bool True on success, false on validation errors
+ * @throws InternalErrorException
+ */
+ public function updateCount($id, $blockId) {
+ $this->loadModels([
+ 'Link' => 'Links.Link',
+ ]);
+
+ //トランザクションBegin
+ $this->setDataSource('master');
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ try {
+ $this->updateAll(
+ array($this->name . '.click_count' => $this->name . '.click_count + 1'),
+ array(
+ $this->name . '.id' => $id,
+ $this->name . '.block_id' => $blockId,
+ )
+ );
+
+ //トランザクションCommit
+ $dataSource->commit();
+
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return true;
+ }
+
+}
diff --git a/Model/LinkBlock.php b/Model/LinkBlock.php
new file mode 100644
index 0000000..6d58886
--- /dev/null
+++ b/Model/LinkBlock.php
@@ -0,0 +1,212 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('BlocksAppModel', 'Blocks.Model');
+
+/**
+ * Block Model
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Blocks\Model
+ */
+class LinkBlock extends BlocksAppModel {
+
+/**
+ * Custom database table name
+ *
+ * @var string
+ */
+ public $useTable = 'blocks';
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array();
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+
+/**
+ * belongsTo associations
+ *
+ * @var array
+ */
+ public $hasOne = array(
+ 'Block' => array(
+ 'className' => 'Block',
+ 'foreignKey' => 'id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+/**
+ * Get link block data
+ *
+ * @param int $blockId blocks.id
+ * @param int $roomId rooms.id
+ * @return array
+ */
+ public function getLinkBlock($blockId, $roomId) {
+ $conditions = array(
+ 'Block.id' => $blockId,
+ 'Block.room_id' => $roomId,
+ );
+
+ $linkBlock = $this->find('first', array(
+ 'recursive' => 0,
+ 'conditions' => $conditions,
+ )
+ );
+
+ return $linkBlock;
+ }
+
+/**
+ * Save block
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on validation errors
+ * @throws InternalErrorException
+ */
+ public function saveLinkBlock($data) {
+ $this->loadModels([
+ 'LinkSetting' => 'Links.LinkSetting',
+ 'Block' => 'Blocks.Block',
+ 'Frame' => 'Frames.Frame',
+ ]);
+
+ //トランザクションBegin
+ $this->setDataSource('master');
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ try {
+ //バリデーション
+ if (! $this->validateLinkBlock($data, ['linkSetting'])) {
+ return false;
+ }
+
+ //ブロックの登録
+ $block = $this->Block->saveByFrameId($data['Frame']['id']);
+
+ //登録処理
+ $this->LinkSetting->data['LinkSetting']['block_key'] = $block['Block']['key'];
+ if (! $this->LinkSetting->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ //トランザクションCommit
+ $dataSource->commit();
+
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return true;
+ }
+
+/**
+ * Validate block
+ *
+ * @param array $data received post data
+ * @param array $contains Optional validate sets
+ * @return bool True on success, false on validation errors
+ */
+ public function validateLinkBlock($data, $contains = []) {
+ if (! $this->Block->validateBlock($data)) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->Block->validationErrors);
+ return false;
+ }
+
+ if (in_array('linkSetting', $contains, true)) {
+ if (! $this->LinkSetting->validateLinkSetting($data)) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->LinkSetting->validationErrors);
+ return false;
+ }
+ }
+ return true;
+ }
+
+/**
+ * Delete block
+ *
+ * @param array $data received post data
+ * @return mixed On success Model::$data if its not empty or true, false on failure
+ * @throws InternalErrorException
+ */
+ public function deleteLinkBlock($data) {
+ $this->setDataSource('master');
+
+ $this->loadModels([
+ 'Link' => 'Links.Link',
+ 'LinkSetting' => 'Links.LinkSetting',
+ 'LinkOrder' => 'Links.LinkOrder',
+ 'Block' => 'Blocks.Block',
+ 'Category' => 'Categories.Category',
+ ]);
+
+ //トランザクションBegin
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ $conditions = array(
+ $this->alias . '.key' => $data['Block']['key']
+ );
+ $blocks = $this->find('list', array(
+ 'recursive' => -1,
+ 'conditions' => $conditions,
+ )
+ );
+ $blocks = array_keys($blocks);
+
+ try {
+ if (! $this->LinkSetting->deleteAll(array($this->LinkSetting->alias . '.block_key' => $data['Block']['key']), false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ if (! $this->Link->deleteAll(array($this->Link->alias . '.block_id' => $blocks), false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ if (! $this->LinkOrder->deleteAll(array($this->LinkOrder->alias . '.block_key' => $data['Block']['key']), false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ //Categoryデータ削除
+ $this->Category->deleteByBlockKey($data['Block']['key']);
+
+ //Blockデータ削除
+ $this->Block->deleteBlock($data['Block']['key']);
+
+ //トランザクションCommit
+ $dataSource->commit();
+
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return true;
+ }
+
+}
diff --git a/Model/LinkFrameSetting.php b/Model/LinkFrameSetting.php
new file mode 100644
index 0000000..47824a4
--- /dev/null
+++ b/Model/LinkFrameSetting.php
@@ -0,0 +1,338 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+App::uses('Folder', 'Utility');
+
+/**
+ * LinkFrameSetting Model
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Model
+ */
+class LinkFrameSetting extends LinksAppModel {
+
+/**
+ * Type
+ *
+ * @var string
+ */
+ const
+ TYPE_DROPDOWN = '1',
+ TYPE_LIST_ONLY_TITLE = '2',
+ TYPE_LIST_WITH_DESCRIPTION = '3';
+
+/**
+ * categorySeparatorLine
+ *
+ * @var array
+ */
+ static public $categorySeparators = array();
+
+/**
+ * categorySeparatorLine default
+ *
+ * @var string
+ */
+ const CATEGORY_SEPARATOR_DEFAULT = 'default';
+
+/**
+ * categorySeparatorLine default
+ *
+ * @var string
+ */
+ const LINE_STYLE_NONE = 'none',
+ LINE_STYLE_DISC = 'disc',
+ LINE_STYLE_CIRCLE = 'circle',
+ LINE_STYLE_LOWER_ALPHA = 'lower-alpha',
+ LINE_STYLE_UPPER_ALPHA = 'upper-alpha';
+
+/**
+ * listStyle
+ *
+ * @var array
+ */
+ static public $listStyles = array();
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array();
+
+/**
+ * Constructor. Binds the model's database table to the object.
+ *
+ * @param bool|int|string|array $id Set this ID for this model on startup,
+ * can also be an array of options, see above.
+ * @param string $table Name of database table to use.
+ * @param string $ds DataSource connection name.
+ * @see Model::__construct()
+ * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
+ */
+ public function __construct($id = false, $table = null, $ds = null) {
+ parent::__construct($id, $table, $ds);
+ $pluginDir = APP . 'Plugin' . DS . $this->plugin . DS . WEBROOT_DIR . DS . 'img' . DS;
+
+ //カテゴリ間の区切り線
+ $dir = new Folder($pluginDir . 'line');
+ $files = $dir->find('.*\..*');
+ $files = Hash::sort($files, '{n}', 'asc');
+
+ self::$categorySeparators = array(
+ array(
+ 'key' => null,
+ 'name' => __d('links', '(no line)'),
+ 'style' => null
+ ),
+ array(
+ 'key' => self::CATEGORY_SEPARATOR_DEFAULT,
+ 'name' => '',
+ 'style' => ''
+ )
+ );
+ foreach ($files as $file) {
+ $info = getimagesize($dir->pwd() . DS . $file);
+ $img = '/' . Inflector::underscore($this->plugin) . DS . 'img' . DS . 'line' . DS . $file;
+ self::$categorySeparators[] = array(
+ 'key' => $file,
+ 'name' => '',
+ 'style' => 'background-image: url(' . $img . '); ' . 'border-image: url(' . $img . '); ' . 'height: ' . $info[1] . 'px;',
+ );
+ }
+ unset($dir);
+
+ //線スタイル
+ $dir = new Folder($pluginDir . 'mark');
+ $files = $dir->find('.*\..*');
+ $files = Hash::sort($files, '{n}', 'asc');
+ self::$listStyles = array(
+ array(
+ 'key' => null,
+ 'name' => '',
+ 'style' => 'list-style-type: ' . self::LINE_STYLE_NONE . ';'
+ ),
+ array(
+ 'key' => self::LINE_STYLE_DISC,
+ 'name' => '',
+ 'style' => 'list-style-type: ' . self::LINE_STYLE_DISC . ';'
+ ),
+ array(
+ 'key' => self::LINE_STYLE_CIRCLE,
+ 'name' => '',
+ 'style' => 'list-style-type: ' . self::LINE_STYLE_CIRCLE . ';'
+ ),
+ array(
+ 'key' => self::LINE_STYLE_LOWER_ALPHA,
+ 'name' => '',
+ 'style' => 'list-style-type: ' . self::LINE_STYLE_LOWER_ALPHA . ';'
+ ),
+ array(
+ 'key' => self::LINE_STYLE_UPPER_ALPHA,
+ 'name' => '',
+ 'style' => 'list-style-type: ' . self::LINE_STYLE_UPPER_ALPHA . ';'
+ ),
+ );
+
+ foreach ($files as $file) {
+ $info = getimagesize($dir->pwd() . DS . $file);
+ $img = '/' . Inflector::underscore($this->plugin) . DS . 'img' . DS . 'mark' . DS . $file;
+ self::$listStyles[] = array(
+ 'key' => $file,
+ 'name' => '',
+ 'style' => 'list-style-type: none; ' . 'list-style-image: url(' . $img . '); '
+ );
+ }
+ unset($dir);
+ }
+
+/**
+ * Called during validation operations, before validation. Please note that custom
+ * validation rules can be defined in $validate.
+ *
+ * @param array $options Options passed from Model::save().
+ * @return bool True if validate operation should continue, false to abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
+ * @see Model::save()
+ */
+ public function beforeValidate($options = array()) {
+ $this->validate = Hash::merge($this->validate, array(
+ 'frame_key' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ 'required' => true,
+ 'on' => 'update', // Limit validation to 'create' or 'update' operations
+ ),
+ ),
+ 'display_type' => array(
+ 'numeric' => array(
+ 'rule' => array('numeric'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ 'required' => true,
+ ),
+ 'inList' => array(
+ 'rule' => array('inList', array(
+ self::TYPE_DROPDOWN,
+ self::TYPE_LIST_ONLY_TITLE,
+ self::TYPE_LIST_WITH_DESCRIPTION
+ )),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ )
+ ),
+ 'open_new_tab' => array(
+ 'boolean' => array(
+ 'rule' => array('boolean'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ ),
+ ),
+ 'display_click_count' => array(
+ 'boolean' => array(
+ 'rule' => array('boolean'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ ),
+ ),
+ 'category_separator_line' => array(
+ 'inList' => array(
+ 'rule' => array('inList',
+ array_keys(Hash::combine(self::$categorySeparators, '{n}.key', '{n}.key'))
+ ),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => true,
+ )
+ ),
+ 'list_style' => array(
+ 'inList' => array(
+ 'rule' => array('inList',
+ array_keys(Hash::combine(self::$listStyles, '{n}.key', '{n}.key'))
+ ),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => true,
+ )
+ ),
+ ));
+
+ return parent::beforeValidate($options);
+ }
+
+/**
+ * Get link setting data
+ *
+ * @param string $frameKey frames.key
+ * @return array
+ */
+ public function getLinkFrameSetting($frameKey) {
+ $conditions = array(
+ 'frame_key' => $frameKey
+ );
+
+ $linkFrameSetting = $this->find('first', array(
+ 'recursive' => -1,
+ 'conditions' => $conditions,
+ )
+ );
+
+ return $linkFrameSetting;
+ }
+
+/**
+ * Get category_separator_line data
+ *
+ * @param string $categorySeparator category_separator_line data
+ * @return array
+ */
+ public function getCategorySeparatorLineCss($categorySeparator) {
+ //カテゴリ間の区切り線
+ $categorySeparators = Hash::combine(self::$categorySeparators, '{n}.key', '{n}');
+ if (isset($categorySeparators[$categorySeparator])) {
+ $result = $categorySeparators[$categorySeparator]['style'];
+ } else {
+ $result = null;
+ }
+
+ return $result;
+ }
+
+/**
+ * Get line_style data
+ *
+ * @param string $lineStyle line_style data
+ * @return array
+ */
+ public function getLineStyleCss($lineStyle) {
+ //カテゴリ間の区切り線
+ $listStyles = Hash::combine(self::$listStyles, '{n}.key', '{n}');
+ if (isset($listStyles[$lineStyle])) {
+ $result = $listStyles[$lineStyle]['style'];
+ } else {
+ $result = null;
+ }
+
+ return $result;
+ }
+
+/**
+ * Save link settings
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on failure
+ * @throws InternalErrorException
+ */
+ public function saveLinkFrameSetting($data) {
+ $this->loadModels([
+ 'LinkFrameSetting' => 'Links.LinkFrameSetting',
+ ]);
+
+ //トランザクションBegin
+ $this->setDataSource('master');
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ try {
+ if (! $this->validateLinkFrameSetting($data)) {
+ return false;
+ }
+
+ if (! $this->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+
+ //トランザクションCommit
+ $dataSource->commit();
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return true;
+ }
+
+/**
+ * Validate linkFrameSettings
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on validation errors
+ */
+ public function validateLinkFrameSetting($data) {
+ $this->set($data);
+ $this->validates();
+ if ($this->validationErrors) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/Model/LinkListsAppModel.php b/Model/LinkListsAppModel.php
deleted file mode 100644
index d3679d3..0000000
--- a/Model/LinkListsAppModel.php
+++ /dev/null
@@ -1,7 +0,0 @@
-
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * LinkOrder Model
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Model
+ */
+class LinkOrder extends LinksAppModel {
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array();
+
+/**
+ * Called during validation operations, before validation. Please note that custom
+ * validation rules can be defined in $validate.
+ *
+ * @param array $options Options passed from Model::save().
+ * @return bool True if validate operation should continue, false to abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
+ * @see Model::save()
+ */
+ public function beforeValidate($options = array()) {
+ $this->validate = Hash::merge($this->validate, array(
+ 'block_key' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ 'required' => true,
+ 'on' => 'update', // Limit validation to 'create' or 'update' operations
+ ),
+ ),
+ 'link_key' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ 'required' => true,
+ 'on' => 'update', // Limit validation to 'create' or 'update' operations
+ ),
+ ),
+ 'weight' => array(
+ 'numeric' => array(
+ 'rule' => array('numeric'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ //'required' => true,
+ ),
+ ),
+ ));
+
+ return parent::beforeValidate($options);
+ }
+
+/**
+ * Called before each save operation, after validation. Return a non-true result
+ * to halt the save.
+ *
+ * @param array $options Options passed from Model::save().
+ * @return bool True if the operation should continue, false if it should abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave
+ * @see Model::save()
+ */
+ public function beforeSave($options = array()) {
+ if (isset($this->data[$this->name]['block_key']) &&
+ isset($this->data[$this->name]['link_key']) &&
+ ! $this->data[$this->name]['weight'] &&
+ array_key_exists('category_key', $this->data[$this->name])
+ ) {
+ $before = $this->find('first', array(
+ 'recursive' => -1,
+ 'fields' => array('block_key', 'category_key', 'weight'),
+ 'conditions' => array('link_key' => $this->data[$this->name]['link_key']),
+ ));
+
+ if ($before) {
+ if ($before[$this->name]['category_key'] !== $this->data[$this->name]['category_key']) {
+ $this->updateAll(
+ array($this->name . '.weight' => $this->name . '.weight - 1'),
+ array(
+ $this->name . '.weight > ' => $before[$this->name]['weight'],
+ $this->name . '.block_key' => $before[$this->name]['block_key'],
+ $this->name . '.category_key' => $before[$this->name]['category_key'],
+ )
+ );
+ $this->data[$this->name]['weight'] = $this->getMaxWeight(
+ $this->data[$this->name]['block_key'],
+ $this->data[$this->name]['category_key']
+ ) + 1;
+ }
+ } elseif (! $this->id) {
+ $this->data[$this->name]['weight'] = $this->getMaxWeight(
+ $this->data[$this->name]['block_key'],
+ $this->data[$this->name]['category_key']
+ ) + 1;
+ }
+ }
+
+ return true;
+ }
+
+/**
+ * Called before every deletion operation.
+ *
+ * @param bool $cascade If true records that depend on this record will also be deleted
+ * @return bool True if the operation should continue, false if it should abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforedelete
+ * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
+ */
+ public function beforeDelete($cascade = true) {
+ if (isset($this->data[$this->name]['link_key']) && isset($this->data[$this->name]['category_key'])) {
+ $before = $this->find('first', array(
+ 'recursive' => -1,
+ 'fields' => array('block_key', 'category_key', 'weight'),
+ 'conditions' => array('link_key' => $this->data[$this->name]['link_key']),
+ ));
+
+ $this->updateAll(
+ array($this->name . '.weight' => $this->name . '.weight - 1'),
+ array(
+ $this->name . '.weight > ' => $before[$this->name]['weight'],
+ $this->name . '.block_key' => $before[$this->name]['block_key'],
+ $this->name . '.category_key' => $before[$this->name]['category_key'],
+ )
+ );
+ }
+ return true;
+ }
+
+/**
+ * validate of link order
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on validation errors
+ */
+ public function validateLinkOrder($data) {
+ $this->set($data);
+ $this->validates();
+ if ($this->validationErrors) {
+ return false;
+ }
+ return true;
+ }
+
+/**
+ * getMaxWeight
+ *
+ * @param string $blockKey blocks.key
+ * @param string $categoryKey categories.key
+ * @return int $weight link_orders.weight
+ */
+ public function getMaxWeight($blockKey, $categoryKey) {
+ $order = $this->find('first', array(
+ 'recursive' => -1,
+ 'fields' => array('weight'),
+ 'conditions' => array('block_key' => $blockKey, 'category_key' => $categoryKey),
+ 'order' => array('weight' => 'DESC')
+ ));
+
+ if (isset($order[$this->alias]['weight'])) {
+ $weight = (int)$order[$this->alias]['weight'];
+ } else {
+ $weight = 0;
+ }
+ return $weight;
+ }
+
+/**
+ * Save LinkOrder
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on validation errors
+ * @throws InternalErrorException
+ */
+ public function saveLinkOrders($data) {
+ $this->loadModels([
+ 'LinkOrder' => 'Links.LinkOrder',
+ ]);
+
+ //トランザクションBegin
+ $this->setDataSource('master');
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ try {
+ //バリデーション
+ $indexes = array_keys($data['LinkOrders']);
+ foreach ($indexes as $i) {
+ if (! $this->validateLinkOrder($data['LinkOrders'][$i])) {
+ return false;
+ }
+ }
+
+ //登録処理
+ foreach ($indexes as $i) {
+ if (! $this->save($data['LinkOrders'][$i], false, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+ }
+
+ //トランザクションCommit
+ $dataSource->commit();
+
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return true;
+ }
+
+}
diff --git a/Model/LinkSetting.php b/Model/LinkSetting.php
new file mode 100644
index 0000000..0f3c40a
--- /dev/null
+++ b/Model/LinkSetting.php
@@ -0,0 +1,145 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * LinkSetting Model
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Model
+ */
+class LinkSetting extends LinksAppModel {
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array();
+
+/**
+ * Called during validation operations, before validation. Please note that custom
+ * validation rules can be defined in $validate.
+ *
+ * @param array $options Options passed from Model::save().
+ * @return bool True if validate operation should continue, false to abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
+ * @see Model::save()
+ */
+ public function beforeValidate($options = array()) {
+ $this->validate = Hash::merge($this->validate, array(
+ 'block_key' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ 'allowEmpty' => false,
+ 'required' => true,
+ 'on' => 'update', // Limit validation to 'create' or 'update' operations
+ ),
+ ),
+ 'use_workflow' => array(
+ 'boolean' => array(
+ 'rule' => array('boolean'),
+ 'message' => __d('net_commons', 'Invalid request.'),
+ ),
+ ),
+ ));
+
+ return parent::beforeValidate($options);
+ }
+
+/**
+ * Get link setting data
+ *
+ * @param string $blockKey blocks.key
+ * @return array
+ */
+ public function getLinkSetting($blockKey) {
+ $conditions = array(
+ 'block_key' => $blockKey
+ );
+
+ $linkSetting = $this->find('first', array(
+ 'recursive' => -1,
+ 'conditions' => $conditions,
+ )
+ );
+
+ return $linkSetting;
+ }
+
+/**
+ * Save link settings
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on failure
+ * @throws InternalErrorException
+ */
+ public function saveLinkSetting($data) {
+ $this->loadModels([
+ 'LinkSetting' => 'Links.LinkSetting',
+ 'BlockRolePermission' => 'Blocks.BlockRolePermission',
+ ]);
+
+ //トランザクションBegin
+ $this->setDataSource('master');
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+
+ try {
+ if (! $this->validateLinkSetting($data)) {
+ return false;
+ }
+ foreach ($data[$this->BlockRolePermission->alias] as $value) {
+ if (! $this->BlockRolePermission->validateBlockRolePermissions($value)) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->BlockRolePermission->validationErrors);
+ return false;
+ }
+ }
+
+ if (! $this->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+ foreach ($data[$this->BlockRolePermission->alias] as $value) {
+ if (! $this->BlockRolePermission->saveMany($value, ['validate' => false])) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+ }
+
+ //トランザクションCommit
+ $dataSource->commit();
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $dataSource->rollback();
+ CakeLog::error($ex);
+ throw $ex;
+ }
+
+ return true;
+ }
+
+/**
+ * validate linkSettings
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on validation errors
+ */
+ public function validateLinkSetting($data) {
+ $this->set($data);
+ $this->validates();
+ if ($this->validationErrors) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/Model/Linklist.php b/Model/Linklist.php
deleted file mode 100644
index 37e50b9..0000000
--- a/Model/Linklist.php
+++ /dev/null
@@ -1,139 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinkListsAppModel', 'LinkLists.Model');
-
-/**
- * Summary for Linklist Model
- */
-class Linklist extends LinkListsAppModel {
-
-/**
- * Use database config
- *
- * @var string
- */
- public $useDbConfig = 'master';
-
-/**
- * Validation rules
- *
- * @var array
- */
- public $validate = array(
- 'linklists_block_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'status' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'language_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'is_auto_translated' => array(
- 'boolean' => array(
- 'rule' => array('boolean'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'url' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- );
-
- //The Associations below have been created with all possible keys, those that are not needed can be removed
-
-/**
- * belongsTo associations
- *
- * @var array
- */
- public $belongsTo = array(
- 'LinklistsBlock' => array(
- 'className' => 'LinklistsBlock',
- 'foreignKey' => 'linklists_block_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- ),
- 'Language' => array(
- 'className' => 'Language',
- 'foreignKey' => 'language_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- ),
- 'LinklistsCategory' => array(
- 'className' => 'LinklistsCategory',
- 'foreignKey' => 'linklists_category_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
-
-/**
- * hasAndBelongsToMany associations
- *
- * @var array
- */
- public $hasAndBelongsToMany = array(
- 'Block' => array(
- 'className' => 'Block',
- 'joinTable' => 'linklists_blocks',
- 'foreignKey' => 'linklist_id',
- 'associationForeignKey' => 'block_id',
- 'unique' => 'keepExisting',
- 'conditions' => '',
- 'fields' => '',
- 'order' => '',
- 'limit' => '',
- 'offset' => '',
- 'finderQuery' => '',
- )
- );
-
-}
diff --git a/Model/LinklistPartSetting.php b/Model/LinklistPartSetting.php
deleted file mode 100644
index 870aacc..0000000
--- a/Model/LinklistPartSetting.php
+++ /dev/null
@@ -1,118 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinkListsAppModel', 'LinkLists.Model');
-
-/**
- * Summary for LinklistPartSetting Model
- */
-class LinklistPartSetting extends LinkListsAppModel {
-
-/**
- * Use database config
- *
- * @var string
- */
- public $useDbConfig = 'master';
-
-/**
- * Validation rules
- *
- * @var array
- */
- public $validate = array(
- 'linklist_block_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'part_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'readable_content' => array(
- 'boolean' => array(
- 'rule' => array('boolean'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'editable_content' => array(
- 'boolean' => array(
- 'rule' => array('boolean'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'creatable_content' => array(
- 'boolean' => array(
- 'rule' => array('boolean'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'publishable_content' => array(
- 'boolean' => array(
- 'rule' => array('boolean'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- );
-
- //The Associations below have been created with all possible keys, those that are not needed can be removed
-
-/**
- * belongsTo associations
- *
- * @var array
- */
- public $belongsTo = array(
- 'LinklistBlock' => array(
- 'className' => 'LinklistBlock',
- 'foreignKey' => 'linklist_block_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- ),
- 'Part' => array(
- 'className' => 'Part',
- 'foreignKey' => 'part_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
-}
diff --git a/Model/LinklistSetting.php b/Model/LinklistSetting.php
deleted file mode 100644
index e44285c..0000000
--- a/Model/LinklistSetting.php
+++ /dev/null
@@ -1,60 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinkListsAppModel', 'LinkLists.Model');
-
-/**
- * Summary for LinklistSetting Model
- */
-class LinklistSetting extends LinkListsAppModel {
-
-/**
- * Use database config
- *
- * @var string
- */
- public $useDbConfig = 'master';
-
-/**
- * Validation rules
- *
- * @var array
- */
- public $validate = array(
- 'linklist_block_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- );
-
- //The Associations below have been created with all possible keys, those that are not needed can be removed
-
-/**
- * belongsTo associations
- *
- * @var array
- */
- public $belongsTo = array(
- 'LinklistBlock' => array(
- 'className' => 'LinklistBlock',
- 'foreignKey' => 'linklist_block_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
-}
diff --git a/Model/LinklistsBlock.php b/Model/LinklistsBlock.php
deleted file mode 100644
index f047f9b..0000000
--- a/Model/LinklistsBlock.php
+++ /dev/null
@@ -1,97 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinkListsAppModel', 'LinkLists.Model');
-
-/**
- * Summary for LinklistsBlock Model
- */
-class LinklistsBlock extends LinkListsAppModel {
-
-/**
- * Use database config
- *
- * @var string
- */
- public $useDbConfig = 'master';
-
-/**
- * Validation rules
- *
- * @var array
- */
- public $validate = array(
- 'block_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- );
-
- //The Associations below have been created with all possible keys, those that are not needed can be removed
-
-/**
- * belongsTo associations
- *
- * @var array
- */
- public $belongsTo = array(
- 'Block' => array(
- 'className' => 'Block',
- 'foreignKey' => 'block_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
-
-/**
- * hasMany associations
- *
- * @var array
- */
- public $hasMany = array(
- 'Linklist' => array(
- 'className' => 'Linklist',
- 'foreignKey' => 'linklists_block_id',
- 'dependent' => false,
- 'conditions' => '',
- 'fields' => '',
- 'order' => '',
- 'limit' => '',
- 'offset' => '',
- 'exclusive' => '',
- 'finderQuery' => '',
- 'counterQuery' => ''
- ),
- 'LinklistsCategory' => array(
- 'className' => 'LinklistsCategory',
- 'foreignKey' => 'linklists_block_id',
- 'dependent' => false,
- 'conditions' => '',
- 'fields' => '',
- 'order' => '',
- 'limit' => '',
- 'offset' => '',
- 'exclusive' => '',
- 'finderQuery' => '',
- 'counterQuery' => ''
- )
- );
-
-}
diff --git a/Model/LinklistsCategory.php b/Model/LinklistsCategory.php
deleted file mode 100644
index 9405527..0000000
--- a/Model/LinklistsCategory.php
+++ /dev/null
@@ -1,121 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinkListsAppModel', 'LinkLists.Model');
-
-/**
- * Summary for LinklistsCategory Model
- */
-class LinklistsCategory extends LinkListsAppModel {
-
-/**
- * Use database config
- *
- * @var string
- */
- public $useDbConfig = 'master';
-
-/**
- * Validation rules
- *
- * @var array
- */
- public $validate = array(
- 'linklists_block_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'status' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'language_id' => array(
- 'numeric' => array(
- 'rule' => array('numeric'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'is_auto_translated' => array(
- 'boolean' => array(
- 'rule' => array('boolean'),
- //'message' => 'Your custom message here',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- );
-
- //The Associations below have been created with all possible keys, those that are not needed can be removed
-
-/**
- * belongsTo associations
- *
- * @var array
- */
- public $belongsTo = array(
- 'LinklistsBlock' => array(
- 'className' => 'LinklistsBlock',
- 'foreignKey' => 'linklists_block_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- ),
- 'Language' => array(
- 'className' => 'Language',
- 'foreignKey' => 'language_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
-
-/**
- * hasMany associations
- *
- * @var array
- */
- public $hasMany = array(
- 'Linklist' => array(
- 'className' => 'Linklist',
- 'foreignKey' => 'linklists_category_id',
- 'dependent' => false,
- 'conditions' => '',
- 'fields' => '',
- 'order' => '',
- 'limit' => '',
- 'offset' => '',
- 'exclusive' => '',
- 'finderQuery' => '',
- 'counterQuery' => ''
- )
- );
-
-}
diff --git a/Model/LinksAppModel.php b/Model/LinksAppModel.php
new file mode 100644
index 0000000..0d7ea30
--- /dev/null
+++ b/Model/LinksAppModel.php
@@ -0,0 +1,23 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('AppModel', 'Model');
+
+/**
+ * LinkApp Model
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Model
+ */
+class LinksAppModel extends AppModel {
+
+}
diff --git a/Test/Case/AllLinksTest.php b/Test/Case/AllLinksTest.php
new file mode 100644
index 0000000..27f65a3
--- /dev/null
+++ b/Test/Case/AllLinksTest.php
@@ -0,0 +1,32 @@
+
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+/**
+ * Links All Test Suite
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Test\Case
+ * @codeCoverageIgnore
+ */
+class AllLinksTest extends CakeTestSuite {
+
+/**
+ * All test suite
+ *
+ * @return CakeTestSuite
+ */
+ public static function suite() {
+ $plugin = preg_replace('/^All([\w]+)Test$/', '$1', __CLASS__);
+ $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
+ $suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case');
+
+ return $suite;
+ }
+}
diff --git a/Test/Case/Controller/LinkListsCategoriesControllerTest.php b/Test/Case/Controller/LinkListsCategoriesControllerTest.php
deleted file mode 100644
index 2e7b1c3..0000000
--- a/Test/Case/Controller/LinkListsCategoriesControllerTest.php
+++ /dev/null
@@ -1,71 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinkListsCategoriesController', 'LinkLists.Controller');
-
-/**
- * Summary for LinkListsCategoriesController Test Case
- */
-class LinkListsCategoriesControllerTest extends ControllerTestCase {
-
-/**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = array(
- 'plugin.link_lists.linklists_category',
- 'plugin.link_lists.linklists_block',
- 'plugin.link_lists.language',
- 'plugin.link_lists.linklist',
- 'plugin.link_lists.site_setting',
- 'plugin.link_lists.site_setting_value'
- );
-
-/**
- * testIndex method
- *
- * @return void
- */
- public function testIndex() {
- }
-
-/**
- * testView method
- *
- * @return void
- */
- public function testView() {
- }
-
-/**
- * testAdd method
- *
- * @return void
- */
- public function testAdd() {
- }
-
-/**
- * testEdit method
- *
- * @return void
- */
- public function testEdit() {
- }
-
-/**
- * testDelete method
- *
- * @return void
- */
- public function testDelete() {
- }
-
-}
diff --git a/Test/Case/Controller/LinkListsControllerTest.php b/Test/Case/Controller/LinkListsControllerTest.php
deleted file mode 100644
index 5c62fb0..0000000
--- a/Test/Case/Controller/LinkListsControllerTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinkListsController', 'LinkLists.Controller');
-
-/**
- * Summary for LinkListsController Test Case
- */
-class LinkListsControllerTest extends ControllerTestCase {
-
-/**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = array(
- 'plugin.link_lists.linklist',
- 'plugin.link_lists.linklists_block',
- 'plugin.link_lists.language',
- 'plugin.link_lists.linklists_category',
- 'plugin.link_lists.block',
- 'plugin.link_lists.blocks_language',
- 'plugin.link_lists.site_setting',
- 'plugin.link_lists.site_setting_value'
- );
-
-/**
- * testIndex method
- *
- * @return void
- */
- public function testIndex() {
- }
-
-/**
- * testView method
- *
- * @return void
- */
- public function testView() {
- }
-
-/**
- * testAdd method
- *
- * @return void
- */
- public function testAdd() {
- }
-
-/**
- * testEdit method
- *
- * @return void
- */
- public function testEdit() {
- }
-
-/**
- * testDelete method
- *
- * @return void
- */
- public function testDelete() {
- }
-
-}
diff --git a/Test/Case/Model/LinkBlockTest.php b/Test/Case/Model/LinkBlockTest.php
new file mode 100644
index 0000000..bccc607
--- /dev/null
+++ b/Test/Case/Model/LinkBlockTest.php
@@ -0,0 +1,55 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksBaseModel', 'Links.Test/Case/Model');
+
+/**
+ * Common code of LinkBlock model test
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Test\Case\Model
+ */
+class LinkBlockTest extends LinksBaseModel {
+
+/**
+ * setUp
+ *
+ * @return void
+ */
+ public function setUp() {
+ parent::setUp();
+ $this->Block = ClassRegistry::init('Blocks.Block');
+ $this->Category = ClassRegistry::init('Categories.Category');
+ $this->CategoryOrder = ClassRegistry::init('Categories.CategoryOrder');
+ $this->Link = ClassRegistry::init('Links.Link');
+ $this->LinkBlock = ClassRegistry::init('Links.LinkBlock');
+ $this->LinkOrder = ClassRegistry::init('Links.LinkOrder');
+ $this->LinkSetting = ClassRegistry::init('Links.LinkSetting');
+ }
+
+/**
+ * tearDown
+ *
+ * @return void
+ */
+ public function tearDown() {
+ unset($this->Block);
+ unset($this->Category);
+ unset($this->CategoryOrder);
+ unset($this->Link);
+ unset($this->LinkBlock);
+ unset($this->LinkOrder);
+ unset($this->LinkSetting);
+ parent::tearDown();
+ }
+}
diff --git a/Test/Case/Model/LinklistPartSettingTest.php b/Test/Case/Model/LinklistPartSettingTest.php
deleted file mode 100644
index ebc516f..0000000
--- a/Test/Case/Model/LinklistPartSettingTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinklistPartSetting', 'LinkLists.Model');
-
-/**
- * Summary for LinklistPartSetting Test Case
- */
-class LinklistPartSettingTest extends CakeTestCase {
-
-/**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = array(
- 'plugin.link_lists.linklist_part_setting',
- 'plugin.link_lists.linklist_block',
- 'plugin.link_lists.part',
- 'plugin.link_lists.language',
- 'plugin.link_lists.languages_part'
- );
-
-/**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- $this->LinklistPartSetting = ClassRegistry::init('LinkLists.LinklistPartSetting');
- }
-
-/**
- * tearDown method
- *
- * @return void
- */
- public function tearDown() {
- unset($this->LinklistPartSetting);
-
- parent::tearDown();
- }
-
-}
diff --git a/Test/Case/Model/LinklistSettingTest.php b/Test/Case/Model/LinklistSettingTest.php
deleted file mode 100644
index b85ee01..0000000
--- a/Test/Case/Model/LinklistSettingTest.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinklistSetting', 'LinkLists.Model');
-
-/**
- * Summary for LinklistSetting Test Case
- */
-class LinklistSettingTest extends CakeTestCase {
-
-/**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = array(
- 'plugin.link_lists.linklist_setting',
- 'plugin.link_lists.linklist_block'
- );
-
-/**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- $this->LinklistSetting = ClassRegistry::init('LinkLists.LinklistSetting');
- }
-
-/**
- * tearDown method
- *
- * @return void
- */
- public function tearDown() {
- unset($this->LinklistSetting);
-
- parent::tearDown();
- }
-
-}
diff --git a/Test/Case/Model/LinklistTest.php b/Test/Case/Model/LinklistTest.php
deleted file mode 100644
index e5eb9a3..0000000
--- a/Test/Case/Model/LinklistTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('Linklist', 'LinkLists.Model');
-
-/**
- * Summary for Linklist Test Case
- */
-class LinklistTest extends CakeTestCase {
-
-/**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = array(
- 'plugin.link_lists.linklist',
- 'plugin.link_lists.linklists_block',
- 'plugin.link_lists.language',
- 'plugin.link_lists.linklists_category',
- 'plugin.link_lists.block',
- 'plugin.link_lists.blocks_language'
- );
-
-/**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- $this->Linklist = ClassRegistry::init('LinkLists.Linklist');
- }
-
-/**
- * tearDown method
- *
- * @return void
- */
- public function tearDown() {
- unset($this->Linklist);
-
- parent::tearDown();
- }
-
-}
diff --git a/Test/Case/Model/LinklistsBlockTest.php b/Test/Case/Model/LinklistsBlockTest.php
deleted file mode 100644
index fdbbc8e..0000000
--- a/Test/Case/Model/LinklistsBlockTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinklistsBlock', 'LinkLists.Model');
-
-/**
- * Summary for LinklistsBlock Test Case
- */
-class LinklistsBlockTest extends CakeTestCase {
-
-/**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = array(
- 'plugin.link_lists.linklists_block',
- 'plugin.link_lists.block',
- 'plugin.link_lists.language',
- 'plugin.link_lists.blocks_language',
- 'plugin.link_lists.linklist',
- 'plugin.link_lists.linklists_category'
- );
-
-/**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- $this->LinklistsBlock = ClassRegistry::init('LinkLists.LinklistsBlock');
- }
-
-/**
- * tearDown method
- *
- * @return void
- */
- public function tearDown() {
- unset($this->LinklistsBlock);
-
- parent::tearDown();
- }
-
-}
diff --git a/Test/Case/Model/LinklistsCategoryTest.php b/Test/Case/Model/LinklistsCategoryTest.php
deleted file mode 100644
index fbfc49e..0000000
--- a/Test/Case/Model/LinklistsCategoryTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-App::uses('LinklistsCategory', 'LinkLists.Model');
-
-/**
- * Summary for LinklistsCategory Test Case
- */
-class LinklistsCategoryTest extends CakeTestCase {
-
-/**
- * Fixtures
- *
- * @var array
- */
- public $fixtures = array(
- 'plugin.link_lists.linklists_category',
- 'plugin.link_lists.linklists_block',
- 'plugin.link_lists.language',
- 'plugin.link_lists.linklist'
- );
-
-/**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- $this->LinklistsCategory = ClassRegistry::init('LinkLists.LinklistsCategory');
- }
-
-/**
- * tearDown method
- *
- * @return void
- */
- public function tearDown() {
- unset($this->LinklistsCategory);
-
- parent::tearDown();
- }
-
-}
diff --git a/Test/Case/Model/LinksBaseModel.php b/Test/Case/Model/LinksBaseModel.php
new file mode 100644
index 0000000..4e7ace4
--- /dev/null
+++ b/Test/Case/Model/LinksBaseModel.php
@@ -0,0 +1,132 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('NetCommonsFrameComponent', 'NetCommons.Controller/Component');
+App::uses('NetCommonsBlockComponent', 'NetCommons.Controller/Component');
+App::uses('NetCommonsRoomRoleComponent', 'NetCommons.Controller/Component');
+App::uses('YACakeTestCase', 'NetCommons.TestSuite');
+App::uses('AuthComponent', 'Component');
+App::uses('Block', 'Blocks.Model');
+App::uses('Link', 'Links.Model');
+App::uses('LinkOrder', 'Links.Model');
+App::uses('LinkBlock', 'Links.Model');
+App::uses('LinkSetting', 'Links.Model');
+App::uses('LinkFrameSetting', 'Links.Model');
+
+/**
+ * Common code for test of Links
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Test\Case\Model
+ */
+class LinksBaseModel extends YACakeTestCase {
+
+/**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = array(
+ 'plugin.blocks.block',
+ 'plugin.blocks.block_role_permission',
+ 'plugin.boxes.box',
+ 'plugin.categories.category',
+ 'plugin.categories.category_order',
+ 'plugin.comments.comment',
+ 'plugin.links.link',
+ 'plugin.links.link_order',
+ 'plugin.links.link_setting',
+ 'plugin.links.link_frame_setting',
+ 'plugin.frames.frame',
+ 'plugin.frames.plugin',
+ 'plugin.m17n.language',
+ 'plugin.rooms.roles_room',
+ 'plugin.rooms.room',
+ 'plugin.users.user_attributes_user',
+ 'plugin.users.user',
+ );
+
+/**
+ * Test case of notEmpty
+ *
+ * @var array
+ */
+ public $validateNotEmpty = array(
+ null, '', false,
+ );
+
+/**
+ * Test case of boolean
+ *
+ * @var array
+ */
+ public $validateBoolean = array(
+ null, '', 'a', '99', 'false', 'true'
+ );
+
+/**
+ * Test case of boolean
+ *
+ * @var array
+ */
+ public $validateNumber = array(
+ null, '', 'abcde', false, true, '123abcd', 'false', 'true'
+ );
+
+/**
+ * Do test assert, after created_date, created_user, modified_date and modified_user fields remove.
+ *
+ * @param array $expected expected data
+ * @param array $result result data
+ * @param int $path remove path
+ * @param array $fields target fields
+ * @return void
+ */
+ protected function _assertArray($expected, $result, $path = 3, $fields = ['created', 'created_user', 'modified', 'modified_user']) {
+ foreach ($fields as $field) {
+ if ($path >= 1) {
+ $result = Hash::remove($result, $field);
+ }
+ if ($path >= 2) {
+ $result = Hash::remove($result, '{n}.' . $field);
+ $result = Hash::remove($result, '{s}.' . $field);
+ if ($field === 'created_user') {
+ $result = Hash::remove($result, 'TrackableCreator');
+ }
+ if ($field === 'modified_user') {
+ $result = Hash::remove($result, 'TrackableUpdater');
+ }
+ }
+ if ($path >= 3) {
+ $result = Hash::remove($result, '{n}.{n}.' . $field);
+ $result = Hash::remove($result, '{n}.{s}.' . $field);
+ if ($field === 'created_user') {
+ $result = Hash::remove($result, '{n}.TrackableCreator');
+ }
+ if ($field === 'modified_user') {
+ $result = Hash::remove($result, '{n}.TrackableUpdater');
+ }
+ }
+ }
+
+ $this->assertEquals($expected, $result);
+ }
+
+/**
+ * Called before the test().
+ *
+ * @return void
+ */
+ public function test() {
+ }
+}
diff --git a/Test/Fixture/LinkFixture.php b/Test/Fixture/LinkFixture.php
new file mode 100644
index 0000000..394bbcc
--- /dev/null
+++ b/Test/Fixture/LinkFixture.php
@@ -0,0 +1,68 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+/**
+ * Link Fixture
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Test\Fixture
+ */
+class LinkFixture extends CakeTestFixture {
+
+/**
+ * Fields
+ *
+ * @var array
+ */
+ public $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'comment' => 'block id | ブロックID | blocks.id | '),
+ 'category_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'category id | カテゴリーID | link_categories.id | '),
+ 'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link key | リンクキー | Hash値 | ', 'charset' => 'utf8'),
+ 'status' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 4, 'comment' => 'public status, 1: public, 2: public pending, 3: draft during 4: remand | 公開状況 1:公開中、2:公開申請中、3:下書き中、4:差し戻し | | '),
+ 'url' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link url | リンク先URL | | ', 'charset' => 'utf8'),
+ 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'title | タイトル | | ', 'charset' => 'utf8'),
+ 'description' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'description | 説明 | | ', 'charset' => 'utf8'),
+ 'click_count' => array('type' => 'integer', 'null' => false, 'default' => '0', 'comment' => 'link click count | クリック数 | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1)
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+
+/**
+ * Records
+ *
+ * @var array
+ */
+ public $records = array(
+ array(
+ 'id' => 1,
+ 'block_id' => 1,
+ 'category_id' => 1,
+ 'key' => 'Lorem ipsum dolor sit amet',
+ 'status' => 1,
+ 'url' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
+ 'title' => 'Lorem ipsum dolor sit amet',
+ 'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
+ 'click_count' => 1,
+ 'created_user' => 1,
+ 'created' => '2015-05-01 07:17:58',
+ 'modified_user' => 1,
+ 'modified' => '2015-05-01 07:17:58'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinkFrameSettingFixture.php b/Test/Fixture/LinkFrameSettingFixture.php
new file mode 100644
index 0000000..17d189e
--- /dev/null
+++ b/Test/Fixture/LinkFrameSettingFixture.php
@@ -0,0 +1,64 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+/**
+ * LinkFrameSetting Fixture
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Test\Fixture
+ */
+class LinkFrameSettingFixture extends CakeTestFixture {
+
+/**
+ * Fields
+ *
+ * @var array
+ */
+ public $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'frame_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'frame key | フレームKey | frames.key | ', 'charset' => 'utf8'),
+ 'display_type' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 4, 'comment' => 'display type, 1: dropdown type, 2: list type (no explanation), 3: list type (with explanation) | 表示方法種別 1: ドロップダウン型、2:リスト型(説明なし)、3:リスト型(説明あり) | | '),
+ 'open_new_tab' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'open new tab, 1: new tab or 0: same window | リンクの開き方 0:同じウィンドウ内、1:新しいタブ | | '),
+ 'display_click_count' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'display of click count, 1: display or 0: no display | リンクのクリック数の表示 0:表示しない、1:表示する | | '),
+ 'category_separator_line' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'separator line between the categories | カテゴリ間の区切り線 | | ', 'charset' => 'utf8'),
+ 'list_style' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'list mark | リストマーク | | ', 'charset' => 'utf8'),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1)
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+
+/**
+ * Records
+ *
+ * @var array
+ */
+ public $records = array(
+ array(
+ 'id' => 1,
+ 'frame_key' => 'Lorem ipsum dolor sit amet',
+ 'display_type' => 1,
+ 'open_new_tab' => 1,
+ 'display_click_count' => 1,
+ 'category_separator_line' => 'Lorem ipsum dolor sit amet',
+ 'list_style' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2015-05-01 07:17:43',
+ 'modified_user' => 1,
+ 'modified' => '2015-05-01 07:17:43'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinkOrderFixture.php b/Test/Fixture/LinkOrderFixture.php
new file mode 100644
index 0000000..86abaf3
--- /dev/null
+++ b/Test/Fixture/LinkOrderFixture.php
@@ -0,0 +1,60 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+/**
+ * LinkOrder Fixture
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Test\Fixture
+ */
+class LinkOrderFixture extends CakeTestFixture {
+
+/**
+ * Fields
+ *
+ * @var array
+ */
+ public $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'block key | ブロックKey | blocks.key | ', 'charset' => 'utf8'),
+ 'category_key' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'category key | カテゴリKey | categories.key | ', 'charset' => 'utf8'),
+ 'link_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link key | リンクKey | links.key | ', 'charset' => 'utf8'),
+ 'weight' => array('type' => 'integer', 'null' => false, 'default' => '0', 'comment' => 'The weight of the display(display order) | 表示の重み(表示順序) | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1)
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+
+/**
+ * Records
+ *
+ * @var array
+ */
+ public $records = array(
+ array(
+ 'id' => 1,
+ 'block_key' => 'Lorem ipsum dolor sit amet',
+ 'category_key' => 'Lorem ipsum dolor sit amet',
+ 'link_key' => 'Lorem ipsum dolor sit amet',
+ 'weight' => 1,
+ 'created_user' => 1,
+ 'created' => '2015-05-01 07:17:55',
+ 'modified_user' => 1,
+ 'modified' => '2015-05-01 07:17:55'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinkSettingFixture.php b/Test/Fixture/LinkSettingFixture.php
new file mode 100644
index 0000000..f49f3af
--- /dev/null
+++ b/Test/Fixture/LinkSettingFixture.php
@@ -0,0 +1,56 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+/**
+ * LinkSetting Fixture
+ *
+ * @author Shohei Nakajima
+ * @package NetCommons\Links\Test\Fixture
+ */
+class LinkSettingFixture extends CakeTestFixture {
+
+/**
+ * Fields
+ *
+ * @var array
+ */
+ public $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'block_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Block key | Blockキー | Hash値 | ', 'charset' => 'utf8'),
+ 'use_workflow' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'Use workflow, 0:Unused 1:Use | コンテンツの承認機能 0:使わない 1:使う | | '),
+ 'created_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'created user | 作成者 | users.id | '),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'created datetime | 作成日時 | | '),
+ 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'comment' => 'modified user | 更新者 | users.id | '),
+ 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'modified datetime | 更新日時 | | '),
+ 'indexes' => array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1)
+ ),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+
+/**
+ * Records
+ *
+ * @var array
+ */
+ public $records = array(
+ array(
+ 'id' => 1,
+ 'block_key' => 'Lorem ipsum dolor sit amet',
+ 'use_workflow' => 1,
+ 'created_user' => 1,
+ 'created' => '2015-05-01 08:11:12',
+ 'modified_user' => 1,
+ 'modified' => '2015-05-01 08:11:12'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinklistFixture.php b/Test/Fixture/LinklistFixture.php
deleted file mode 100644
index d400499..0000000
--- a/Test/Fixture/LinklistFixture.php
+++ /dev/null
@@ -1,65 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-/**
- * Summary for LinklistFixture
- */
-class LinklistFixture extends CakeTestFixture {
-
-/**
- * Fields
- *
- * @var array
- */
- public $fields = array(
- 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
- 'linklists_block_id' => array('type' => 'integer', 'null' => false, 'default' => null),
- 'status' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 3),
- 'language_id' => array('type' => 'integer', 'null' => false, 'default' => '2'),
- 'is_auto_translated' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
- 'translation_engine' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
- 'linklists_category_id' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'title' => array('type' => 'string', 'null' => true, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
- 'url' => array('type' => 'string', 'null' => false, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
- 'description' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
- 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'indexes' => array(
- 'PRIMARY' => array('column' => 'id', 'unique' => 1)
- ),
- 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
- );
-
-/**
- * Records
- *
- * @var array
- */
- public $records = array(
- array(
- 'id' => 1,
- 'linklists_block_id' => 1,
- 'status' => 1,
- 'language_id' => 1,
- 'is_auto_translated' => 1,
- 'translation_engine' => 'Lorem ipsum dolor sit amet',
- 'linklists_category_id' => 1,
- 'title' => 'Lorem ipsum dolor sit amet',
- 'url' => 'Lorem ipsum dolor sit amet',
- 'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
- 'created_user' => 1,
- 'created' => '2014-08-30 00:52:54',
- 'modified_user' => 1,
- 'modified' => '2014-08-30 00:52:54'
- ),
- );
-
-}
diff --git a/Test/Fixture/LinklistPartSettingFixture.php b/Test/Fixture/LinklistPartSettingFixture.php
deleted file mode 100644
index 4623518..0000000
--- a/Test/Fixture/LinklistPartSettingFixture.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-/**
- * Summary for LinklistPartSettingFixture
- */
-class LinklistPartSettingFixture extends CakeTestFixture {
-
-/**
- * Fields
- *
- * @var array
- */
- public $fields = array(
- 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
- 'linklist_block_id' => array('type' => 'integer', 'null' => false, 'default' => null),
- 'part_id' => array('type' => 'integer', 'null' => false, 'default' => '0'),
- 'readable_content' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
- 'editable_content' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
- 'creatable_content' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
- 'publishable_content' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
- 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'indexes' => array(
- 'PRIMARY' => array('column' => 'id', 'unique' => 1)
- ),
- 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
- );
-
-/**
- * Records
- *
- * @var array
- */
- public $records = array(
- array(
- 'id' => 1,
- 'linklist_block_id' => 1,
- 'part_id' => 1,
- 'readable_content' => 1,
- 'editable_content' => 1,
- 'creatable_content' => 1,
- 'publishable_content' => 1,
- 'created_user' => 1,
- 'created' => '2014-08-30 00:55:01',
- 'modified_user' => 1,
- 'modified' => '2014-08-30 00:55:01'
- ),
- );
-
-}
diff --git a/Test/Fixture/LinklistSettingFixture.php b/Test/Fixture/LinklistSettingFixture.php
deleted file mode 100644
index 8bf60c0..0000000
--- a/Test/Fixture/LinklistSettingFixture.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-/**
- * Summary for LinklistSettingFixture
- */
-class LinklistSettingFixture extends CakeTestFixture {
-
-/**
- * Fields
- *
- * @var array
- */
- public $fields = array(
- 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
- 'linklist_block_id' => array('type' => 'integer', 'null' => false, 'default' => null),
- 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'indexes' => array(
- 'PRIMARY' => array('column' => 'id', 'unique' => 1)
- ),
- 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
- );
-
-/**
- * Records
- *
- * @var array
- */
- public $records = array(
- array(
- 'id' => 1,
- 'linklist_block_id' => 1,
- 'created_user' => 1,
- 'created' => '2014-08-30 00:55:24',
- 'modified_user' => 1,
- 'modified' => '2014-08-30 00:55:24'
- ),
- );
-
-}
diff --git a/Test/Fixture/LinklistsBlockFixture.php b/Test/Fixture/LinklistsBlockFixture.php
deleted file mode 100644
index 0b741b6..0000000
--- a/Test/Fixture/LinklistsBlockFixture.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-/**
- * Summary for LinklistsBlockFixture
- */
-class LinklistsBlockFixture extends CakeTestFixture {
-
-/**
- * Fields
- *
- * @var array
- */
- public $fields = array(
- 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
- 'block_id' => array('type' => 'integer', 'null' => false, 'default' => null),
- 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'indexes' => array(
- 'PRIMARY' => array('column' => 'id', 'unique' => 1)
- ),
- 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
- );
-
-/**
- * Records
- *
- * @var array
- */
- public $records = array(
- array(
- 'id' => 1,
- 'block_id' => 1,
- 'created_user' => 1,
- 'created' => '2014-08-30 00:54:39',
- 'modified_user' => 1,
- 'modified' => '2014-08-30 00:54:39'
- ),
- );
-
-}
diff --git a/Test/Fixture/LinklistsCategoryFixture.php b/Test/Fixture/LinklistsCategoryFixture.php
deleted file mode 100644
index 27d5a14..0000000
--- a/Test/Fixture/LinklistsCategoryFixture.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
-* @link http://www.netcommons.org NetCommons Project
-* @license http://www.netcommons.org/license.txt NetCommons License
- */
-
-/**
- * Summary for LinklistsCategoryFixture
- */
-class LinklistsCategoryFixture extends CakeTestFixture {
-
-/**
- * Fields
- *
- * @var array
- */
- public $fields = array(
- 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
- 'linklists_block_id' => array('type' => 'integer', 'null' => false, 'default' => null),
- 'status' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 3),
- 'language_id' => array('type' => 'integer', 'null' => false, 'default' => '2'),
- 'is_auto_translated' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
- 'translation_engine' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
- 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
- 'created_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null),
- 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
- 'indexes' => array(
- 'PRIMARY' => array('column' => 'id', 'unique' => 1)
- ),
- 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
- );
-
-/**
- * Records
- *
- * @var array
- */
- public $records = array(
- array(
- 'id' => 1,
- 'linklists_block_id' => 1,
- 'status' => 1,
- 'language_id' => 1,
- 'is_auto_translated' => 1,
- 'translation_engine' => 'Lorem ipsum dolor sit amet',
- 'title' => 'Lorem ipsum dolor sit amet',
- 'created_user' => 1,
- 'created' => '2014-08-30 00:53:41',
- 'modified_user' => 1,
- 'modified' => '2014-08-30 00:53:41'
- ),
- );
-
-}
diff --git a/View/BlockRolePermissions/edit.ctp b/View/BlockRolePermissions/edit.ctp
new file mode 100644
index 0000000..0124f3b
--- /dev/null
+++ b/View/BlockRolePermissions/edit.ctp
@@ -0,0 +1,28 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Html->script('/links/js/links.js', false); ?>
+
+
+ element('NetCommons.setting_tabs', $settingTabs); ?>
+
+
+ element('Blocks.setting_tabs', $blockSettingTabs); ?>
+
+ element('Blocks.edit_form', array(
+ 'controller' => 'BlockRolePermission',
+ 'action' => 'edit' . '/' . $frameId . '/' . $blockId,
+ 'callback' => 'Links.BlockRolePermissions/edit_form',
+ 'cancelUrl' => '/links/blocks/index/' . $frameId,
+ )); ?>
+
+
diff --git a/View/Blocks/edit.ctp b/View/Blocks/edit.ctp
new file mode 100644
index 0000000..5f81f43
--- /dev/null
+++ b/View/Blocks/edit.ctp
@@ -0,0 +1,34 @@
+
+ * @author Ryo Ozawa
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+
+ element('NetCommons.setting_tabs', $settingTabs); ?>
+
+
+ element('Blocks.setting_tabs', $blockSettingTabs); ?>
+
+ element('Blocks.edit_form', array(
+ 'controller' => 'Blocks',
+ 'action' => h($this->request->params['action']) . '/' . $frameId . '/' . $blockId,
+ 'callback' => 'Links.Blocks/edit_form',
+ 'cancelUrl' => '/links/blocks/index/' . $frameId
+ )); ?>
+
+ request->params['action'] === 'edit') : ?>
+ element('Blocks.delete_form', array(
+ 'controller' => 'Blocks',
+ 'action' => 'delete/' . $frameId . '/' . $blockId,
+ 'callback' => 'Links.Blocks/delete_form'
+ )); ?>
+
+
+
diff --git a/View/Blocks/index.ctp b/View/Blocks/index.ctp
new file mode 100644
index 0000000..2aa02b7
--- /dev/null
+++ b/View/Blocks/index.ctp
@@ -0,0 +1,101 @@
+
+ * @author Ryo Ozawa
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+
+ element('NetCommons.setting_tabs', $settingTabs); ?>
+
+
+
+
+
+ Form->create('', array(
+ 'url' => '/frames/frames/edit/' . $frameId
+ )); ?>
+
+ Form->hidden('Frame.id', array(
+ 'value' => $frameId,
+ )); ?>
+
+
+
+
+ | # |
+
+ Paginator->sort('Link.name', __d('links', 'Link list Title')); ?>
+ |
+
+ Paginator->sort('Block.public_type', __d('links', 'Public Type')); ?>
+ |
+
+ Paginator->sort('Block.modified', __d('links', 'Updated Date')); ?>
+ |
+
+
+
+
+ >
+ |
+ Form->input('Frame.block_id',
+ array(
+ 'type' => 'radio',
+ 'name' => 'data[Frame][block_id]',
+ 'options' => array((int)$linkBlock['block']['id'] => ''),
+ 'div' => false,
+ 'legend' => false,
+ 'label' => false,
+ 'hiddenField' => false,
+ 'checked' => (int)$linkBlock['block']['id'] === (int)$blockId,
+ 'onclick' => 'submit()'
+ )); ?>
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+ Date->dateFormat($linkBlock['block']['modified']); ?>
+ |
+
+
+
+
+ Form->end(); ?>
+
+
+ element('NetCommons.paginator', array(
+ 'url' => Hash::merge(
+ array('controller' => 'blocks', 'action' => 'index', $frameId),
+ $this->Paginator->params['named']
+ )
+ )); ?>
+
+
+
+
+
+
+
+
diff --git a/View/Blocks/not_found.ctp b/View/Blocks/not_found.ctp
new file mode 100644
index 0000000..5a891a3
--- /dev/null
+++ b/View/Blocks/not_found.ctp
@@ -0,0 +1,28 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+
+ element('NetCommons.setting_tabs', $settingTabs); ?>
+
+
+
+
diff --git a/View/Categories/edit.ctp b/View/Categories/edit.ctp
new file mode 100644
index 0000000..d8713c3
--- /dev/null
+++ b/View/Categories/edit.ctp
@@ -0,0 +1,25 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+
+ element('NetCommons.setting_tabs', $settingTabs); ?>
+
+
+ element('Blocks.setting_tabs', $blockSettingTabs); ?>
+
+ element('Categories.edit_form', array(
+ 'cancelUrl' => '/links/blocks/' . h($this->request->params['action']) . '/' . $frameId . '/' . $blockId,
+ )); ?>
+
+
+
+
diff --git a/View/Elements/BlockRolePermissions/edit_form.ctp b/View/Elements/BlockRolePermissions/edit_form.ctp
new file mode 100644
index 0000000..3dc446d
--- /dev/null
+++ b/View/Elements/BlockRolePermissions/edit_form.ctp
@@ -0,0 +1,32 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Form->hidden('LinkSetting.id', array(
+ 'value' => isset($linkSetting['id']) ? (int)$linkSetting['id'] : null,
+ )); ?>
+
+Form->hidden('LinkSetting.block_key', array(
+ 'value' => isset($linkSetting['blockKey']) ? $linkSetting['blockKey'] : null,
+ )); ?>
+
+Form->hidden('Block.id', array(
+ 'value' => $blockId,
+ )); ?>
+
+element('Blocks.content_role_setting', array(
+ 'roles' => $roles,
+ 'permissions' => isset($blockRolePermissions) ? $blockRolePermissions : null,
+ 'useWorkflow' => array(
+ 'name' => 'LinkSetting.use_workflow',
+ 'value' => $linkSetting['useWorkflow']
+ ),
+ ));
diff --git a/View/Elements/Blocks/delete_form.ctp b/View/Elements/Blocks/delete_form.ctp
new file mode 100644
index 0000000..5a16d94
--- /dev/null
+++ b/View/Elements/Blocks/delete_form.ctp
@@ -0,0 +1,26 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+
+
+
+Form->hidden('Block.id', array(
+ 'value' => isset($block['id']) ? $block['id'] : null,
+ )); ?>
+Form->hidden('Block.key', array(
+ 'value' => isset($block['key']) ? $block['key'] : null,
+ )); ?>
+Form->button(' ' . __d('net_commons', 'Delete'), array(
+ 'name' => 'delete',
+ 'class' => 'btn btn-danger pull-right',
+ 'onclick' => 'return confirm(\'' . sprintf(__d('net_commons', 'Deleting the %s. Are you sure to proceed?'), __d('links', 'Link List')) . '\')'
+ ));
diff --git a/View/Elements/Blocks/edit_form.ctp b/View/Elements/Blocks/edit_form.ctp
new file mode 100644
index 0000000..fc34c4d
--- /dev/null
+++ b/View/Elements/Blocks/edit_form.ctp
@@ -0,0 +1,71 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Form->hidden('Frame.id', array(
+ 'value' => $frameId,
+ )); ?>
+
+Form->hidden('Block.id', array(
+ 'value' => $block['id'],
+ )); ?>
+
+Form->hidden('Block.key', array(
+ 'value' => $block['key'],
+ )); ?>
+
+Form->hidden('Block.language_id', array(
+ 'value' => $languageId,
+ )); ?>
+
+Form->hidden('Block.room_id', array(
+ 'value' => $roomId,
+ )); ?>
+
+Form->hidden('Block.plugin_key', array(
+ 'value' => $this->params['plugin'],
+ )); ?>
+
+Form->hidden('LinkSetting.id', array(
+ 'value' => isset($linkSetting['id']) ? (int)$linkSetting['id'] : null,
+ )); ?>
+
+
+
+element('Blocks.public_type'); ?>
+
+request->params['action'] === 'edit') : ?>
+ element('Categories.index', array(
+ 'categories' => $categories
+ )); ?>
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+?>
+
+Form->hidden('LinkFrameSetting.id', array(
+ 'value' => isset($linkFrameSetting['id']) ? (int)$linkFrameSetting['id'] : null,
+ )); ?>
+
+Form->hidden('LinkFrameSetting.frame_key', array(
+ 'value' => $frameKey,
+ )); ?>
+
+Form->hidden('Frame.id', array(
+ 'value' => $frameId,
+ )); ?>
+
+Form->hidden('Frame.key', array(
+ 'value' => $frameKey,
+ )); ?>
+
+
+ Form->input('LinkFrameSetting.display_type', array(
+ 'label' => __d('links', 'Display method'),
+ 'type' => 'select',
+ 'error' => false,
+ 'class' => 'form-control',
+ 'options' => array(
+ LinkFrameSetting::TYPE_DROPDOWN => __d('links', 'Show by dropdown'),
+ LinkFrameSetting::TYPE_LIST_ONLY_TITLE => __d('links', 'Show list'),
+ LinkFrameSetting::TYPE_LIST_WITH_DESCRIPTION => __d('links', 'Show list (Description)'),
+ ),
+ 'value' => (isset($linkFrameSetting['displayType']) ? $linkFrameSetting['displayType'] : LinkFrameSetting::TYPE_DROPDOWN)
+ )); ?>
+
+
+
+ Form->input('LinkFrameSetting.open_new_tab', array(
+ 'label' => __d('links', 'Open as a new tab'),
+ 'type' => 'checkbox',
+ 'error' => false,
+ 'checked' => (isset($linkFrameSetting['openNewTab']) ? (int)$linkFrameSetting['openNewTab'] : null)
+ )); ?>
+
+
+
+ Form->input('LinkFrameSetting.display_click_count', array(
+ 'label' => __d('links', 'Count view'),
+ 'type' => 'checkbox',
+ 'error' => false,
+ 'checked' => (isset($linkFrameSetting['displayClickCount']) ? (int)$linkFrameSetting['displayClickCount'] : null)
+ )); ?>
+
+
+
+
+
diff --git a/View/Elements/Links/delete_form.ctp b/View/Elements/Links/delete_form.ctp
new file mode 100644
index 0000000..014152e
--- /dev/null
+++ b/View/Elements/Links/delete_form.ctp
@@ -0,0 +1,40 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Form->create('Link', array(
+ 'type' => 'delete',
+ 'controller' => 'links',
+ 'action' => 'delete/' . $frameId . '/' . h($link['key'])
+ )); ?>
+
+ Form->hidden('Block.id', array(
+ 'value' => $blockId,
+ )); ?>
+
+ Form->hidden('Block.key', array(
+ 'value' => $block['key'],
+ )); ?>
+
+ Form->hidden('Link.id', array(
+ 'value' => isset($link['id']) ? (int)$link['id'] : null,
+ )); ?>
+
+ Form->hidden('Link.key', array(
+ 'value' => $link['key'],
+ )); ?>
+
+ Form->button(' ', array(
+ 'name' => 'delete',
+ 'class' => 'btn btn-danger',
+ 'onclick' => 'return confirm(\'' . sprintf(__d('net_commons', 'Deleting the %s. Are you sure to proceed?'), __d('links', 'Link')) . '\')'
+ )); ?>
+Form->end();
diff --git a/View/Elements/Links/edit_form.ctp b/View/Elements/Links/edit_form.ctp
new file mode 100644
index 0000000..20f2598
--- /dev/null
+++ b/View/Elements/Links/edit_form.ctp
@@ -0,0 +1,136 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Form->hidden('Block.id', array(
+ 'value' => $blockId,
+ )); ?>
+
+Form->hidden('Block.key', array(
+ 'value' => $blockKey,
+ )); ?>
+
+Form->hidden('Frame.id', array(
+ 'value' => $frameId,
+ )); ?>
+
+Form->hidden('Link.id', array(
+ 'value' => isset($link['id']) ? (int)$link['id'] : null,
+ )); ?>
+
+Form->hidden('Link.block_id', array(
+ 'value' => $blockId,
+ )); ?>
+
+Form->hidden('Link.key', array(
+ 'value' => $link['key'],
+ )); ?>
+
+Form->hidden('Link.language_id', array(
+ 'value' => $languageId,
+ )); ?>
+
+Form->hidden('LinkOrder.id', array(
+ 'value' => isset($linkOrder['id']) ? (int)$linkOrder['id'] : null,
+ )); ?>
+
+Form->hidden('LinkOrder.block_key', array(
+ 'value' => $blockKey,
+ )); ?>
+
+Form->hidden('LinkOrder.link_key', array(
+ 'value' => isset($link['key']) ? $link['key'] : null,
+ )); ?>
+
+
+
+
+
+ 0) : ?>
+
+
+
+ Form->input('Link.category_id', array(
+ 'label' => __d('categories', 'Category'),
+ 'type' => 'select',
+ 'error' => false,
+ 'class' => 'form-control',
+ 'empty' => array(0 => __d('categories', 'Select Category')),
+ 'options' => $categories,
+ 'value' => (isset($link['categoryId']) ? $link['categoryId'] : '0')
+ )); ?>
+
+
+
+
diff --git a/View/Elements/Links/edit_link.ctp b/View/Elements/Links/edit_link.ctp
new file mode 100644
index 0000000..07e1e7c
--- /dev/null
+++ b/View/Elements/Links/edit_link.ctp
@@ -0,0 +1,28 @@
+getLinks()
+ * - $frameId: frames.id
+ * - $userId: users.id
+ * - $contentEditable: Content editable status
+ *
+ * @author Noriko Arai
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+$editUrl = $this->Html->url(array(
+ 'controller' => 'links',
+ 'action' => 'edit',
+ $frameId,
+ $link['link']['key']
+ ));
+?>
+
+
+
+
+
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+
diff --git a/View/Elements/Links/index_list_only_title.ctp b/View/Elements/Links/index_list_only_title.ctp
new file mode 100644
index 0000000..daa6c80
--- /dev/null
+++ b/View/Elements/Links/index_list_only_title.ctp
@@ -0,0 +1,36 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+ $category) : ?>
+
+
+
+
+
+
+
+ $link) : ?>
+ -
+
+ element('Links/link', array('link' => $link)); ?>
+ element('Links/edit_link', array('link' => $link)); ?>
+
+
+
+
+
+
+
+
+
+
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+ $category) : ?>
+
+
+
+
+
+
+
+ $link) : ?>
+ -
+
+ element('Links/link', array('link' => $link)); ?>
+ element('Links/edit_link', array('link' => $link)); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+getLinks()
+ * - $linkFrameSetting: A result data of LinkFrameSetting->getLinkFrameSetting()
+ *
+ * @author Noriko Arai
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+
+ >
+
+
+
+
+
+
+
+
+
+
+ element('NetCommons.status_label',
+ array('status' => $link['link']['status'])); ?>
+
diff --git a/View/LinkFrameSettings/edit.ctp b/View/LinkFrameSettings/edit.ctp
new file mode 100644
index 0000000..54dfc16
--- /dev/null
+++ b/View/LinkFrameSettings/edit.ctp
@@ -0,0 +1,42 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+$categorySeparators = Hash::combine(LinkFrameSetting::$categorySeparators, '{n}.key', '{n}');
+$listStyles = Hash::combine(LinkFrameSetting::$listStyles, '{n}.key', '{n}');
+?>
+
+Html->css('/links/css/style.css', false); ?>
+Html->script('/links/js/links.js', false); ?>
+
+
+
+ element('NetCommons.setting_tabs', $settingTabs); ?>
+
+
+ element('Blocks.edit_form', array(
+ 'controller' => 'LinkFrameSettings',
+ 'action' => 'edit' . '/' . $frameId,
+ 'callback' => 'Links.LinkFrameSettings/edit_form',
+ 'cancelUrl' => '/' . $cancelUrl,
+ )); ?>
+
+
diff --git a/View/LinkOrders/edit.ctp b/View/LinkOrders/edit.ctp
new file mode 100644
index 0000000..94df24d
--- /dev/null
+++ b/View/LinkOrders/edit.ctp
@@ -0,0 +1,95 @@
+
+ * @author Ryo Ozawa
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Html->script('/links/js/links.js'); ?>
+
+
+
+
+
+
+
+
+ Form->create('LinkOrder', array('novalidate' => true)); ?>
+ Form->unlockField('LinkOrders'); ?>
+
+ Form->hidden('Block.id', array(
+ 'value' => $blockId,
+ )); ?>
+
+ Form->hidden('Block.key', array(
+ 'value' => $blockKey,
+ )); ?>
+
+
+
+
+
+
+ {{cate.category.name}}
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form->button(__d('net_commons', 'OK'), array(
+ 'class' => 'btn btn-primary btn-workflow',
+ 'name' => 'save',
+ )); ?>
+
+
+ Form->end(); ?>
+
+
diff --git a/View/Links/edit.ctp b/View/Links/edit.ctp
new file mode 100644
index 0000000..fa73a64
--- /dev/null
+++ b/View/Links/edit.ctp
@@ -0,0 +1,53 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Html->script('/links/js/links.js', false); ?>
+
+
+
+
+
+
+
+
+
+
+ Form->create('Link', array('novalidate' => true)); ?>
+
+
+ element('Links/edit_form'); ?>
+
+
+
+ element('Comments.form'); ?>
+
+
+
+ Form->end(); ?>
+
+ request->params['action'] === 'edit') : ?>
+
+
+
+
+ element('Comments.index'); ?>
+
+
+
diff --git a/View/Links/index.ctp b/View/Links/index.ctp
new file mode 100644
index 0000000..3fc9cc2
--- /dev/null
+++ b/View/Links/index.ctp
@@ -0,0 +1,59 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+$this->Token->unlockField('Link.id');
+$tokens = $this->Token->getToken($tokenFields, $hiddenFields);
+?>
+
+Html->css('/links/css/style.css', false); ?>
+Html->script('/links/js/links.js', false); ?>
+
+
+
+
+
+
+
+
+
+ element('Links/index_dropdown'); ?>
+
+
+ element('Links/index_list_only_title'); ?>
+
+
+ element('Links/index_list_with_description'); ?>
+
+
+
+
+
diff --git a/View/Links/view.ctp b/View/Links/view.ctp
new file mode 100644
index 0000000..dc6c684
--- /dev/null
+++ b/View/Links/view.ctp
@@ -0,0 +1,67 @@
+
+ * @author Shohei Nakajima
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+?>
+
+Html->script('/links/js/links.js', false); ?>
+
+
diff --git a/webroot/css/style.css b/webroot/css/style.css
new file mode 100644
index 0000000..3b443bf
--- /dev/null
+++ b/webroot/css/style.css
@@ -0,0 +1,41 @@
+/**
+ * links/css/style.css
+ *
+ * @author Takako Miyagawa
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+.nc-links-edit-anchor {
+ margin-left: 20px;
+}
+li.list-group-item.nc-links-li {
+ border: none;
+ padding: 0px;
+ display: list-item;
+}
+.nc-links-li {
+ margin-top: 8px;
+ margin-left: 30px;
+ margin-bottom: 15px;
+}
+li.nc-links-li > h3.nc-links-li-title {
+ margin-top: 0px;
+ margin-bottom: 2px;
+}
+
+hr.nc-links-edit-line {
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+.nc-input-dropdown .pull-left > hr.nc-links-edit-line {
+ min-width: 100px;
+ width: 250px;
+ max-width: 600px;
+}
+ul.nc-links-edit-mark {
+ padding-left: 20px;
+ margin-top: 0px;
+ margin-bottom: 0px;
+}
+
diff --git a/webroot/img/line/line_a1.gif b/webroot/img/line/line_a1.gif
new file mode 100644
index 0000000000000000000000000000000000000000..80de4a67aab11fe1c4edac6d26319545219c2c94
GIT binary patch
literal 49
zcmZ?wbhEHb=K
literal 0
HcmV?d00001
diff --git a/webroot/img/line/line_a2.gif b/webroot/img/line/line_a2.gif
new file mode 100644
index 0000000000000000000000000000000000000000..1a508356f4aa7fca0b42b24050519432cae47333
GIT binary patch
literal 49
zcmZ?wbhEHb*o2x2iNY|wfO)4|B63Z7#SFt8FUzc03^@A#5sqbQA}vs
JHA7YgYXBPJ5F`Kq
literal 0
HcmV?d00001
diff --git a/webroot/img/line/line_c2.gif b/webroot/img/line/line_c2.gif
new file mode 100644
index 0000000000000000000000000000000000000000..58fd20b5a9dcf5c88d80d2a7fd0e6a31c7a82e60
GIT binary patch
literal 56
zcmZ?wbhEHbWMyDwn8?hq^M2md7aKO-iTVHkzv538Mg|6E1|0?<0Le2jan6w!U}Ktg
J&5)JB8UP8f53>LO
literal 0
HcmV?d00001
diff --git a/webroot/img/line/line_c3.gif b/webroot/img/line/line_c3.gif
new file mode 100644
index 0000000000000000000000000000000000000000..6e21b28ca0f877e57ef789f904e058a405df6ef1
GIT binary patch
literal 56
zcmZ?wbhEHbWMyDwn8?gfbLQ~&`?qqA@A?1#zv538Mg|6E1|0?<0Le2jan6w!U}Ktg
J&5)JB8UPAV55WKc
literal 0
HcmV?d00001
diff --git a/webroot/img/line/line_c4.gif b/webroot/img/line/line_c4.gif
new file mode 100644
index 0000000000000000000000000000000000000000..c1e255c7667ba86d79d35db22631a8012e72cbec
GIT binary patch
literal 56
zcmZ?wbhEHbWMyDwn8?g}V)tWUvMR6EzUW
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_a2.gif b/webroot/img/mark/mark_a2.gif
new file mode 100644
index 0000000000000000000000000000000000000000..7061243c8ac11a514ba19c43349b5b484210fceb
GIT binary patch
literal 60
zcmZ?wbhEHbWM^P!n8?JSHu2AyGiUz)|Ifg{p!k!8k%57UK?leN%CZC5ye<0eSqC3P
NggACI6f!bc0{{*}5U&6L
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_a3.gif b/webroot/img/mark/mark_a3.gif
new file mode 100644
index 0000000000000000000000000000000000000000..ddb07987e678d4b4a0c5069105c0028c46dfdf17
GIT binary patch
literal 60
zcmZ?wbhEHbWM^P!n8?Jye~9hOnKS?Y|7T!eQ2fcl$iTqFpaWzBW!Zsj-WL7#tb-3C
MLL5693K>=3FtGQMovGUkC$(
FH2_KS3-|y4
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_b3.gif b/webroot/img/mark/mark_b3.gif
new file mode 100644
index 0000000000000000000000000000000000000000..2c058d12c94c8566c5f88ffff9af7e0d57623e2d
GIT binary patch
literal 53
zcmZ?wbhEHbWM^P!XkcXcpT_Y2|9{1wEQ|~cj0`#qKmd|qVB%>>=3FtGQMovGUkC$(
FH2`3W42A#z
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_c1.gif b/webroot/img/mark/mark_c1.gif
new file mode 100644
index 0000000000000000000000000000000000000000..72a110306ac7cf1b12b9bf0b53718dae733ec5a8
GIT binary patch
literal 53
zcmZ?wbhEHbWM^P!XkcXM>FN3Z|G(l-7DfgJMg|=QAOOiQF!A^#RIYgN_QoV{*-!=s
FYXEq^4m|(>
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_c2.gif b/webroot/img/mark/mark_c2.gif
new file mode 100644
index 0000000000000000000000000000000000000000..4eb3930e13f78997666224905467c58273115cab
GIT binary patch
literal 53
zcmZ?wbhEHbWM^P!XkcWJOxX1Q|9{1wEQ|~cj0`#qKmd|qVB+yfs9f>j?Tty^vY`wN
F)&OO<4a5Kd
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_c3.gif b/webroot/img/mark/mark_c3.gif
new file mode 100644
index 0000000000000000000000000000000000000000..e284895a470940031fcfdd1f5e6c3a2d1481e8e8
GIT binary patch
literal 53
zcmZ?wbhEHbWM^P!XkcW}DNFwU|G(l-7DfgJAddkEKr#$WJU$7PD;~VPG09stl!3t-
E0ANoIo&W#<
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_c4.gif b/webroot/img/mark/mark_c4.gif
new file mode 100644
index 0000000000000000000000000000000000000000..80d71a50af8e425a4ec6be8511184d8656c3b9b3
GIT binary patch
literal 53
zcmZ?wbhEHbWM^P!XkcVmV`2LL|9{1wEQ|~cj0`#qKmd|qVB+yfs9f>j?Tty^vY`wN
F)&OJ)4YB|L
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_d1.gif b/webroot/img/mark/mark_d1.gif
new file mode 100644
index 0000000000000000000000000000000000000000..336a498f3ee4111e9784f731a8a8c5f2e522ba04
GIT binary patch
literal 102
zcmZ?wbhEHb?00YIJEMQs(M1s^ZFl$Tf
yI`hduOtoQe`2}x-3y!IRvD?00YIJEMQs(M1s^ZFl$Tf
yI`hduOtoQe`2}x-3y!IRvDM1s^ZFsn=KS|g%x
qij!r@m2-_-W$rw2O_1ny$Xv9vV&b!(%kK7smbr7(y#LI}U=08o5g$ze
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_d4.gif b/webroot/img/mark/mark_d4.gif
new file mode 100644
index 0000000000000000000000000000000000000000..a199c3a50ae59bc9249123c17f486d6bf5fa7705
GIT binary patch
literal 98
zcmZ?wbhEHb?=PFm00W9YS-?yk5D8Mtz^tyZYmJJ+
qDNd#(SI#wVmAUi8H9?}+A#>5viiyvDF1y+{a&ozv>i_@$CjM1s^ZFsn=KS|g%x
qij!r@m2-_-W$rw2O_1ny$Xv9vV&b!(%kK7smbr7(y#LI}U=08m^dCV0
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_e1.gif b/webroot/img/mark/mark_e1.gif
new file mode 100644
index 0000000000000000000000000000000000000000..91d67b1c10cf885a175da4c29e53b12056085931
GIT binary patch
literal 196
zcmV;#06YIjNk%w1VG{ro0J9DN_2kI++N%GrDD>&p`Ob#;(T@JLJo(Rv{NdH_2b05>aD4ek3bszca3;V`3;;?Q9n6edK)qzHTh$dbi$_(%?>i>YH}m@p>m#FW{J
yy(JA*j4f@LP7l36h4zW3sd3y?h`welR%>EQ1X(A0c*0DPlhs7#bWO5db^ZI9Kri
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_e2.gif b/webroot/img/mark/mark_e2.gif
new file mode 100644
index 0000000000000000000000000000000000000000..9500204375fa9502e59c2a66afb80d9846d9059f
GIT binary patch
literal 196
zcmV;#06YIjNk%w1VG{ro0J9DN=jiL-;^n@@&cevi%+c7^+TX*;(%0JG>+J2s%G1u$
z+1T6Q=IH9Z#LoZ!{{R30A^8LW000gEEC2ui022Tc000DW&`HS_F~X3=rgum&G-TNf
z1@Zxk>5>XCA?^Drs#Dl};V`38;?Q9n5~e}Lln8tR$dbi$_(%?>i>YH}m@p>m#FW{J
yy(JA*j4f@LP7l36h4zW3sd3y?h`welR%>EQ1X(A0c*0DPlhs7#bWO5db?96I*!z
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_e3.gif b/webroot/img/mark/mark_e3.gif
new file mode 100644
index 0000000000000000000000000000000000000000..e3fed11c8bcd4001b9e16ec83e14ad1b249d1d72
GIT binary patch
literal 196
zcmV;#06YIjNk%w1VG{ro0J9DN}Rs<
zY|HMU;_%R^>skN*{{R30A^8LW000gEEC2ui022Tc000DW&`HUN8Dbd1rgz1XG-TN%
zOYs4S>5>RA747>Xsi>YH}m@p>m#FW{J
yy(JA*j4f@LP7l36h4zW3sd3y?h`welR%>EQ1X(A0c*0DPlhs7#bWO5db@}Ray=J
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_e4.gif b/webroot/img/mark/mark_e4.gif
new file mode 100644
index 0000000000000000000000000000000000000000..231f793d4b4e45784da4e27b82866640618ad02f
GIT binary patch
literal 196
zcmV;#06YIjNk%w1VG{ro0J9DN%iGVd%(gd%N=lJiO_N=ax|&9hSCze=YNUABAG-TNr
zO7a1V>5>aDCGGnzs-xJv;xMBUq0nIz2qr_tLYH}m@p>m#FW{J
yy(JA*j4f@LP7l36h4zW3sd3y?h`welR%>EQ1X(A0c*0DPlhs7#bWO5db^pDNo7(
literal 0
HcmV?d00001
diff --git a/webroot/img/mark/mark_e5.gif b/webroot/img/mark/mark_e5.gif
new file mode 100644
index 0000000000000000000000000000000000000000..97076fbcdc2dcfa406901b28af86d8227c33b598
GIT binary patch
literal 196
zcmV;#06YIjNk%w1VG{ro0J9DN;mp_8vcsc4aJzPw$datfnX$QWlgX5>=h@(?O?s?U
zf2&b^;L6mZJ#PR1{{R30A^8LW000gEEC2ui022Tc000DW&`HUPSz?*OrgsRDG-TN%
z1o8oc>5>C5A?^DPszca3;V`3;;?Q9n6sAPQqzHTh$dbi$_(%?>i>YH}m@p>m#FW{J
yy(JA*j4f@LP7l36h4zW3sd3y?h`welR%>EQ1X(A0c*0DPlhs7#bWO5db^a|5G#o
literal 0
HcmV?d00001
diff --git a/webroot/js/links.js b/webroot/js/links.js
new file mode 100644
index 0000000..5a1c309
--- /dev/null
+++ b/webroot/js/links.js
@@ -0,0 +1,224 @@
+/**
+ * @fileoverview Links Javascript
+ * @author nakajimashouhei@gmail.com (Shohei Nakajima)
+ */
+
+
+/**
+ * LinksIndex Javascript
+ *
+ * @param {string} Controller name
+ * @param {function($scope, $http, $window)} Controller
+ */
+NetCommonsApp.controller('LinksIndex', function($scope, $http, $window) {
+
+ /**
+ * data
+ *
+ * @type {object}
+ */
+ $scope.data = {};
+
+ /**
+ * initialize
+ *
+ * @return {void}
+ */
+ $scope.initialize = function(data) {
+ $scope.frameId = data.frameId;
+
+ $scope.data = {
+ _Token: data['_Token'],
+ Frame: {id: data['frameId']},
+ Link: {id: ''}
+ };
+ };
+
+ /**
+ * Click link
+ *
+ * @param {integer} links.id
+ * @return {void}
+ */
+ $scope.clickLink = function($event, id, key) {
+ $scope.data.Link.id = id;
+
+ $http.get('/net_commons/net_commons/csrfToken.json')
+ .success(function(token) {
+ $scope.data._Token.key = token.data._Token.key;
+
+ //POSTリクエスト
+ $http.post(
+ '/links/links/link/' + $scope.frameId + '/' + key + '.json',
+ $.param({_method: 'POST', data: $scope.data}),
+ {cache: false,
+ headers:
+ {'Content-Type': 'application/x-www-form-urlencoded'}
+ }
+ ).success(function() {
+ var element = $('#nc-badge-' + $scope.frameId + '-' + id);
+ if (element) {
+ var count = parseInt(element.html()) + 1;
+ element.html(count);
+ }
+ if ($event.target.target) {
+ $window.open($event.target.href, $event.target.target);
+ } else {
+ $window.location.href = $event.target.href;
+ }
+ });
+ });
+ };
+});
+
+
+/**
+ * LinksEdit Javascript
+ *
+ * @param {string} Controller name
+ * @param {function($scope, $http)} Controller
+ */
+NetCommonsApp.controller('LinksEdit', function($scope, $http) {
+
+ /**
+ * initialize
+ *
+ * @return {void}
+ */
+ $scope.initialize = function(data) {
+ $scope.link = data.link;
+ $scope.frameId = data.frameId;
+ $scope.action = data.action;
+ };
+
+ /**
+ * Get url
+ *
+ * @return {void}
+ */
+ $scope.getUrl = function() {
+ var element = $('input[name="data[Link][url]"]');
+
+ $http.get('/links/links/get/' + $scope.frameId + '.json',
+ {params: {url: element[0].value}})
+ .success(function(data) {
+ element = $('input[name="data[Link][title]"]');
+ if (! angular.isUndefined(element[0]) &&
+ ! angular.isUndefined(data['title'])) {
+ element[0].value = data['title'];
+ }
+
+ element = $('textarea[name="data[Link][description]"]');
+ if (! angular.isUndefined(element[0]) &&
+ ! angular.isUndefined(data['description'])) {
+ element[0].value = data['description'];
+ }
+
+ $scope.urlError = '';
+ })
+ .error(function(data) {
+ $scope.urlError =
+ angular.isUndefined(data['error']) ? data['name'] : data['error'];
+ });
+ };
+
+});
+
+
+/**
+ * LinksEdit Javascript
+ *
+ * @param {string} Controller name
+ * @param {function($scope)} Controller
+ */
+NetCommonsApp.controller('LinkFrameSettings', function($scope) {
+
+ /**
+ * initialize
+ *
+ * @return {void}
+ */
+ $scope.initialize = function(data) {
+ $scope.linkFrameSetting = data.linkFrameSetting;
+ $scope.frameId = data.frameId;
+ $scope.currentCategorySeparatorLine = data.currentCategorySeparatorLine;
+ $scope.currentListStyle = data.currentListStyle;
+ };
+
+ /**
+ * Select categorySeparatorLine
+ *
+ * @return {void}
+ */
+ $scope.selectCategorySeparatorLine = function(line) {
+ $scope.linkFrameSetting.categorySeparatorLine = line.key;
+ $scope.currentCategorySeparatorLine = line;
+ };
+
+ /**
+ * Select listStyle
+ *
+ * @return {void}
+ */
+ $scope.selectListStyle = function(mark) {
+ $scope.linkFrameSetting.listStyle = mark.key;
+ $scope.currentListStyle = mark;
+ };
+
+});
+
+
+/**
+ * LinkOrders Javascript
+ *
+ * @param {string} Controller name
+ * @param {function($scope)} Controller
+ */
+NetCommonsApp.controller('LinkOrders', function($scope) {
+
+ /**
+ * Links
+ *
+ * @type {object}
+ */
+ $scope.links = {};
+
+ /**
+ * Categories
+ *
+ * @type {object}
+ */
+ $scope.categories = [];
+
+ /**
+ * initialize
+ *
+ * @return {void}
+ */
+ $scope.initialize = function(data) {
+ angular.forEach(data.categories, function(value) {
+ $scope.categories.push(value);
+ });
+ $scope.links = data.links;
+ };
+
+ /**
+ * move
+ *
+ * @return {void}
+ */
+ $scope.move = function(categoryId, type, index) {
+ index = index + 1;
+
+ var dest = (type === 'up') ? index - 1 : index + 1;
+ if (angular.isUndefined($scope.links[categoryId][dest])) {
+ return false;
+ }
+
+ var destLink = angular.copy($scope.links[categoryId][dest]);
+ var targetLink = angular.copy($scope.links[categoryId][index]);
+ $scope.links[categoryId][index] = destLink;
+ $scope.links[categoryId][dest] = targetLink;
+ };
+
+});
From 8f0ea6ac848e9aaa523b0f53f0cf91e82807e1bc Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Tue, 5 May 2015 19:40:11 +0900
Subject: [PATCH 004/274] Add plugins in composer.json
---
composer.json | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index aa52a89..3d33016 100644
--- a/composer.json
+++ b/composer.json
@@ -17,8 +17,19 @@
"require-dev": {
"mustangostang/spyc": "dev-master",
"satooshi/php-coveralls": "dev-master",
- "netcommons/net-commons": "dev-master",
+ "netcommons/auth": "dev-master",
+ "netcommons/auth-general": "dev-master",
+ "netcommons/boxes": "dev-master",
+ "netcommons/blocks": "dev-master",
+ "netcommons/categories": "dev-master",
+ "netcommons/comments": "dev-master",
+ "netcommons/containers": "dev-master",
"netcommons/frames": "dev-master",
+ "netcommons/install": "dev-master",
+ "netcommons/m17n": "dev-master",
+ "netcommons/net-commons": "dev-master",
+ "netcommons/roles": "dev-master",
+ "netcommons/rooms": "dev-master",
"netcommons/pages": "dev-master",
"netcommons/users": "dev-master"
},
From de8d90ec9c1af72085e3ae9a5ede5d7614c4bbc2 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 6 May 2015 01:13:34 +0900
Subject: [PATCH 005/274] Fix i18n
---
Locale/jpn/LC_MESSAGES/links.mo | Bin 0 -> 1671 bytes
Locale/jpn/LC_MESSAGES/links.po | 109 ++++++++++++++++++++++++++++++
Locale/links.pot | 114 ++++++++++++++++++++++++++++++++
View/Blocks/index.ctp | 6 +-
4 files changed, 226 insertions(+), 3 deletions(-)
create mode 100644 Locale/jpn/LC_MESSAGES/links.mo
create mode 100644 Locale/jpn/LC_MESSAGES/links.po
create mode 100644 Locale/links.pot
diff --git a/Locale/jpn/LC_MESSAGES/links.mo b/Locale/jpn/LC_MESSAGES/links.mo
new file mode 100644
index 0000000000000000000000000000000000000000..5b0c8a189c15b211af94f11bf080cd835fc18b40
GIT binary patch
literal 1671
zcmZvbT}&KR6vwZMwq3tlzhattn^*(3gG&vyF2%^llwkHNyW6ITPXl{_fn{bhb17hA
z!pxKwD3w~n(iDSjL@-n<2{pDAYhvQ7Pn!6oF_&4`S0DT2|ITh$qTcMizd7fgd(OH4
zoBd;N%`Cxq5pzH0ub8i3PCtYNWB0>^>;dSUS@-vf{U_K8`|pas5lIffJ^{+S?}PFj178A1z~{k_!I!~h
zP{#jM+5ZcC0`>#&Rd5%I$@n9n^tXcYTmqCj^jG{JfECHfF8F0ET!AJ)przCS*V-N^
z5oq-SC^eLN>>RRhIpq7ux0Cf`FOZHri7EAwca*x4TEnC{-C%X3%^Wf~J*%@}(q=J@
zGwB~7?ac1B^gP#1gS6{*KBtY+LB{*cEIFy^IhLi|q-Gb_bc6CfM!C*&jP{roEZwGg
zt(Vo4j>JI{MHRUW1PhJoHZOnW@I^E77>Q}t0JBJ(4bxWB92kTd1kyt`i3g1i)RRP>
z8C0{WMh(Pqt&60!!8}f_=XuGpn3tmJJ~yG?_}gr?zG2X*HGZOvFRUL`Dfz!>-Z}@gnqSxS>%A
z%O7ocGjcS1IE;ZnCB@F_GRwc?j?r*9(%5h~{5ImEn$4Arr5Sck?d>Twoqh*VM(+?5Rx(T*jL>LHyyH|$$A9BuoiVlAd_#RW)Mgr-87MKDN3WcX
z@Hg5wJ8O$nQD`~Q<&S^vaTlI}0QoH%xHQ}rXXReM2
zZ$)@(!u`e{pYUhg&GBV_exW$KDx6zeH@@6lyjP8YYvYGcixZd0*2-7Ks~?eaK(TPQ
zxHemI?i8mMh(G>?KQ)ic!ujk}Dk_|d!krZEkHTFP-h}XO3ipaXQ}FL2U|BeqgmYgw
z^TPckFy$#y-X_AmDZKN-y^Rh_1?=DQr|7_N!f0zvNZiyD0NNF8}hS&E?f#
zBM1@Rg7DUZ8tbH3SlwEh*;ZmZ5B?5Sr!y@aSGZHvj>lYiGPvtGc}1^)OOy&1g)@Wh
zzm>9jbGY)3B<_{6PQjri1PbT6aAt*b4ndQ``&xKjaA-`pOGrRA?u>0MEmvM*r%_ve
bgN^U6LdCkuQ
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2015-05-05 13:20+0000\n"
+"PO-Revision-Date: 2015-05-06 00:51+0900\n"
+"Last-Translator: NAME \n"
+"Language-Team: LANGUAGE \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+"X-Generator: Poedit 1.7.5\n"
+
+#: Links/Controller/BlocksController.php:131
+msgid "New Bookmark List %s"
+msgstr "新規リンクリスト%s"
+
+#: Links/Controller/LinksController.php:150;155
+msgid "Failed to obtain the title for this page."
+msgstr "入力したURLからタイトルを取得できませんでした"
+
+#: Links/Model/Link.php:125;131 Links/View/Elements/Links/edit_form.ctp:55
+#: Links/View/Links/view.ctp:26
+msgid "URL"
+msgstr ""
+
+#: Links/Model/Link.php:139 Links/View/Elements/Links/edit_form.ctp:93
+#: Links/View/Links/view.ctp:37
+msgid "Title"
+msgstr "タイトル"
+
+#: Links/Model/LinkFrameSetting.php:95
+msgid "(no line)"
+msgstr "(線なし)"
+
+#: Links/View/Blocks/index.ctp:37 Links/View/Elements/Blocks/edit_form.ctp:46
+msgid "Link list Title"
+msgstr "リンクリスト名称"
+
+#: Links/View/Elements/Blocks/delete_form.ctp:14;25
+msgid "Link List"
+msgstr "リンクリスト"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:32
+msgid "Display method"
+msgstr "表示方法選択"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:37
+msgid "Show by dropdown"
+msgstr "ドロップダウン"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:38
+msgid "Show list"
+msgstr "一覧表示"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:39
+msgid "Show list (Description)"
+msgstr "一覧表示(説明付き)"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:47
+msgid "Open as a new tab"
+msgstr "新しいタブで開く"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:56
+msgid "Count view"
+msgstr "リンク先参照回数の表示"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:65
+msgid "Line"
+msgstr "カテゴリ間の区切り線"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:106
+msgid "Marker"
+msgstr "リストマーカー"
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:122;142
+msgid "Sample"
+msgstr "サンプル"
+
+#: Links/View/Elements/Links/delete_form.ctp:38
+msgid "Link"
+msgstr "リンク"
+
+#: Links/View/Elements/Links/edit_form.ctp:70
+msgid "GO!"
+msgstr "取得"
+
+#: Links/View/Elements/Links/edit_form.ctp:129 Links/View/Links/view.ctp:57
+msgid "Description"
+msgstr "説明"
+
+#: Links/View/Elements/Links/index_dropdown.ctp:17
+msgid "Select link to show"
+msgstr "リンクを選択してください"
+
+#: Links/View/LinkOrders/edit.ctp:35
+msgid "No link."
+msgstr "リンクがありません。"
+
+#: Links/View/Links/index.ctp:30
+msgid "Sort link"
+msgstr "表示順変更"
+
+#: Links/View/Links/index.ctp:37
+msgid "Create link"
+msgstr "リンクの作成"
diff --git a/Locale/links.pot b/Locale/links.pot
new file mode 100644
index 0000000..3dced4a
--- /dev/null
+++ b/Locale/links.pot
@@ -0,0 +1,114 @@
+# LANGUAGE translation of CakePHP Application
+# Copyright YEAR NAME
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2015-05-05 15:03+0000\n"
+"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
+"Last-Translator: NAME \n"
+"Language-Team: LANGUAGE \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+
+#: Links/Controller/BlocksController.php:131
+msgid "New Bookmark List %s"
+msgstr ""
+
+#: Links/Controller/LinksController.php:150;155
+msgid "Failed to obtain the title for this page."
+msgstr ""
+
+#: Links/Model/Link.php:125;131
+#: Links/View/Elements/Links/edit_form.ctp:55
+#: Links/View/Links/view.ctp:26
+msgid "URL"
+msgstr ""
+
+#: Links/Model/Link.php:139
+#: Links/View/Elements/Links/edit_form.ctp:93
+#: Links/View/Links/view.ctp:37
+msgid "Title"
+msgstr ""
+
+#: Links/Model/LinkFrameSetting.php:95
+msgid "(no line)"
+msgstr ""
+
+#: Links/View/Blocks/index.ctp:37
+#: Links/View/Elements/Blocks/edit_form.ctp:46
+msgid "Link list Title"
+msgstr ""
+
+#: Links/View/Elements/Blocks/delete_form.ctp:14;25
+msgid "Link List"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:32
+msgid "Display method"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:37
+msgid "Show by dropdown"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:38
+msgid "Show list"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:39
+msgid "Show list (Description)"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:47
+msgid "Open as a new tab"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:56
+msgid "Count view"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:65
+msgid "Line"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:106
+msgid "Marker"
+msgstr ""
+
+#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:122;142
+msgid "Sample"
+msgstr ""
+
+#: Links/View/Elements/Links/delete_form.ctp:38
+msgid "Link"
+msgstr ""
+
+#: Links/View/Elements/Links/edit_form.ctp:70
+msgid "GO!"
+msgstr ""
+
+#: Links/View/Elements/Links/edit_form.ctp:129
+#: Links/View/Links/view.ctp:57
+msgid "Description"
+msgstr ""
+
+#: Links/View/Elements/Links/index_dropdown.ctp:17
+msgid "Select link to show"
+msgstr ""
+
+#: Links/View/LinkOrders/edit.ctp:35
+msgid "No link."
+msgstr ""
+
+#: Links/View/Links/index.ctp:30
+msgid "Sort link"
+msgstr ""
+
+#: Links/View/Links/index.ctp:37
+msgid "Create link"
+msgstr ""
+
diff --git a/View/Blocks/index.ctp b/View/Blocks/index.ctp
index 2aa02b7..727eca9 100644
--- a/View/Blocks/index.ctp
+++ b/View/Blocks/index.ctp
@@ -37,10 +37,10 @@
Paginator->sort('Link.name', __d('links', 'Link list Title')); ?>
|
- Paginator->sort('Block.public_type', __d('links', 'Public Type')); ?>
+ Paginator->sort('Block.public_type', __d('blocks', 'Publishing setting')); ?>
|
- Paginator->sort('Block.modified', __d('links', 'Updated Date')); ?>
+ Paginator->sort('Block.modified', __d('net_commons', 'Updated date')); ?>
|
@@ -72,7 +72,7 @@
-
+
From 794c08ebc8688cded16b5bcb88748a83e6134fe3 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 6 May 2015 10:00:25 +0900
Subject: [PATCH 006/274] Fixed phpdoc comment
---
Model/LinkBlock.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Model/LinkBlock.php b/Model/LinkBlock.php
index 6d58886..d342a8d 100644
--- a/Model/LinkBlock.php
+++ b/Model/LinkBlock.php
@@ -1,6 +1,6 @@
* @package NetCommons\Blocks\Model
From 9f274f8539f0bfa073ab460ce785b0d6621fcfbf Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 8 May 2015 11:05:34 +0900
Subject: [PATCH 007/274] Add ng-cloak
---
View/Elements/Links/edit_form.ctp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/View/Elements/Links/edit_form.ctp b/View/Elements/Links/edit_form.ctp
index 20f2598..d9e30ea 100644
--- a/View/Elements/Links/edit_form.ctp
+++ b/View/Elements/Links/edit_form.ctp
@@ -79,7 +79,7 @@
'field' => 'url',
]); ?>
-
+
{{urlError}}
From 458fbda6a27c9c52819d4210abccbb8f15ce654d Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 8 May 2015 18:52:09 +0900
Subject: [PATCH 008/274] Fix to blockPermissionEditable from
permissionEditable.
---
Controller/BlockRolePermissionsController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Controller/BlockRolePermissionsController.php b/Controller/BlockRolePermissionsController.php
index f59165d..e82b437 100644
--- a/Controller/BlockRolePermissionsController.php
+++ b/Controller/BlockRolePermissionsController.php
@@ -44,7 +44,7 @@ class BlockRolePermissionsController extends LinksAppController {
'NetCommons.NetCommonsRoomRole' => array(
//コンテンツの権限設定
'allowedActions' => array(
- 'permissionEditable' => array('edit')
+ 'blockPermissionEditable' => array('edit')
),
),
);
From c6a05e06432592dacdeb3da37e19be24d2398ebb Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 9 May 2015 22:02:46 +0900
Subject: [PATCH 009/274] Fix of category specification changes
---
Controller/CategoriesController.php | 78 -----------------------------
Model/LinkBlock.php | 25 +++++++--
View/Categories/edit.ctp | 25 ---------
View/Elements/Blocks/edit_form.ctp | 8 ++-
4 files changed, 23 insertions(+), 113 deletions(-)
delete mode 100644 Controller/CategoriesController.php
delete mode 100644 View/Categories/edit.ctp
diff --git a/Controller/CategoriesController.php b/Controller/CategoriesController.php
deleted file mode 100644
index 84ddb4e..0000000
--- a/Controller/CategoriesController.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
- * @author Shohei Nakajima
- * @link http://www.netcommons.org NetCommons Project
- * @license http://www.netcommons.org/license.txt NetCommons License
- * @copyright Copyright 2014, NetCommons Project
- */
-
-App::uses('LinksAppController', 'Links.Controller');
-
-/**
- * Categories Controller
- *
- * @author Shohei Nakajima
- * @package NetCommons\Links\Controller
- */
-class CategoriesController extends LinksAppController {
-
-/**
- * use model
- *
- * @var array
- */
- public $uses = array(
- 'Categories.Category',
- );
-
-/**
- * use components
- *
- * @var array
- */
- public $components = array(
- 'NetCommons.NetCommonsFrame',
- 'NetCommons.NetCommonsBlock',
- 'NetCommons.NetCommonsRoomRole' => array(
- //コンテンツの権限設定
- 'allowedActions' => array(
- 'blockEditable' => array('edit')
- ),
- ),
- 'Categories.Categories',
- );
-
-/**
- * beforeFilter
- *
- * @return void
- */
- public function beforeFilter() {
- parent::beforeFilter();
-
- $this->layout = 'NetCommons.setting';
- $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
- $this->set($results);
-
- //タブの設定
- $this->initTabs('block_index', 'block_settings');
- }
-
-/**
- * edit
- *
- * @return void
- */
- public function edit() {
- //blockId取得
- if (! $this->NetCommonsBlock->validateBlockId()) {
- $this->throwBadRequest();
- return false;
- }
- $this->set('blockId', (int)$this->params['pass'][1]);
- $this->Categories->edit();
- }
-}
diff --git a/Model/LinkBlock.php b/Model/LinkBlock.php
index d342a8d..9b27ef3 100644
--- a/Model/LinkBlock.php
+++ b/Model/LinkBlock.php
@@ -86,6 +86,7 @@ public function getLinkBlock($blockId, $roomId) {
public function saveLinkBlock($data) {
$this->loadModels([
'LinkSetting' => 'Links.LinkSetting',
+ 'Category' => 'Categories.Category',
'Block' => 'Blocks.Block',
'Frame' => 'Frames.Frame',
]);
@@ -97,19 +98,22 @@ public function saveLinkBlock($data) {
try {
//バリデーション
- if (! $this->validateLinkBlock($data, ['linkSetting'])) {
+ if (! $data = $this->validateLinkBlock($data, ['linkSetting', 'category'])) {
return false;
}
- //ブロックの登録
+ //登録処理
$block = $this->Block->saveByFrameId($data['Frame']['id']);
- //登録処理
$this->LinkSetting->data['LinkSetting']['block_key'] = $block['Block']['key'];
if (! $this->LinkSetting->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
+ $data['Block']['id'] = (int)$block['Block']['id'];
+ $data['Block']['key'] = $block['Block']['key'];
+ $this->Category->saveCategories($data);
+
//トランザクションCommit
$dataSource->commit();
@@ -128,7 +132,7 @@ public function saveLinkBlock($data) {
*
* @param array $data received post data
* @param array $contains Optional validate sets
- * @return bool True on success, false on validation errors
+ * @return mixed Array on success, false on validation errors
*/
public function validateLinkBlock($data, $contains = []) {
if (! $this->Block->validateBlock($data)) {
@@ -142,7 +146,18 @@ public function validateLinkBlock($data, $contains = []) {
return false;
}
}
- return true;
+
+ if (in_array('category', $contains, true)) {
+ if (! isset($data['Categories'])) {
+ $data['Categories'] = [];
+ }
+ if (! $data = $this->Category->validateCategories($data)) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->Category->validationErrors);
+ return false;
+ }
+ }
+
+ return $data;
}
/**
diff --git a/View/Categories/edit.ctp b/View/Categories/edit.ctp
deleted file mode 100644
index d8713c3..0000000
--- a/View/Categories/edit.ctp
+++ /dev/null
@@ -1,25 +0,0 @@
-
- * @author Shohei Nakajima
- * @link http://www.netcommons.org NetCommons Project
- * @license http://www.netcommons.org/license.txt NetCommons License
- * @copyright Copyright 2014, NetCommons Project
- */
-?>
-
-
- element('NetCommons.setting_tabs', $settingTabs); ?>
-
-
- element('Blocks.setting_tabs', $blockSettingTabs); ?>
-
- element('Categories.edit_form', array(
- 'cancelUrl' => '/links/blocks/' . h($this->request->params['action']) . '/' . $frameId . '/' . $blockId,
- )); ?>
-
-
-
-
diff --git a/View/Elements/Blocks/edit_form.ctp b/View/Elements/Blocks/edit_form.ctp
index fc34c4d..040c66e 100644
--- a/View/Elements/Blocks/edit_form.ctp
+++ b/View/Elements/Blocks/edit_form.ctp
@@ -64,8 +64,6 @@
element('Blocks.public_type'); ?>
-request->params['action'] === 'edit') : ?>
- element('Categories.index', array(
- 'categories' => $categories
- )); ?>
-element('Categories.edit_form', array(
+ 'categories' => isset($categories) ? $categories : null
+ ));
From b71ccf57c053b55768713f0271580150f28a6f80 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sun, 10 May 2015 15:23:38 +0900
Subject: [PATCH 010/274] Fix to list hedear.
---
View/Blocks/index.ctp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/View/Blocks/index.ctp b/View/Blocks/index.ctp
index 727eca9..e6741d2 100644
--- a/View/Blocks/index.ctp
+++ b/View/Blocks/index.ctp
@@ -32,7 +32,7 @@
- | # |
+ |
Paginator->sort('Link.name', __d('links', 'Link list Title')); ?>
|
@@ -67,11 +67,11 @@
-
+
-
+
-
+
|
From 40f34e9127265ca1b7daa89c7edffc092ef05e02 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 11 May 2015 14:02:56 +0900
Subject: [PATCH 011/274] Fix i18n
---
Locale/jpn/LC_MESSAGES/links.mo | Bin 1671 -> 1666 bytes
Locale/jpn/LC_MESSAGES/links.po | 6 +++---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Locale/jpn/LC_MESSAGES/links.mo b/Locale/jpn/LC_MESSAGES/links.mo
index 5b0c8a189c15b211af94f11bf080cd835fc18b40..ad5dec8eccad3e5745a10d733560e9cfbfc7fde5 100644
GIT binary patch
delta 243
zcmZqYZQ`A9r9PXHfkB6vfq|QWfnf#<1A{b>UIL_rfb;<%%?6||L;1IWv=fm37AkJQ
z%D^B8snO)w%-`kA^b8HS7&M-5
fpY^zL)#JwLnhcMd)<14u^|-ki$k@D<xy%?6}zK>7E9v=fm32`X;N
z%D^B8{fEU0+Z=1xW~CJqBL1p@;sQ^U!#nZGNW>zQ&fXguFO
m>v7|%$Bol986G#UdfdGEant&ztsPJMo1V8W-@Jk45+eYSaxAd`
diff --git a/Locale/jpn/LC_MESSAGES/links.po b/Locale/jpn/LC_MESSAGES/links.po
index 7ebf712..05101df 100644
--- a/Locale/jpn/LC_MESSAGES/links.po
+++ b/Locale/jpn/LC_MESSAGES/links.po
@@ -5,14 +5,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2015-05-05 13:20+0000\n"
-"PO-Revision-Date: 2015-05-06 00:51+0900\n"
+"PO-Revision-Date: 2015-05-11 12:52+0900\n"
"Last-Translator: NAME \n"
"Language-Team: LANGUAGE \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-"X-Generator: Poedit 1.7.5\n"
+"X-Generator: Poedit 1.6.10\n"
#: Links/Controller/BlocksController.php:131
msgid "New Bookmark List %s"
@@ -66,7 +66,7 @@ msgstr "新しいタブで開く"
#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:56
msgid "Count view"
-msgstr "リンク先参照回数の表示"
+msgstr "クリック回数の表示"
#: Links/View/Elements/LinkFrameSettings/edit_form.ctp:65
msgid "Line"
From d65a1e0a9110d48a83807b65e68c616f5d69e69e Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 11 May 2015 14:03:15 +0900
Subject: [PATCH 012/274] Fix for core codes can add custom tabs
---
Controller/LinksAppController.php | 44 ++++++++++++++++++-------------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
index b92b644..5f50196 100644
--- a/Controller/LinksAppController.php
+++ b/Controller/LinksAppController.php
@@ -113,16 +113,20 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
$settingTabs = array(
'tabs' => array(
'block_index' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'blocks',
- 'action' => 'index',
- $this->viewVars['frameId'],
+ 'url' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'blocks',
+ 'action' => 'index',
+ $this->viewVars['frameId'],
+ )
),
'frame_settings' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'link_frame_settings',
- 'action' => 'edit',
- $this->viewVars['frameId'],
+ 'url' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'link_frame_settings',
+ 'action' => 'edit',
+ $this->viewVars['frameId'],
+ )
),
),
'active' => $mainActiveTab
@@ -132,18 +136,22 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
$blockSettingTabs = array(
'tabs' => array(
'block_settings' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'blocks',
- 'action' => $this->params['action'],
- $this->viewVars['frameId'],
- $this->viewVars['blockId']
+ 'url' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'blocks',
+ 'action' => $this->params['action'],
+ $this->viewVars['frameId'],
+ $this->viewVars['blockId']
+ )
),
'role_permissions' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'block_role_permissions',
- 'action' => 'edit',
- $this->viewVars['frameId'],
- $this->viewVars['blockId']
+ 'url' => array(
+ 'plugin' => $this->params['plugin'],
+ 'controller' => 'block_role_permissions',
+ 'action' => 'edit',
+ $this->viewVars['frameId'],
+ $this->viewVars['blockId']
+ )
),
),
'active' => $blockActiveTab
From 4dd6eccaecdd5a019039196c94161db231681add Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 11 May 2015 14:36:19 +0900
Subject: [PATCH 013/274] Fix the layout value to class variable from
beforeFilter
---
Controller/BlockRolePermissionsController.php | 8 +++++++-
Controller/BlocksController.php | 8 +++++++-
Controller/LinkFrameSettingsController.php | 8 +++++++-
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Controller/BlockRolePermissionsController.php b/Controller/BlockRolePermissionsController.php
index e82b437..e6ba6dd 100644
--- a/Controller/BlockRolePermissionsController.php
+++ b/Controller/BlockRolePermissionsController.php
@@ -19,6 +19,13 @@
*/
class BlockRolePermissionsController extends LinksAppController {
+/**
+ * layout
+ *
+ * @var array
+ */
+ public $layout = 'NetCommons.setting';
+
/**
* use models
*
@@ -57,7 +64,6 @@ class BlockRolePermissionsController extends LinksAppController {
public function beforeFilter() {
parent::beforeFilter();
- $this->layout = 'NetCommons.setting';
$results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
$this->set($results);
diff --git a/Controller/BlocksController.php b/Controller/BlocksController.php
index 7156f07..7055fa4 100644
--- a/Controller/BlocksController.php
+++ b/Controller/BlocksController.php
@@ -19,6 +19,13 @@
*/
class BlocksController extends LinksAppController {
+/**
+ * layout
+ *
+ * @var array
+ */
+ public $layout = 'NetCommons.setting';
+
/**
* use models
*
@@ -67,7 +74,6 @@ public function beforeFilter() {
parent::beforeFilter();
$this->Auth->deny('index');
- $this->layout = 'NetCommons.setting';
$results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
$this->set($results);
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index 209f62d..2b507a0 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -19,6 +19,13 @@
*/
class LinkFrameSettingsController extends LinksAppController {
+/**
+ * layout
+ *
+ * @var array
+ */
+ public $layout = 'NetCommons.setting';
+
/**
* use models
*
@@ -51,7 +58,6 @@ class LinkFrameSettingsController extends LinksAppController {
public function beforeFilter() {
parent::beforeFilter();
- $this->layout = 'NetCommons.setting';
$results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
$this->set($results);
From 067cf272ae2fa28d2304b62589edf7e11204c2aa Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 13 May 2015 00:33:57 +0900
Subject: [PATCH 014/274] Fix to redirectByFrameId()
---
Controller/LinkFrameSettingsController.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index 2b507a0..a2a00a7 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -91,9 +91,7 @@ public function edit() {
$data = $this->data;
$this->LinkFrameSetting->saveLinkFrameSetting($data);
if ($this->handleValidationError($this->LinkFrameSetting->validationErrors)) {
- if (! $this->request->is('ajax')) {
- $this->redirect('/' . $this->viewVars['cancelUrl']);
- }
+ $this->redirectByFrameId();
return;
}
}
From f9f58e69b5c050950e86b941a34f88f165a8f384 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 13 May 2015 16:57:49 +0900
Subject: [PATCH 015/274] Bugfix linklist name error
---
Controller/BlocksController.php | 2 ++
Model/LinkBlock.php | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/Controller/BlocksController.php b/Controller/BlocksController.php
index 7055fa4..b75edd6 100644
--- a/Controller/BlocksController.php
+++ b/Controller/BlocksController.php
@@ -151,6 +151,7 @@ public function add() {
}
$data['Block']['id'] = null;
$data['Block']['key'] = null;
+ unset($data['Frame']);
}
$results = $this->camelizeKeyRecursive(Hash::merge($block, $data));
@@ -185,6 +186,7 @@ public function edit() {
}
return;
}
+ unset($data['Frame']);
$results = $this->camelizeKeyRecursive($data);
$this->set($results);
diff --git a/Model/LinkBlock.php b/Model/LinkBlock.php
index 9b27ef3..1b014c3 100644
--- a/Model/LinkBlock.php
+++ b/Model/LinkBlock.php
@@ -135,6 +135,15 @@ public function saveLinkBlock($data) {
* @return mixed Array on success, false on validation errors
*/
public function validateLinkBlock($data, $contains = []) {
+ $this->Block->validate = Hash::merge($this->Block->validate, array(
+ 'name' => array(
+ 'notEmpty' => array(
+ 'rule' => array('notEmpty'),
+ 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'Link list Title')),
+ 'required' => true,
+ )
+ ))
+ );
if (! $this->Block->validateBlock($data)) {
$this->validationErrors = Hash::merge($this->validationErrors, $this->Block->validationErrors);
return false;
From 2fb75c5815d467125cfb689c9093b42295dfe4d3 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Thu, 14 May 2015 16:47:08 +0900
Subject: [PATCH 016/274] Bugfix tabs.
---
Controller/BlockRolePermissionsController.php | 1 -
Controller/BlocksController.php | 1 -
Controller/LinkFrameSettingsController.php | 1 -
Controller/LinksAppController.php | 12 +++++++++---
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/Controller/BlockRolePermissionsController.php b/Controller/BlockRolePermissionsController.php
index e6ba6dd..bae47d1 100644
--- a/Controller/BlockRolePermissionsController.php
+++ b/Controller/BlockRolePermissionsController.php
@@ -46,7 +46,6 @@ class BlockRolePermissionsController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsFrame',
'NetCommons.NetCommonsBlock',
'NetCommons.NetCommonsRoomRole' => array(
//コンテンツの権限設定
diff --git a/Controller/BlocksController.php b/Controller/BlocksController.php
index b75edd6..81f4875 100644
--- a/Controller/BlocksController.php
+++ b/Controller/BlocksController.php
@@ -44,7 +44,6 @@ class BlocksController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsFrame',
'NetCommons.NetCommonsBlock',
'NetCommons.NetCommonsRoomRole' => array(
//コンテンツの権限設定
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index a2a00a7..a66bfd9 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -41,7 +41,6 @@ class LinkFrameSettingsController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsFrame',
'NetCommons.NetCommonsRoomRole' => array(
//コンテンツの権限設定
'allowedActions' => array(
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
index 5f50196..e14620e 100644
--- a/Controller/LinksAppController.php
+++ b/Controller/LinksAppController.php
@@ -25,8 +25,8 @@ class LinksAppController extends AppController {
* @var array
*/
public $components = array(
- 'Security',
'NetCommons.NetCommonsFrame',
+ 'Security',
);
/**
@@ -109,6 +109,12 @@ public function initLink($contains = []) {
* @return void
*/
public function initTabs($mainActiveTab, $blockActiveTab) {
+ if (isset($this->params['pass'][1])) {
+ $blockId = (int)$this->params['pass'][1];
+ } else {
+ $blockId = null;
+ }
+
//タブの設定
$settingTabs = array(
'tabs' => array(
@@ -141,7 +147,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'controller' => 'blocks',
'action' => $this->params['action'],
$this->viewVars['frameId'],
- $this->viewVars['blockId']
+ $blockId
)
),
'role_permissions' => array(
@@ -150,7 +156,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'controller' => 'block_role_permissions',
'action' => 'edit',
$this->viewVars['frameId'],
- $this->viewVars['blockId']
+ $blockId
)
),
),
From cbd81d6fc0a8912d8c72e4659ad948c6718e5583 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 16 May 2015 20:07:34 +0900
Subject: [PATCH 017/274] Fix by block role permission
---
View/Elements/BlockRolePermissions/edit_form.ctp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/View/Elements/BlockRolePermissions/edit_form.ctp b/View/Elements/BlockRolePermissions/edit_form.ctp
index 3dc446d..5d3ff8b 100644
--- a/View/Elements/BlockRolePermissions/edit_form.ctp
+++ b/View/Elements/BlockRolePermissions/edit_form.ctp
@@ -22,11 +22,15 @@
'value' => $blockId,
)); ?>
-element('Blocks.content_role_setting', array(
+element('Blocks.block_role_setting', array(
'roles' => $roles,
- 'permissions' => isset($blockRolePermissions) ? $blockRolePermissions : null,
- 'useWorkflow' => array(
- 'name' => 'LinkSetting.use_workflow',
- 'value' => $linkSetting['useWorkflow']
+ 'model' => 'LinkSetting',
+ 'useWorkflow' => 'use_workflow',
+ 'creatablePermissions' => array(
+ 'contentCreatable' => __d('blocks', 'Content creatable roles'),
+ ),
+ 'options' => array(
+ Block::NEED_APPROVAL => __d('blocks', 'Need approval'),
+ Block::NOT_NEED_APPROVAL => __d('blocks', 'Not need approval'),
),
));
From c5caece613badc197fc443cb7eae49f2ea251d71 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 18 May 2015 20:18:13 +0900
Subject: [PATCH 018/274] Bugfix index conditions of editor
---
Controller/LinksController.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
index ac4438f..d682324 100644
--- a/Controller/LinksController.php
+++ b/Controller/LinksController.php
@@ -388,7 +388,6 @@ private function __setConditions() {
'Link.created_user !=' => (int)$this->viewVars['userId'],
);
$latestConditons = array(
- 'Link.is_active' => false,
'Link.is_latest' => true,
'Link.created_user' => (int)$this->viewVars['userId'],
);
From 1535c6a702a57d0554b821e190b632ae3b55b24b Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Thu, 21 May 2015 17:51:44 +0900
Subject: [PATCH 019/274] Fix to common code of block edit hidden attributes
---
View/Elements/Blocks/edit_form.ctp | 24 +-----------------------
1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/View/Elements/Blocks/edit_form.ctp b/View/Elements/Blocks/edit_form.ctp
index 040c66e..642a8da 100644
--- a/View/Elements/Blocks/edit_form.ctp
+++ b/View/Elements/Blocks/edit_form.ctp
@@ -10,29 +10,7 @@
*/
?>
-Form->hidden('Frame.id', array(
- 'value' => $frameId,
- )); ?>
-
-Form->hidden('Block.id', array(
- 'value' => $block['id'],
- )); ?>
-
-Form->hidden('Block.key', array(
- 'value' => $block['key'],
- )); ?>
-
-Form->hidden('Block.language_id', array(
- 'value' => $languageId,
- )); ?>
-
-Form->hidden('Block.room_id', array(
- 'value' => $roomId,
- )); ?>
-
-Form->hidden('Block.plugin_key', array(
- 'value' => $this->params['plugin'],
- )); ?>
+element('Blocks.form_hidden'); ?>
Form->hidden('LinkSetting.id', array(
'value' => isset($linkSetting['id']) ? (int)$linkSetting['id'] : null,
From ef302cdb4f23fbaf997150983286e279e9abb02a Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 22 May 2015 16:07:08 +0900
Subject: [PATCH 020/274] Bugfix by get link info
---
Controller/LinksController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
index d682324..8384169 100644
--- a/Controller/LinksController.php
+++ b/Controller/LinksController.php
@@ -45,7 +45,7 @@ class LinksController extends LinksAppController {
'NetCommons.NetCommonsRoomRole' => array(
//コンテンツの権限設定
'allowedActions' => array(
- 'contentCreatable' => array('add', 'edit', 'delete'),
+ 'contentCreatable' => array('add', 'edit', 'delete', 'get'),
),
),
'Categories.Categories',
From c02ff7627c897d194ec40fd368fa0b25de041211 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 22 May 2015 16:07:38 +0900
Subject: [PATCH 021/274] Add code deleting workflow comment
---
Model/Link.php | 4 ++++
Model/LinkBlock.php | 7 +++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Model/Link.php b/Model/Link.php
index d73af80..fbe1b8f 100644
--- a/Model/Link.php
+++ b/Model/Link.php
@@ -225,6 +225,7 @@ public function saveLink($data) {
}
//Comment登録
if (isset($data['Comment']) && $this->Comment->data) {
+ $this->Comment->data[$this->Comment->name]['block_key'] = $link['Block']['key'];
$this->Comment->data[$this->Comment->name]['content_key'] = $link[$this->name]['key'];
if (! $this->Comment->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
@@ -307,6 +308,9 @@ public function deleteLink($data) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
+ //コメントの削除
+ $this->Comment->deleteByContentKey($data['Link']['key']);
+
//トランザクションCommit
$dataSource->commit();
diff --git a/Model/LinkBlock.php b/Model/LinkBlock.php
index 1b014c3..bb7ab22 100644
--- a/Model/LinkBlock.php
+++ b/Model/LinkBlock.php
@@ -177,17 +177,17 @@ public function validateLinkBlock($data, $contains = []) {
* @throws InternalErrorException
*/
public function deleteLinkBlock($data) {
- $this->setDataSource('master');
-
$this->loadModels([
'Link' => 'Links.Link',
'LinkSetting' => 'Links.LinkSetting',
'LinkOrder' => 'Links.LinkOrder',
'Block' => 'Blocks.Block',
'Category' => 'Categories.Category',
+ 'Comment' => 'Comments.Comment',
]);
//トランザクションBegin
+ $this->setDataSource('master');
$dataSource = $this->getDataSource();
$dataSource->begin();
@@ -214,6 +214,9 @@ public function deleteLinkBlock($data) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
+ //コメントの削除
+ $this->Comment->deleteByBlockKey($data['Block']['key']);
+
//Categoryデータ削除
$this->Category->deleteByBlockKey($data['Block']['key']);
From fa9fe092ebab4206dd3b97cc8275fa288bd445f0 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Thu, 28 May 2015 01:12:35 +0900
Subject: [PATCH 022/274] Fix phpunit file name
---
Test/Case/AllLinksTest.php | 13 ++++++++++++-
Test/Case/Model/LinkBlockTest.php | 13 +++++++++++--
.../{LinksBaseModel.php => LinksModelTestBase.php} | 10 +---------
3 files changed, 24 insertions(+), 12 deletions(-)
rename Test/Case/Model/{LinksBaseModel.php => LinksModelTestBase.php} (96%)
diff --git a/Test/Case/AllLinksTest.php b/Test/Case/AllLinksTest.php
index 27f65a3..8518499 100644
--- a/Test/Case/AllLinksTest.php
+++ b/Test/Case/AllLinksTest.php
@@ -25,7 +25,18 @@ class AllLinksTest extends CakeTestSuite {
public static function suite() {
$plugin = preg_replace('/^All([\w]+)Test$/', '$1', __CLASS__);
$suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
- $suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case');
+
+ $directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
+ $Folder = new Folder($directory);
+ $exceptions = array(
+ 'LinksModelTestBase.php',
+ );
+ $files = $Folder->tree(null, $exceptions, 'files');
+ foreach ($files as $file) {
+ if (substr($file, -4) === '.php') {
+ $suite->addTestFile($file);
+ }
+ }
return $suite;
}
diff --git a/Test/Case/Model/LinkBlockTest.php b/Test/Case/Model/LinkBlockTest.php
index bccc607..fa8d6ad 100644
--- a/Test/Case/Model/LinkBlockTest.php
+++ b/Test/Case/Model/LinkBlockTest.php
@@ -11,7 +11,7 @@
* @copyright Copyright 2014, NetCommons Project
*/
-App::uses('LinksBaseModel', 'Links.Test/Case/Model');
+App::uses('LinksModelTestBase', 'Links.Test/Case/Model');
/**
* Common code of LinkBlock model test
@@ -19,7 +19,7 @@
* @author Shohei Nakajima
* @package NetCommons\Links\Test\Case\Model
*/
-class LinkBlockTest extends LinksBaseModel {
+class LinkBlockTest extends LinksModelTestBase {
/**
* setUp
@@ -52,4 +52,13 @@ public function tearDown() {
unset($this->LinkSetting);
parent::tearDown();
}
+
+/**
+ * Called before the test().
+ *
+ * @return void
+ */
+ public function testIndex() {
+ }
+
}
diff --git a/Test/Case/Model/LinksBaseModel.php b/Test/Case/Model/LinksModelTestBase.php
similarity index 96%
rename from Test/Case/Model/LinksBaseModel.php
rename to Test/Case/Model/LinksModelTestBase.php
index 4e7ace4..8891df8 100644
--- a/Test/Case/Model/LinksBaseModel.php
+++ b/Test/Case/Model/LinksModelTestBase.php
@@ -29,7 +29,7 @@
* @author Shohei Nakajima
* @package NetCommons\Links\Test\Case\Model
*/
-class LinksBaseModel extends YACakeTestCase {
+class LinksModelTestBase extends YACakeTestCase {
/**
* Fixtures
@@ -121,12 +121,4 @@ protected function _assertArray($expected, $result, $path = 3, $fields = ['creat
$this->assertEquals($expected, $result);
}
-
-/**
- * Called before the test().
- *
- * @return void
- */
- public function test() {
- }
}
From 11ded9d378250bebed5706d35f4c956809a64dbb Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Thu, 28 May 2015 01:27:43 +0900
Subject: [PATCH 023/274] Add plugin manager
---
composer.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 3d33016..fffd7b6 100644
--- a/composer.json
+++ b/composer.json
@@ -28,9 +28,10 @@
"netcommons/install": "dev-master",
"netcommons/m17n": "dev-master",
"netcommons/net-commons": "dev-master",
+ "netcommons/pages": "dev-master",
+ "netcommons/plugin-manager": "dev-master",
"netcommons/roles": "dev-master",
"netcommons/rooms": "dev-master",
- "netcommons/pages": "dev-master",
"netcommons/users": "dev-master"
},
"license": "NetCommons License",
From 742a1e4ffdf07f4da1f8997e07dc857cacd59bdf Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 30 May 2015 00:21:20 +0900
Subject: [PATCH 024/274] Fix reconsidering page
---
Controller/BlockRolePermissionsController.php | 3 ---
Controller/BlocksController.php | 3 ---
Controller/LinkFrameSettingsController.php | 3 ---
Controller/LinksAppController.php | 12 +-----------
4 files changed, 1 insertion(+), 20 deletions(-)
diff --git a/Controller/BlockRolePermissionsController.php b/Controller/BlockRolePermissionsController.php
index bae47d1..4269aa2 100644
--- a/Controller/BlockRolePermissionsController.php
+++ b/Controller/BlockRolePermissionsController.php
@@ -63,9 +63,6 @@ class BlockRolePermissionsController extends LinksAppController {
public function beforeFilter() {
parent::beforeFilter();
- $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
- $this->set($results);
-
//タブの設定
$this->initTabs('block_index', 'role_permissions');
}
diff --git a/Controller/BlocksController.php b/Controller/BlocksController.php
index 81f4875..e18c137 100644
--- a/Controller/BlocksController.php
+++ b/Controller/BlocksController.php
@@ -73,9 +73,6 @@ public function beforeFilter() {
parent::beforeFilter();
$this->Auth->deny('index');
- $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
- $this->set($results);
-
//タブの設定
$this->initTabs('block_index', 'block_settings');
}
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index a66bfd9..db4af63 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -57,9 +57,6 @@ class LinkFrameSettingsController extends LinksAppController {
public function beforeFilter() {
parent::beforeFilter();
- $results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
- $this->set($results);
-
//タブの設定
$this->initTabs('frame_settings', '');
}
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
index e14620e..2081a03 100644
--- a/Controller/LinksAppController.php
+++ b/Controller/LinksAppController.php
@@ -26,6 +26,7 @@ class LinksAppController extends AppController {
*/
public $components = array(
'NetCommons.NetCommonsFrame',
+ 'Pages.PageLayout',
'Security',
);
@@ -38,17 +39,6 @@ class LinksAppController extends AppController {
'Links.LinkBlock',
);
-/**
- * beforeFilter
- *
- * @return void
- */
- public function beforeFilter() {
- parent::beforeFilter();
- $results = $this->camelizeKeyRecursive(['current' => $this->current]);
- $this->set($results);
- }
-
/**
* initLink
*
From 4b4bbe7b74437fc899435821e5d66c6739b6f18c Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 30 May 2015 00:43:46 +0900
Subject: [PATCH 025/274] Rename BlockController
---
Config/Migration/1430464483_initial.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Config/Migration/1430464483_initial.php b/Config/Migration/1430464483_initial.php
index fc6bd09..706c5c9 100644
--- a/Config/Migration/1430464483_initial.php
+++ b/Config/Migration/1430464483_initial.php
@@ -123,6 +123,8 @@ class Initial extends CakeMigration {
'namespace' => 'netcommons/links',
'name' => 'リンクリスト',
'type' => 1,
+ 'default_action' => 'links/index',
+ 'default_setting_action' => 'link_blocks/index',
),
),
From c2c01fcb392625c12154d12cc020e18a2d567fd0 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sun, 31 May 2015 23:21:27 +0900
Subject: [PATCH 026/274] Rename BlocksController
---
...=> LinkBlockRolePermissionsController.php} | 4 ++--
...ontroller.php => LinkBlocksController.php} | 24 +++++++------------
Controller/LinksAppController.php | 6 ++---
Test/Case/Model/LinksModelTestBase.php | 4 ++--
.../edit_form.ctp | 0
.../{Blocks => LinkBlocks}/delete_form.ctp | 0
.../{Blocks => LinkBlocks}/edit_form.ctp | 0
.../edit.ctp | 6 ++---
View/{Blocks => LinkBlocks}/edit.ctp | 10 ++++----
View/{Blocks => LinkBlocks}/index.ctp | 16 ++-----------
View/{Blocks => LinkBlocks}/not_found.ctp | 2 +-
11 files changed, 26 insertions(+), 46 deletions(-)
rename Controller/{BlockRolePermissionsController.php => LinkBlockRolePermissionsController.php} (94%)
rename Controller/{BlocksController.php => LinkBlocksController.php} (86%)
rename View/Elements/{BlockRolePermissions => LinkBlockRolePermissions}/edit_form.ctp (100%)
rename View/Elements/{Blocks => LinkBlocks}/delete_form.ctp (100%)
rename View/Elements/{Blocks => LinkBlocks}/edit_form.ctp (100%)
rename View/{BlockRolePermissions => LinkBlockRolePermissions}/edit.ctp (81%)
rename View/{Blocks => LinkBlocks}/edit.ctp (79%)
rename View/{Blocks => LinkBlocks}/index.ctp (76%)
rename View/{Blocks => LinkBlocks}/not_found.ctp (94%)
diff --git a/Controller/BlockRolePermissionsController.php b/Controller/LinkBlockRolePermissionsController.php
similarity index 94%
rename from Controller/BlockRolePermissionsController.php
rename to Controller/LinkBlockRolePermissionsController.php
index 4269aa2..1432e2c 100644
--- a/Controller/BlockRolePermissionsController.php
+++ b/Controller/LinkBlockRolePermissionsController.php
@@ -17,7 +17,7 @@
* @author Shohei Nakajima
* @package NetCommons\Links\Controller
*/
-class BlockRolePermissionsController extends LinksAppController {
+class LinkBlockRolePermissionsController extends LinksAppController {
/**
* layout
@@ -104,7 +104,7 @@ public function edit() {
$this->LinkSetting->saveLinkSetting($data);
if ($this->handleValidationError($this->LinkSetting->validationErrors)) {
if (! $this->request->is('ajax')) {
- $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
diff --git a/Controller/BlocksController.php b/Controller/LinkBlocksController.php
similarity index 86%
rename from Controller/BlocksController.php
rename to Controller/LinkBlocksController.php
index e18c137..89d63bf 100644
--- a/Controller/BlocksController.php
+++ b/Controller/LinkBlocksController.php
@@ -17,7 +17,7 @@
* @author Shohei Nakajima
* @package NetCommons\Links\Controller
*/
-class BlocksController extends LinksAppController {
+class LinkBlocksController extends LinksAppController {
/**
* layout
@@ -95,18 +95,10 @@ public function index() {
//'limit' => 1
)
);
- try {
- $linkBlocks = $this->Paginator->paginate('LinkBlock');
- } catch (Exception $ex) {
- if (isset($this->request['paging']) && $this->params['named']) {
- $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
- return;
- }
- CakeLog::error($ex);
- throw $ex;
- }
+
+ $linkBlocks = $this->Paginator->paginate('LinkBlock');
if (! $linkBlocks) {
- $this->view = 'Blocks/not_found';
+ $this->view = 'not_found';
return;
}
@@ -123,7 +115,7 @@ public function index() {
* @return void
*/
public function add() {
- $this->view = 'Blocks/edit';
+ $this->view = 'edit';
$this->set('blockId', null);
$block = $this->Block->create(
@@ -141,7 +133,7 @@ public function add() {
$this->LinkBlock->saveLinkBlock($data);
if ($this->handleValidationError($this->LinkBlock->validationErrors)) {
if (! $this->request->is('ajax')) {
- $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
@@ -178,7 +170,7 @@ public function edit() {
$this->LinkBlock->saveLinkBlock($data);
if ($this->handleValidationError($this->LinkBlock->validationErrors)) {
if (! $this->request->is('ajax')) {
- $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
@@ -208,7 +200,7 @@ public function delete() {
if ($this->request->isDelete()) {
if ($this->LinkBlock->deleteLinkBlock($this->data)) {
if (! $this->request->is('ajax')) {
- $this->redirect('/links/blocks/index/' . $this->viewVars['frameId']);
+ $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
index 2081a03..7006b18 100644
--- a/Controller/LinksAppController.php
+++ b/Controller/LinksAppController.php
@@ -111,7 +111,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'block_index' => array(
'url' => array(
'plugin' => $this->params['plugin'],
- 'controller' => 'blocks',
+ 'controller' => 'link_blocks',
'action' => 'index',
$this->viewVars['frameId'],
)
@@ -134,7 +134,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'block_settings' => array(
'url' => array(
'plugin' => $this->params['plugin'],
- 'controller' => 'blocks',
+ 'controller' => 'link_blocks',
'action' => $this->params['action'],
$this->viewVars['frameId'],
$blockId
@@ -143,7 +143,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'role_permissions' => array(
'url' => array(
'plugin' => $this->params['plugin'],
- 'controller' => 'block_role_permissions',
+ 'controller' => 'link_block_role_permissions',
'action' => 'edit',
$this->viewVars['frameId'],
$blockId
diff --git a/Test/Case/Model/LinksModelTestBase.php b/Test/Case/Model/LinksModelTestBase.php
index 8891df8..5f57b14 100644
--- a/Test/Case/Model/LinksModelTestBase.php
+++ b/Test/Case/Model/LinksModelTestBase.php
@@ -48,10 +48,10 @@ class LinksModelTestBase extends YACakeTestCase {
'plugin.links.link_setting',
'plugin.links.link_frame_setting',
'plugin.frames.frame',
- 'plugin.frames.plugin',
'plugin.m17n.language',
- 'plugin.rooms.roles_room',
+ 'plugin.plugin_manager.plugin',
'plugin.rooms.room',
+ 'plugin.rooms.roles_room',
'plugin.users.user_attributes_user',
'plugin.users.user',
);
diff --git a/View/Elements/BlockRolePermissions/edit_form.ctp b/View/Elements/LinkBlockRolePermissions/edit_form.ctp
similarity index 100%
rename from View/Elements/BlockRolePermissions/edit_form.ctp
rename to View/Elements/LinkBlockRolePermissions/edit_form.ctp
diff --git a/View/Elements/Blocks/delete_form.ctp b/View/Elements/LinkBlocks/delete_form.ctp
similarity index 100%
rename from View/Elements/Blocks/delete_form.ctp
rename to View/Elements/LinkBlocks/delete_form.ctp
diff --git a/View/Elements/Blocks/edit_form.ctp b/View/Elements/LinkBlocks/edit_form.ctp
similarity index 100%
rename from View/Elements/Blocks/edit_form.ctp
rename to View/Elements/LinkBlocks/edit_form.ctp
diff --git a/View/BlockRolePermissions/edit.ctp b/View/LinkBlockRolePermissions/edit.ctp
similarity index 81%
rename from View/BlockRolePermissions/edit.ctp
rename to View/LinkBlockRolePermissions/edit.ctp
index 0124f3b..9bd357b 100644
--- a/View/BlockRolePermissions/edit.ctp
+++ b/View/LinkBlockRolePermissions/edit.ctp
@@ -19,10 +19,10 @@
element('Blocks.setting_tabs', $blockSettingTabs); ?>
element('Blocks.edit_form', array(
- 'controller' => 'BlockRolePermission',
+ 'controller' => 'LinkBlockRolePermission',
'action' => 'edit' . '/' . $frameId . '/' . $blockId,
- 'callback' => 'Links.BlockRolePermissions/edit_form',
- 'cancelUrl' => '/links/blocks/index/' . $frameId,
+ 'callback' => 'Links.LinkBlockRolePermissions/edit_form',
+ 'cancelUrl' => '/links/link_blocks/index/' . $frameId,
)); ?>
diff --git a/View/Blocks/edit.ctp b/View/LinkBlocks/edit.ctp
similarity index 79%
rename from View/Blocks/edit.ctp
rename to View/LinkBlocks/edit.ctp
index 5f81f43..317502d 100644
--- a/View/Blocks/edit.ctp
+++ b/View/LinkBlocks/edit.ctp
@@ -17,17 +17,17 @@
element('Blocks.setting_tabs', $blockSettingTabs); ?>
element('Blocks.edit_form', array(
- 'controller' => 'Blocks',
+ 'controller' => 'LinkBlocks',
'action' => h($this->request->params['action']) . '/' . $frameId . '/' . $blockId,
- 'callback' => 'Links.Blocks/edit_form',
- 'cancelUrl' => '/links/blocks/index/' . $frameId
+ 'callback' => 'Links.LinkBlocks/edit_form',
+ 'cancelUrl' => '/links/link_blocks/index/' . $frameId
)); ?>
request->params['action'] === 'edit') : ?>
element('Blocks.delete_form', array(
- 'controller' => 'Blocks',
+ 'controller' => 'LinkBlocks',
'action' => 'delete/' . $frameId . '/' . $blockId,
- 'callback' => 'Links.Blocks/delete_form'
+ 'callback' => 'Links.LinkBlocks/delete_form'
)); ?>
diff --git a/View/Blocks/index.ctp b/View/LinkBlocks/index.ctp
similarity index 76%
rename from View/Blocks/index.ctp
rename to View/LinkBlocks/index.ctp
index e6741d2..a8ed628 100644
--- a/View/Blocks/index.ctp
+++ b/View/LinkBlocks/index.ctp
@@ -15,7 +15,7 @@
@@ -36,9 +36,6 @@
Paginator->sort('Link.name', __d('links', 'Link list Title')); ?>
|
-
- Paginator->sort('Block.public_type', __d('blocks', 'Publishing setting')); ?>
- |
Paginator->sort('Block.modified', __d('net_commons', 'Updated date')); ?>
|
@@ -62,19 +59,10 @@
)); ?>
-
+
|
-
-
-
-
-
-
-
-
- |
Date->dateFormat($linkBlock['block']['modified']); ?>
|
diff --git a/View/Blocks/not_found.ctp b/View/LinkBlocks/not_found.ctp
similarity index 94%
rename from View/Blocks/not_found.ctp
rename to View/LinkBlocks/not_found.ctp
index 5a891a3..1961ed4 100644
--- a/View/Blocks/not_found.ctp
+++ b/View/LinkBlocks/not_found.ctp
@@ -15,7 +15,7 @@
From 6366ea0cf94202c4aa591d6bba1c113bd1c8b1e5 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 1 Jun 2015 18:06:07 +0900
Subject: [PATCH 027/274] Fix i18n
---
Locale/jpn/LC_MESSAGES/links.mo | Bin 1666 -> 1604 bytes
Locale/jpn/LC_MESSAGES/links.po | 23 +++++++++++++----------
Locale/links.pot | 16 ++++++++--------
3 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/Locale/jpn/LC_MESSAGES/links.mo b/Locale/jpn/LC_MESSAGES/links.mo
index ad5dec8eccad3e5745a10d733560e9cfbfc7fde5..a4ef4d098d01a8f129968d8df7af43f1156f82a9 100644
GIT binary patch
delta 643
zcmYMxPbdUY9Ki9ncGsV^>(Ba|f6YN6MmuWJ9#I?=Nl{8hrftPct)Z0KS|#P+uyJv9
zP>O?clag|AQBDquy*l6~7vJ9+`PJLczM1!Xzj?oxjogMa&(XkvBI+3}jC)2aW6Q@6
z@s4Hqfg$|Hax5$J;-~s6tQ4mBW
zpkO1!N)#=uZPX@+Ai=A!5p1mdUtGjTCf~l<*_pR*uPc(3iAS%#sR%!#nQ_NxW27DY
z5zZo|T\n"
"Language-Team: LANGUAGE \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-"X-Generator: Poedit 1.6.10\n"
+"POT-Creation-Date: \n"
+"Language: ja\n"
+"X-Generator: Poedit 1.8.1\n"
-#: Links/Controller/BlocksController.php:131
+#: Links/Controller/LinkBlocksController.php:125
msgid "New Bookmark List %s"
msgstr "新規リンクリスト%s"
@@ -32,15 +33,17 @@ msgstr ""
msgid "Title"
msgstr "タイトル"
+#: Links/Model/LinkBlock.php:142
+#: Links/View/Elements/LinkBlocks/edit_form.ctp:24
+#: Links/View/LinkBlocks/index.ctp:37
+msgid "Link list Title"
+msgstr "リンクリスト名"
+
#: Links/Model/LinkFrameSetting.php:95
msgid "(no line)"
msgstr "(線なし)"
-#: Links/View/Blocks/index.ctp:37 Links/View/Elements/Blocks/edit_form.ctp:46
-msgid "Link list Title"
-msgstr "リンクリスト名称"
-
-#: Links/View/Elements/Blocks/delete_form.ctp:14;25
+#: Links/View/Elements/LinkBlocks/delete_form.ctp:14;25
msgid "Link List"
msgstr "リンクリスト"
@@ -102,7 +105,7 @@ msgstr "リンクがありません。"
#: Links/View/Links/index.ctp:30
msgid "Sort link"
-msgstr "表示順変更"
+msgstr ""
#: Links/View/Links/index.ctp:37
msgid "Create link"
diff --git a/Locale/links.pot b/Locale/links.pot
index 3dced4a..47aa667 100644
--- a/Locale/links.pot
+++ b/Locale/links.pot
@@ -5,7 +5,6 @@
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2015-05-05 15:03+0000\n"
"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
"Last-Translator: NAME \n"
"Language-Team: LANGUAGE \n"
@@ -14,7 +13,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-#: Links/Controller/BlocksController.php:131
+#: Links/Controller/LinkBlocksController.php:125
msgid "New Bookmark List %s"
msgstr ""
@@ -34,16 +33,17 @@ msgstr ""
msgid "Title"
msgstr ""
-#: Links/Model/LinkFrameSetting.php:95
-msgid "(no line)"
+#: Links/Model/LinkBlock.php:142
+#: Links/View/Elements/LinkBlocks/edit_form.ctp:24
+#: Links/View/LinkBlocks/index.ctp:37
+msgid "Link list Title"
msgstr ""
-#: Links/View/Blocks/index.ctp:37
-#: Links/View/Elements/Blocks/edit_form.ctp:46
-msgid "Link list Title"
+#: Links/Model/LinkFrameSetting.php:95
+msgid "(no line)"
msgstr ""
-#: Links/View/Elements/Blocks/delete_form.ctp:14;25
+#: Links/View/Elements/LinkBlocks/delete_form.ctp:14;25
msgid "Link List"
msgstr ""
From 28de019a0b08dfc85a036a553e8a0d0354df4abc Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 18 Jul 2015 10:26:18 +0900
Subject: [PATCH 028/274] Fix travis.yml
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index adbdf21..2664aa8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,7 +15,8 @@ before_script:
- git clone git://github.com/NetCommons3/NetCommons3 $NETCOMMONS_BUILD_DIR
- cd $NETCOMMONS_BUILD_DIR
- git checkout $NETCOMMONS_VERSION
- - . tools/build/plugins/cakephp/travis/pre.sh
+ - travis_wait . tools/build/plugins/cakephp/travis/pre.sh
+ - . tools/build/plugins/cakephp/travis/environment.sh
script:
- . tools/build/plugins/cakephp/travis/main.sh
From 511a2a75481d6a574e43023a341b0172af0c5a64 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 18 Jul 2015 11:11:07 +0900
Subject: [PATCH 029/274] Fix cakephp/cakephp version
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index fffd7b6..bd48699 100644
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,7 @@
}
},
"require": {
- "cakephp/cakephp": "~2.4",
+ "cakephp/cakephp": "~2.6.9",
"cakephp/debug_kit": "~2.2",
"cakedc/migrations": "~2.2",
"twbs/bootstrap": "~3.1",
From 38157856872b40d5d6f6721da92a7ad279090988 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 5 Aug 2015 12:00:56 +0900
Subject: [PATCH 030/274] Fixed initial data generation of Migration
---
Config/Migration/001_plugin_records.php | 130 ++++++++++++++++++++++++
Config/Migration/1430464483_initial.php | 61 -----------
2 files changed, 130 insertions(+), 61 deletions(-)
create mode 100644 Config/Migration/001_plugin_records.php
diff --git a/Config/Migration/001_plugin_records.php b/Config/Migration/001_plugin_records.php
new file mode 100644
index 0000000..58e9189
--- /dev/null
+++ b/Config/Migration/001_plugin_records.php
@@ -0,0 +1,130 @@
+
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('NetCommonsMigration', 'NetCommons.Config/Migration');
+
+/**
+ * Add plugin migration
+ *
+ * @package NetCommons\PluginManager\Config\Migration
+ */
+class PluginRecords extends NetCommonsMigration {
+
+/**
+ * Migration description
+ *
+ * @var string
+ */
+ public $description = 'plugin_records';
+
+/**
+ * Actions to be performed
+ *
+ * @var array $migration
+ */
+ public $migration = array(
+ 'up' => array(),
+ 'down' => array(),
+ );
+
+/**
+ * plugin data
+ *
+ * @var array $migration
+ */
+ public $records = array(
+ 'Plugin' => array(
+ //日本語
+ array(
+ 'language_id' => '2',
+ 'key' => 'links',
+ 'namespace' => 'netcommons/links',
+ 'name' => 'リンクリスト',
+ 'type' => 1,
+ 'default_action' => 'links/index',
+ 'default_setting_action' => 'link_blocks/index',
+ ),
+ //英語
+ array(
+ 'language_id' => '1',
+ 'key' => 'links',
+ 'namespace' => 'netcommons/links',
+ 'name' => 'Bookmark List',
+ 'type' => 1,
+ 'default_action' => 'links/index',
+ 'default_setting_action' => 'link_blocks/index',
+ ),
+ ),
+ 'PluginsRole' => array(
+ array(
+ 'role_key' => 'room_administrator',
+ 'plugin_key' => 'links'
+ ),
+ ),
+ 'PluginsRoom' => array(
+ array(
+ 'room_id' => '1',
+ 'plugin_key' => 'links'
+ ),
+ ),
+ 'PluginsSpace' => array(
+ array(
+ 'space_id' => '1',
+ 'plugin_key' => 'links'
+ ),
+ array(
+ 'space_id' => '2',
+ 'plugin_key' => 'links',
+ ),
+ array(
+ 'space_id' => '3',
+ 'plugin_key' => 'links',
+ ),
+ array(
+ 'space_id' => '4',
+ 'plugin_key' => 'links',
+ ),
+ ),
+ );
+
+/**
+ * Before migration callback
+ *
+ * @param string $direction Direction of migration process (up or down)
+ * @return bool Should process continue
+ */
+ public function before($direction) {
+ return true;
+ }
+
+/**
+ * After migration callback
+ *
+ * @param string $direction Direction of migration process (up or down)
+ * @return bool Should process continue
+ */
+ public function after($direction) {
+ $this->loadModels([
+ 'Plugin' => 'PluginManager.Plugin',
+ ]);
+
+ if ($direction === 'down') {
+ $this->Plugin->uninstallPlugin($this->records['Plugin'][0]['key']);
+ return true;
+ }
+
+ foreach ($this->records as $model => $records) {
+ if (!$this->updateRecords($model, $records)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/Config/Migration/1430464483_initial.php b/Config/Migration/1430464483_initial.php
index 706c5c9..e2f6f55 100644
--- a/Config/Migration/1430464483_initial.php
+++ b/Config/Migration/1430464483_initial.php
@@ -110,39 +110,6 @@ class Initial extends CakeMigration {
),
);
-/**
- * recodes
- *
- * @var array $migration
- */
- public $records = array(
- 'Plugin' => array(
- array(
- 'language_id' => 2,
- 'key' => 'links',
- 'namespace' => 'netcommons/links',
- 'name' => 'リンクリスト',
- 'type' => 1,
- 'default_action' => 'links/index',
- 'default_setting_action' => 'link_blocks/index',
- ),
- ),
-
- 'PluginsRole' => array(
- array(
- 'role_key' => 'room_administrator',
- 'plugin_key' => 'links'
- ),
- ),
-
- 'PluginsRoom' => array(
- array(
- 'room_id' => '1',
- 'plugin_key' => 'links'
- ),
- ),
- );
-
/**
* Before migration callback
*
@@ -160,34 +127,6 @@ public function before($direction) {
* @return bool Should process continue
*/
public function after($direction) {
- if ($direction === 'down') {
- return true;
- }
-
- foreach ($this->records as $model => $records) {
- if (!$this->updateRecords($model, $records)) {
- return false;
- }
- }
- return true;
- }
-
-/**
- * Update model records
- *
- * @param string $model model name to update
- * @param string $records records to be stored
- * @return bool Should process continue
- */
- public function updateRecords($model, $records) {
- $Model = $this->generateModel($model);
- foreach ($records as $record) {
- $Model->create();
- if (!$Model->save($record, false)) {
- return false;
- }
- }
-
return true;
}
}
From 0848236d9d63c85ee89252531fa408f5167cdc3c Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Tue, 11 Aug 2015 12:16:10 +0900
Subject: [PATCH 031/274] =?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=A0=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E3=81=AE=E9=96=8B=E7=99=BA=E3=81=AB=E3=82=88=E3=82=8B?=
=?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4=E3=83=B3=E3=83=87=E3=83=BC?=
=?UTF-8?q?=E3=82=BF=E3=81=AE=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Config/Migration/001_plugin_records.php | 28 ++++++-------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/Config/Migration/001_plugin_records.php b/Config/Migration/001_plugin_records.php
index 58e9189..50f2c2d 100644
--- a/Config/Migration/001_plugin_records.php
+++ b/Config/Migration/001_plugin_records.php
@@ -69,28 +69,12 @@ class PluginRecords extends NetCommonsMigration {
),
),
'PluginsRoom' => array(
- array(
- 'room_id' => '1',
- 'plugin_key' => 'links'
- ),
- ),
- 'PluginsSpace' => array(
- array(
- 'space_id' => '1',
- 'plugin_key' => 'links'
- ),
- array(
- 'space_id' => '2',
- 'plugin_key' => 'links',
- ),
- array(
- 'space_id' => '3',
- 'plugin_key' => 'links',
- ),
- array(
- 'space_id' => '4',
- 'plugin_key' => 'links',
- ),
+ //パブリックスペース
+ array('room_id' => '1', 'plugin_key' => 'links', ),
+ //プライベートスペース
+ array('room_id' => '2', 'plugin_key' => 'links', ),
+ //グループスペース
+ array('room_id' => '3', 'plugin_key' => 'links', ),
),
);
From c0a029db9d6a22fabcefdc02dfb4cbc4cac45885 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 12 Aug 2015 05:45:37 +0900
Subject: [PATCH 032/274] =?UTF-8?q?Fixture=E5=85=B1=E9=80=9A=E5=8C=96?=
=?UTF-8?q?=E3=81=AB=E3=82=88=E3=82=8B=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Test/Case/Model/LinksModelTestBase.php | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/Test/Case/Model/LinksModelTestBase.php b/Test/Case/Model/LinksModelTestBase.php
index 5f57b14..5c1e682 100644
--- a/Test/Case/Model/LinksModelTestBase.php
+++ b/Test/Case/Model/LinksModelTestBase.php
@@ -37,9 +37,6 @@ class LinksModelTestBase extends YACakeTestCase {
* @var array
*/
public $fixtures = array(
- 'plugin.blocks.block',
- 'plugin.blocks.block_role_permission',
- 'plugin.boxes.box',
'plugin.categories.category',
'plugin.categories.category_order',
'plugin.comments.comment',
@@ -47,13 +44,6 @@ class LinksModelTestBase extends YACakeTestCase {
'plugin.links.link_order',
'plugin.links.link_setting',
'plugin.links.link_frame_setting',
- 'plugin.frames.frame',
- 'plugin.m17n.language',
- 'plugin.plugin_manager.plugin',
- 'plugin.rooms.room',
- 'plugin.rooms.roles_room',
- 'plugin.users.user_attributes_user',
- 'plugin.users.user',
);
/**
From 9d8d9ad2f5288b4c259c0f5eb136f7cd2862c822 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 12 Aug 2015 05:48:07 +0900
Subject: [PATCH 033/274] =?UTF-8?q?Fixture=E5=85=B1=E9=80=9A=E5=8C=96?=
=?UTF-8?q?=E3=81=AB=E3=82=88=E3=82=8B=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Test/Case/Model/LinksModelTestBase.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Test/Case/Model/LinksModelTestBase.php b/Test/Case/Model/LinksModelTestBase.php
index 5c1e682..076b23a 100644
--- a/Test/Case/Model/LinksModelTestBase.php
+++ b/Test/Case/Model/LinksModelTestBase.php
@@ -37,6 +37,9 @@ class LinksModelTestBase extends YACakeTestCase {
* @var array
*/
public $fixtures = array(
+ //'plugin.blocks.block',
+ //'plugin.blocks.block_role_permission',
+ //'plugin.boxes.box',
'plugin.categories.category',
'plugin.categories.category_order',
'plugin.comments.comment',
@@ -44,6 +47,13 @@ class LinksModelTestBase extends YACakeTestCase {
'plugin.links.link_order',
'plugin.links.link_setting',
'plugin.links.link_frame_setting',
+ //'plugin.frames.frame',
+ //'plugin.m17n.language',
+ //'plugin.plugin_manager.plugin',
+ //'plugin.rooms.room',
+ //'plugin.rooms.roles_room',
+ //'plugin.users.user_attributes_user',
+ //'plugin.users.user',
);
/**
From 18334a0b5a6dd0918d3181f919fbc02b60fd2248 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 12 Aug 2015 12:18:46 +0900
Subject: [PATCH 034/274] typo
---
Config/Schema/schema.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Config/Schema/schema.php b/Config/Schema/schema.php
index c66169c..78db591 100644
--- a/Config/Schema/schema.php
+++ b/Config/Schema/schema.php
@@ -28,7 +28,7 @@ class AppSchema extends CakeSchema {
/**
* before
*
- * @param array $event savent
+ * @param array $event event
* @return bool
*/
public function before($event = array()) {
@@ -38,7 +38,7 @@ public function before($event = array()) {
/**
* after
*
- * @param array $event savent
+ * @param array $event event
* @return void
*/
public function after($event = array()) {
From 771132bc3c84fcc804b8c4d530f1dabebefb314b Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 14 Aug 2015 14:25:48 +0900
Subject: [PATCH 035/274] =?UTF-8?q?Fixture=E5=85=B1=E9=80=9A=E5=8C=96?=
=?UTF-8?q?=E3=81=AB=E3=82=88=E3=82=8B=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Test/Case/Model/LinksModelTestBase.php | 10 ----------
composer.json | 15 +--------------
2 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/Test/Case/Model/LinksModelTestBase.php b/Test/Case/Model/LinksModelTestBase.php
index 076b23a..5c1e682 100644
--- a/Test/Case/Model/LinksModelTestBase.php
+++ b/Test/Case/Model/LinksModelTestBase.php
@@ -37,9 +37,6 @@ class LinksModelTestBase extends YACakeTestCase {
* @var array
*/
public $fixtures = array(
- //'plugin.blocks.block',
- //'plugin.blocks.block_role_permission',
- //'plugin.boxes.box',
'plugin.categories.category',
'plugin.categories.category_order',
'plugin.comments.comment',
@@ -47,13 +44,6 @@ class LinksModelTestBase extends YACakeTestCase {
'plugin.links.link_order',
'plugin.links.link_setting',
'plugin.links.link_frame_setting',
- //'plugin.frames.frame',
- //'plugin.m17n.language',
- //'plugin.plugin_manager.plugin',
- //'plugin.rooms.room',
- //'plugin.rooms.roles_room',
- //'plugin.users.user_attributes_user',
- //'plugin.users.user',
);
/**
diff --git a/composer.json b/composer.json
index bd48699..75fdf87 100644
--- a/composer.json
+++ b/composer.json
@@ -16,23 +16,10 @@
},
"require-dev": {
"mustangostang/spyc": "dev-master",
- "satooshi/php-coveralls": "dev-master",
- "netcommons/auth": "dev-master",
- "netcommons/auth-general": "dev-master",
- "netcommons/boxes": "dev-master",
- "netcommons/blocks": "dev-master",
"netcommons/categories": "dev-master",
"netcommons/comments": "dev-master",
- "netcommons/containers": "dev-master",
- "netcommons/frames": "dev-master",
- "netcommons/install": "dev-master",
- "netcommons/m17n": "dev-master",
"netcommons/net-commons": "dev-master",
- "netcommons/pages": "dev-master",
- "netcommons/plugin-manager": "dev-master",
- "netcommons/roles": "dev-master",
- "netcommons/rooms": "dev-master",
- "netcommons/users": "dev-master"
+ "satooshi/php-coveralls": "dev-master"
},
"license": "NetCommons License",
"authors": [
From c6568e945ad38988639bd1c428a8221840ec110a Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 21 Aug 2015 13:28:35 +0900
Subject: [PATCH 036/274] =?UTF-8?q?=E3=82=BB=E3=82=AD=E3=83=A5=E3=83=AA?=
=?UTF-8?q?=E3=83=86=E3=82=A3=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D?=
=?UTF-8?q?=E3=83=B3=E3=83=88=E3=80=81=E4=B8=80=E6=99=82=E7=9A=84=E3=81=AB?=
=?UTF-8?q?OFF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/LinksAppController.php | 2 +-
webroot/js/links.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
index 7006b18..7fdf22c 100644
--- a/Controller/LinksAppController.php
+++ b/Controller/LinksAppController.php
@@ -27,7 +27,7 @@ class LinksAppController extends AppController {
public $components = array(
'NetCommons.NetCommonsFrame',
'Pages.PageLayout',
- 'Security',
+ //'Security',
);
/**
diff --git a/webroot/js/links.js b/webroot/js/links.js
index 5a1c309..711422d 100644
--- a/webroot/js/links.js
+++ b/webroot/js/links.js
@@ -45,7 +45,7 @@ NetCommonsApp.controller('LinksIndex', function($scope, $http, $window) {
$http.get('/net_commons/net_commons/csrfToken.json')
.success(function(token) {
- $scope.data._Token.key = token.data._Token.key;
+ //$scope.data._Token.key = token.data._Token.key;
//POSTリクエスト
$http.post(
From 3ee5f4654973130c772a20134c3bc63066ce626c Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 22 Aug 2015 06:43:37 +0900
Subject: [PATCH 037/274] =?UTF-8?q?TokenHelper=E3=81=AE=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/LinksAppController.php | 2 +-
Controller/LinksController.php | 7 ++++---
View/Links/index.ctp | 2 +-
webroot/js/links.js | 7 ++++---
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
index 7fdf22c..7006b18 100644
--- a/Controller/LinksAppController.php
+++ b/Controller/LinksAppController.php
@@ -27,7 +27,7 @@ class LinksAppController extends AppController {
public $components = array(
'NetCommons.NetCommonsFrame',
'Pages.PageLayout',
- //'Security',
+ 'Security',
);
/**
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
index 8384169..3769090 100644
--- a/Controller/LinksController.php
+++ b/Controller/LinksController.php
@@ -105,7 +105,8 @@ public function index() {
'id' => $this->viewVars['frameId']
),
'Link' => array(
- 'id' => null
+ 'id' => null,
+ 'key' => null,
),
);
$tokenFields = Hash::flatten($this->request->data);
@@ -342,8 +343,8 @@ public function delete() {
*/
public function link() {
$linkKey = null;
- if (isset($this->params['pass'][1])) {
- $linkKey = $this->params['pass'][1];
+ if (isset($this->data['Link']['key'])) {
+ $linkKey = $this->data['Link']['key'];
}
$this->set('linkKey', $linkKey);
diff --git a/View/Links/index.ctp b/View/Links/index.ctp
index 3fc9cc2..7e8d654 100644
--- a/View/Links/index.ctp
+++ b/View/Links/index.ctp
@@ -10,7 +10,7 @@
*/
$this->Token->unlockField('Link.id');
-$tokens = $this->Token->getToken($tokenFields, $hiddenFields);
+$tokens = $this->Token->getToken('Link', '/links/links/link/' . $frameId . '.json', $tokenFields, $hiddenFields);
?>
Html->css('/links/css/style.css', false); ?>
diff --git a/webroot/js/links.js b/webroot/js/links.js
index 711422d..790f3e6 100644
--- a/webroot/js/links.js
+++ b/webroot/js/links.js
@@ -30,7 +30,7 @@ NetCommonsApp.controller('LinksIndex', function($scope, $http, $window) {
$scope.data = {
_Token: data['_Token'],
Frame: {id: data['frameId']},
- Link: {id: ''}
+ Link: {id: '', key: ''}
};
};
@@ -45,11 +45,12 @@ NetCommonsApp.controller('LinksIndex', function($scope, $http, $window) {
$http.get('/net_commons/net_commons/csrfToken.json')
.success(function(token) {
- //$scope.data._Token.key = token.data._Token.key;
+ $scope.data._Token.key = token.data._Token.key;
+ $scope.data.Link.key = key;
//POSTリクエスト
$http.post(
- '/links/links/link/' + $scope.frameId + '/' + key + '.json',
+ '/links/links/link/' + $scope.frameId + '.json',
$.param({_method: 'POST', data: $scope.data}),
{cache: false,
headers:
From a8552054404b25eaa8a82d0ff78a215b4edc8e29 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 26 Aug 2015 13:45:30 +0900
Subject: [PATCH 038/274] =?UTF-8?q?cakephp/cakephp=E3=81=AE=E3=83=90?=
=?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=922.x=E3=81=AB?=
=?UTF-8?q?=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 75fdf87..8de0e58 100644
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,7 @@
}
},
"require": {
- "cakephp/cakephp": "~2.6.9",
+ "cakephp/cakephp": "~2.6",
"cakephp/debug_kit": "~2.2",
"cakedc/migrations": "~2.2",
"twbs/bootstrap": "~3.1",
From 4fc6988750019121a27fffc5504112f262979a7b Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 7 Sep 2015 16:30:49 +0900
Subject: [PATCH 039/274] =?UTF-8?q?=E5=85=B1=E9=80=9A=E5=87=A6=E7=90=86?=
=?UTF-8?q?=E3=81=AE=E8=A6=8B=E7=9B=B4=E3=81=97=E3=81=AB=E9=96=A2=E3=81=99?=
=?UTF-8?q?=E3=82=8B=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/LinkFrameSettingsController.php | 2 +-
Controller/LinkOrdersController.php | 2 +-
Controller/LinksController.php | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index db4af63..0b69646 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -87,7 +87,7 @@ public function edit() {
$data = $this->data;
$this->LinkFrameSetting->saveLinkFrameSetting($data);
if ($this->handleValidationError($this->LinkFrameSetting->validationErrors)) {
- $this->redirectByFrameId();
+ $this->redirect(Current::backToPageUrl());
return;
}
}
diff --git a/Controller/LinkOrdersController.php b/Controller/LinkOrdersController.php
index 71e8dd0..dbaf9e8 100644
--- a/Controller/LinkOrdersController.php
+++ b/Controller/LinkOrdersController.php
@@ -82,7 +82,7 @@ public function edit() {
//validationError
if ($this->handleValidationError($this->LinkOrder->validationErrors)) {
//リダイレクト
- $this->redirectByFrameId();
+ $this->redirect(Current::backToPageUrl());
return;
}
}
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
index 3769090..2b5f928 100644
--- a/Controller/LinksController.php
+++ b/Controller/LinksController.php
@@ -228,7 +228,7 @@ public function add() {
$this->Link->saveLink($data);
if ($this->handleValidationError($this->Link->validationErrors)) {
- $this->redirectByFrameId();
+ $this->redirect(Current::backToPageUrl());
return;
}
}
@@ -290,7 +290,7 @@ public function edit() {
$this->Link->saveLink($data);
if ($this->handleValidationError($this->Link->validationErrors)) {
- $this->redirectByFrameId();
+ $this->redirect(Current::backToPageUrl());
return;
}
@@ -333,7 +333,7 @@ public function delete() {
return;
}
- $this->redirectByFrameId();
+ $this->redirect(Current::backToPageUrl());
}
/**
@@ -363,7 +363,7 @@ public function link() {
return;
}
- $this->redirectByFrameId();
+ $this->redirect(Current::backToPageUrl());
}
/**
From efe8571e2dbb0d5e4fb80307cb4a38f9878a30f9 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Wed, 9 Sep 2015 11:16:40 +0900
Subject: [PATCH 040/274] =?UTF-8?q?notEmpty=E3=82=92notBlank=E3=81=AB?=
=?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=88cakephp2.7=E5=AF=BE=E5=BF=9C?=
=?UTF-8?q?=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Model/Link.php | 12 ++++++------
Model/LinkBlock.php | 4 ++--
Model/LinkFrameSetting.php | 4 ++--
Model/LinkOrder.php | 8 ++++----
Model/LinkSetting.php | 4 ++--
Test/Case/Model/LinksModelTestBase.php | 2 +-
6 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/Model/Link.php b/Model/Link.php
index fbe1b8f..62199a7 100644
--- a/Model/Link.php
+++ b/Model/Link.php
@@ -98,8 +98,8 @@ public function beforeValidate($options = array()) {
),
),
'key' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => __d('net_commons', 'Invalid request.'),
'allowEmpty' => false,
'required' => true,
@@ -120,8 +120,8 @@ public function beforeValidate($options = array()) {
//status to set in PublishableBehavior.
'url' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'URL')),
'allowEmpty' => false,
'required' => true,
@@ -134,8 +134,8 @@ public function beforeValidate($options = array()) {
),
),
'title' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'Title')),
'allowEmpty' => false,
'required' => true,
diff --git a/Model/LinkBlock.php b/Model/LinkBlock.php
index bb7ab22..5225457 100644
--- a/Model/LinkBlock.php
+++ b/Model/LinkBlock.php
@@ -137,8 +137,8 @@ public function saveLinkBlock($data) {
public function validateLinkBlock($data, $contains = []) {
$this->Block->validate = Hash::merge($this->Block->validate, array(
'name' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'Link list Title')),
'required' => true,
)
diff --git a/Model/LinkFrameSetting.php b/Model/LinkFrameSetting.php
index 47824a4..0237ffc 100644
--- a/Model/LinkFrameSetting.php
+++ b/Model/LinkFrameSetting.php
@@ -168,8 +168,8 @@ public function __construct($id = false, $table = null, $ds = null) {
public function beforeValidate($options = array()) {
$this->validate = Hash::merge($this->validate, array(
'frame_key' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => __d('net_commons', 'Invalid request.'),
'allowEmpty' => false,
'required' => true,
diff --git a/Model/LinkOrder.php b/Model/LinkOrder.php
index 6d18ecd..ec18b0d 100644
--- a/Model/LinkOrder.php
+++ b/Model/LinkOrder.php
@@ -38,8 +38,8 @@ class LinkOrder extends LinksAppModel {
public function beforeValidate($options = array()) {
$this->validate = Hash::merge($this->validate, array(
'block_key' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => __d('net_commons', 'Invalid request.'),
'allowEmpty' => false,
'required' => true,
@@ -47,8 +47,8 @@ public function beforeValidate($options = array()) {
),
),
'link_key' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => __d('net_commons', 'Invalid request.'),
'allowEmpty' => false,
'required' => true,
diff --git a/Model/LinkSetting.php b/Model/LinkSetting.php
index 0f3c40a..c3b4052 100644
--- a/Model/LinkSetting.php
+++ b/Model/LinkSetting.php
@@ -38,8 +38,8 @@ class LinkSetting extends LinksAppModel {
public function beforeValidate($options = array()) {
$this->validate = Hash::merge($this->validate, array(
'block_key' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
'message' => __d('net_commons', 'Invalid request.'),
'allowEmpty' => false,
'required' => true,
diff --git a/Test/Case/Model/LinksModelTestBase.php b/Test/Case/Model/LinksModelTestBase.php
index 5c1e682..dcb53fe 100644
--- a/Test/Case/Model/LinksModelTestBase.php
+++ b/Test/Case/Model/LinksModelTestBase.php
@@ -47,7 +47,7 @@ class LinksModelTestBase extends YACakeTestCase {
);
/**
- * Test case of notEmpty
+ * Test case of notBlank
*
* @var array
*/
From c5846ad7be959cbc10e3acef7d5dbc64b1beee58 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 11 Sep 2015 10:01:18 +0900
Subject: [PATCH 041/274] =?UTF-8?q?=E5=85=B1=E9=80=9A=E5=87=A6=E7=90=86?=
=?UTF-8?q?=E3=81=AE=E8=A6=8B=E7=9B=B4=E3=81=97=E3=81=AB=E3=82=88=E3=82=8B?=
=?UTF-8?q?=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/LinkBlockRolePermissionsController.php | 2 +-
Controller/LinkBlocksController.php | 4 ++--
Controller/LinkFrameSettingsController.php | 2 +-
Controller/LinkOrdersController.php | 2 +-
Controller/LinksController.php | 6 +++---
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Controller/LinkBlockRolePermissionsController.php b/Controller/LinkBlockRolePermissionsController.php
index 1432e2c..bea97b9 100644
--- a/Controller/LinkBlockRolePermissionsController.php
+++ b/Controller/LinkBlockRolePermissionsController.php
@@ -102,7 +102,7 @@ public function edit() {
if ($this->request->isPost()) {
$data = $this->data;
$this->LinkSetting->saveLinkSetting($data);
- if ($this->handleValidationError($this->LinkSetting->validationErrors)) {
+ if ($this->NetCommons->handleValidationError($this->LinkSetting->validationErrors)) {
if (! $this->request->is('ajax')) {
$this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
}
diff --git a/Controller/LinkBlocksController.php b/Controller/LinkBlocksController.php
index 89d63bf..ac4a71f 100644
--- a/Controller/LinkBlocksController.php
+++ b/Controller/LinkBlocksController.php
@@ -131,7 +131,7 @@ public function add() {
$data = $this->__parseRequestData();
$this->LinkBlock->saveLinkBlock($data);
- if ($this->handleValidationError($this->LinkBlock->validationErrors)) {
+ if ($this->NetCommons->handleValidationError($this->LinkBlock->validationErrors)) {
if (! $this->request->is('ajax')) {
$this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
}
@@ -168,7 +168,7 @@ public function edit() {
$data['LinkSetting']['block_key'] = $data['Block']['key'];
$this->LinkBlock->saveLinkBlock($data);
- if ($this->handleValidationError($this->LinkBlock->validationErrors)) {
+ if ($this->NetCommons->handleValidationError($this->LinkBlock->validationErrors)) {
if (! $this->request->is('ajax')) {
$this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
}
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index 0b69646..624903d 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -86,7 +86,7 @@ public function edit() {
if ($this->request->isPost()) {
$data = $this->data;
$this->LinkFrameSetting->saveLinkFrameSetting($data);
- if ($this->handleValidationError($this->LinkFrameSetting->validationErrors)) {
+ if ($this->NetCommons->handleValidationError($this->LinkFrameSetting->validationErrors)) {
$this->redirect(Current::backToPageUrl());
return;
}
diff --git a/Controller/LinkOrdersController.php b/Controller/LinkOrdersController.php
index dbaf9e8..672ab4a 100644
--- a/Controller/LinkOrdersController.php
+++ b/Controller/LinkOrdersController.php
@@ -80,7 +80,7 @@ public function edit() {
$this->LinkOrder->saveLinkOrders($data);
//validationError
- if ($this->handleValidationError($this->LinkOrder->validationErrors)) {
+ if ($this->NetCommons->handleValidationError($this->LinkOrder->validationErrors)) {
//リダイレクト
$this->redirect(Current::backToPageUrl());
return;
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
index 2b5f928..fae2d9f 100644
--- a/Controller/LinksController.php
+++ b/Controller/LinksController.php
@@ -174,7 +174,7 @@ public function get() {
$results['description'] = mb_convert_encoding($matches[3], 'utf-8', 'auto');
}
- $this->renderJson($results);
+ $this->NetCommons->renderJson($results);
}
/**
@@ -227,7 +227,7 @@ public function add() {
unset($data['LinkOrder']['weight']);
$this->Link->saveLink($data);
- if ($this->handleValidationError($this->Link->validationErrors)) {
+ if ($this->NetCommons->handleValidationError($this->Link->validationErrors)) {
$this->redirect(Current::backToPageUrl());
return;
}
@@ -289,7 +289,7 @@ public function edit() {
$this->Link->saveLink($data);
- if ($this->handleValidationError($this->Link->validationErrors)) {
+ if ($this->NetCommons->handleValidationError($this->Link->validationErrors)) {
$this->redirect(Current::backToPageUrl());
return;
}
From c72a271259d837174ed3ca75a655227b3c2d370b Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 11 Sep 2015 14:12:39 +0900
Subject: [PATCH 042/274] =?UTF-8?q?=E5=85=B1=E9=80=9A=E5=87=A6=E7=90=86?=
=?UTF-8?q?=E3=81=AE=E8=A6=8B=E7=9B=B4=E3=81=97=E3=81=AB=E3=82=88=E3=82=8B?=
=?UTF-8?q?=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/LinkFrameSettingsController.php | 2 +-
Controller/LinkOrdersController.php | 2 +-
Controller/LinksController.php | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index 624903d..e656b9f 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -87,7 +87,7 @@ public function edit() {
$data = $this->data;
$this->LinkFrameSetting->saveLinkFrameSetting($data);
if ($this->NetCommons->handleValidationError($this->LinkFrameSetting->validationErrors)) {
- $this->redirect(Current::backToPageUrl());
+ $this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
}
diff --git a/Controller/LinkOrdersController.php b/Controller/LinkOrdersController.php
index 672ab4a..271475f 100644
--- a/Controller/LinkOrdersController.php
+++ b/Controller/LinkOrdersController.php
@@ -82,7 +82,7 @@ public function edit() {
//validationError
if ($this->NetCommons->handleValidationError($this->LinkOrder->validationErrors)) {
//リダイレクト
- $this->redirect(Current::backToPageUrl());
+ $this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
}
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
index fae2d9f..473eea9 100644
--- a/Controller/LinksController.php
+++ b/Controller/LinksController.php
@@ -228,7 +228,7 @@ public function add() {
$this->Link->saveLink($data);
if ($this->NetCommons->handleValidationError($this->Link->validationErrors)) {
- $this->redirect(Current::backToPageUrl());
+ $this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
}
@@ -290,7 +290,7 @@ public function edit() {
$this->Link->saveLink($data);
if ($this->NetCommons->handleValidationError($this->Link->validationErrors)) {
- $this->redirect(Current::backToPageUrl());
+ $this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
@@ -333,7 +333,7 @@ public function delete() {
return;
}
- $this->redirect(Current::backToPageUrl());
+ $this->redirect(NetCommonsUrl::backToPageUrl());
}
/**
@@ -363,7 +363,7 @@ public function link() {
return;
}
- $this->redirect(Current::backToPageUrl());
+ $this->redirect(NetCommonsUrl::backToPageUrl());
}
/**
From 0b21cae7804767fa54d52e93c1162edd1ee302cf Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sun, 13 Sep 2015 17:29:17 +0900
Subject: [PATCH 043/274] =?UTF-8?q?phpunit=E3=82=B9=E3=82=AD=E3=83=83?=
=?UTF-8?q?=E3=83=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Test/Case/AllLinksTest.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Test/Case/AllLinksTest.php b/Test/Case/AllLinksTest.php
index 8518499..45d831a 100644
--- a/Test/Case/AllLinksTest.php
+++ b/Test/Case/AllLinksTest.php
@@ -30,6 +30,8 @@ public static function suite() {
$Folder = new Folder($directory);
$exceptions = array(
'LinksModelTestBase.php',
+ //後で削除
+ 'LinkBlockTest.php'
);
$files = $Folder->tree(null, $exceptions, 'files');
foreach ($files as $file) {
From 2857c7951d8441ee72fb550d5dbdd6f9bfa48939 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 30 Oct 2015 11:30:29 +0900
Subject: [PATCH 044/274] =?UTF-8?q?schema=E3=83=95=E3=82=A1=E3=82=A4?=
=?UTF-8?q?=E3=83=AB=E3=81=AE=E3=82=AF=E3=83=A9=E3=82=B9=E5=90=8D=E5=A4=89?=
=?UTF-8?q?=E6=9B=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Config/Schema/schema.php | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/Config/Schema/schema.php b/Config/Schema/schema.php
index 78db591..1c36865 100644
--- a/Config/Schema/schema.php
+++ b/Config/Schema/schema.php
@@ -1,6 +1,6 @@
* @author Shohei Nakajima
@@ -10,13 +10,14 @@
*/
/**
- * AppSchema file
+ * Schema file
*
+ * @author Noriko Arai
* @author Shohei Nakajima
- * @package NetCommons\Faqs\Config\Schema
+ * @package NetCommons\Likes\Config\Schema
* @SuppressWarnings(PHPMD.LongVariable)
*/
-class AppSchema extends CakeSchema {
+class LinksSchema extends CakeSchema {
/**
* Database connection
From 4c513d2c18add386b9a49107f67548d0dcba0625 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 14 Nov 2015 23:38:27 +0900
Subject: [PATCH 045/274] =?UTF-8?q?phpunit.xml.dist=E3=82=92whitelist?=
=?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
phpunit.xml.dist | 42 +++++++++++-------------------------------
1 file changed, 11 insertions(+), 31 deletions(-)
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 41acbf2..ad9f079 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,39 +1,19 @@
-
- app/Config
- app/Controller
- app/Console
- app/Lib
- app/Locale
- app/Model
- app/Vendor
- app/View
- app/Test
- app/Plugin/Auth
- app/Plugin/AuthGeneral
- app/Plugin/Blocks
- app/Plugin/Boxes
- app/Plugin/Categories
- app/Plugin/Comments
- app/Plugin/DebugKit
- app/Plugin/DebugKit
- app/Plugin/Frames
- app/Plugin/Migration
- app/Plugin/MobileDetect
- app/Plugin/NetCommons
- app/Plugin/NetCommons
- app/Plugin/Pages
- app/Plugin/TinyMCE
- app/Plugin/Users
- lib/Cake
- vendors
- app/Plugin
-
+
+ app/Plugin/Links
+ app/Plugin/Links
+
+ app/Plugin/Links/Config/Migration
+ app/Plugin/Links/Config/Schema
+ app/Plugin/Links/Test/Case
+ app/Plugin/Links/Test/Fixture
+
+
-
\ No newline at end of file
+
From 65d3a22ece3db9dca56eb9865f1c6c4f0ba99fe7 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 16 Nov 2015 13:39:56 +0900
Subject: [PATCH 046/274] =?UTF-8?q?phpunit.xml.dist=E3=82=92=E3=82=BF?=
=?UTF-8?q?=E3=83=96=E3=81=8B=E3=82=89=E3=82=B9=E3=83=9A=E3=83=BC=E3=82=B9?=
=?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
phpunit.xml.dist | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index ad9f079..1d0d11a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -4,12 +4,12 @@
app/Plugin/Links
app/Plugin/Links
-
- app/Plugin/Links/Config/Migration
- app/Plugin/Links/Config/Schema
- app/Plugin/Links/Test/Case
- app/Plugin/Links/Test/Fixture
-
+
+ app/Plugin/Links/Config/Migration
+ app/Plugin/Links/Config/Schema
+ app/Plugin/Links/Test/Case
+ app/Plugin/Links/Test/Fixture
+
From 5249668048286a7cc54a832065170bd3888659bc Mon Sep 17 00:00:00 2001
From: Shohei Nakajima
Date: Fri, 25 Dec 2015 18:42:31 +0900
Subject: [PATCH 047/274] Delete comments
https://github.com/NetCommons3/NetCommons3/issues/81
---
composer.json | 1 -
1 file changed, 1 deletion(-)
diff --git a/composer.json b/composer.json
index 8de0e58..61960c7 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,6 @@
"require-dev": {
"mustangostang/spyc": "dev-master",
"netcommons/categories": "dev-master",
- "netcommons/comments": "dev-master",
"netcommons/net-commons": "dev-master",
"satooshi/php-coveralls": "dev-master"
},
From 89184f26567636b9d86f22b443c194780fd19436 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sun, 3 Jan 2016 06:30:40 +0900
Subject: [PATCH 048/274] =?UTF-8?q?=E5=85=B1=E9=80=9A=E5=8C=96=E5=87=A6?=
=?UTF-8?q?=E7=90=86=E3=81=AE=E5=AF=BE=E5=BF=9C=20https://github.com/NetCo?=
=?UTF-8?q?mmons3/Links/issues/4=20https://github.com/NetCommons3/Links/is?=
=?UTF-8?q?sues/5=20https://github.com/NetCommons3/Links/issues/6=20https:?=
=?UTF-8?q?//github.com/NetCommons3/Links/issues/13=20https://github.com/N?=
=?UTF-8?q?etCommons3/Links/issues/14=20https://github.com/NetCommons3/Lin?=
=?UTF-8?q?ks/issues/15?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../LinkBlockRolePermissionsController.php | 83 ++--
Controller/LinkBlocksController.php | 145 +++----
Controller/LinkFrameSettingsController.php | 56 +--
Controller/LinkOrdersController.php | 68 ++--
Controller/LinksAppController.php | 128 +------
Controller/LinksController.php | 357 +++++++-----------
Locale/jpn/LC_MESSAGES/links.mo | Bin 1604 -> 0 bytes
Locale/jpn/LC_MESSAGES/links.po | 4 +
Model/Link.php | 189 +++-------
Model/LinkBlock.php | 250 +++++++-----
Model/LinkFrameSetting.php | 100 ++---
Model/LinkOrder.php | 128 +++----
Model/LinkSetting.php | 77 +---
Model/LinksAppModel.php | 1 -
.../LinkBlockRolePermissions/edit_form.ctp | 24 +-
View/Elements/LinkBlocks/delete_form.ctp | 25 +-
View/Elements/LinkBlocks/edit_form.ctp | 38 +-
View/Elements/LinkFrameSettings/edit_form.ctp | 79 ++--
View/Elements/Links/delete_form.ctp | 39 +-
View/Elements/Links/edit_form.ctp | 126 ++-----
View/Elements/Links/edit_link.ctp | 22 +-
View/Elements/Links/index_dropdown.ctp | 13 +-
View/Elements/Links/index_list_only_title.ctp | 16 +-
.../Links/index_list_with_description.ctp | 18 +-
View/Elements/Links/link.ctp | 26 +-
View/LinkBlockRolePermissions/edit.ctp | 15 +-
View/LinkBlocks/edit.ctp | 26 +-
View/LinkBlocks/index.ctp | 108 ++----
View/LinkBlocks/not_found.ctp | 28 --
View/LinkFrameSettings/edit.ctp | 29 +-
View/LinkOrders/edit.ctp | 136 ++++---
View/Links/edit.ctp | 57 ++-
View/Links/index.ctp | 96 +++--
View/Links/view.ctp | 88 +++--
webroot/js/links.js | 70 ++--
35 files changed, 984 insertions(+), 1681 deletions(-)
delete mode 100644 Locale/jpn/LC_MESSAGES/links.mo
delete mode 100644 View/LinkBlocks/not_found.ctp
diff --git a/Controller/LinkBlockRolePermissionsController.php b/Controller/LinkBlockRolePermissionsController.php
index bea97b9..e1c79ef 100644
--- a/Controller/LinkBlockRolePermissionsController.php
+++ b/Controller/LinkBlockRolePermissionsController.php
@@ -32,12 +32,8 @@ class LinkBlockRolePermissionsController extends LinksAppController {
* @var array
*/
public $uses = array(
- 'Roles.Role',
- 'Roles.DefaultRolePermission',
- 'Blocks.Block',
- 'Blocks.BlockRolePermission',
- 'Rooms.RolesRoom',
- 'Links.LinkSetting'
+ 'Links.LinkBlock',
+ 'Links.LinkSetting',
);
/**
@@ -46,26 +42,25 @@ class LinkBlockRolePermissionsController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsBlock',
- 'NetCommons.NetCommonsRoomRole' => array(
- //コンテンツの権限設定
- 'allowedActions' => array(
- 'blockPermissionEditable' => array('edit')
+ 'Blocks.BlockTabs' => array(
+ 'mainTabs' => array('block_index', 'frame_settings'),
+ 'blockTabs' => array('block_settings', 'role_permissions'),
+ ),
+ 'NetCommons.Permission' => array(
+ 'allow' => array(
+ 'edit' => 'block_permission_editable',
),
),
);
/**
- * beforeFilter
+ * use helpers
*
- * @return void
+ * @var array
*/
- public function beforeFilter() {
- parent::beforeFilter();
-
- //タブの設定
- $this->initTabs('block_index', 'role_permissions');
- }
+ public $helpers = array(
+ 'Blocks.BlockRolePermissionForm'
+ );
/**
* edit
@@ -73,48 +68,32 @@ public function beforeFilter() {
* @return void
*/
public function edit() {
- if (! $this->NetCommonsBlock->validateBlockId()) {
+ if (! $linkBlock = $this->LinkBlock->getLinkBlock()) {
$this->throwBadRequest();
return false;
}
- $this->set('blockId', (int)$this->params['pass'][1]);
- if (! $this->initLink(['linkSetting'])) {
- return;
- }
- if (! $block = $this->Block->find('first', array(
- 'recursive' => -1,
- 'conditions' => array(
- 'Block.id' => $this->viewVars['blockId'],
- ),
- ))) {
- $this->throwBadRequest();
- return false;
- };
- $this->set('blockId', $block['Block']['id']);
- $this->set('blockKey', $block['Block']['key']);
-
- $permissions = $this->NetCommonsBlock->getBlockRolePermissions(
- $this->viewVars['blockKey'],
- ['content_creatable', 'content_publishable']
+ $permissions = $this->Workflow->getBlockRolePermissions(
+ array('content_creatable', 'content_publishable')
);
+ $this->set('roles', $permissions['Roles']);
if ($this->request->isPost()) {
- $data = $this->data;
- $this->LinkSetting->saveLinkSetting($data);
- if ($this->NetCommons->handleValidationError($this->LinkSetting->validationErrors)) {
- if (! $this->request->is('ajax')) {
- $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
- }
+ if ($this->LinkSetting->saveLinkSetting($this->request->data)) {
+ $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
return;
}
- }
+ $this->NetCommons->handleValidationError($this->FaqSetting->validationErrors);
+ $this->request->data['BlockRolePermission'] = Hash::merge(
+ $permissions['BlockRolePermissions'],
+ $this->request->data['BlockRolePermission']
+ );
- $results = array(
- 'BlockRolePermissions' => $permissions['BlockRolePermissions'],
- 'roles' => $permissions['Roles'],
- );
- $results = $this->camelizeKeyRecursive($results);
- $this->set($results);
+ } else {
+ $this->request->data['LinkSetting'] = $linkBlock['LinkSetting'];
+ $this->request->data['Block'] = $linkBlock['Block'];
+ $this->request->data['BlockRolePermission'] = $permissions['BlockRolePermissions'];
+ $this->request->data['Frame'] = Current::read('Frame');
+ }
}
}
diff --git a/Controller/LinkBlocksController.php b/Controller/LinkBlocksController.php
index ac4a71f..297b214 100644
--- a/Controller/LinkBlocksController.php
+++ b/Controller/LinkBlocksController.php
@@ -32,10 +32,7 @@ class LinkBlocksController extends LinksAppController {
* @var array
*/
public $uses = array(
- 'Blocks.Block',
- 'Frames.Frame',
- 'Links.LinkSetting',
- 'Categories.Category',
+ 'Links.LinkBlock',
);
/**
@@ -44,11 +41,14 @@ class LinkBlocksController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsBlock',
- 'NetCommons.NetCommonsRoomRole' => array(
- //コンテンツの権限設定
- 'allowedActions' => array(
- 'blockEditable' => array('index', 'add', 'edit', 'delete')
+ 'Blocks.BlockTabs' => array(
+ 'mainTabs' => array('block_index', 'frame_settings'),
+ 'blockTabs' => array('block_settings', 'role_permissions'),
+ ),
+ 'Categories.CategoryEdit',
+ 'NetCommons.Permission' => array(
+ 'allow' => array(
+ 'index,add,edit,delete' => 'block_editable',
),
),
'Paginator',
@@ -61,7 +61,7 @@ class LinkBlocksController extends LinksAppController {
* @var array
*/
public $helpers = array(
- 'NetCommons.Date',
+ 'Blocks.BlockForm',
);
/**
@@ -73,40 +73,32 @@ public function beforeFilter() {
parent::beforeFilter();
$this->Auth->deny('index');
- //タブの設定
- $this->initTabs('block_index', 'block_settings');
+ //CategoryEditComponentの削除
+ if ($this->params['action'] === 'index') {
+ $this->Components->unload('Categories.CategoryEdit');
+ }
}
/**
* index
*
* @return void
- * @throws Exception
*/
public function index() {
$this->Paginator->settings = array(
'LinkBlock' => array(
'order' => array('Block.id' => 'desc'),
- 'conditions' => array(
- 'Block.language_id' => $this->viewVars['languageId'],
- 'Block.room_id' => $this->viewVars['roomId'],
- 'Block.plugin_key ' => $this->params['plugin'],
- ),
- //'limit' => 1
+ 'conditions' => $this->LinkBlock->getBlockConditions(),
)
);
$linkBlocks = $this->Paginator->paginate('LinkBlock');
if (! $linkBlocks) {
- $this->view = 'not_found';
+ $this->view = 'Blocks.Blocks/not_found';
return;
}
-
- $results = array(
- 'linkBlocks' => $linkBlocks
- );
- $results = $this->camelizeKeyRecursive($results);
- $this->set($results);
+ $this->set('linkBlocks', $linkBlocks);
+ $this->request->data['Frame'] = Current::read('Frame');
}
/**
@@ -117,33 +109,19 @@ public function index() {
public function add() {
$this->view = 'edit';
- $this->set('blockId', null);
- $block = $this->Block->create(
- array(
- 'id' => null,
- 'key' => null,
- 'name' => __d('links', 'New Bookmark List %s', date('YmdHis')),
- )
- );
-
- $data = array();
if ($this->request->isPost()) {
- $data = $this->__parseRequestData();
-
- $this->LinkBlock->saveLinkBlock($data);
- if ($this->NetCommons->handleValidationError($this->LinkBlock->validationErrors)) {
- if (! $this->request->is('ajax')) {
- $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
- }
+ //登録処理
+ if ($this->LinkBlock->saveLinkBlock($this->data)) {
+ $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
return;
}
- $data['Block']['id'] = null;
- $data['Block']['key'] = null;
- unset($data['Frame']);
- }
+ $this->NetCommons->handleValidationError($this->LinkBlock->validationErrors);
- $results = $this->camelizeKeyRecursive(Hash::merge($block, $data));
- $this->set($results);
+ } else {
+ //表示処理(初期データセット)
+ $this->request->data = $this->LinkBlock->createLinkBlock();
+ $this->request->data['Frame'] = Current::read('Frame');
+ }
}
/**
@@ -152,32 +130,23 @@ public function add() {
* @return void
*/
public function edit() {
- if (! $this->NetCommonsBlock->validateBlockId()) {
- $this->throwBadRequest();
- return false;
- }
- $this->set('blockId', (int)$this->params['pass'][1]);
-
- if (! $this->initLink(['linkSetting'])) {
- return;
- }
- $this->Categories->initCategories();
-
- if ($this->request->isPost()) {
- $data = $this->__parseRequestData();
- $data['LinkSetting']['block_key'] = $data['Block']['key'];
-
- $this->LinkBlock->saveLinkBlock($data);
- if ($this->NetCommons->handleValidationError($this->LinkBlock->validationErrors)) {
- if (! $this->request->is('ajax')) {
- $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
- }
+ if ($this->request->isPut()) {
+ //登録処理
+ if ($this->LinkBlock->saveLinkBlock($this->data)) {
+ $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
return;
}
- unset($data['Frame']);
+ $this->NetCommons->handleValidationError($this->LinkBlock->validationErrors);
- $results = $this->camelizeKeyRecursive($data);
- $this->set($results);
+ } else {
+ //表示処理(初期データセット)
+ $linkBlock = $this->LinkBlock->getLinkBlock();
+ if (! $linkBlock) {
+ $this->throwBadRequest();
+ return false;
+ }
+ $this->request->data = Hash::merge($this->request->data, $linkBlock);
+ $this->request->data['Frame'] = Current::read('Frame');
}
}
@@ -187,43 +156,13 @@ public function edit() {
* @return void
*/
public function delete() {
- if (! $this->NetCommonsBlock->validateBlockId()) {
- $this->throwBadRequest();
- return false;
- }
- $this->set('blockId', (int)$this->params['pass'][1]);
-
- if (! $this->initLink()) {
- return;
- }
-
if ($this->request->isDelete()) {
if ($this->LinkBlock->deleteLinkBlock($this->data)) {
- if (! $this->request->is('ajax')) {
- $this->redirect('/links/link_blocks/index/' . $this->viewVars['frameId']);
- }
+ $this->redirect(NetCommonsUrl::backToIndexUrl('default_setting_action'));
return;
}
}
$this->throwBadRequest();
}
-
-/**
- * Parse data from request
- *
- * @return array
- */
- private function __parseRequestData() {
- $data = $this->data;
- if ($data['Block']['public_type'] === Block::TYPE_LIMITED) {
- //$data['Block']['from'] = implode('-', $data['Block']['from']);
- //$data['Block']['to'] = implode('-', $data['Block']['to']);
- } else {
- unset($data['Block']['from'], $data['Block']['to']);
- }
-
- return $data;
- }
-
}
diff --git a/Controller/LinkFrameSettingsController.php b/Controller/LinkFrameSettingsController.php
index e656b9f..7c78d69 100644
--- a/Controller/LinkFrameSettingsController.php
+++ b/Controller/LinkFrameSettingsController.php
@@ -41,61 +41,33 @@ class LinkFrameSettingsController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsRoomRole' => array(
- //コンテンツの権限設定
- 'allowedActions' => array(
- 'pageEditable' => array('edit')
+ 'Blocks.BlockTabs' => array(
+ 'mainTabs' => array('block_index', 'frame_settings'),
+ 'blockTabs' => array('block_settings', 'role_permissions'),
+ ),
+ 'NetCommons.Permission' => array(
+ 'allow' => array(
+ 'edit' => 'page_editable',
),
),
);
-/**
- * beforeFilter
- *
- * @return void
- */
- public function beforeFilter() {
- parent::beforeFilter();
-
- //タブの設定
- $this->initTabs('frame_settings', '');
- }
-
/**
* edit
*
* @return void
*/
public function edit() {
- if (! $this->NetCommonsFrame->validateFrameId()) {
- $this->throwBadRequest();
- return false;
- }
- if (! $linkFrameSetting = $this->LinkFrameSetting->getLinkFrameSetting($this->viewVars['frameKey'])) {
- $linkFrameSetting = $this->LinkFrameSetting->create(array(
- 'id' => null,
- 'display_type' => LinkFrameSetting::TYPE_DROPDOWN,
- 'frame_key' => $this->viewVars['frameKey'],
- 'category_separator_line' => null,
- 'list_style' => null,
- ));
- }
- $linkFrameSetting = $this->camelizeKeyRecursive($linkFrameSetting);
-
- $data = array();
- if ($this->request->isPost()) {
- $data = $this->data;
- $this->LinkFrameSetting->saveLinkFrameSetting($data);
- if ($this->NetCommons->handleValidationError($this->LinkFrameSetting->validationErrors)) {
+ if ($this->request->isPut() || $this->request->isPost()) {
+ if ($this->LinkFrameSetting->saveLinkFrameSetting($this->data)) {
$this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
- }
+ $this->NetCommons->handleValidationError($this->LinkFrameSetting->validationErrors);
- $data = Hash::merge(
- $linkFrameSetting, $data
- );
- $results = $this->camelizeKeyRecursive($data);
- $this->set($results);
+ } else {
+ $this->request->data = $this->LinkFrameSetting->getLinkFrameSetting(true);
+ $this->request->data['Frame'] = Current::read('Frame');
+ }
}
}
diff --git a/Controller/LinkOrdersController.php b/Controller/LinkOrdersController.php
index 271475f..3fd856c 100644
--- a/Controller/LinkOrdersController.php
+++ b/Controller/LinkOrdersController.php
@@ -26,9 +26,8 @@ class LinkOrdersController extends LinksAppController {
*/
public $uses = array(
'Links.Link',
+ 'Links.LinkBlock',
'Links.LinkOrder',
- 'Links.LinkFrameSetting',
- 'Categories.Category',
);
/**
@@ -37,15 +36,12 @@ class LinkOrdersController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsBlock',
- 'NetCommons.NetCommonsRoomRole' => array(
- //コンテンツの権限設定
- 'allowedActions' => array(
- 'contentEditable' => array('edit'),
+ 'NetCommons.Permission' => array(
+ 'allow' => array(
+ 'edit' => 'content_editable',
),
),
'Categories.Categories',
- 'Paginator',
);
/**
@@ -54,42 +50,42 @@ class LinkOrdersController extends LinksAppController {
* @return void
*/
public function edit() {
- if (! $this->initLink()) {
- return;
+ $linkBlock = $this->LinkBlock->getLinkBlock();
+ if (! $linkBlock) {
+ $this->setAction('throwBadRequest');
+ return false;
}
- $this->Categories->initCategories(true);
+ $this->set('linkBlock', $linkBlock['LinkBlock']);
- $this->Paginator->settings = array(
- 'Link' => array(
- 'order' => array('LinkOrder.weight' => 'asc'),
- 'conditions' => array(
- 'Link.block_id' => $this->viewVars['blockId'],
- 'Link.is_latest' => true,
- ),
- 'limit' => -1
- )
- );
- $links = $this->Paginator->paginate('Link');
- $links = Hash::combine($links, '{n}.LinkOrder.weight', '{n}', '{n}.Category.id');
+ //カテゴリ
+ array_unshift($this->viewVars['categories'], $this->Category->create(array('id' => 0, 'name' => '')));
- //POST処理
- $data = array();
- if ($this->request->isPost()) {
- //登録処理
- $data = $this->data;
+ //リンクデータ取得
+ $links = $this->Link->find('all', array(
+ 'recursive' => 0,
+ 'conditions' => array(
+ 'Link.block_id' => Current::read('Block.id'),
+ 'Link.is_latest' => true,
+ ),
+ 'order' => array(
+ 'CategoryOrder.weight' => 'asc',
+ 'LinkOrder.weight' => 'asc',
+ ),
+ ));
+ $this->set('links', Hash::combine($links, '{n}.LinkOrder.weight', '{n}', '{n}.Link.category_id'));
- $this->LinkOrder->saveLinkOrders($data);
- //validationError
- if ($this->NetCommons->handleValidationError($this->LinkOrder->validationErrors)) {
- //リダイレクト
+ if ($this->request->isPost()) {
+ if ($this->LinkOrder->saveLinkOrders($this->data)) {
$this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
- }
+ $this->NetCommons->handleValidationError($this->LinkOrder->validationErrors);
- $data = Hash::merge(array('links' => $links), $data);
- $results = $this->camelizeKeyRecursive($data);
- $this->set($results);
+ } else {
+ $this->request->data['LinkOrders'] = Hash::combine($links, '{n}.LinkOrder.id', '{n}');
+ $this->request->data['Frame'] = Current::read('Frame');
+ $this->request->data['Block'] = Current::read('Block');
+ }
}
}
diff --git a/Controller/LinksAppController.php b/Controller/LinksAppController.php
index 7006b18..fa171ce 100644
--- a/Controller/LinksAppController.php
+++ b/Controller/LinksAppController.php
@@ -10,6 +10,7 @@
*/
App::uses('AppController', 'Controller');
+App::uses('LinkFrameSetting', 'Links.Model');
/**
* LinksApp Controller
@@ -25,134 +26,7 @@ class LinksAppController extends AppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsFrame',
'Pages.PageLayout',
'Security',
);
-
-/**
- * use models
- *
- * @var array
- */
- public $uses = array(
- 'Links.LinkBlock',
- );
-
-/**
- * initLink
- *
- * @param array $contains Optional result sets
- * @return bool True on success, False on failure
- */
- public function initLink($contains = []) {
- if (! $linkBlock = $this->LinkBlock->getLinkBlock($this->viewVars['blockId'], $this->viewVars['roomId'])) {
- $this->throwBadRequest();
- return false;
- }
- $linkBlock = $this->camelizeKeyRecursive($linkBlock);
- $this->set($linkBlock);
-
- if (in_array('linkSetting', $contains, true)) {
- if (! $linkSetting = $this->LinkSetting->getLinkSetting($linkBlock['linkBlock']['key'])) {
- $linkSetting = $this->LinkSetting->create(
- array('id' => null)
- );
- }
- $linkSetting = $this->camelizeKeyRecursive($linkSetting);
- $this->set($linkSetting);
- }
-
- if (in_array('linkFrameSetting', $contains, true)) {
- if (! $linkFrameSetting = $this->LinkFrameSetting->getLinkFrameSetting($this->viewVars['frameKey'])) {
- $linkFrameSetting = $this->LinkFrameSetting->create(array(
- 'id' => null,
- 'display_type' => LinkFrameSetting::TYPE_DROPDOWN,
- 'category_separator_line' => LinkFrameSetting::CATEGORY_SEPARATOR_DEFAULT,
- 'list_style' => LinkFrameSetting::LINE_STYLE_DISC,
- ));
- }
-
- //カテゴリ間の区切り線
- $separatorLine = $linkFrameSetting['LinkFrameSetting']['category_separator_line'];
- $linkFrameSetting['LinkFrameSetting']['category_separator_line_css'] =
- $this->LinkFrameSetting->getCategorySeparatorLineCss($separatorLine);
-
- //リストマーク
- $listStyle = $linkFrameSetting['LinkFrameSetting']['list_style'];
- $linkFrameSetting['LinkFrameSetting']['list_style_css'] = $this->LinkFrameSetting->getLineStyleCss($listStyle);
-
- $linkFrameSetting = $this->camelizeKeyRecursive($linkFrameSetting);
- $this->set($linkFrameSetting);
- }
-
- $this->set('userId', (int)$this->Auth->user('id'));
-
- return true;
- }
-
-/**
- * initTabs
- *
- * @param string $mainActiveTab Main active tab
- * @param string $blockActiveTab Block active tab
- * @return void
- */
- public function initTabs($mainActiveTab, $blockActiveTab) {
- if (isset($this->params['pass'][1])) {
- $blockId = (int)$this->params['pass'][1];
- } else {
- $blockId = null;
- }
-
- //タブの設定
- $settingTabs = array(
- 'tabs' => array(
- 'block_index' => array(
- 'url' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'link_blocks',
- 'action' => 'index',
- $this->viewVars['frameId'],
- )
- ),
- 'frame_settings' => array(
- 'url' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'link_frame_settings',
- 'action' => 'edit',
- $this->viewVars['frameId'],
- )
- ),
- ),
- 'active' => $mainActiveTab
- );
- $this->set('settingTabs', $settingTabs);
-
- $blockSettingTabs = array(
- 'tabs' => array(
- 'block_settings' => array(
- 'url' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'link_blocks',
- 'action' => $this->params['action'],
- $this->viewVars['frameId'],
- $blockId
- )
- ),
- 'role_permissions' => array(
- 'url' => array(
- 'plugin' => $this->params['plugin'],
- 'controller' => 'link_block_role_permissions',
- 'action' => 'edit',
- $this->viewVars['frameId'],
- $blockId
- )
- ),
- ),
- 'active' => $blockActiveTab
- );
- $this->set('blockSettingTabs', $blockSettingTabs);
- }
-
}
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
index 473eea9..2b96889 100644
--- a/Controller/LinksController.php
+++ b/Controller/LinksController.php
@@ -26,12 +26,11 @@ class LinksController extends LinksAppController {
* @var array
*/
public $uses = array(
- 'Blocks.Block',
'Links.Link',
+ 'Links.LinkBlock',
'Links.LinkOrder',
'Links.LinkFrameSetting',
'Categories.Category',
- 'Comments.Comment',
);
/**
@@ -40,12 +39,9 @@ class LinksController extends LinksAppController {
* @var array
*/
public $components = array(
- 'NetCommons.NetCommonsBlock',
- 'NetCommons.NetCommonsWorkflow',
- 'NetCommons.NetCommonsRoomRole' => array(
- //コンテンツの権限設定
- 'allowedActions' => array(
- 'contentCreatable' => array('add', 'edit', 'delete', 'get'),
+ 'NetCommons.Permission' => array(
+ 'allow' => array(
+ 'link,add,edit,delete' => 'content_creatable',
),
),
'Categories.Categories',
@@ -57,7 +53,8 @@ class LinksController extends LinksAppController {
* @var array
*/
public $helpers = array(
- 'NetCommons.Token'
+ 'NetCommons.Token',
+ 'Workflow.Workflow',
);
/**
@@ -67,7 +64,18 @@ class LinksController extends LinksAppController {
*/
public function beforeFilter() {
parent::beforeFilter();
- $this->Auth->allow('index', 'view', 'link');
+
+ if (! Current::read('Block.id')) {
+ $this->setAction('emptyRender');
+ return false;
+ }
+
+ $linkBlock = $this->LinkBlock->getLinkBlock();
+ if (! $linkBlock) {
+ $this->setAction('throwBadRequest');
+ return false;
+ }
+ $this->set('linkBlock', $linkBlock['LinkBlock']);
}
/**
@@ -76,43 +84,28 @@ public function beforeFilter() {
* @return void
*/
public function index() {
- if (! $this->viewVars['blockId']) {
- $this->autoRender = false;
- return;
- }
- if (! $this->initLink(['linkFrameSetting'])) {
+ $linkFrameSetting = $this->LinkFrameSetting->getLinkFrameSetting(true);
+ if (! $linkFrameSetting) {
+ $this->throwBadRequest();
return;
}
- $this->Categories->initCategories(true, '{n}.Category.id');
+ $this->set('linkFrameSetting', $linkFrameSetting['LinkFrameSetting']);
- //条件
- $conditions = $this->__setConditions();
+ //カテゴリ
+ array_unshift($this->viewVars['categories'], $this->Category->create(array('id' => 0)));
//取得
- $links = $this->Link->getLinks($conditions);
- $links = Hash::combine($links, '{n}.Link.id', '{n}', '{n}.Category.id');
-
- //Viewにセット
- $results = array(
- 'links' => $links
- );
- $results = $this->camelizeKeyRecursive($results);
- $this->set($results);
-
- //Tokenセット
- $this->request->data = array(
- 'Frame' => array(
- 'id' => $this->viewVars['frameId']
+ $links = $this->Link->getWorkflowContents('all', array(
+ 'recursive' => 0,
+ 'conditions' => array(
+ 'Link.block_id' => Current::read('Block.id'),
),
- 'Link' => array(
- 'id' => null,
- 'key' => null,
+ 'order' => array(
+ 'CategoryOrder.weight' => 'asc',
+ 'LinkOrder.weight' => 'asc',
),
- );
- $tokenFields = Hash::flatten($this->request->data);
- $hiddenFields = array('Frame.id');
- $this->set('tokenFields', $tokenFields);
- $this->set('hiddenFields', $hiddenFields);
+ ));
+ $this->set('links', Hash::combine($links, '{n}.Link.id', '{n}', '{n}.Category.id'));
}
/**
@@ -121,17 +114,29 @@ public function index() {
* @return void
*/
public function view() {
- $linkKey = null;
- if (isset($this->params['pass'][1])) {
- $linkKey = $this->params['pass'][1];
+ $link = $this->Link->getWorkflowContents('first', array(
+ 'recursive' => -1,
+ 'conditions' => array(
+ $this->Link->alias . '.block_id' => Current::read('Block.id'),
+ $this->Link->alias . '.key' => Hash::get($this->params['pass'], '1')
+ )
+ ));
+ if (! $link) {
+ $this->throwBadRequest();
+ return;
}
- $this->set('linkKey', $linkKey);
+ $this->set('link', $link);
- //データ取得
- if (! $this->__initLink(['linkFrameSetting'])) {
+ $category = Hash::extract(
+ $this->viewVars['categories'],
+ '{n}.Category[id=' . $link['Link']['category_id'] . ']'
+ );
+ $this->set('category', Hash::get($category, '0', array()));
+
+ if (! $this->Link->updateCount($link['Link']['id'])) {
+ $this->throwBadRequest();
return;
}
- $this->Categories->initCategories();
}
/**
@@ -185,61 +190,31 @@ public function get() {
public function add() {
$this->view = 'edit';
- //データ取得
- if (! $this->initLink()) {
- return;
- }
- $this->Categories->initCategories(false, '{n}.Category.id');
-
- $link = $this->Link->create(
- array(
- 'id' => null,
- 'key' => null,
- 'block_id' => $this->viewVars['blockId'],
- 'category_id' => null,
- )
- );
- $linkOrder = $this->LinkOrder->create(
- array(
- 'id' => null,
- 'block_key' => $this->viewVars['blockKey'],
- 'link_key' => null,
- )
- );
-
- //POSTの場合、登録処理
- $data = array();
if ($this->request->isPost()) {
- if (! $status = $this->NetCommonsWorkflow->parseStatus()) {
- return;
- }
- if (isset($this->viewVars['categories'][$this->data['Link']['category_id']])) {
- $category['Category'] = $this->viewVars['categories'][$this->data['Link']['category_id']]['category'];
- } else {
- $category = $this->Category->create(array('key' => null));
- }
- $data = Hash::merge(
- $this->data, array(
- 'Link' => array('status' => $status),
- ),
- $category
+ //登録処理
+ $data = $this->data;
+ $data['Link']['status'] = $this->Workflow->parseStatus();
+ $category = Hash::extract(
+ $this->viewVars['categories'],
+ '{n}.Category[id=' . Hash::get($data, 'Link.category_id', '') . ']'
);
- unset($data['LinkOrder']['weight']);
+ $data['LinkOrder']['category_key'] = Hash::get($category, '0.key', '');
+ unset($data['Link']['id'], $data['LinkOrder']['weight']);
- $this->Link->saveLink($data);
- if ($this->NetCommons->handleValidationError($this->Link->validationErrors)) {
+ if ($this->Link->saveLink($data)) {
$this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
- }
+ $this->NetCommons->handleValidationError($this->Link->validationErrors);
- //Viewにセット
- $data = Hash::merge(
- $link, $linkOrder, $data,
- ['contentStatus' => null, 'comments' => []]
- );
- $results = $this->camelizeKeyRecursive($data);
- $this->set($results);
+ } else {
+ $this->request->data = Hash::merge($this->request->data,
+ $this->Link->create(),
+ $this->LinkOrder->create()
+ );
+ $this->request->data['Frame'] = Current::read('Frame');
+ $this->request->data['Block'] = Current::read('Block');
+ }
}
/**
@@ -248,62 +223,51 @@ public function add() {
* @return void
*/
public function edit() {
- $linkKey = null;
- if (isset($this->params['pass'][1])) {
- $linkKey = $this->params['pass'][1];
- }
- $this->set('linkKey', $linkKey);
-
//データ取得
- if (! $this->__initLink(['comments'])) {
- return;
+ $linkKey = $this->params['pass'][1];
+ if ($this->request->isPut()) {
+ $linkKey = $this->data['Link']['key'];
}
- $this->Categories->initCategories(false, '{n}.Category.id');
+ $link = $this->Link->getWorkflowContents('first', array(
+ 'recursive' => 0,
+ 'conditions' => array(
+ $this->Link->alias . '.block_id' => Current::read('Block.id'),
+ $this->Link->alias . '.key' => $linkKey
+ )
+ ));
- //POSTの場合、登録処理
- $data = array();
- if ($this->request->isPost()) {
- if (! $status = $this->NetCommonsWorkflow->parseStatus()) {
- return;
- }
+ //編集権限チェック
+ if (! $this->Link->canEditWorkflowContent($link)) {
+ $this->throwBadRequest();
+ return false;
+ }
+ if ($this->request->isPut()) {
+ //登録処理
$data = $this->data;
-
- $categoryId = $data['Link']['category_id'];
- $category = array();
- if (isset($this->viewVars['categories'][$categoryId])) {
- $category['Category'] = $this->viewVars['categories'][$categoryId]['category'];
- } else {
- $category = $this->Category->create(array('key' => null));
- }
-
- $data = Hash::merge(
- $data, $category,
- array('Link' => array(
- 'status' => $status,
- 'click_count' => $this->viewVars['link']['clickCount'],
- 'created_user' => $this->viewVars['link']['createdUser']
- ))
+ $data['Link']['status'] = $this->Workflow->parseStatus();
+ $category = Hash::extract(
+ $this->viewVars['categories'],
+ '{n}.Category[id=' . $data['Link']['category_id'] . ']'
);
- unset($data['Link']['id'], $data['LinkOrder']['weight']);
+ $data['LinkOrder']['category_key'] = Hash::get($category, '0.key', '');
+ unset($data['Link']['id']);
- $this->Link->saveLink($data);
-
- if ($this->NetCommons->handleValidationError($this->Link->validationErrors)) {
+ if ($this->Link->saveLink($data)) {
$this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
+ $this->NetCommons->handleValidationError($this->Link->validationErrors);
- $data['contentStatus'] = null;
- $data['comments'] = null;
+ } else {
+ $this->request->data = $link;
+ $this->request->data['Frame'] = Current::read('Frame');
+ $this->request->data['Block'] = Current::read('Block');
}
- $data = Hash::merge(
- $this->viewVars, $data,
- ['contentStatus' => $this->viewVars['link']['status']]
- );
- $results = $this->camelizeKeyRecursive($data);
- $this->set($results);
+ //コメント取得
+ $comments = $this->Link->getCommentsByContentKey($linkKey);
+ $this->set('comments', $comments);
}
/**
@@ -312,20 +276,24 @@ public function edit() {
* @return void
*/
public function delete() {
- $linkKey = null;
- if (isset($this->params['pass'][1])) {
- $linkKey = $this->params['pass'][1];
+ if (! $this->request->isDelete()) {
+ $this->throwBadRequest();
+ return;
}
- $this->set('linkKey', $linkKey);
//データ取得
- if (! $this->__initLink()) {
- return;
- }
+ $link = $this->Link->getWorkflowContents('first', array(
+ 'recursive' => -1,
+ 'conditions' => array(
+ $this->Link->alias . '.block_id' => Current::read('Block.id'),
+ $this->Link->alias . '.key' => $this->data['Link']['key']
+ )
+ ));
- if (! $this->request->isDelete()) {
+ //削除権限チェック
+ if (! $this->Link->canDeleteWorkflowContent($link)) {
$this->throwBadRequest();
- return;
+ return false;
}
if (! $this->Link->deleteLink($this->data)) {
@@ -342,101 +310,28 @@ public function delete() {
* @return void
*/
public function link() {
- $linkKey = null;
- if (isset($this->data['Link']['key'])) {
- $linkKey = $this->data['Link']['key'];
- }
- $this->set('linkKey', $linkKey);
-
- //データ取得
- if (! $this->__initLink()) {
- return;
- }
-
if (! $this->request->isPost()) {
$this->throwBadRequest();
return;
}
- if (! $this->Link->updateCount($this->data['Link']['id'], $this->viewVars['blockId'])) {
+ $link = $this->Link->getWorkflowContents('first', array(
+ 'recursive' => -1,
+ 'conditions' => array(
+ $this->Link->alias . '.block_id' => Current::read('Block.id'),
+ $this->Link->alias . '.id' => Hash::get($this->data, 'Link.id')
+ )
+ ));
+ if (! $link) {
$this->throwBadRequest();
return;
}
- $this->redirect(NetCommonsUrl::backToPageUrl());
- }
-
-/**
- * Get conditions function for getting the Link data.
- *
- * @return array Conditions data
- */
- private function __setConditions() {
- //言語の指定
- $activeConditions = array(
- 'Link.is_active' => true,
- );
- $latestConditons = array();
-
- if ($this->viewVars['contentEditable']) {
- $activeConditions = array();
- $latestConditons = array(
- 'Link.is_latest' => true,
- );
- } elseif ($this->viewVars['contentCreatable']) {
- $activeConditions = array(
- 'Link.is_active' => true,
- 'Link.created_user !=' => (int)$this->viewVars['userId'],
- );
- $latestConditons = array(
- 'Link.is_latest' => true,
- 'Link.created_user' => (int)$this->viewVars['userId'],
- );
- }
-
- $conditions = array(
- 'Link.block_id' => $this->viewVars['blockId'],
- 'OR' => array($activeConditions, $latestConditons)
- );
-
- return $conditions;
- }
-
-/**
- * Function do set into view with getting the Link data.
- *
- * @param array $contains Optional result sets
- * @return bool True on success, False on failure
- */
- private function __initLink($contains = []) {
- if (! $this->initLink($contains)) {
- return false;
- }
-
- $conditions = $this->__setConditions();
- if (! $link = $this->Link->getLink(
- $this->viewVars['blockId'],
- $this->viewVars['linkKey'],
- $conditions
- )) {
+ if (! $this->Link->updateCount($this->data['Link']['id'])) {
$this->throwBadRequest();
- return false;
- }
- $link = $this->camelizeKeyRecursive($link);
- $this->set($link);
-
- if (in_array('comments', $contains, true)) {
- $comments = $this->Comment->getComments(
- array(
- 'plugin_key' => $this->params['plugin'],
- 'content_key' => $this->viewVars['linkKey'],
- )
- );
- $comments = $this->camelizeKeyRecursive($comments);
- $this->set(['comments' => $comments]);
+ return;
}
- return true;
+ $this->redirect(NetCommonsUrl::backToPageUrl());
}
-
}
diff --git a/Locale/jpn/LC_MESSAGES/links.mo b/Locale/jpn/LC_MESSAGES/links.mo
deleted file mode 100644
index a4ef4d098d01a8f129968d8df7af43f1156f82a9..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1604
zcmZvaUuauZ9LJB^O^wrO{fo|Vgb6L<#zd&r)QVl3)k>O%B%1?4ylGC`yCnC9drwyj
zg1z_7*>#&8lV-z8bx^y}X*Z~Uwz*C4#TQ=$pMCH&Sqnbsqxj|=R7*DY1O{gE%W?H;xn4+EaTH~hVM+`B+dTpUgLHYvg6V9-0l%-*r
ztj}=DMSYT&gdDT-Y`<<4MV?EGTREv4CYNJ^OG6d~AF*smhQrJHs0g$Ep=VeES?E&;
zK0IMKvVJP!#Ixka26ek2Y?c%ge4k|%N)Q7>{;b22L7{~(8!8Kv>kiks2|KChSVk|E
z;hhmhF)V|!sVHa6nqV1xcy5yCZL6HOCd|5mQZ`S#ZA+8wtX@jWwhkkjHjvj23fn>Z
zF`h~fy&mt)@`LeoW?(28N)2ggam1iYtq&86@#iDa4lVM67K!p`XDrgOH}X;>5=!Wf
z)Uvj2Iz?Stc8n)`2IKtY_+ZaK;?ulOlDI>zx;^wfGH_Xu(
z@5~u8lq!zfdQsbN*(E2&&2k_*-2=&Nyg#1q;&nxL{7{N2#ss=Bf~*$&F3lPI+enNb
z)BQ+PM!|-Jn*vR$HChaIe;87FhNDN=@h^gF952O>y
zJ)ykg%KKhhuT7n?d2ts+uP%)Vqc>|D&p&J{4$#d*v@E|3;AD2CG%BtS`+ro7@b7f4-@7
zPb$|#=4QE59(e|h9;N>L3Od-RoKWs8O8;86
qbX@sgD$Jjprj)mY0Br5*)cVqe#xrac+UgIm_T4#*kY2AjU-l2bNFEOW
diff --git a/Locale/jpn/LC_MESSAGES/links.po b/Locale/jpn/LC_MESSAGES/links.po
index 506afbf..7fef5c2 100644
--- a/Locale/jpn/LC_MESSAGES/links.po
+++ b/Locale/jpn/LC_MESSAGES/links.po
@@ -110,3 +110,7 @@ msgstr ""
#: Links/View/Links/index.ctp:37
msgid "Create link"
msgstr "リンクの作成"
+
+#: Links/View/Links/index.ctp:37
+msgid "Link creatable roles"
+msgstr "リンクを追加できる権限"
diff --git a/Model/Link.php b/Model/Link.php
index 62199a7..3021212 100644
--- a/Model/Link.php
+++ b/Model/Link.php
@@ -28,8 +28,9 @@ class Link extends LinksAppModel {
* @var array
*/
public $actsAs = array(
- 'NetCommons.Publishable',
'NetCommons.OriginalKey',
+ 'Workflow.WorkflowComment',
+ 'Workflow.Workflow',
);
/**
@@ -54,13 +55,6 @@ class Link extends LinksAppModel {
'fields' => '',
'order' => array('LinkOrder.weight' => 'asc')
),
- 'Block' => array(
- 'className' => 'Block',
- 'foreignKey' => 'block_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- ),
'Category' => array(
'className' => 'Categories.Category',
'foreignKey' => 'category_id',
@@ -106,9 +100,6 @@ public function beforeValidate($options = array()) {
'on' => 'update', // Limit validation to 'create' or 'update' operations
),
),
-
- //status to set in PublishableBehavior.
-
'click_count' => array(
'numeric' => array(
'rule' => array('numeric'),
@@ -143,46 +134,35 @@ public function beforeValidate($options = array()) {
),
));
- return parent::beforeValidate($options);
- }
+ if (isset($this->data['LinkOrder'])) {
+ $this->LinkOrder->set($this->data['LinkOrder']);
+ if (! $this->LinkOrder->validates()) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->LinkOrder->validationErrors);
+ return false;
+ }
+ }
-/**
- * Get Links
- *
- * @param array $conditions findAll conditions
- * @return array Links
- */
- public function getLinks($conditions) {
- $links = $this->find('all', array(
- 'recursive' => 0,
- 'conditions' => $conditions,
- 'order' => array(
- 'CategoryOrder.weight' => 'asc',
- 'LinkOrder.weight' => 'asc',
- ),
- ));
- return $links;
+ return parent::beforeValidate($options);
}
/**
- * Get Link
+ * Called after each successful save operation.
*
- * @param int $blockId blocks.id
- * @param string $linkKey links.key
- * @param array $conditions find conditions
- * @return array Link
+ * @param bool $created True if this save created a new record
+ * @param array $options Options passed from Model::save().
+ * @return void
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave
+ * @see Model::save()
+ * @throws InternalErrorException
*/
- public function getLink($blockId, $linkKey, $conditions = []) {
- $conditions[$this->alias . '.block_id'] = $blockId;
- $conditions[$this->alias . '.key'] = $linkKey;
-
- $link = $this->find('first', array(
- 'recursive' => 0,
- 'conditions' => $conditions,
- )
- );
-
- return $link;
+ public function afterSave($created, $options = array()) {
+ //LinkOrder登録
+ if (isset($this->LinkOrder->data['LinkOrder'])) {
+ $this->LinkOrder->data['LinkOrder']['link_key'] = $this->data[$this->alias]['key'];
+ if (! $this->LinkOrder->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
+ }
+ }
}
/**
@@ -194,85 +174,36 @@ public function getLink($blockId, $linkKey, $conditions = []) {
*/
public function saveLink($data) {
$this->loadModels([
- 'Link' => 'Links.Link',
+ 'Category' => 'Categories.Category',
'LinkOrder' => 'Links.LinkOrder',
- 'Comment' => 'Comments.Comment',
]);
//トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ $this->begin();
- try {
- //バリデーション
- if (! $this->validateLink($data, ['linkOrder', 'comment'])) {
- return false;
- }
+ //バリデーション
+ $this->set($data);
+ if (! $this->validates()) {
+ return false;
+ }
+ try {
//Link登録
if (! $link = $this->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
- //LinkOrder登録
- $this->LinkOrder->data['LinkOrder']['category_key'] = $data['Category']['key'];
- if (! $data['LinkOrder']['link_key']) {
- $this->LinkOrder->data['LinkOrder']['link_key'] = $link[$this->alias]['key'];
- }
- if (! $this->LinkOrder->save(null, false)) {
- throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
- }
- //Comment登録
- if (isset($data['Comment']) && $this->Comment->data) {
- $this->Comment->data[$this->Comment->name]['block_key'] = $link['Block']['key'];
- $this->Comment->data[$this->Comment->name]['content_key'] = $link[$this->name]['key'];
- if (! $this->Comment->save(null, false)) {
- throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
- }
- }
-
//トランザクションCommit
- $dataSource->commit();
+ $this->commit();
} catch (Exception $ex) {
//トランザクションRollback
- $dataSource->rollback();
- CakeLog::error($ex);
- throw $ex;
+ $this->rollback($ex);
}
return $link;
}
-/**
- * validate of Link
- *
- * @param array $data received post data
- * @param array $contains Optional validate sets
- * @return bool True on success, false on validation errors
- */
- public function validateLink($data, $contains = []) {
- $this->set($data);
- $this->validates();
- if ($this->validationErrors) {
- return false;
- }
- if (in_array('linkOrder', $contains, true)) {
- if (! $this->LinkOrder->validateLinkOrder($data)) {
- $this->validationErrors = Hash::merge($this->validationErrors, $this->LinkOrder->validationErrors);
- return false;
- }
- }
- if (in_array('comment', $contains, true) && isset($data['Comment'])) {
- if (! $this->Comment->validateByStatus($data, array('plugin' => $this->plugin, 'caller' => $this->name))) {
- $this->validationErrors = Hash::merge($this->validationErrors, $this->Comment->validationErrors);
- return false;
- }
- }
- return true;
- }
-
/**
* Delete Link
*
@@ -282,44 +213,30 @@ public function validateLink($data, $contains = []) {
*/
public function deleteLink($data) {
$this->loadModels([
- 'Link' => 'Links.Link',
'LinkOrder' => 'Links.LinkOrder',
- 'Comment' => 'Comments.Comment',
]);
//トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ $this->begin();
try {
if (! $this->deleteAll(array($this->alias . '.key' => $data['Link']['key']), false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
- $this->LinkOrder->data = array(
- $this->LinkOrder->name => array(
- 'link_key' => $data['Link']['key'],
- )
- );
- if (! $this->LinkOrder->deleteAll(
- $this->LinkOrder->data[$this->LinkOrder->name], false
- )) {
+ if (! $this->LinkOrder->delete($data['LinkOrder']['id'])) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//コメントの削除
- $this->Comment->deleteByContentKey($data['Link']['key']);
+ $this->deleteCommentsByContentKey($data['Link']['key']);
//トランザクションCommit
- $dataSource->commit();
+ $this->commit();
} catch (Exception $ex) {
//トランザクションRollback
- $dataSource->rollback();
- //エラー出力
- CakeLog::error($ex);
- throw $ex;
+ $this->rollback($ex);
}
return true;
@@ -329,39 +246,31 @@ public function deleteLink($data) {
* Update count
*
* @param int $id links.id
- * @param int $blockId blocks.id
* @return bool True on success, false on validation errors
- * @throws InternalErrorException
*/
- public function updateCount($id, $blockId) {
- $this->loadModels([
- 'Link' => 'Links.Link',
- ]);
-
+ public function updateCount($id) {
//トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ $this->begin();
try {
$this->updateAll(
- array($this->name . '.click_count' => $this->name . '.click_count + 1'),
+ array($this->alias . '.click_count' => $this->alias . '.click_count + 1'),
array(
- $this->name . '.id' => $id,
- $this->name . '.block_id' => $blockId,
+ $this->alias . '.id' => $id,
+ $this->alias . '.block_id' => Current::read('Block.id'),
)
);
//トランザクションCommit
- $dataSource->commit();
+ $this->commit();
} catch (Exception $ex) {
//トランザクションRollback
- $dataSource->rollback();
- CakeLog::error($ex);
- throw $ex;
+ $this->rollback($ex);
}
+ $this->setSlaveDataSource();
+
return true;
}
diff --git a/Model/LinkBlock.php b/Model/LinkBlock.php
index 5225457..872cc37 100644
--- a/Model/LinkBlock.php
+++ b/Model/LinkBlock.php
@@ -19,7 +19,7 @@
* LinkBlock Model
*
* @author Shohei Nakajima
- * @package NetCommons\Blocks\Model
+ * @package NetCommons\Links\Model
*/
class LinkBlock extends BlocksAppModel {
@@ -46,7 +46,7 @@ class LinkBlock extends BlocksAppModel {
*/
public $hasOne = array(
'Block' => array(
- 'className' => 'Block',
+ 'className' => 'Blocks.Block',
'foreignKey' => 'id',
'conditions' => '',
'fields' => '',
@@ -55,122 +55,178 @@ class LinkBlock extends BlocksAppModel {
);
/**
- * Get link block data
+ * use behaviors
*
- * @param int $blockId blocks.id
- * @param int $roomId rooms.id
- * @return array
+ * @var array
*/
- public function getLinkBlock($blockId, $roomId) {
- $conditions = array(
- 'Block.id' => $blockId,
- 'Block.room_id' => $roomId,
- );
-
- $linkBlock = $this->find('first', array(
- 'recursive' => 0,
- 'conditions' => $conditions,
+ public $actsAs = array(
+ 'Blocks.Block' => array(
+ 'name' => 'LinkBlock.name',
+ 'loadModels' => array(
+ 'Category' => 'Categories.Category',
+ 'CategoryOrder' => 'Categories.CategoryOrder',
+ 'WorkflowComment' => 'Workflow.WorkflowComment',
)
- );
-
- return $linkBlock;
- }
+ ),
+ 'Categories.Category',
+ 'M17n.M17n',
+ 'Workflow.WorkflowComment',
+ );
/**
- * Save block
+ * Called during validation operations, before validation. Please note that custom
+ * validation rules can be defined in $validate.
*
- * @param array $data received post data
- * @return bool True on success, false on validation errors
- * @throws InternalErrorException
+ * @param array $options Options passed from Model::save().
+ * @return bool True if validate operation should continue, false to abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
+ * @see Model::save()
*/
- public function saveLinkBlock($data) {
- $this->loadModels([
- 'LinkSetting' => 'Links.LinkSetting',
- 'Category' => 'Categories.Category',
- 'Block' => 'Blocks.Block',
- 'Frame' => 'Frames.Frame',
- ]);
-
- //トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ public function beforeValidate($options = array()) {
+ $this->validate = Hash::merge($this->validate, array(
+ 'name' => array(
+ 'notBlank' => array(
+ 'rule' => array('notBlank'),
+ 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'Link list Title')),
+ 'required' => true,
+ )
+ )
+ ));
- try {
- //バリデーション
- if (! $data = $this->validateLinkBlock($data, ['linkSetting', 'category'])) {
+ if (isset($this->data['LinkSetting'])) {
+ $this->LinkSetting->set($this->data['LinkSetting']);
+ if (! $this->LinkSetting->validates()) {
+ $this->validationErrors = Hash::merge($this->validationErrors, $this->LinkSetting->validationErrors);
return false;
}
+ }
- //登録処理
- $block = $this->Block->saveByFrameId($data['Frame']['id']);
+ return parent::beforeValidate($options);
+ }
- $this->LinkSetting->data['LinkSetting']['block_key'] = $block['Block']['key'];
+/**
+ * Called before each save operation, after validation. Return a non-true result
+ * to halt the save.
+ *
+ * @param array $options Options passed from Model::save().
+ * @return bool True if the operation should continue, false if it should abort
+ * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave
+ * @throws InternalErrorException
+ * @see Model::save()
+ */
+ public function beforeSave($options = array()) {
+ //LinkSetting登録
+ if (isset($this->data['LinkSetting'])) {
+ $this->LinkSetting->set($this->data['LinkSetting']);
+ }
+ if (isset($this->LinkSetting->data['LinkSetting'])) {
if (! $this->LinkSetting->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
+ }
- $data['Block']['id'] = (int)$block['Block']['id'];
- $data['Block']['key'] = $block['Block']['key'];
- $this->Category->saveCategories($data);
+ return true;
+ }
- //トランザクションCommit
- $dataSource->commit();
+/**
+ * LinkBlockデータ生成
+ *
+ * @return array LinkBlockデータ配列
+ */
+ public function createLinkBlock() {
+ $this->LinkSetting = ClassRegistry::init('Links.LinkSetting');
- } catch (Exception $ex) {
- //トランザクションRollback
- $dataSource->rollback();
- CakeLog::error($ex);
- throw $ex;
- }
+ $linkBlock = $this->createAll(array(
+ 'LinkBlock' => array(
+ 'name' => __d('links', 'New Bookmark List %s', date('YmdHis')),
+ ),
+ ));
- return true;
+ return Hash::merge($linkBlock, $this->LinkSetting->create());
}
/**
- * Validate block
+ * LinkBlockデータ取得
*
- * @param array $data received post data
- * @param array $contains Optional validate sets
- * @return mixed Array on success, false on validation errors
+ * @return array LinkBlockデータ配列
*/
- public function validateLinkBlock($data, $contains = []) {
- $this->Block->validate = Hash::merge($this->Block->validate, array(
- 'name' => array(
- 'notBlank' => array(
- 'rule' => array('notBlank'),
- 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('links', 'Link list Title')),
- 'required' => true,
- )
- ))
- );
- if (! $this->Block->validateBlock($data)) {
- $this->validationErrors = Hash::merge($this->validationErrors, $this->Block->validationErrors);
+ public function getLinkBlock() {
+ $this->LinkSetting = ClassRegistry::init('Links.LinkSetting');
+
+ $linkBlock = $this->find('all', array(
+ 'recursive' => -1,
+ 'fields' => array(
+ $this->alias . '.*',
+ $this->Block->alias . '.*',
+ $this->LinkSetting->alias . '.*',
+ ),
+ 'joins' => array(
+ array(
+ 'table' => $this->Block->table,
+ 'alias' => $this->Block->alias,
+ 'type' => 'INNER',
+ 'conditions' => array(
+ $this->alias . '.id' . ' = ' . $this->Block->alias . ' .id',
+ ),
+ ),
+ array(
+ 'table' => $this->LinkSetting->table,
+ 'alias' => $this->LinkSetting->alias,
+ 'type' => 'INNER',
+ 'conditions' => array(
+ $this->alias . '.key' . ' = ' . $this->LinkSetting->alias . ' .block_key',
+ ),
+ ),
+ ),
+ 'conditions' => $this->getBlockConditionById(),
+ ));
+
+ if (! $linkBlock) {
return false;
}
+ return $linkBlock[0];
+ }
- if (in_array('linkSetting', $contains, true)) {
- if (! $this->LinkSetting->validateLinkSetting($data)) {
- $this->validationErrors = Hash::merge($this->validationErrors, $this->LinkSetting->validationErrors);
- return false;
- }
+/**
+ * LinkBlock登録処理
+ *
+ * @param array $data received post data
+ * @return bool True on success, false on validation errors
+ * @throws InternalErrorException
+ */
+ public function saveLinkBlock($data) {
+ $this->loadModels([
+ 'LinkSetting' => 'Links.LinkSetting',
+ ]);
+
+ //トランザクションBegin
+ $this->begin();
+
+ //バリデーション
+ $this->set($data);
+ if (! $this->validates()) {
+ return false;
}
- if (in_array('category', $contains, true)) {
- if (! isset($data['Categories'])) {
- $data['Categories'] = [];
- }
- if (! $data = $this->Category->validateCategories($data)) {
- $this->validationErrors = Hash::merge($this->validationErrors, $this->Category->validationErrors);
- return false;
+ try {
+ //登録処理
+ if (! $this->save(null, false)) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
+
+ //トランザクションCommit
+ $this->commit();
+
+ } catch (Exception $ex) {
+ //トランザクションRollback
+ $this->rollback($ex);
}
- return $data;
+ return true;
}
/**
- * Delete block
+ * LinkBlockの削除処理
*
* @param array $data received post data
* @return mixed On success Model::$data if its not empty or true, false on failure
@@ -181,24 +237,18 @@ public function deleteLinkBlock($data) {
'Link' => 'Links.Link',
'LinkSetting' => 'Links.LinkSetting',
'LinkOrder' => 'Links.LinkOrder',
- 'Block' => 'Blocks.Block',
- 'Category' => 'Categories.Category',
- 'Comment' => 'Comments.Comment',
]);
//トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ $this->begin();
$conditions = array(
$this->alias . '.key' => $data['Block']['key']
);
$blocks = $this->find('list', array(
- 'recursive' => -1,
- 'conditions' => $conditions,
- )
- );
+ 'recursive' => -1,
+ 'conditions' => $conditions,
+ ));
$blocks = array_keys($blocks);
try {
@@ -214,23 +264,15 @@ public function deleteLinkBlock($data) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
- //コメントの削除
- $this->Comment->deleteByBlockKey($data['Block']['key']);
-
- //Categoryデータ削除
- $this->Category->deleteByBlockKey($data['Block']['key']);
-
//Blockデータ削除
- $this->Block->deleteBlock($data['Block']['key']);
+ $this->deleteBlock($data['Block']['key']);
//トランザクションCommit
- $dataSource->commit();
+ $this->commit();
} catch (Exception $ex) {
//トランザクションRollback
- $dataSource->rollback();
- CakeLog::error($ex);
- throw $ex;
+ $this->rollback($ex);
}
return true;
diff --git a/Model/LinkFrameSetting.php b/Model/LinkFrameSetting.php
index 0237ffc..3c16a2a 100644
--- a/Model/LinkFrameSetting.php
+++ b/Model/LinkFrameSetting.php
@@ -2,7 +2,6 @@
/**
* LinkFrameSetting Model
*
- *
* @author Noriko Arai
* @author Shohei Nakajima
* @link http://www.netcommons.org NetCommons Project
@@ -228,63 +227,40 @@ public function beforeValidate($options = array()) {
}
/**
- * Get link setting data
+ * LinkFrameSettingデータ取得
*
- * @param string $frameKey frames.key
- * @return array
+ * @param bool $created 作成フラグ
+ * @return array LinkFrameSettingデータ配列
*/
- public function getLinkFrameSetting($frameKey) {
+ public function getLinkFrameSetting($created) {
$conditions = array(
- 'frame_key' => $frameKey
+ 'frame_key' => Current::read('Frame.key')
);
$linkFrameSetting = $this->find('first', array(
- 'recursive' => -1,
- 'conditions' => $conditions,
- )
- );
-
- return $linkFrameSetting;
- }
+ 'recursive' => -1,
+ 'conditions' => $conditions,
+ ));
-/**
- * Get category_separator_line data
- *
- * @param string $categorySeparator category_separator_line data
- * @return array
- */
- public function getCategorySeparatorLineCss($categorySeparator) {
- //カテゴリ間の区切り線
- $categorySeparators = Hash::combine(self::$categorySeparators, '{n}.key', '{n}');
- if (isset($categorySeparators[$categorySeparator])) {
- $result = $categorySeparators[$categorySeparator]['style'];
- } else {
- $result = null;
+ if ($created && ! $linkFrameSetting) {
+ $linkFrameSetting = $this->create();
}
- return $result;
- }
-
-/**
- * Get line_style data
- *
- * @param string $lineStyle line_style data
- * @return array
- */
- public function getLineStyleCss($lineStyle) {
//カテゴリ間の区切り線
- $listStyles = Hash::combine(self::$listStyles, '{n}.key', '{n}');
- if (isset($listStyles[$lineStyle])) {
- $result = $listStyles[$lineStyle]['style'];
- } else {
- $result = null;
- }
+ $separatorLine = $linkFrameSetting['LinkFrameSetting']['category_separator_line'];
+ $linkFrameSetting['LinkFrameSetting']['category_separator_line_css'] =
+ Hash::get(Hash::extract(self::$categorySeparators, '{n}[key=' . $separatorLine . ']'), '0.style');
+
+ //リストマーク
+ $listStyle = $linkFrameSetting['LinkFrameSetting']['list_style'];
+ $linkFrameSetting['LinkFrameSetting']['list_style_css'] =
+ Hash::get(Hash::extract(self::$listStyles, '{n}[key=' . $listStyle . ']'), '0.style');
- return $result;
+ return $linkFrameSetting;
}
/**
- * Save link settings
+ * LinkFrameSettingデータ登録処理
*
* @param array $data received post data
* @return bool True on success, false on failure
@@ -296,43 +272,27 @@ public function saveLinkFrameSetting($data) {
]);
//トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ $this->begin();
- try {
- if (! $this->validateLinkFrameSetting($data)) {
- return false;
- }
+ //バリデーション
+ $this->set($data);
+ if (! $this->validates()) {
+ return false;
+ }
+ try {
if (! $this->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//トランザクションCommit
- $dataSource->commit();
+ $this->commit();
+
} catch (Exception $ex) {
//トランザクションRollback
- $dataSource->rollback();
- CakeLog::error($ex);
- throw $ex;
+ $this->rollback($ex);
}
return true;
}
-
-/**
- * Validate linkFrameSettings
- *
- * @param array $data received post data
- * @return bool True on success, false on validation errors
- */
- public function validateLinkFrameSetting($data) {
- $this->set($data);
- $this->validates();
- if ($this->validationErrors) {
- return false;
- }
- return true;
- }
}
diff --git a/Model/LinkOrder.php b/Model/LinkOrder.php
index ec18b0d..66a0b0a 100644
--- a/Model/LinkOrder.php
+++ b/Model/LinkOrder.php
@@ -78,37 +78,32 @@ public function beforeValidate($options = array()) {
* @see Model::save()
*/
public function beforeSave($options = array()) {
- if (isset($this->data[$this->name]['block_key']) &&
- isset($this->data[$this->name]['link_key']) &&
- ! $this->data[$this->name]['weight'] &&
- array_key_exists('category_key', $this->data[$this->name])
- ) {
+ if (isset($this->data[$this->alias]['link_key']) &&
+ ! $this->data[$this->alias]['weight'] &&
+ array_key_exists('category_key', $this->data[$this->alias])) {
+
$before = $this->find('first', array(
- 'recursive' => -1,
- 'fields' => array('block_key', 'category_key', 'weight'),
- 'conditions' => array('link_key' => $this->data[$this->name]['link_key']),
- ));
+ 'recursive' => -1,
+ 'fields' => array('category_key', 'weight'),
+ 'conditions' => array('link_key' => $this->data[$this->alias]['link_key']),
+ ));
if ($before) {
- if ($before[$this->name]['category_key'] !== $this->data[$this->name]['category_key']) {
+ if ($before[$this->alias]['category_key'] !== $this->data[$this->alias]['category_key']) {
$this->updateAll(
- array($this->name . '.weight' => $this->name . '.weight - 1'),
+ array($this->alias . '.weight' => $this->alias . '.weight - 1'),
array(
- $this->name . '.weight > ' => $before[$this->name]['weight'],
- $this->name . '.block_key' => $before[$this->name]['block_key'],
- $this->name . '.category_key' => $before[$this->name]['category_key'],
+ $this->alias . '.weight > ' => $before[$this->alias]['weight'],
+ $this->alias . '.block_key' => Current::read('Block.key'),
+ $this->alias . '.category_key' => $before[$this->alias]['category_key'],
)
);
- $this->data[$this->name]['weight'] = $this->getMaxWeight(
- $this->data[$this->name]['block_key'],
- $this->data[$this->name]['category_key']
- ) + 1;
+ $this->data[$this->alias]['weight'] = $this->getMaxWeight(
+ $this->data[$this->alias]['category_key']) + 1;
}
} elseif (! $this->id) {
- $this->data[$this->name]['weight'] = $this->getMaxWeight(
- $this->data[$this->name]['block_key'],
- $this->data[$this->name]['category_key']
- ) + 1;
+ $this->data[$this->alias]['weight'] = $this->getMaxWeight(
+ $this->data[$this->alias]['category_key']) + 1;
}
}
@@ -124,19 +119,19 @@ public function beforeSave($options = array()) {
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function beforeDelete($cascade = true) {
- if (isset($this->data[$this->name]['link_key']) && isset($this->data[$this->name]['category_key'])) {
+ if ($this->id) {
$before = $this->find('first', array(
- 'recursive' => -1,
- 'fields' => array('block_key', 'category_key', 'weight'),
- 'conditions' => array('link_key' => $this->data[$this->name]['link_key']),
- ));
+ 'recursive' => -1,
+ 'fields' => array('block_key', 'category_key', 'weight'),
+ 'conditions' => array('id' => $this->id),
+ ));
$this->updateAll(
- array($this->name . '.weight' => $this->name . '.weight - 1'),
+ array($this->alias . '.weight' => $this->alias . '.weight - 1'),
array(
- $this->name . '.weight > ' => $before[$this->name]['weight'],
- $this->name . '.block_key' => $before[$this->name]['block_key'],
- $this->name . '.category_key' => $before[$this->name]['category_key'],
+ $this->alias . '.weight > ' => $before[$this->alias]['weight'],
+ $this->alias . '.block_key' => $before[$this->alias]['block_key'],
+ $this->alias . '.category_key' => $before[$this->alias]['category_key'],
)
);
}
@@ -144,34 +139,21 @@ public function beforeDelete($cascade = true) {
}
/**
- * validate of link order
- *
- * @param array $data received post data
- * @return bool True on success, false on validation errors
- */
- public function validateLinkOrder($data) {
- $this->set($data);
- $this->validates();
- if ($this->validationErrors) {
- return false;
- }
- return true;
- }
-
-/**
- * getMaxWeight
+ * Category毎の表示順序
*
- * @param string $blockKey blocks.key
- * @param string $categoryKey categories.key
- * @return int $weight link_orders.weight
+ * @param string $categoryKey Category.key
+ * @return int $weight LinkOrders.weight
*/
- public function getMaxWeight($blockKey, $categoryKey) {
+ public function getMaxWeight($categoryKey) {
$order = $this->find('first', array(
- 'recursive' => -1,
- 'fields' => array('weight'),
- 'conditions' => array('block_key' => $blockKey, 'category_key' => $categoryKey),
- 'order' => array('weight' => 'DESC')
- ));
+ 'recursive' => -1,
+ 'fields' => array('weight'),
+ 'conditions' => array(
+ 'block_key' => Current::read('Block.key'),
+ 'category_key' => $categoryKey
+ ),
+ 'order' => array('weight' => 'DESC')
+ ));
if (isset($order[$this->alias]['weight'])) {
$weight = (int)$order[$this->alias]['weight'];
@@ -189,42 +171,28 @@ public function getMaxWeight($blockKey, $categoryKey) {
* @throws InternalErrorException
*/
public function saveLinkOrders($data) {
- $this->loadModels([
- 'LinkOrder' => 'Links.LinkOrder',
- ]);
-
//トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ $this->begin();
- try {
- //バリデーション
- $indexes = array_keys($data['LinkOrders']);
- foreach ($indexes as $i) {
- if (! $this->validateLinkOrder($data['LinkOrders'][$i])) {
- return false;
- }
- }
+ //バリデーション
+ if (! $this->validateMany($data['LinkOrders'])) {
+ return false;
+ }
+ try {
//登録処理
- foreach ($indexes as $i) {
- if (! $this->save($data['LinkOrders'][$i], false, false)) {
- throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
- }
+ if (! $this->saveMany($data['LinkOrders'], ['validate' => false])) {
+ throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//トランザクションCommit
- $dataSource->commit();
+ $this->commit();
} catch (Exception $ex) {
//トランザクションRollback
- $dataSource->rollback();
- CakeLog::error($ex);
- throw $ex;
+ $this->rollback($ex);
}
return true;
}
-
}
diff --git a/Model/LinkSetting.php b/Model/LinkSetting.php
index c3b4052..1de0fa3 100644
--- a/Model/LinkSetting.php
+++ b/Model/LinkSetting.php
@@ -26,6 +26,15 @@ class LinkSetting extends LinksAppModel {
*/
public $validate = array();
+/**
+ * use behaviors
+ *
+ * @var array
+ */
+ public $actsAs = array(
+ 'Blocks.BlockRolePermission',
+ );
+
/**
* Called during validation operations, before validation. Please note that custom
* validation rules can be defined in $validate.
@@ -57,26 +66,6 @@ public function beforeValidate($options = array()) {
return parent::beforeValidate($options);
}
-/**
- * Get link setting data
- *
- * @param string $blockKey blocks.key
- * @return array
- */
- public function getLinkSetting($blockKey) {
- $conditions = array(
- 'block_key' => $blockKey
- );
-
- $linkSetting = $this->find('first', array(
- 'recursive' => -1,
- 'conditions' => $conditions,
- )
- );
-
- return $linkSetting;
- }
-
/**
* Save link settings
*
@@ -87,59 +76,31 @@ public function getLinkSetting($blockKey) {
public function saveLinkSetting($data) {
$this->loadModels([
'LinkSetting' => 'Links.LinkSetting',
- 'BlockRolePermission' => 'Blocks.BlockRolePermission',
]);
//トランザクションBegin
- $this->setDataSource('master');
- $dataSource = $this->getDataSource();
- $dataSource->begin();
+ $this->begin();
- try {
- if (! $this->validateLinkSetting($data)) {
- return false;
- }
- foreach ($data[$this->BlockRolePermission->alias] as $value) {
- if (! $this->BlockRolePermission->validateBlockRolePermissions($value)) {
- $this->validationErrors = Hash::merge($this->validationErrors, $this->BlockRolePermission->validationErrors);
- return false;
- }
- }
+ //バリデーション
+ $this->set($data);
+ if (! $this->validates()) {
+ return false;
+ }
+ try {
if (! $this->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
- foreach ($data[$this->BlockRolePermission->alias] as $value) {
- if (! $this->BlockRolePermission->saveMany($value, ['validate' => false])) {
- throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
- }
- }
//トランザクションCommit
- $dataSource->commit();
+ $this->commit();
+
} catch (Exception $ex) {
//トランザクションRollback
- $dataSource->rollback();
- CakeLog::error($ex);
- throw $ex;
+ $this->rollback($ex);
}
return true;
}
-/**
- * validate linkSettings
- *
- * @param array $data received post data
- * @return bool True on success, false on validation errors
- */
- public function validateLinkSetting($data) {
- $this->set($data);
- $this->validates();
- if ($this->validationErrors) {
- return false;
- }
- return true;
- }
-
}
diff --git a/Model/LinksAppModel.php b/Model/LinksAppModel.php
index 0d7ea30..565806f 100644
--- a/Model/LinksAppModel.php
+++ b/Model/LinksAppModel.php
@@ -2,7 +2,6 @@
/**
* LinkApp Model
*
- *
* @author Noriko Arai
* @author Shohei Nakajima
* @link http://www.netcommons.org NetCommons Project
diff --git a/View/Elements/LinkBlockRolePermissions/edit_form.ctp b/View/Elements/LinkBlockRolePermissions/edit_form.ctp
index 5d3ff8b..d507f70 100644
--- a/View/Elements/LinkBlockRolePermissions/edit_form.ctp
+++ b/View/Elements/LinkBlockRolePermissions/edit_form.ctp
@@ -1,6 +1,6 @@
* @author Shohei Nakajima
@@ -10,25 +10,21 @@
*/
?>
-Form->hidden('LinkSetting.id', array(
- 'value' => isset($linkSetting['id']) ? (int)$linkSetting['id'] : null,
- )); ?>
+NetCommonsForm->hidden('LinkSetting.id'); ?>
+NetCommonsForm->hidden('LinkSetting.block_key'); ?>
+NetCommonsForm->hidden('Block.id'); ?>
+NetCommonsForm->hidden('Block.key'); ?>
-Form->hidden('LinkSetting.block_key', array(
- 'value' => isset($linkSetting['blockKey']) ? $linkSetting['blockKey'] : null,
- )); ?>
-Form->hidden('Block.id', array(
- 'value' => $blockId,
+element('Blocks.block_creatable_setting', array(
+ 'settingPermissions' => array(
+ 'content_creatable' => __d('links', 'Link creatable roles'),
+ ),
)); ?>
-element('Blocks.block_role_setting', array(
- 'roles' => $roles,
+element('Blocks.block_approval_setting', array(
'model' => 'LinkSetting',
'useWorkflow' => 'use_workflow',
- 'creatablePermissions' => array(
- 'contentCreatable' => __d('blocks', 'Content creatable roles'),
- ),
'options' => array(
Block::NEED_APPROVAL => __d('blocks', 'Need approval'),
Block::NOT_NEED_APPROVAL => __d('blocks', 'Not need approval'),
diff --git a/View/Elements/LinkBlocks/delete_form.ctp b/View/Elements/LinkBlocks/delete_form.ctp
index 5a16d94..32d6e69 100644
--- a/View/Elements/LinkBlocks/delete_form.ctp
+++ b/View/Elements/LinkBlocks/delete_form.ctp
@@ -1,6 +1,6 @@
* @author Shohei Nakajima
@@ -10,17 +10,16 @@
*/
?>
-
+
-Form->hidden('Block.id', array(
- 'value' => isset($block['id']) ? $block['id'] : null,
- )); ?>
-Form->hidden('Block.key', array(
- 'value' => isset($block['key']) ? $block['key'] : null,
- )); ?>
-Form->button(' ' . __d('net_commons', 'Delete'), array(
- 'name' => 'delete',
- 'class' => 'btn btn-danger pull-right',
- 'onclick' => 'return confirm(\'' . sprintf(__d('net_commons', 'Deleting the %s. Are you sure to proceed?'), __d('links', 'Link List')) . '\')'
- ));
+
+NetCommonsForm->hidden('Block.id'); ?>
+NetCommonsForm->hidden('Block.key'); ?>
+NetCommonsForm->hidden('LinkBlock.key'); ?>
+
+Button->delete(
+ __d('net_commons', 'Delete'),
+ sprintf(__d('net_commons', 'Deleting the %s. Are you sure to proceed?'), __d('links', 'Link List')),
+ array('addClass' => 'pull-right')
+ );
diff --git a/View/Elements/LinkBlocks/edit_form.ctp b/View/Elements/LinkBlocks/edit_form.ctp
index 642a8da..1da4fcc 100644
--- a/View/Elements/LinkBlocks/edit_form.ctp
+++ b/View/Elements/LinkBlocks/edit_form.ctp
@@ -1,6 +1,6 @@
* @author Shohei Nakajima
@@ -11,37 +11,15 @@
?>
element('Blocks.form_hidden'); ?>
+NetCommonsForm->hidden('LinkSetting.id'); ?>
+NetCommonsForm->hidden('LinkSetting.block_key'); ?>
-Form->hidden('LinkSetting.id', array(
- 'value' => isset($linkSetting['id']) ? (int)$linkSetting['id'] : null,
+NetCommonsForm->input('LinkBlock.name', array(
+ 'type' => 'text',
+ 'label' => __d('links', 'Link list Title'),
+ 'required' => true
)); ?>
-
-
element('Blocks.public_type'); ?>
-element('Categories.edit_form', array(
- 'categories' => isset($categories) ? $categories : null
- ));
+element('Categories.edit_form');
\ No newline at end of file
diff --git a/View/Elements/LinkFrameSettings/edit_form.ctp b/View/Elements/LinkFrameSettings/edit_form.ctp
index 9aecef4..f4262fa 100644
--- a/View/Elements/LinkFrameSettings/edit_form.ctp
+++ b/View/Elements/LinkFrameSettings/edit_form.ctp
@@ -1,6 +1,6 @@
* @author Shohei Nakajima
@@ -11,64 +11,39 @@
?>
-Form->hidden('LinkFrameSetting.id', array(
- 'value' => isset($linkFrameSetting['id']) ? (int)$linkFrameSetting['id'] : null,
+NetCommonsForm->hidden('LinkFrameSetting.id'); ?>
+NetCommonsForm->hidden('LinkFrameSetting.frame_key'); ?>
+NetCommonsForm->hidden('Frame.id'); ?>
+NetCommonsForm->hidden('Frame.key'); ?>
+
+NetCommonsForm->input('LinkFrameSetting.display_type', array(
+ 'label' => __d('links', 'Display method'),
+ 'type' => 'select',
+ 'options' => array(
+ LinkFrameSetting::TYPE_DROPDOWN => __d('links', 'Show by dropdown'),
+ LinkFrameSetting::TYPE_LIST_ONLY_TITLE => __d('links', 'Show list'),
+ LinkFrameSetting::TYPE_LIST_WITH_DESCRIPTION => __d('links', 'Show list (Description)'),
+ ),
)); ?>
-Form->hidden('LinkFrameSetting.frame_key', array(
- 'value' => $frameKey,
+NetCommonsForm->inlineCheckbox('LinkFrameSetting.open_new_tab', array(
+ 'label' => __d('links', 'Open as a new tab'),
+ 'type' => 'checkbox',
)); ?>
-Form->hidden('Frame.id', array(
- 'value' => $frameId,
+NetCommonsForm->inlineCheckbox('LinkFrameSetting.display_click_count', array(
+ 'label' => __d('links', 'Count view'),
+ 'type' => 'checkbox',
)); ?>
-Form->hidden('Frame.key', array(
- 'value' => $frameKey,
- )); ?>
-
-
- Form->input('LinkFrameSetting.display_type', array(
- 'label' => __d('links', 'Display method'),
- 'type' => 'select',
- 'error' => false,
- 'class' => 'form-control',
- 'options' => array(
- LinkFrameSetting::TYPE_DROPDOWN => __d('links', 'Show by dropdown'),
- LinkFrameSetting::TYPE_LIST_ONLY_TITLE => __d('links', 'Show list'),
- LinkFrameSetting::TYPE_LIST_WITH_DESCRIPTION => __d('links', 'Show list (Description)'),
- ),
- 'value' => (isset($linkFrameSetting['displayType']) ? $linkFrameSetting['displayType'] : LinkFrameSetting::TYPE_DROPDOWN)
- )); ?>
-
-
-
- Form->input('LinkFrameSetting.open_new_tab', array(
- 'label' => __d('links', 'Open as a new tab'),
- 'type' => 'checkbox',
- 'error' => false,
- 'checked' => (isset($linkFrameSetting['openNewTab']) ? (int)$linkFrameSetting['openNewTab'] : null)
- )); ?>
-
-
-
- Form->input('LinkFrameSetting.display_click_count', array(
- 'label' => __d('links', 'Count view'),
- 'type' => 'checkbox',
- 'error' => false,
- 'checked' => (isset($linkFrameSetting['displayClickCount']) ? (int)$linkFrameSetting['displayClickCount'] : null)
- )); ?>
-
-
- |