diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..0b590c2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,29 @@
+language: php
+
+php:
+ - 5.4
+ - 5.5
+ - 5.6
+
+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/Controller/LinkAuthorityController.php b/Controller/LinkAuthorityController.php
new file mode 100644
index 0000000..9bc6775
--- /dev/null
+++ b/Controller/LinkAuthorityController.php
@@ -0,0 +1,195 @@
+
+ * @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');
+
+/**
+ * LinkAuthority Controller
+ *
+ * @author Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ */
+class LinkAuthorityController extends LinksAppController {
+
+/**
+ * use model
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Blocks.BlockRolePermission',
+ 'Rooms.RolesRoom',
+ 'Rooms.RoomRolePermission',
+ 'Roles.Role',
+ 'Frames.Frame'
+ );
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow();
+ }
+
+/**
+ * view method
+ *
+ * @param int $frameId frames.id
+ * @param string $lang ex)"en" or "ja" etc.
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function view($frameId = 0, $type = 'list') {
+ if ($this->response->statusCode() !== 200) {
+ return $this->render(false);
+ }
+
+ return $this->render('LinkAuthority/view', false);
+ }
+
+ public function form($frameId = 0) {
+ // frameIdからroom取得
+ $frame = $this->Frame->findById($frameId);
+ $roles = $this->RolesRoom->findAllByRoomId($frame['Frame']['room_id']);
+ foreach($roles as $role){
+ $roleKey = $role['RolesRoom']['role_key'];
+ $rolePermission[$roleKey] = false;
+ }
+ unset($rolePermission['room_administrator']); //ルーム管理者は制限しないので取り除く
+ $this->set('rolePermission', $rolePermission);
+ $this->set('frameId', $frameId);
+ }
+ public function edit($frameId = 0) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+ //保存
+ if ($this->saveBlockRolePermission($frameId, $this->data)) {
+
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+
+ $error = __d('net_commons', 'Failed to register data.');
+// $error .= $this->formatValidationErrors($this->LinkFrameSetting->validationErrors);
+ throw new ForbiddenException($error);
+ }
+
+ }
+ public function get($frameId = 0) {
+ // frameIdからroom取得
+ $frame = $this->Frame->findById($frameId);
+ $roomId = $frame['Frame']['room_id'];
+
+ $roles = $this->getContentCreatableRoomRoles($roomId);
+debug($roles);
+ // リンク集の権限をblock_role_permissionsから取り出す(不要?)
+ $blockRolePermission = $this->getBlockRolePermissionByFrame($frame);
+ $ret = array();
+ foreach($roles as $role){
+ $roleKey = $role['Role']['key'];
+ $var = array(
+ 'name' => $role['Role']['name'],
+ 'permission' => false, // MyTodo BlockRolePermissionからセット
+ );
+ $ret['add_link'][$roleKey] = $var;
+ }
+ unset($ret['add_link']['room_administrator']); //ルーム管理者は制限しないので取り除く
+ $this->set('roles', $ret);
+ $this->set('_serialize', 'roles');
+ return $this->render(false);
+
+ }
+
+ /**
+ * ルーム管理者以外でリンク作成可能(contetn_creatable)なルームロールを返す
+ *
+ */
+ protected function getContentCreatableRoomRoles($roomId) {
+ // ルームから roles_rooms からルームのロールを読み出し
+ // role_keyに対応した言語をrolesテーブルから読み出したいのでbindModel モデルで定義しときたいなぁ
+ $this->RolesRoom->bindModel(
+ array(
+ 'hasMany' => array(
+ 'RoomRolePermission' => array(
+ 'className' => 'Rooms.RoomRolePermission'
+ )
+ ),
+ 'belongsTo' => array(
+ 'Role' => array(
+ 'className' => 'Roles.Role',
+ 'foreignKey' => false,
+ 'conditions' => array('RolesRoom.role_key = Role.key'),
+ ),
+ ),
+ )
+ );
+ $conditions = array(
+ 'room_id' => $roomId,
+ 'RoomRolePermission.permission' => 'content_creatable', //ε( v ゚ω゚) < conttent_creatableはマジックナンバー?
+ 'RoomRolePermission.value' => 1, //ε( v ゚ω゚) <マジックナンバー?
+ 'role_key !=' => 'room_administrator' // ルーム管理者は除外する
+ );
+
+ $roles = $this->RolesRoom->find('all', array(
+ 'conditions' => $conditions
+ ));
+ return $roles;
+
+ }
+
+ protected function saveBlockRolePermission($frameId, $data) {
+ // MyTodo 現在のBlockRolePermissionを削除
+
+ $frame = $this->Frame->findById($frameId);
+ $roomId = $frame['Frame']['room_id'];
+ // block_key
+ $blockKey = $frame['Block']['key'];
+ foreach($data['BlockRolePermission'] as $permission => $roles){
+ foreach($roles as $roleKey => $value){
+ $saveData = array(
+ 'roles_room_id' => '', // MyTodo
+ 'block_key' => $blockKey,
+ 'permission' => $permission,
+ 'value' => $value,
+ );
+ $this->BlockRolePermission->create(); // MyTodo 既にある場合は?
+ $this->BlockRolePermission->save($saveData);
+ }
+ }
+ // roles_room_id <- roke_key AND room_id から
+ // permisssion
+ // value
+
+ }
+
+ protected function getBlockRolePermissionByFrame($frame) {
+ $blockKey = $frame['Block']['key'];
+ $blockRolePermission = $this->BlockRolePermission->findByBlockKey($blockKey);
+ return $blockRolePermission;
+ }
+}
diff --git a/Controller/LinkCategoryController.php b/Controller/LinkCategoryController.php
new file mode 100644
index 0000000..a6707b6
--- /dev/null
+++ b/Controller/LinkCategoryController.php
@@ -0,0 +1,204 @@
+
+ * @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');
+
+/**
+ * LinkCategory Controller
+ *
+ * @property LinkCategory $LinkCategory
+ *
+ * @author Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ */
+class LinkCategoryController extends LinksAppController {
+
+/**
+ * use model
+ *
+ * @var array
+ */
+ //public $uses = array();
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow();
+ $frameId = (isset($this->params['pass'][0]) ? (int)$this->params['pass'][0] : 0);
+
+ //Roleのデータをviewにセット
+ if (! $this->NetCommonsRoomRole->setView($this)) {
+// throw new ForbiddenException();
+ }
+
+ //編集権限チェック
+ if (! $this->viewVars['contentEditable']) {
+// throw new ForbiddenException();
+ }
+
+ //Frameのデータをviewにセット
+ if (! $this->NetCommonsFrame->setView($this, $frameId)) {
+// throw new ForbiddenException();
+ }
+
+
+ }
+
+
+/**
+ * view method
+ *
+ * @param int $frameId frames.id
+ * @param string $lang ex)"en" or "ja" etc.
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function view($frameId = 0, $type = 'list') {
+ if ($this->response->statusCode() !== 200) {
+ return $this->render(false);
+ }
+
+ // カテゴリ取得
+ $linkCategories = $this->LinkCategory->getCategories(
+ $this->viewVars['blockId'] // MyTodo まだブロックレコードがないときは0なので、どうする?
+ );
+ $this->set('linkCategories', $linkCategories);
+
+ return $this->render('LinkCategory/view', false);
+ }
+/**
+* form method
+*
+* @param int $frameId frames.id
+* @return CakeResponse A response object containing the rendered view.
+*/
+ public function form($frameId = 0) {
+ return $this->render('LinkCategory/form', false);
+ }
+
+ public function add($frameId = 0) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+
+ $postData = $this->data;
+// unset($postData['Announcement']['id']);
+
+ //保存
+ if ($this->LinkCategory->saveLinkCategory($postData)) {
+// $announcement = $this->Announcement->getAnnouncement(
+// $this->viewVars['blockId'],
+// $this->viewVars['contentEditable']
+// );
+
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+ 'link_category' => $postData,
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+ throw new ForbiddenException(__d('net_commons', 'Failed to register data.'));
+ }
+ }
+
+ public function categories_form($frameId = 0){
+ // カテゴリ取得
+ $linkCategories = $this->LinkCategory->getCategories(
+ $this->viewVars['blockId'] // MyTodo まだブロックレコードがないときは0なので、どうする?
+ );
+ $this->set('linkCategories', $linkCategories);
+ return $this->render('LinkCategory/categories_form', false);
+ }
+
+ public function update_all($frameId = 0) {
+ // MyTodo frameIdとLinkCategory.idの関連付けが正当か(セキュリティコンポーネントでIDがhidden変更不可ならOKか)
+ // MyTodo Frameでの権限チェックも必用
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+
+ $postData = $this->data;
+// unset($postData['Announcement']['id']);
+
+ //保存
+ if ($this->LinkCategory->updateCategories($postData)) {
+// $announcement = $this->Announcement->getAnnouncement(
+// $this->viewVars['blockId'],
+// $this->viewVars['contentEditable']
+// );
+
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+// 'link_category' => $postData,
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+ throw new ForbiddenException(__d('net_commons', 'Failed to register data.'));
+ }
+ }
+
+ public function delete_form($frameId = 0) {
+ return $this->render('LinkCategory/delete_form', false);
+ }
+
+ public function delete($frameId = 0) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+ // MyTodo frameIdとLinkCategory.idの関連付けが正当なら削除OK
+ // MyTodo Frameでの権限チェックも必用
+ $id = $this->data['LinkCategory']['id'];
+
+ //保存
+ if ($this->LinkCategory->delete($id)) {
+ // MyTodo 同一リンクの別バリエーションデータが存在しなければorderも削除。
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+// 'link_category' => $postData,
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+ throw new ForbiddenException(__d('net_commons', 'Failed to register data.'));
+ }
+ }
+
+ public function get_categories($frameId = 0) {
+ // カテゴリ取得
+ $linkCategories = $this->LinkCategory->getCategories(
+ $this->viewVars['blockId'] // MyTodo まだブロックレコードがないときは0なので、どうする?
+ );
+
+ $this->set('linkCategories', $linkCategories);
+ $this->set('_serialize', array('linkCategories'));
+ return $this->render(false);
+ }
+}
diff --git a/Controller/LinkDisplayController.php b/Controller/LinkDisplayController.php
new file mode 100644
index 0000000..786d227
--- /dev/null
+++ b/Controller/LinkDisplayController.php
@@ -0,0 +1,62 @@
+
+ * @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');
+
+/**
+ * LinkDisplay Controller
+ *
+ * @author Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ */
+class LinkDisplayController extends LinksAppController {
+
+/**
+ * use model
+ *
+ * @var array
+ */
+ //public $uses = array();
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow();
+ }
+
+/**
+ * view method
+ *
+ * @param int $frameId frames.id
+ * @param string $lang ex)"en" or "ja" etc.
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function view($frameId = 0, $type = 'list') {
+ if ($this->response->statusCode() !== 200) {
+ return $this->render(false);
+ }
+
+ return $this->render('LinkDisplay/view', false);
+ }
+}
diff --git a/Controller/LinkEditController.php b/Controller/LinkEditController.php
new file mode 100644
index 0000000..08171b1
--- /dev/null
+++ b/Controller/LinkEditController.php
@@ -0,0 +1,77 @@
+
+ * @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');
+
+/**
+ * LinkEdit Controller
+ *
+ * @author Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ */
+class LinkEditController extends LinksAppController {
+
+/**
+ * use model
+ *
+ * @var array
+ */
+ //public $uses = array();
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow();
+ }
+
+/**
+ * view method
+ *
+ * @param int $frameId frames.id
+ * @param string $lang ex)"en" or "ja" etc.
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function view($frameId = 0, $type = 'list') {
+ if ($this->response->statusCode() !== 200) {
+ return $this->render(false);
+ }
+
+ return $this->render('LinkEdit/view', false);
+ }
+
+/**
+ * viewEdit method
+ *
+ * @param int $frameId frames.id
+ * @param string $lang ex)"en" or "ja" etc.
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function viewEdit($frameId = 0, $type = 'list') {
+ if ($this->response->statusCode() !== 200) {
+ return $this->render(false);
+ }
+
+ return $this->render('Links/link_add', false);
+ }
+}
diff --git a/Controller/LinkFrameSettingController.php b/Controller/LinkFrameSettingController.php
new file mode 100644
index 0000000..b64d6f8
--- /dev/null
+++ b/Controller/LinkFrameSettingController.php
@@ -0,0 +1,117 @@
+
+ * @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');
+
+/**
+ * Links Controller
+ *
+ * @author Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ *
+ * @property LinkFrameSetting $LinkFrameSetting
+ */
+class LinkFrameSettingController extends LinksAppController {
+
+public $helpers = array('Links.LinksStatus');
+/**
+ * use model
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Links.LinkFrameSetting',
+ );
+
+/**
+ * use component
+ *
+ * @var array
+ */
+
+ public $components = array(
+ 'NetCommons.NetCommonsBlock', //use Announcement model
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow();
+
+ $frameId = (isset($this->params['pass'][0]) ? (int)$this->params['pass'][0] : 0);
+ //Frameのデータをviewにセット
+ if (! $this->NetCommonsFrame->setView($this, $frameId)) {
+ $this->response->statusCode(400);
+ return;
+ }
+ //Roleのデータをviewにセット
+ if (! $this->NetCommonsRoomRole->setView($this)) {
+ $this->response->statusCode(400);
+ return;
+ }
+ }
+
+ public function get($frameId = 0) {
+ $linkFrameSetting = $this->LinkFrameSetting->getByFrameId($frameId);
+ $this->set('linkFrameSetting', $linkFrameSetting['LinkFrameSetting']);
+ $this->set('_serialize', 'linkFrameSetting');
+ return $this->render(false);
+
+ }
+
+
+ public function form($frameId = 0) {
+ $this->set(compact('frameId'));
+ $linkFrameSetting = $this->LinkFrameSetting->getByFrameId($frameId);
+ $this->set(compact('linkFrameSetting'));
+ }
+
+ public function edit($frameId) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+ //保存
+ if ($this->LinkFrameSetting->save($this->data)) {
+
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+ 'link' => $this->data,
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+
+ $error = __d('net_commons', 'Failed to register data.');
+ $error .= $this->formatValidationErrors($this->LinkFrameSetting->validationErrors);
+ throw new ForbiddenException($error);
+ }
+
+ }
+
+ // MyTodo モデルに移動するか、ヘルパかコンポーネントかビヘイビアにする… ->beforeValidate
+ protected function formatValidationErrors($validationErrors) {
+ $errors = array();
+ foreach($validationErrors as $field => $fieldErrors){
+ foreach($fieldErrors as $errorMessage){
+ $errors[] = __d('links', $field) . ':' . __d('links', $errorMessage);
+ }
+ }
+ $returnMessage = implode("\n", $errors);
+ return $returnMessage;
+ }
+}
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/LinksAppController.php b/Controller/LinksAppController.php
new file mode 100644
index 0000000..3514b52
--- /dev/null
+++ b/Controller/LinksAppController.php
@@ -0,0 +1,29 @@
+
+ * @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 Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ */
+class LinksAppController extends AppController {
+
+/**
+ * use component
+ *
+ * @var array
+ */
+ public $components = array(
+ 'Security'
+ );
+}
diff --git a/Controller/LinksController.php b/Controller/LinksController.php
new file mode 100644
index 0000000..f744527
--- /dev/null
+++ b/Controller/LinksController.php
@@ -0,0 +1,276 @@
+
+ * @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');
+
+/**
+ * Links Controller
+ *
+ * @author Ryuji AMANO
+ * @package NetCommons\Links\Controller
+ *
+ * @property Link $Link
+ */
+class LinksController extends LinksAppController {
+
+public $helpers = array('Links.LinksStatus');
+/**
+ * use model
+ *
+ * @var array
+ */
+ public $uses = array(
+ 'Links.Link',
+ 'Links.LinkCategory',
+ );
+
+/**
+ * use component
+ *
+ * @var array
+ */
+
+ public $components = array(
+ 'NetCommons.NetCommonsBlock', //use Announcement model
+ 'NetCommons.NetCommonsFrame',
+ 'NetCommons.NetCommonsRoomRole',
+ );
+
+/**
+ * beforeFilter
+ *
+ * @return void
+ */
+ public function beforeFilter() {
+ parent::beforeFilter();
+ $this->Auth->allow();
+
+ $frameId = (isset($this->params['pass'][0]) ? (int)$this->params['pass'][0] : 0);
+ //Frameのデータをviewにセット
+ if (! $this->NetCommonsFrame->setView($this, $frameId)) {
+ // 何もかえしてこなくなった
+// $this->response->statusCode(400);
+// return;
+ }
+ //Roleのデータをviewにセット
+ if (! $this->NetCommonsRoomRole->setView($this)) {
+// $this->response->statusCode(400);
+// return;
+ }
+ }
+
+/**
+ * index method
+ *
+ * @param int $frameId frames.id
+ * @param string $lang ex)"en" or "ja" etc.
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function index($frameId = 0, $type = 'list') {
+// $type = 'dropdown';
+ $this->set('type', $type);
+ // カテゴリ一覧を取得
+ $categories = $this->LinkCategory->getCategories(
+ $this->viewVars['blockId'] // MyTodo まだブロックレコードがないときは0なので、どうする?s
+ );
+ foreach($categories as &$category){
+ //Linkデータを取得
+ $links = $this->Link->getLinksByCategoryId(
+ $category['LinkCategory']['id'],
+ $this->viewVars['blockId'],
+ $this->viewVars['contentEditable']
+ );
+ $category['links'] = $links;
+ }
+ $this->set('categories', $categories);
+ return $this->render('Links/index');
+ }
+
+/**
+ * show linkAdd method
+ *
+ * @param int $frameId frames.id
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function linkAdd($frameId = 0) {
+ if ($this->response->statusCode() !== 200) {
+ return $this->render(false);
+ }
+
+ //編集権限チェック
+ if (! $this->viewVars['contentEditable']) {
+ $this->response->statusCode(403);
+ return $this->render(false);
+ }
+
+ return $this->render('Links/link_add', false);
+ }
+
+/**
+ * show manage method
+ *
+ * @param int $frameId frames.id
+ * @return CakeResponse A response object containing the rendered view.
+ */
+ public function manage($frameId = 0) {
+ if ($this->response->statusCode() !== 200) {
+ return $this->render(false);
+ }
+
+ //編集権限チェック
+ if (! $this->viewVars['contentEditable']) {
+ $this->response->statusCode(403);
+ return $this->render(false);
+ }
+
+
+ return $this->render('Links/manage', false);
+ }
+
+ public function add_form($frameId = 0) {
+ return $this->render('Links/add_form', false);
+ }
+
+ public function add($frameId) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+
+ $postData = $this->data;
+
+ //保存
+ if ($this->Link->add($this->data)) {
+
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+ 'link' => $postData,
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+
+ $error = __d('net_commons', 'Failed to register data.');
+ $error .= $this->formatValidationErrors($this->Link->validationErrors);
+ throw new ForbiddenException($error);
+ }
+
+ }
+
+ // json で呼ぶこと前提 indexとほぼ一緒
+
+ // MyTodo indexもjson apiでデータもらう形に変えたらよさげ
+ public function all($frameId = 0) {
+ // カテゴリ一覧を取得
+ $categories = $this->LinkCategory->getCategories(
+ $this->viewVars['blockId'] // MyTodo まだブロックレコードがないときは0なので、どうする?s
+ );
+ foreach($categories as &$category){
+ //Linkデータを取得
+ $links = $this->Link->getLinksByCategoryId(
+ $category['LinkCategory']['id'],
+ $this->viewVars['blockId'],
+ $this->viewVars['contentEditable']
+ );
+ $category['links'] = $links;
+ }
+ $this->set('categories', $categories);
+ $this->set('_serialize', 'categories');
+ return $this->render(false);
+ }
+
+ public function update_weight_form($frameId = 0) {
+// return $this->render('Links/update_weight_form', false);
+ }
+
+ public function delete_form($frameId = 0, $linkId) {
+ $this->set(compact('frameId', 'linkId'));
+
+ }
+
+ public function delete($frameId = 0) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+
+ // MyTodo リンクIDから削除する権限があるか確認
+ $id = $this->data['Link']['id'];
+ //保存
+ if ($this->Link->delete($id)) {
+ // MyTodo 同一リンクの別バリエーションデータが存在しなければorderも削除。
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+ throw new ForbiddenException(__d('net_commons', 'Failed to register data.'));
+ }
+
+ }
+ public function edit_form($frameId = 0, $linkId) {
+ $this->set(compact('frameId', 'linkId'));
+ }
+
+ public function edit($frameId, $linkId) {
+ if (! $this->request->isPost()) {
+ throw new MethodNotAllowedException();
+ }
+
+ $postData = $this->data;
+
+ //保存
+ if ($this->Link->save($this->data)) {
+
+ $result = array(
+ 'name' => __d('net_commons', 'Successfully finished.'),
+ 'link' => $postData,
+ );
+
+ $this->set(compact('result'));
+ $this->set('_serialize', 'result');
+ return $this->render(false);
+ } else {
+
+ $error = __d('net_commons', 'Failed to register data.');
+ $error .= $this->formatValidationErrors($this->Link->validationErrors);
+ throw new ForbiddenException($error);
+ }
+
+ }
+
+ public function visit($linkId) {
+ $link = $this->Link->findById($linkId);
+ $link['Link']['click_number']++;
+ $this->Link->save($link);
+ $this->redirect($link['Link']['url']);
+ return false;
+ }
+
+ // MyTodo モデルに移動するか、ヘルパかコンポーネントかビヘイビアにする…
+ protected function formatValidationErrors($validationErrors) {
+ $errors = array();
+ foreach($validationErrors as $field => $fieldErrors){
+ foreach($fieldErrors as $errorMessage){
+ $errors[] = __d('links', $field) . ':' . __d('links', $errorMessage);
+ }
+ }
+ $returnMessage = implode("\n", $errors);
+ return $returnMessage;
+ }
+
+ public function test(){
+
+ }
+
+}
diff --git a/Model/Link.php b/Model/Link.php
new file mode 100644
index 0000000..2cfd034
--- /dev/null
+++ b/Model/Link.php
@@ -0,0 +1,165 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * Summary for Link Model
+ * @var LinkOrder $LinkOrder
+ */
+class Link extends LinksAppModel {
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array(
+ 'url' => array(
+ 'url' => [
+ 'rule' => array('url'),
+// 'message' => 'Your custom message here',
+ 'message' => 'required url', // ここでは__d()を使えないので多言語化のキーを記述しておいて、後プロセスで__dをかます。
+ //'allowEmpty' => false,
+ 'required' => true,
+ //'last' => false, // Stop validation after this rule
+ //'on' => 'create', // Limit validation to 'create' or 'update' operations
+ ],
+ ),
+
+ 'link_category_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
+ ),
+ ),
+ 'key' => 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
+ ),
+ ),
+ '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
+ ),
+ ),
+ 'click_number' => 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(
+ 'LinkCategory' => array(
+ 'className' => 'Links.LinkCategory',
+ 'foreignKey' => 'link_category_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'LinkOrder' => array(
+ 'className' => 'Links.LinkOrder',
+ 'foreignKey' => false,
+ 'conditions' => array('Link.key = LinkOrder.link_key'),
+ )
+
+
+ );
+
+ public function getLinksByCategoryId($categoryId, $blockId, $contentEditable){
+ $conditions = array(
+ 'link_category_id' => $categoryId,
+ 'LinkCategory.block_id' => $blockId,
+ );
+ if (! $contentEditable) {
+ $conditions['status'] = NetCommonsBlockComponent::STATUS_PUBLISHED;
+ }
+
+ $links = $this->find('all', array(
+ 'conditions' => $conditions,
+ 'order' => 'LinkOrder.weight ASC',
+ )
+ );
+
+ return $links;
+ }
+
+ public function add($postData) {
+ //DBへの登録
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+ try {
+
+ // MyTodo block_id取得, key生成、 created_userセットは別途ビヘイビアつくってBeforeSaveあたりで処理すりゃええんちゃうか
+ //linksへ 登録
+ $link['Link'] = $postData['Link'];
+ $link['Link']['key'] = $this->_makeKey(); //新規時はkeyを新規に発行
+ $link['Link']['created_user'] = CakeSession::read('Auth.User.id');
+
+
+
+ if (! $this->save($link)) {
+ throw new ForbiddenException(serialize($this->validationErrors));
+ }
+ $this->LinkOrder->addLinkOrder($link);
+ $dataSource->commit();
+ return true;
+
+ } catch (Exception $ex) {
+ CakeLog::error($ex->getTraceAsString());
+ $dataSource->rollback();
+ return false;
+ }
+ }
+
+ // Todo ビヘイビアにしたらええと思う
+ protected function _makeKey() {
+ $className = get_class($this);
+ return hash('sha256', $className . microtime());
+ }
+}
diff --git a/Model/LinkCategory.php b/Model/LinkCategory.php
new file mode 100644
index 0000000..f81de85
--- /dev/null
+++ b/Model/LinkCategory.php
@@ -0,0 +1,211 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * Summary for LinkCategory Model
+ */
+class LinkCategory extends LinksAppModel {
+
+/**
+ * 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
+ ),
+ ),
+ 'key' => 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
+ ),
+ ),
+ '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(
+ 'Block' => array(
+ 'className' => 'Block',
+ 'foreignKey' => 'block_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'LinkCategoryOrder' => array(
+ 'className' => 'Links.LinkCategoryOrder',
+ 'foreignKey' => false,
+ 'conditions' => array('LinkCategory.key = LinkCategoryOrder.link_category_key'),
+ )
+ );
+
+/**
+ * hasMany associations
+ *
+ * @var array
+ */
+ public $hasMany = array(
+ 'Link' => array(
+ 'className' => 'Links.Link',
+ 'foreignKey' => 'link_category_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+
+ public $actsAs = array('Containable');
+
+ public function getCategories($blockId){
+ $conditions = array(
+ 'block_id' => $blockId,
+ );
+
+ $this->unbindModel(array(
+ 'belongsTo' => array('Block'),
+ 'hasMany' => array('Link'),
+ ));
+
+ // ソート順はlink_category_ordersテーブル参照
+ $categories = $this->find('all', array(
+ 'conditions' => $conditions,
+ 'order' => 'LinkCategoryOrder.weight ASC',
+ )
+ );
+
+ return $categories;
+ }
+
+ public function saveLinkCategory($postData){
+ $models = array(
+ 'Frame' => 'Frames.Frame',
+ 'Block' => 'Blocks.Block',
+ );
+ foreach ($models as $model => $class) {
+ $this->$model = ClassRegistry::init($class);
+ $this->$model->setDataSource('master');
+ }
+
+ //frame関連のセット
+ $frame = $this->Frame->findById($postData['Frame']['frame_id']);
+ if (! $frame) {
+ return false;
+ }
+ if (! isset($frame['Frame']['block_id']) ||
+ $frame['Frame']['block_id'] === '0') {
+ //generate link_categories.key
+ }
+
+ //DBへの登録
+ $dataSource = $this->getDataSource();
+ $dataSource->begin();
+ try {
+ $blockId = $this->__saveBlock($frame);
+
+ // MyTodo block_id取得, key生成、 created_userセットは別途ビヘイビアつくってBeforeSaveあたりで処理すりゃええんちゃうか
+ //link_categoriesへ 登録
+ $linkCategory['LinkCategory'] = $postData['LinkCategory'];
+ $linkCategory['LinkCategory']['key'] = hash('sha256', 'link_category_' . microtime()); //新規時はkeyを新規に発行
+ $linkCategory['LinkCategory']['block_id'] = $blockId;
+ $linkCategory['LinkCategory']['created_user'] = CakeSession::read('Auth.User.id');
+
+
+
+ if (! $this->save($linkCategory)) {
+ throw new ForbiddenException(serialize($this->validationErrors));
+ }
+ $this->LinkCategoryOrder->addLinkCategoryOrder($linkCategory);
+ $dataSource->commit();
+ return true;
+
+ } catch (Exception $ex) {
+ CakeLog::error($ex->getTraceAsString());
+ $dataSource->rollback();
+ return false;
+ }
+
+ }
+
+ public function updateCategories($postData) {
+ return $this->saveMany($postData['LinkCategories'], array('deep' => true));
+ }
+
+ /**
+ * save block
+ * ブロックモデルが担当した方がいいんじゃね? By Ryuji
+ * @param array $frame frame data
+ * @return int blocks.id
+ * @throws ForbiddenException
+ *
+ */
+ private function __saveBlock($frame) {
+ if (! isset($frame['Frame']['block_id']) ||
+ $frame['Frame']['block_id'] === '0') {
+ //blocksテーブル登録
+ $block = array();
+ $block['Block']['room_id'] = $frame['Frame']['room_id'];
+ $block['Block']['language_id'] = $frame['Frame']['language_id'];
+ $block = $this->Block->save($block);
+ if (! $block) {
+ throw new ForbiddenException(serialize($this->Block->validationErrors));
+ }
+ $blockId = (int)$block['Block']['id'];
+
+ //framesテーブル更新
+ $frame['Frame']['block_id'] = $blockId;
+ if (! $this->Frame->save($frame)) {
+ throw new ForbiddenException(serialize($this->Frame->validationErrors));
+ }
+ }
+
+ return (int)$frame['Frame']['block_id'];
+ }
+
+}
diff --git a/Model/LinkCategoryOrder.php b/Model/LinkCategoryOrder.php
new file mode 100644
index 0000000..2115fe1
--- /dev/null
+++ b/Model/LinkCategoryOrder.php
@@ -0,0 +1,82 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * Summary for LinkCategoryOrder Model
+ */
+class LinkCategoryOrder extends LinksAppModel {
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array(
+ 'link_category_key' => 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
+ ),
+ ),
+ 'block_key' => 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
+ ),
+ ),
+ 'weight' => 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
+ ),
+ ),
+ );
+
+ public function addLinkCategoryOrder($linkCategory){
+ $Block = ClassRegistry::init('Block');
+ $block = $Block->findById($linkCategory['LinkCategory']['block_id']);
+
+ $linkCategoryOrder['LinkCategoryOrder']['link_category_key'] = $linkCategory['LinkCategory']['key'];
+ $linkCategoryOrder['LinkCategoryOrder']['block_key'] = $block['Block']['key'];
+
+ $linkCategoryOrder['LinkCategoryOrder']['weight'] = $this->_getMaxWightByBlockKey($block['Block']['key']) + 1;
+ $linkCategoryOrder['LinkCategoryOrder']['created_user'] = CakeSession::read('Auth.User.id');;
+
+ if (! $this->save($linkCategoryOrder)) {
+ throw new ForbiddenException(serialize($this->validationErrors));
+ }
+
+ }
+
+ protected function _getMaxWightByBlockKey($blockKey) {
+ $options = array(
+ 'conditions' => array(
+ 'block_key' => $blockKey,
+ ),
+ 'order' => 'weight DESC'
+ );
+ $linkCategoryOrder = $this->find('first', $options);
+ return $linkCategoryOrder['LinkCategoryOrder']['weight'] ;
+ }
+}
diff --git a/Model/LinkFrameSetting.php b/Model/LinkFrameSetting.php
new file mode 100644
index 0000000..c2edab7
--- /dev/null
+++ b/Model/LinkFrameSetting.php
@@ -0,0 +1,97 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * Summary for LinkFrameSetting Model
+ */
+class LinkFrameSetting extends LinksAppModel {
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array(
+ 'frame_key' => 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
+ ),
+ ),
+ 'display_type' => 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
+ ),
+ ),
+ 'open_new_tab' => 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
+ ),
+ ),
+ 'display_click_number' => 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
+ ),
+ ),
+ );
+
+ public function getByFrameId($frameId) {
+ $this->Frame = ClassRegistry::init('Frames.Frame');
+ $frame = $this->Frame->findById($frameId);
+ $frameKey = $frame['Frame']['key'];
+ $linkFrameSetting = $this->findByFrameKey($frameKey);
+
+ if($linkFrameSetting){
+ return $linkFrameSetting;
+ }else{
+ $newLinkFrameSetting = $this->getBlank();
+ $newLinkFrameSetting['LinkFrameSetting']['frame_key'] = $frameKey;
+ return $newLinkFrameSetting;
+ }
+ }
+
+ private function getBlank() {
+ $defaults = array();
+
+ $schema = (array)$this->schema();
+ foreach ($schema as $field => $properties) {
+ if ($this->primaryKey !== $field && isset($properties['default']) && $properties['default'] !== '') {
+ $defaults[$field] = $properties['default'];
+ }else{
+ $defaults[$field] = null;
+ }
+ }
+ $ret = array(
+ $this->alias => $defaults
+ );
+ return $ret;
+ }
+}
diff --git a/Model/LinkOrder.php b/Model/LinkOrder.php
new file mode 100644
index 0000000..12cb5c9
--- /dev/null
+++ b/Model/LinkOrder.php
@@ -0,0 +1,89 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('LinksAppModel', 'Links.Model');
+
+/**
+ * Summary for LinkOrder Model
+ */
+class LinkOrder extends LinksAppModel {
+
+/**
+ * Validation rules
+ *
+ * @var array
+ */
+ public $validate = array(
+ 'link_key' => 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
+ ),
+ ),
+ 'link_category_key' => 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
+ ),
+ ),
+ 'weight' => 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
+ ),
+ ),
+ );
+
+ public function addLinkOrder($link) {
+ $LinkCategory = ClassRegistry::init('Links.LinkCategory');
+ $linkCategoryId = $link['Link']['link_category_id'];
+ $linkCategory = $LinkCategory->findById($linkCategoryId);
+ $linkCategoryKey = $linkCategory['LinkCategory']['key'];
+
+
+ $linkOrder['LinkOrder']['link_key'] = $link['Link']['key'];
+ $linkOrder['LinkOrder']['link_category_key'] = $linkCategoryKey;
+
+ $linkOrder['LinkOrder']['weight'] = $this->_getMaxWeightByLinkCategoryKey($linkCategoryKey) + 1;
+ $linkOrder['LinkOrder']['created_user'] = CakeSession::read('Auth.User.id');;
+
+ if (! $this->save($linkOrder)) {
+ throw new ForbiddenException(serialize($this->validationErrors));
+ }
+
+ }
+ protected function _getMaxWeightByLinkCategoryKey($linkCategoryKey) {
+ $options = array(
+ 'conditions' => array(
+ 'link_category_key' => $linkCategoryKey,
+ ),
+ 'order' => 'weight DESC'
+ );
+ $linkOrder = $this->find('first', $options);
+ if(empty($linkOrder)){
+ return 0; // まだ登録がない
+ }else{
+ return $linkOrder['LinkOrder']['weight'] ;
+ }
+ }
+
+}
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/LinkListsAppModel.php b/Model/LinksAppModel.php
similarity index 50%
rename from Model/LinkListsAppModel.php
rename to Model/LinksAppModel.php
index d3679d3..40c3512 100644
--- a/Model/LinkListsAppModel.php
+++ b/Model/LinksAppModel.php
@@ -2,6 +2,6 @@
App::uses('AppModel', 'Model');
-class LinkListsAppModel extends AppModel {
+class LinksAppModel extends AppModel {
}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..eaac6bb
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+Links
+=====
+
+プロトタイプ(管理画面のモーダル改修済)
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/Controller/LinksControllerTest.php b/Test/Case/Controller/LinksControllerTest.php
new file mode 100644
index 0000000..a00f55a
--- /dev/null
+++ b/Test/Case/Controller/LinksControllerTest.php
@@ -0,0 +1,84 @@
+
+ * @link http://www.netcommons.org NetCommons Project
+ * @license http://www.netcommons.org/license.txt NetCommons License
+ * @copyright Copyright 2014, NetCommons Project
+ */
+
+App::uses('LinksController', 'Links.Controller');
+App::uses('NetCommonsFrameComponent', 'NetCommons.Controller/Component');
+App::uses('NetCommonsBlockComponent', 'NetCommons.Controller/Component');
+App::uses('NetCommonsRoomRoleComponent', 'NetCommons.Controller/Component');
+
+/**
+ * LinksController Test Case
+ */
+class LinksControllerTest extends ControllerTestCase {
+
+/**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = array(
+// 'plugin.links.link',
+// 'plugin.links.site_setting',
+// 'plugin.links.site_setting_value'
+ 'site_setting',
+// 'plugin.frames.box',
+// 'plugin.frames.language',
+ 'plugin.rooms.room',
+ 'plugin.rooms.roles_rooms_user',
+ 'plugin.roles.default_role_permission',
+ 'plugin.rooms.roles_room',
+ 'plugin.rooms.room_role_permission',
+ 'plugin.rooms.user',
+ );
+
+ /**
+ * setUp
+ *
+ * @return void
+ */
+ public function setUp() {
+ parent::setUp();
+ Configure::write('Config.language', 'ja');
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown() {
+ Configure::write('Config.language', null);
+ parent::tearDown();
+ }
+
+// /**
+// * testBeforeFilterByNoSetFrameId method
+// *
+// * @return void
+// */
+// public function testBeforeFilterByNoSetFrameId() {
+// $this->setExpectedException('ForbiddenException');
+// $this->testAction('/announcements/announcements/index', array('method' => 'get'));
+// }
+
+ /**
+ * testIndex method
+ *
+ * @return void
+ */
+ public function testIndex() {
+ $result = $this->testAction('/links/links/index/1', array('method' => 'get'));
+ debug($result);
+
+ $expected = '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.';
+ $this->assertTextContains($expected, $this->view);
+ }
+
+}
diff --git a/Test/Case/Model/LinklistSettingTest.php b/Test/Case/Model/LinkCategoryOrderTest.php
similarity index 56%
rename from Test/Case/Model/LinklistSettingTest.php
rename to Test/Case/Model/LinkCategoryOrderTest.php
index b85ee01..7e3b75e 100644
--- a/Test/Case/Model/LinklistSettingTest.php
+++ b/Test/Case/Model/LinkCategoryOrderTest.php
@@ -1,18 +1,18 @@
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
-App::uses('LinklistSetting', 'LinkLists.Model');
+App::uses('LinkCategoryOrder', 'Links.Model');
/**
- * Summary for LinklistSetting Test Case
+ * Summary for LinkCategoryOrder Test Case
*/
-class LinklistSettingTest extends CakeTestCase {
+class LinkCategoryOrderTest extends CakeTestCase {
/**
* Fixtures
@@ -20,8 +20,7 @@ class LinklistSettingTest extends CakeTestCase {
* @var array
*/
public $fixtures = array(
- 'plugin.link_lists.linklist_setting',
- 'plugin.link_lists.linklist_block'
+ 'plugin.links.link_category_order'
);
/**
@@ -31,7 +30,7 @@ class LinklistSettingTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
- $this->LinklistSetting = ClassRegistry::init('LinkLists.LinklistSetting');
+ $this->LinkCategoryOrder = ClassRegistry::init('Links.LinkCategoryOrder');
}
/**
@@ -40,7 +39,7 @@ public function setUp() {
* @return void
*/
public function tearDown() {
- unset($this->LinklistSetting);
+ unset($this->LinkCategoryOrder);
parent::tearDown();
}
diff --git a/Test/Case/Model/LinkCategoryTest.php b/Test/Case/Model/LinkCategoryTest.php
new file mode 100644
index 0000000..2fdfc23
--- /dev/null
+++ b/Test/Case/Model/LinkCategoryTest.php
@@ -0,0 +1,110 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('LinkCategory', 'Links.Model');
+
+/**
+ * Summary for LinkCategory Test Case
+ *
+ * @property LinkCategory $LinkCategory
+ */
+class LinkCategoryTest extends CakeTestCase {
+
+/**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = array(
+ 'plugin.links.link_category',
+ 'plugin.links.link_category_order',
+ 'plugin.links.block',
+ 'plugin.links.link'
+ );
+
+/**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp() {
+ parent::setUp();
+ $this->LinkCategory = ClassRegistry::init('Links.LinkCategory');
+ }
+
+/**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown() {
+ unset($this->LinkCategory);
+
+ parent::tearDown();
+ }
+
+
+ public function testAssociationLinkCategoryOrder() {
+ $linkCategory = $this->LinkCategory->findById(1);
+ $this->assertEqual($linkCategory['LinkCategoryOrder']['id'], 1);
+
+ $linkCategory = $this->LinkCategory->findById(2);
+ $this->assertEqual($linkCategory['LinkCategoryOrder']['id'], 2);
+
+ $linkCategory = $this->LinkCategory->findById(3);
+ $this->assertEqual($linkCategory['LinkCategoryOrder']['id'], 1);
+ }
+
+ public function testAssociationLink() {
+ $linkCategory = $this->LinkCategory->findById(1);
+ $this->assertEqual(count($linkCategory['Link']), 2);
+
+ $linkCategory = $this->LinkCategory->findById(2);
+ $this->assertEqual(count($linkCategory['Link']), 1);
+ }
+
+ public function testGetCategories() {
+ $blockId = 1;
+ $categories = $this->LinkCategory->getCategories($blockId);
+ $this->assertEqual($categories[0]['LinkCategory']['id'], 2);
+ $this->assertEqual($categories[1]['LinkCategory']['id'], 1);
+ }
+
+ public function testUpdateCategories() {
+ $data = array(
+ array(
+ 'LinkCategory' => array(
+
+ 'id' => 1,
+ 'name' => 'ID1DATA'
+ ),
+ 'LinkCategoryOrder' => array(
+ 'id' => 1,
+ 'weight' => 1
+ )
+ ),
+ array(
+ 'LinkCategory' => array(
+
+ 'id' => 2,
+ 'name' => 'ID2DATA'
+ ),
+ 'LinkCategoryOrder' => array(
+ 'id' => 2,
+ 'weight' => 2
+ )
+ ),
+ );
+ $resultTrue = $this->LinkCategory->updateCategories($data);
+ $this->assertTrue($resultTrue);
+ $linkCategory1 = $this->LinkCategory->findById(1);
+ $this->assertEqual($linkCategory1['LinkCategory']['name'], 'ID1DATA');
+
+ }
+}
diff --git a/Test/Case/Model/LinklistsCategoryTest.php b/Test/Case/Model/LinkFrameSettingTest.php
similarity index 51%
rename from Test/Case/Model/LinklistsCategoryTest.php
rename to Test/Case/Model/LinkFrameSettingTest.php
index fbfc49e..8124ae9 100644
--- a/Test/Case/Model/LinklistsCategoryTest.php
+++ b/Test/Case/Model/LinkFrameSettingTest.php
@@ -1,18 +1,18 @@
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
-App::uses('LinklistsCategory', 'LinkLists.Model');
+App::uses('LinkFrameSetting', 'Links.Model');
/**
- * Summary for LinklistsCategory Test Case
+ * Summary for LinkFrameSetting Test Case
*/
-class LinklistsCategoryTest extends CakeTestCase {
+class LinkFrameSettingTest extends CakeTestCase {
/**
* Fixtures
@@ -20,10 +20,7 @@ class LinklistsCategoryTest extends CakeTestCase {
* @var array
*/
public $fixtures = array(
- 'plugin.link_lists.linklists_category',
- 'plugin.link_lists.linklists_block',
- 'plugin.link_lists.language',
- 'plugin.link_lists.linklist'
+ 'plugin.links.link_frame_setting'
);
/**
@@ -33,7 +30,7 @@ class LinklistsCategoryTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
- $this->LinklistsCategory = ClassRegistry::init('LinkLists.LinklistsCategory');
+ $this->LinkFrameSetting = ClassRegistry::init('Links.LinkFrameSetting');
}
/**
@@ -42,7 +39,7 @@ public function setUp() {
* @return void
*/
public function tearDown() {
- unset($this->LinklistsCategory);
+ unset($this->LinkFrameSetting);
parent::tearDown();
}
diff --git a/Test/Case/Model/LinkOrderTest.php b/Test/Case/Model/LinkOrderTest.php
new file mode 100644
index 0000000..9e89790
--- /dev/null
+++ b/Test/Case/Model/LinkOrderTest.php
@@ -0,0 +1,87 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('LinkOrder', 'Links.Model');
+
+
+class LinkOrderTesting extends LinkOrder{
+ public $useTable = 'link_orders';
+ public $alias = 'LinkOrder';
+ public function _getMaxWeightByLinkCategoryKey($linkCategoryKey) {
+ return parent::_getMaxWeightByLinkCategoryKey($linkCategoryKey);
+ }
+}
+/**
+ * Summary for LinkOrder Test Case
+ */
+class LinkOrderTest extends CakeTestCase {
+
+/**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = array(
+ 'plugin.links.link_order',
+ 'plugin.links.link_category',
+ 'plugin.links.link_category_order',
+ 'plugin.links.link',
+ 'plugin.links.block',
+ );
+
+/**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp() {
+ parent::setUp();
+ $this->LinkOrder = ClassRegistry::init('Links.LinkOrder');
+ $this->LinkOrderTesting = ClassRegistry::init('Links.LinkOrderTesting');
+ }
+
+/**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown() {
+ unset($this->LinkOrder);
+
+ parent::tearDown();
+ }
+
+ public function testGetMaxWeight() {
+ $key = 'ckey1';
+ $max = $this->LinkOrderTesting->_getMaxWeightByLinkCategoryKey($key);
+ $this->assertEqual($max, 10);
+
+ $max = $this->LinkOrderTesting->_getMaxWeightByLinkCategoryKey('noDataKey');
+ $this->assertEqual($max, 0);
+ }
+
+ public function testAddLinkOrder() {
+// $link = array(
+// 'Link' => array(
+// 'description' => "desc",
+// 'link_category_id' => 2,
+// 'status' => 1,
+// 'title' => 'title',
+// 'url' => 'url'
+// )
+// );
+ $link = array(
+ 'Link' => array('key' => 'key01', 'link_category_id' => 1)
+ );
+ $this->LinkOrder->addLinkOrder($link);
+
+
+ }
+
+}
diff --git a/Test/Case/Model/LinkTest.php b/Test/Case/Model/LinkTest.php
new file mode 100644
index 0000000..8337367
--- /dev/null
+++ b/Test/Case/Model/LinkTest.php
@@ -0,0 +1,95 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('Link', 'Links.Model');
+
+/**
+ * Summary for Link Test Case
+ *
+ * @property Link $Link
+ */
+class LinkTest extends CakeTestCase {
+
+/**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = array(
+ 'plugin.links.link',
+ 'plugin.links.link_order',
+ 'plugin.links.link_category',
+ 'plugin.links.link_category_order',
+ 'plugin.links.block',
+ );
+
+/**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp() {
+ parent::setUp();
+ $this->Link = ClassRegistry::init('Links.Link');
+ }
+
+/**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown() {
+ unset($this->Link);
+
+ parent::tearDown();
+ }
+
+ public function testAssociationLinkOrder() {
+ $link = $this->Link->findById(1);
+ $this->assertEqual($link['LinkOrder']['id'], 1);
+
+ $link = $this->Link->findById(2);
+ $this->assertEqual($link['LinkOrder']['id'], 2);
+ }
+
+ public function testAssociationLinkCategory() {
+ $link = $this->Link->findById(1);
+ $this->assertEqual($link['LinkCategory']['id'], 1);
+ }
+
+
+ public function testGetLinksByCategoryId() {
+ $categoryId = 1;
+ $blockId = 1;
+ $contentEditable = true;
+
+ //
+ $links = $this->Link->getLinksByCategoryId($categoryId, $blockId, $contentEditable);
+
+ $this->assertEqual(count($links), 2);
+ }
+ public function testGetLinksByCategoryId4NotEditable() {
+ $categoryId = 1;
+ $blockId = 1;
+ $contentEditable = false;
+ $links = $this->Link->getLinksByCategoryId($categoryId, $blockId, $contentEditable);
+ $this->assertEqual(count($links), 1);
+ }
+ // リンクがオーダー順にとれてるか
+ public function testGetLinksByCategoryIdOrderWight() {
+ $categoryId = 1;
+ $blockId = 1;
+ $contentEditable = true;
+ $links = $this->Link->getLinksByCategoryId($categoryId, $blockId, $contentEditable);
+
+ $this->assertEqual($links[0]['Link']['id'] , 2);
+ $this->assertEqual($links[1]['Link']['id'] , 1);
+ }
+
+}
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/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/Fixture/LinkCategoryFixture.php b/Test/Fixture/LinkCategoryFixture.php
new file mode 100644
index 0000000..57fcfb7
--- /dev/null
+++ b/Test/Fixture/LinkCategoryFixture.php
@@ -0,0 +1,81 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+/**
+ * Summary for LinkCategoryFixture
+ */
+class LinkCategoryFixture 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 | '),
+ 'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'category key | カテゴリーKey | | ', 'charset' => 'utf8'),
+ 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'category name | カテゴリー名 | | ', 'charset' => 'utf8'),
+ 'is_auto_translated' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'translation type. 0:original , 1:auto translation | 翻訳タイプ 0:オリジナル、1:自動翻訳 | | '),
+ 'translation_engine' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'translation engine | 翻訳エンジン | | ', 'charset' => 'utf8'),
+ '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_id' => 1,
+ 'key' => 'key1',
+ 'name' => '株式会社RYUS',
+ 'is_auto_translated' => 1,
+ 'translation_engine' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:24',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:24'
+ ),
+ array(
+ 'id' => 2,
+ 'block_id' => 1,
+ 'key' => 'key2',
+ 'name' => 'Lorem ipsum dolor sit amet',
+ 'is_auto_translated' => 1,
+ 'translation_engine' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:24',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:24'
+ ),
+ array(
+ 'id' => 3,
+ 'block_id' => 2,
+ 'key' => 'key1',
+ 'name' => 'RYUS INC',
+ 'is_auto_translated' => 1,
+ 'translation_engine' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:24',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:24'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinkCategoryOrderFixture.php b/Test/Fixture/LinkCategoryOrderFixture.php
new file mode 100644
index 0000000..4d9add5
--- /dev/null
+++ b/Test/Fixture/LinkCategoryOrderFixture.php
@@ -0,0 +1,63 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+/**
+ * Summary for LinkCategoryOrderFixture
+ */
+class LinkCategoryOrderFixture extends CakeTestFixture {
+
+/**
+ * Fields
+ *
+ * @var array
+ */
+ public $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'link_category_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'category key | カテゴリーKey | link_categories.key | ', 'charset' => 'utf8'),
+ 'block_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'block key | ブロックKey | blocks.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,
+ 'link_category_key' => 'key1',
+ 'block_key' => 'Lorem ipsum dolor sit amet',
+ 'weight' => 2,
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:50',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:50'
+ ),
+ array(
+ 'id' => 2,
+ 'link_category_key' => 'key2',
+ 'block_key' => 'Lorem ipsum dolor sit amet',
+ 'weight' => 1,
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:50',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:50'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinkFixture.php b/Test/Fixture/LinkFixture.php
new file mode 100644
index 0000000..bbf6c82
--- /dev/null
+++ b/Test/Fixture/LinkFixture.php
@@ -0,0 +1,100 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+App::uses('Link', 'Links.Model');
+App::uses('NetCommonsBlockComponent', 'NetCommons.Controller/Component');
+
+/**
+ * Summary for LinkFixture
+ */
+class LinkFixture extends CakeTestFixture {
+
+/**
+ * Fields
+ *
+ * @var array
+ */
+ public $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'link_category_id' => array('type' => 'integer', 'null' => false, '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_number' => array('type' => 'integer', 'null' => false, 'default' => '0', 'comment' => 'link access number | リンクアクセス数 | | '),
+ 'is_auto_translated' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'translation type. 0:original , 1:auto translation | 翻訳タイプ 0:オリジナル、1:自動翻訳 | | '),
+ 'translation_engine' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'translation engine | 翻訳エンジン | | ', 'charset' => 'utf8'),
+ '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,
+ 'link_category_id' => 1,
+ 'key' => 'key1',
+ 'status' => NetCommonsBlockComponent::STATUS_PUBLISHED,
+ '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_number' => 1,
+ 'is_auto_translated' => 1,
+ 'translation_engine' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:32',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:32'
+ ),
+ array(
+ 'id' => 2,
+ 'link_category_id' => 1,
+ 'key' => 'key2',
+ 'status' => NetCommonsBlockComponent::STATUS_DRAFTED,
+ '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_number' => 1,
+ 'is_auto_translated' => 1,
+ 'translation_engine' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:32',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:32'
+ ),
+ array(
+ 'id' => 3,
+ 'link_category_id' => 2,
+ 'key' => 'key3',
+ 'status' => NetCommonsBlockComponent::STATUS_PUBLISHED,
+ '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_number' => 1,
+ 'is_auto_translated' => 1,
+ 'translation_engine' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:32',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:32'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinkFrameSettingFixture.php b/Test/Fixture/LinkFrameSettingFixture.php
new file mode 100644
index 0000000..e7377ee
--- /dev/null
+++ b/Test/Fixture/LinkFrameSettingFixture.php
@@ -0,0 +1,59 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+/**
+ * Summary for LinkFrameSettingFixture
+ */
+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' => 'boolean', 'null' => false, 'default' => '0', '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_number' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'displayclick number, 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' => '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,
+ 'frame_key' => 'Lorem ipsum dolor sit amet',
+ 'display_type' => 1,
+ 'open_new_tab' => 1,
+ 'display_click_number' => 1,
+ 'category_separator_line' => 'Lorem ipsum dolor sit amet',
+ 'list_style' => 'Lorem ipsum dolor sit amet',
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:55:51',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:55:51'
+ ),
+ );
+
+}
diff --git a/Test/Fixture/LinkOrderFixture.php b/Test/Fixture/LinkOrderFixture.php
new file mode 100644
index 0000000..4f8c5b1
--- /dev/null
+++ b/Test/Fixture/LinkOrderFixture.php
@@ -0,0 +1,73 @@
+
+* @link http://www.netcommons.org NetCommons Project
+* @license http://www.netcommons.org/license.txt NetCommons License
+ */
+
+/**
+ * Summary for LinkOrderFixture
+ */
+class LinkOrderFixture extends CakeTestFixture {
+
+/**
+ * Fields
+ *
+ * @var array
+ */
+ public $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID | | | '),
+ 'link_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'link key | リンクKey | links.key | ', 'charset' => 'utf8'),
+ 'link_category_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'category key | カテゴリーKey | link_categories.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,
+ 'link_key' => 'key1',
+ 'link_category_key' => 'ckey1',
+ 'weight' => 10,
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:40',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:40'
+ ),
+ array(
+ 'id' => 2,
+ 'link_key' => 'key2',
+ 'link_category_key' => 'ckey2',
+ 'weight' => 1,
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:40',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:40'
+ ),
+ array(
+ 'id' => 3,
+ 'link_key' => 'key3',
+ 'link_category_key' => 'ckey3',
+ 'weight' => 5,
+ 'created_user' => 1,
+ 'created' => '2014-10-25 04:56:40',
+ 'modified_user' => 1,
+ 'modified' => '2014-10-25 04:56:40'
+ ),
+ );
+
+}
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/Elements/LinkCategory/content_edit_btn_category.ctp b/View/Elements/LinkCategory/content_edit_btn_category.ctp
new file mode 100644
index 0000000..dd6d568
--- /dev/null
+++ b/View/Elements/LinkCategory/content_edit_btn_category.ctp
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/View/Elements/LinkEdit/content_edit_btn_link.ctp b/View/Elements/LinkEdit/content_edit_btn_link.ctp
new file mode 100644
index 0000000..d2216e7
--- /dev/null
+++ b/View/Elements/LinkEdit/content_edit_btn_link.ctp
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/View/Elements/Links/dropdown.ctp b/View/Elements/Links/dropdown.ctp
new file mode 100644
index 0000000..439d32c
--- /dev/null
+++ b/View/Elements/Links/dropdown.ctp
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/View/Elements/Links/header_button.ctp b/View/Elements/Links/header_button.ctp
new file mode 100644
index 0000000..d8362db
--- /dev/null
+++ b/View/Elements/Links/header_button.ctp
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/View/Elements/Links/index_add_link.ctp b/View/Elements/Links/index_add_link.ctp
new file mode 100644
index 0000000..d82c8d4
--- /dev/null
+++ b/View/Elements/Links/index_add_link.ctp
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+ Form->label('category', __('カテゴリー'));
+
+ echo $this->Form->input('category', array(
+ 'label' => false,
+ 'type' => 'select',
+// 'options' => array(1 => 'カテゴリー1', '2' => 'カテゴリー2', '3' => 'カテゴリー3'),
+ 'selected' => 1,
+ 'class' => 'form-control',
+ 'ng-model' => 'newLink.Link.link_category_id',
+ 'ng-options' => 'category.LinkCategory.id as category.LinkCategory.name for category in linkCategories',
+// 'value' => '{{selectedCategory.Link.id}}',
+ )
+ );
+ ?>
+
+
+
+ Form->label('title', __('タイトル'));
+
+ echo $this->Form->input('title', array(
+ 'label' => false,
+ 'type' => 'text',
+ 'class' => 'form-control',
+ 'ng-model' => 'newLink.Link.title'
+ )
+ );
+ ?>
+
+
+
+
+ Form->label('description', __('説明'));
+
+ echo $this->Form->input('description', array(
+ 'label' => false,
+ 'type' => 'textarea',
+ 'rows' => 2,
+ 'class' => 'form-control',
+ 'ng-model' => 'newLink.Link.description'
+ )
+ );
+ ?>
+
+
+
+
+
+
+
+
+
+
diff --git a/View/Elements/Links/list.ctp b/View/Elements/Links/list.ctp
new file mode 100644
index 0000000..ab05b62
--- /dev/null
+++ b/View/Elements/Links/list.ctp
@@ -0,0 +1,31 @@
+
+
diff --git a/View/Elements/content_move_btn.ctp b/View/Elements/content_move_btn.ctp
new file mode 100644
index 0000000..7252a8f
--- /dev/null
+++ b/View/Elements/content_move_btn.ctp
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/View/Helper/LinksStatusHelper.php b/View/Helper/LinksStatusHelper.php
new file mode 100644
index 0000000..ee17044
--- /dev/null
+++ b/View/Helper/LinksStatusHelper.php
@@ -0,0 +1,32 @@
+申請中';
+ break;
+ case NetCommonsBlockComponent::STATUS_DISAPPROVED:
+ $ret = '差し戻し';
+ break;
+ case NetCommonsBlockComponent::STATUS_DRAFTED:
+ $ret = '下書き';
+ break;
+ default:
+ $ret = '';
+
+ }
+ return $ret;
+ }
+}
\ No newline at end of file
diff --git a/View/LinkAuthority/form.ctp b/View/LinkAuthority/form.ctp
new file mode 100644
index 0000000..70cafa8
--- /dev/null
+++ b/View/LinkAuthority/form.ctp
@@ -0,0 +1,17 @@
+Form->create(null);
+
+foreach($rolePermission as $roleKey => $permission){
+ echo $this->Form->input('add_link.'.$roleKey.'.name');
+ echo $this->Form->chekcbox('add_link.'.$roleKey.'.permission');
+}
+
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ )
+);
+
+
+echo $this->Form->end();
\ No newline at end of file
diff --git a/View/LinkAuthority/view.ctp b/View/LinkAuthority/view.ctp
new file mode 100644
index 0000000..79a8ff4
--- /dev/null
+++ b/View/LinkAuthority/view.ctp
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
diff --git a/View/LinkCategory/categories_form.ctp b/View/LinkCategory/categories_form.ctp
new file mode 100644
index 0000000..b28f8b1
--- /dev/null
+++ b/View/LinkCategory/categories_form.ctp
@@ -0,0 +1,45 @@
+Form->create(null);
+
+$count = 0;
+
+//$linkCategories = array_fill(0, 7, array());
+
+foreach($linkCategories as $linkCategory){
+ echo $this->Form->input(sprintf('LinkCategories.%d.LinkCategory.id', $count), array(
+ 'type' => 'text',
+ 'value' => $linkCategory['LinkCategory']['id']
+ )
+ );
+ echo $this->Form->input(sprintf('LinkCategories.%d.LinkCategory.name', $count), array(
+ 'type' => 'text',
+ )
+ );
+ echo $this->Form->input(sprintf('LinkCategories.%d.LinkCategoryOrder.id', $count), array(
+ 'type' => 'text',
+ 'value' => $linkCategory['LinkCategoryOrder']['id']
+ )
+ );
+ echo $this->Form->input(sprintf('LinkCategories.%d.LinkCategoryOrder.weight', $count), array(
+ 'type' => 'text',
+ )
+ );
+
+$count++;
+}
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ 'ng-model' => 'edit.data.Frame.frame_id'
+ )
+);
+
+
+echo $this->Form->end();
diff --git a/View/LinkCategory/delete_form.ctp b/View/LinkCategory/delete_form.ctp
new file mode 100644
index 0000000..ee103f0
--- /dev/null
+++ b/View/LinkCategory/delete_form.ctp
@@ -0,0 +1,24 @@
+Form->create(null);
+
+echo $this->Form->input('LinkCategory.id', array(
+ 'type' => 'text',
+ )
+);
+
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ 'ng-model' => 'edit.data.Frame.frame_id'
+ )
+);
+
+
+echo $this->Form->end();
diff --git a/View/LinkCategory/form.ctp b/View/LinkCategory/form.ctp
new file mode 100644
index 0000000..6aec635
--- /dev/null
+++ b/View/LinkCategory/form.ctp
@@ -0,0 +1,45 @@
+Form->create(null);
+
+echo $this->Form->input('LinkCategory.name', array(
+ 'type' => 'text',
+ 'value' => '',
+ 'ng-model' => 'edit.data.LinkCategory.name'
+ )
+);
+
+//if ($contentPublishable) {
+// $options = array(
+// NetCommonsBlockComponent::STATUS_PUBLISHED,
+// NetCommonsBlockComponent::STATUS_DRAFTED,
+// NetCommonsBlockComponent::STATUS_DISAPPROVED,
+// );
+//} else {
+// $options = array(
+// NetCommonsBlockComponent::STATUS_APPROVED,
+// NetCommonsBlockComponent::STATUS_DRAFTED,
+// );
+//}
+//echo $this->Form->input('Announcement.status', array(
+// 'type' => 'select',
+// 'options' => array_combine($options, $options)
+// )
+// );
+
+//echo $this->element('AnnouncementEdit/common_form');
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ 'ng-model' => 'edit.data.Frame.frame_id'
+ )
+);
+
+//echo $this->Form->input('LinkCategory.block_id', array(
+// 'type' => 'hidden',
+// 'value' => (int)$blockId,
+// 'ng-model' => 'edit.data.LinkCategory.block_id',
+// )
+//);
+
+echo $this->Form->end();
diff --git a/View/LinkCategory/view.ctp b/View/LinkCategory/view.ctp
new file mode 100644
index 0000000..b2b274e
--- /dev/null
+++ b/View/LinkCategory/view.ctp
@@ -0,0 +1,84 @@
+
+ $linkCategory): ?>
+
+
+
+ element('content_move_btn',
+ array('size' => '2 col-md-2', 'upDisabled' => false, 'downDisabled' => false)
+ ); ?>
+
+
+ Form->input('category_name.1', array(
+ 'label' => false,
+ 'type' => 'text',
+ 'class' => 'form-control',
+// 'value' => h($linkCategory['LinkCategory']['name']),
+ 'ng-model' => 'linkCategory.LinkCategory.name'
+ )
+ );
+ ?>
+
+ element('LinkCategory/content_edit_btn_category', array('published' => false, 'size' => '2 col-md-1')); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ Form->input('LinkCategory.name', array(
+ 'label' => false,
+ 'type' => 'text',
+ 'class' => 'form-control',
+ 'value' => '',
+ 'ng-model' => 'edit.data.LinkCategory.name',
+ )
+ );
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/View/LinkDisplay/view.ctp b/View/LinkDisplay/view.ctp
new file mode 100644
index 0000000..41d1cc0
--- /dev/null
+++ b/View/LinkDisplay/view.ctp
@@ -0,0 +1,121 @@
+
+
+
+
+
+ Form->input('open_new_tab', array(
+ //'label' => false,
+ 'type' => 'checkbox',
+ 'label' => 'リンクをクリック時、新規ウィンドウで表示する',
+ 'div' => array('class' => 'bold', 'style' => 'margin-left: 0px;'),
+ 'checked' => true,
+ 'ng-model' => 'FrameSetting.open_new_tab',
+
+ )
+ );
+ ?>
+
+
+
+ Form->input('display_click_number', array(
+ //'label' => false,
+ 'type' => 'checkbox',
+ 'label' => 'リンク先参照回数を表示する',
+ 'div' => array('class' => 'bold', 'style' => 'margin-left: 0px;'),
+ 'checked' => true,
+ 'ng-model' => 'FrameSetting.display_click_number',
+ )
+ );
+ ?>
+
+
+
+
+ Form->label('category_separator_line', __('カテゴリ間の区切り線'));
+
+ echo $this->Form->input('category_separator_line', array(
+ 'label' => false,
+ 'type' => 'textarea',
+ 'rows' => 2,
+ 'value' => 'MyTodo',
+ 'class' => 'form-control',
+ 'ng-model' => 'FrameSetting.category_separator_line',
+ )
+ );
+ ?>
+
+
+
+ Form->label('list_style', __('リストマーカー'));
+
+ echo $this->Form->input('list_style', array(
+ 'label' => false,
+ 'type' => 'textarea',
+ 'rows' => 2,
+ 'value' => 'MyTodo',
+ 'class' => 'form-control',
+ 'ng-model' => 'FrameSetting.list_style',
+ )
+ );
+ ?>
+
+
+
+
+
+
+
+
diff --git a/View/LinkEdit/view.ctp b/View/LinkEdit/view.ctp
new file mode 100644
index 0000000..847994c
--- /dev/null
+++ b/View/LinkEdit/view.ctp
@@ -0,0 +1,57 @@
+
+
+
+
+
+ {{linkCategory.LinkCategory.name}}
+
+
+
+
+
+
+ element('content_move_btn', array('size' => '12 col-md-1', 'upDisabled' => true, 'moveParams' => array('categoryIndex', 'linkIndex'))); ?>
+
+
+
+
+ {{link.Link.description}}
+
+
+ element('LinkEdit/content_edit_btn_link', array(
+ 'published' => false,
+ 'size' => 12,
+ 'url' => $url,
+ 'title' => $title,
+ 'description' => $description)); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/View/LinkFrameSetting/form.ctp b/View/LinkFrameSetting/form.ctp
new file mode 100644
index 0000000..a39481f
--- /dev/null
+++ b/View/LinkFrameSetting/form.ctp
@@ -0,0 +1,20 @@
+Form->create(null);
+
+echo $this->Form->input('LinkFrameSetting.id', array('type'=>'hidden', 'value' => $linkFrameSetting['LinkFrameSetting']['id']));
+echo $this->Form->input('LinkFrameSetting.frame_key', array('type'=>'hidden', 'value' => $linkFrameSetting['LinkFrameSetting']['frame_key']));
+
+echo $this->Form->input('LinkFrameSetting.display_type', array('options' => array(0,1,2))); // MyTodo fix Magic Number
+echo $this->Form->chekcbox('LinkFrameSetting.open_new_tab');
+echo $this->Form->chekcbox('LinkFrameSetting.display_click_number');
+echo $this->Form->input('LinkFrameSetting.category_separator_line');
+echo $this->Form->input('LinkFrameSetting.list_style');
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ )
+);
+
+
+echo $this->Form->end();
\ No newline at end of file
diff --git a/View/Links/add_form.ctp b/View/Links/add_form.ctp
new file mode 100644
index 0000000..c486626
--- /dev/null
+++ b/View/Links/add_form.ctp
@@ -0,0 +1,23 @@
+Form->create(null);
+
+$fields = array(
+ 'Link.url',
+ 'Link.title',
+ 'Link.description',
+ 'Link.link_category_id',
+ 'Link.status'
+);
+foreach($fields as $field){
+echo $this->Form->input($field, array('type' => 'text'));
+}
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ )
+);
+
+
+echo $this->Form->end();
\ No newline at end of file
diff --git a/View/Links/delete_form.ctp b/View/Links/delete_form.ctp
new file mode 100644
index 0000000..b5dd872
--- /dev/null
+++ b/View/Links/delete_form.ctp
@@ -0,0 +1,14 @@
+Form->create(null);
+
+echo $this->Form->input('Link.id', array('type' => 'hidden', 'value' => $linkId));
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ )
+);
+
+
+echo $this->Form->end();
\ No newline at end of file
diff --git a/View/Links/edit_form.ctp b/View/Links/edit_form.ctp
new file mode 100644
index 0000000..d3272d0
--- /dev/null
+++ b/View/Links/edit_form.ctp
@@ -0,0 +1,26 @@
+Form->create(null);
+
+echo $this->Form->input('Link.id', array('type' => 'hidden', value => $linkId));
+
+$fields = array(
+ 'Link.url',
+
+ 'Link.title',
+ 'Link.description',
+ 'Link.link_category_id',
+ 'Link.status'
+);
+foreach($fields as $field){
+ echo $this->Form->input($field, array('type' => 'text'));
+}
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ )
+);
+
+
+echo $this->Form->end();
\ No newline at end of file
diff --git a/View/Links/index.ctp b/View/Links/index.ctp
new file mode 100644
index 0000000..f038f93
--- /dev/null
+++ b/View/Links/index.ctp
@@ -0,0 +1,40 @@
+Html->script('/links/js/links.js?'.time()); ?>
+
+
+
+,
+ )">
+
+
+ element('Links/header_button'); ?>
+
+
+
+
+
+
+
+ element('Links/list'); ?>
+
+
+
+ element('Links/dropdown'); ?>
+
+
+
+
+
diff --git a/View/Links/link_add.ctp b/View/Links/link_add.ctp
new file mode 100644
index 0000000..ead8069
--- /dev/null
+++ b/View/Links/link_add.ctp
@@ -0,0 +1,14 @@
+
+
+
+ element('Links/index_add_link', array('ngClick' => 'cancel()')); ?>
+
diff --git a/View/Links/manage.ctp b/View/Links/manage.ctp
new file mode 100644
index 0000000..f2d2afa
--- /dev/null
+++ b/View/Links/manage.ctp
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+ requestAction('/links/LinkEdit/view/' . $frameId, array('return')); ?>
+
+
+
+ requestAction('/links/LinkEdit/viewEdit/' . $frameId, array('return')); ?>
+
+
+
+
+
+ requestAction('/links/LinkCategory/view/' . $frameId, array('return')); ?>
+
+
+
+ requestAction('/links/LinkDisplay/view/' . $frameId, array('return')); ?>
+
+
+ requestAction('/links/LinkAuthority/view/' . $frameId, array('return')); ?>
+
+
+
+
+
diff --git a/View/Links/update_weight_form.ctp b/View/Links/update_weight_form.ctp
new file mode 100644
index 0000000..0bdf906
--- /dev/null
+++ b/View/Links/update_weight_form.ctp
@@ -0,0 +1,24 @@
+Form->create(null);
+
+$fields = array(
+ 'Link.url',
+ 'Link.title',
+ 'Link.description',
+ 'Link.link_category_id',
+ 'Link.status'
+);
+foreach($fields as $field){
+ echo $this->Form->input($field, array('type' => 'text'));
+}
+
+echo $this->Form->input('Frame.frame_id', array(
+ 'type' => 'hidden',
+ 'value' => (int)$frameId,
+ )
+);
+
+
+echo $this->Form->end();
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..46c562c
--- /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/users": "dev-master"
+ },
+ "license": "LicenseRef-NetCommons",
+ "license-ref-net-commons": "https://raw.githubusercontent.com/NetCommons3/NetCommons3/master/license.txt",
+ "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/webroot/js/links.js b/webroot/js/links.js
new file mode 100644
index 0000000..1ffe777
--- /dev/null
+++ b/webroot/js/links.js
@@ -0,0 +1,1096 @@
+/*
+ * 発生箇所 : プレビューを閉じる。
+ * 編集 閉じる 編集 --- で発生。
+ *
+ * */
+function Links_boolean2intInArray(arrayVar){
+ for(var key in arrayVar){
+ if(arrayVar[key] instanceof Array || arrayVar[key] instanceof Object){
+ arguments.callee(arrayVar[key]);
+ }else if(arrayVar[key] === true){
+ arrayVar[key] = 1;
+ }else if(arrayVar[key] === false){
+ arrayVar[key] = 0;
+ }
+ }
+ return arrayVar;
+
+}
+//NetCommonsApp.filter('Links_statusView', function() {
+//
+// return function(status) {
+// status = Number(status);
+// switch(status){
+// case 1: // 公開
+// return '';
+// break;
+// case 2: // 申請
+// return '申請中';
+// break;
+// case 3: // 下書き
+// return '下書き';
+// break;
+// case 4: // 差し戻し
+// return '差し戻し';
+// break;
+// }
+// }
+//});
+//NetCommonsApp.config(['$resourceProvider', function($resourceProvider) {
+// // Don't strip trailing slashes from calculated URLs
+//// $resourceProvider.defaults.stripTrailingSlashes = false;
+//}]);
+
+NetCommonsApp.factory('Links_getSiteInfo', ['$http', '$q', function ($http, $q){
+ var getSiteInfo = function (url, successCallBack, errorCallBack){
+ $.ajax({
+ type: "GET",
+ url: url,
+ dataType: "html",
+ error:function(XMLHttpRequest, textStatus, errorThrown){
+ console.log(XMLHttpRequest);
+ console.log(textStatus);
+ console.log(errorThrown);
+
+ // 通常はここでtextStatusやerrorThrownの値を見て処理を切り分けるか、
+ // 単純に通信に失敗した際の処理を記述します。
+// this; // thisは他のコールバック関数同様にAJAX通信時のオプションを示します。
+ },
+ success:function(data, dataType){
+ console.log(data);
+ console.log(dataType);
+ // dataの値を用いて、通信成功時の処理を記述します。
+// this; // thisはAJAX送信時に設定したオプションです
+ }
+
+ });
+
+// $http({
+// url: url,
+// method: 'get',
+// withCredentials: true
+// })
+// .success(function(data){
+// var siteHtml = $('').html(data);
+// var title = $(siteHtml).find('title').innerText();
+// var description = $(siteHtml).find('meta[name=description]').innerText();
+// console.log(title);
+// console.log(description);
+// successCallBack(title, description);
+//
+// }).error(function(data, status){
+// errorCallBack(data, status);
+//
+// })
+ }
+ return getSiteInfo;
+
+}]);
+
+NetCommonsApp.factory('Links_ajaxPostService', ['$http', '$q', function ($http, $q) {
+ // ここのスコープは1度しか実行されない
+// var success = function (){
+//
+// };
+// var error = function (){
+//
+// }
+ var send = function (postData, formUrl, postUrl) {
+ var deferred = $q.defer();
+ var promise = deferred.promise;
+
+
+ // jsonで返さないんだから、.jsonつけなきゃいい?
+ $http.get(formUrl +
+// '/' + Math.random() + '.json')
+ '/' + Math.random())//今はjson形式でないので.jsonつけるのやめた
+ .success(function (data) {
+ //フォームエレメント生成
+ var form = $('').html(data);
+
+ console.log(postData);
+ console.log(form);
+ postData._Token = {
+ };
+ //セキュリティキーセット
+ postData._Token.key =
+ $(form).find('input[name="data[_Token][key]"]').val();
+ postData._Token.fields =
+ $(form).find('input[name="data[_Token][fields]"]').val();
+ postData._Token.unlocked =
+ $(form).find('input[name="data[_Token][unlocked]"]').val();
+
+ var postParams = {
+ _method: 'POST',
+ data: postData
+ };
+
+ // POST
+ postParams = angular.fromJson(angular.toJson(postParams)); // hashに$$hashKeyがつくのでこれで除去してる
+ // booleanをそのままPOSTすると文字列の'true', 'false'になっちゃうので、0,1に変換
+ postParams = Links_boolean2intInArray(postParams);
+ console.log(postParams);
+ $http.post(postUrl +
+ '/' + Math.random() + '.json',
+ $.param(postParams),
+ {headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
+ .success(function (data) {
+ // success condition
+ deferred.resolve(data);
+//
+// $scope.flash.success(data.name);
+// $modalInstance.close(); //
+ })
+ .error(function (data, status) {
+ // error condition
+ deferred.reject(data, status);
+// $scope.flash.danger(status + ' ' + data.name);
+// $scope.sending = false;
+ });
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ // error condition
+ deferred.reject(data, status);
+// $scope.flash.danger(status + ' ' + data.name);
+// $scope.sending = false;
+ });
+ promise.success = function (fn) {
+ promise.then(fn);
+ return promise;
+ }
+
+ promise.error = function (fn) {
+ promise.then(null, fn);
+ return promise;
+ }
+
+ return promise;
+
+ }
+ // ここで return したオブジェクトがサービスになる
+ return {
+ send: send
+ }
+
+}]);
+NetCommonsApp.factory('Links_RolePermissionRepository', ['$http','$q','Links_ajaxPostService', function ($http, $q, Links_ajaxPostService) {
+ var form_url = '/links/link_authority/form/';
+ var put_url = '/links/link_authority/edit/';
+ var get_url = '/links/link_authority/get/';
+
+
+ return{
+ get: function (frameId, callback) {
+ $http.get(get_url + frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ callback(data);
+ // 3.データ取得できたら、元のObjectに内容を追加
+ }).error(function (data, status) {
+ });
+ },
+ put: function(frameId, rolePermissions){
+ var deferred = $q.defer();
+ var promise = deferred.promise;
+ var postData ;
+ postData = rolePermissions;
+ postData.Frame = {
+ frame_id: frameId
+ }
+ console.log(postData);
+ Links_ajaxPostService.send(
+ postData,
+ form_url + frameId,
+ put_url + frameId
+ )
+ .success(function (data) {
+ console.log(data);
+ deferred.resolve(data);
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ deferred.reject(data, status);
+ });
+ promise.success = function (fn) {
+ promise.then(fn);
+ return promise;
+ }
+
+ promise.error = function (fn) {
+ promise.then(null, fn);
+ return promise;
+ }
+ return promise;
+ }
+ }
+
+}])
+NetCommonsApp.factory('Links_FrameSettingRepository', ['$http','$q','Links_ajaxPostService', function ($http, $q, Links_ajaxPostService) {
+ var form_url = '/links/link_frame_setting/form/';
+ var put_url = '/links/link_frame_setting/edit/';
+ var get_url = '/links/link_frame_setting/get/';
+
+
+ return{
+ get: function (frameId, callback) {
+ $http.get(get_url + frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ callback(data);
+ // 3.データ取得できたら、元のObjectに内容を追加
+ }).error(function (data, status) {
+ });
+ },
+ // これだとget2をコールしたときの戻り値は空配列で、データ取得完了時に空配列から実データ入りになる。戻り値を操作したいときは向かない
+ get2: function (frameId) {
+ var resultPointer = []
+ $http.get('/links/link_frame_setting/get/' + frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ // 3.データ取得できたら、元のObjectに内容を追加
+ angular.extend(resultPointer, data);
+ }).error(function (data, status) {
+ });
+ return resultPointer;
+ },
+ put: function(frameId, linkFrameSetting){
+ var deferred = $q.defer();
+ var promise = deferred.promise;
+ var postData = {
+ 'Frame':{
+ frame_id: frameId
+ },
+ LinkFrameSetting:{
+ id: linkFrameSetting.id,
+ frame_key: linkFrameSetting.frame_key,
+ display_type: linkFrameSetting.display_type,
+ open_new_tab: linkFrameSetting.open_new_tab,
+ display_click_number:linkFrameSetting.display_click_number,
+ category_separator_line:linkFrameSetting.category_separator_line,
+ list_style:linkFrameSetting.list_style
+ }
+ }
+ Links_ajaxPostService.send(
+ postData,
+ form_url + frameId,
+ put_url + frameId
+ )
+ .success(function (data) {
+ console.log(data);
+ deferred.resolve(data);
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ deferred.reject(data, status);
+ });
+ promise.success = function (fn) {
+ promise.then(fn);
+ return promise;
+ }
+
+ promise.error = function (fn) {
+ promise.then(null, fn);
+ return promise;
+ }
+
+
+ return promise;
+
+ }
+
+ }
+
+}])
+//NetCommonsApp.factory('Links_LinkCategoryRepository', ['$http', function($http){
+// var list = function(frameId){
+//
+// resultPointer = [];
+// // カテゴリをjsonで返す
+// $http.get('/links/link_category/get_categories/' + frameId + '/'+ Math.random() + '.json')
+// .success(function(data){
+// // 3.データ取得できたら、元のObjectに内容を追加
+// angular.extend(resultPointer, data.resultPointer);
+// $scope.$digest();
+// return data.linkCategories;
+// }).error(function(data,status){
+// });
+// return resultPointer;
+// }
+//
+// var loadCategories = function (frameId, loadTarget){
+// $http.get('/links/link_category/get_categories/' + frameId + '/'+ Math.random() + '.json')
+// .success(function(data){
+// // 3.データ取得できたら、元のObjectに内容を追加
+// loadTarget = data.linkCategories;
+// console.log(loadTarget);
+// }).error(function(data,status){
+// });
+// }
+// return {
+// list: list,
+// loadCategories: loadCategories
+// }
+//}]);
+
+
+
+NetCommonsApp.controller('Links',
+ function ($scope, $http, $sce, $timeout, dialogs, $modal) {
+
+
+ $scope.LINK_ADD_URL = '/links/links/linkAdd/';
+ $scope.PLUGIN_MANAGE_URL = '/links/links/manage/';
+
+ $scope.frameId = 0;
+
+ $scope.visibleHeaderBtn = true;
+ $scope.visibleContainer = true;
+ $scope.visibleManage = false;
+ $scope.visibleAddLink = true;
+
+ $scope.visibleContentList = false;
+ $scope.visibleContentDropdown = true;
+
+ $scope.visibleAddLinkForm = false;
+ $scope.Form = {
+ 'link_url': '',
+ 'title': '',
+ 'description': ''
+ };
+
+ $scope.initialize = function (frameId, visibleContentList, visibleContentDropdown) {
+ $scope.frameId = frameId;
+ $scope.visibleContentList = visibleContentList;
+ $scope.visibleContentDropdown = visibleContentDropdown;
+
+
+ };
+
+ $scope.showContainer = function () {
+ $scope.visibleHeaderBtn = true;
+ $scope.visibleContainer = true;
+ $scope.visibleManage = false;
+ $scope.visibleAddLink = true;
+ };
+
+ $scope.postDisplayStyle = function () {
+ if ($scope.visibleContentList === true) {
+ $scope.visibleContentList = false;
+ $scope.visibleContentDropdown = true;
+ } else {
+ $scope.visibleContentList = true;
+ $scope.visibleContentDropdown = false;
+ }
+ $scope.showContainer();
+ };
+
+ $scope.showAddLink = function () {
+ $scope.Form.link_url = '';
+ $scope.Form.title = '';
+ $scope.Form.description = '';
+
+ //リンク追加ダイアログ取得のURL
+ var url = $scope.LINK_ADD_URL + $scope.frameId;
+ //ダイアログで使用するJSコントローラ
+ var controller = 'Links.linkAdd';
+
+ $modal.open({
+ templateUrl: url,
+ controller: controller,
+ backdrop: 'static',
+ scope: $scope
+ });
+ };
+
+ $scope.showManage = function () {
+ $scope.visibleAddLinkForm = false;
+
+ //管理モーダル取得のURL
+ var url = $scope.PLUGIN_MANAGE_URL + $scope.frameId;
+ //ダイアログで使用するJSコントローラ
+ var controller = 'Links.manage';
+
+ modal = $modal.open({
+ templateUrl: url,
+ controller: controller,
+ backdrop: 'static',
+ scope: $scope
+ });
+ modal.result.then(
+ function (result) {
+ // 表示方法変更設定時
+ $scope.postDisplayStyle();
+ },
+ function (reason) {
+ }
+ );
+ }
+
+ // リンク追加・編集時のカテゴリ選択ドロップダウン用モデルにカテゴリ一覧をロードする
+ $scope.loadCategories = function () {
+ $http.get('/links/link_category/get_categories/' + $scope.frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ $scope.linkCategories = data.linkCategories;
+ }).error(function (data, status) {
+ $scope.flash.danger(status + ' ' + data.name);
+ });
+
+ }
+ // リンク追加・編集時のカテゴリ選択ドロップダウン用モデル
+ $scope.linkCategories = [''];
+
+ });
+
+NetCommonsApp.controller('Links.linkAdd',
+ function ($scope, $http, $sce, $modalInstance, $timeout, dialogs, Links_ajaxPostService, Links_getSiteInfo) {
+
+ // カテゴリ一覧
+ $scope.newLink = { // postされるデータ
+ Link: {
+ link_category_id: 0,
+ status: 0, // MyTodo Statusサービスがいるかな
+ url: '',
+ title: '',
+ description: ''
+ },
+ Frame: {
+ frame_id: $scope.frameId
+ }
+ }
+
+ $scope.loadCategories();
+// console.log($scope.linkCategories);
+ // カテゴリ一覧取得
+// $http.get('/links/link_category/get_categories/'+$scope.frameId +'/'+ Math.random() + '.json')
+// .success(function(data){
+// $scope.linkCategories = data.linkCategories;
+// }).error(function(data,status){
+// $scope.flash.danger(status + ' ' + data.name);
+// });
+
+ $scope.getSiteInfo = function () {
+
+ var url = $scope.newLink.Link.url;
+ console.log(url);
+ Links_getSiteInfo(url,
+ function(title, description){
+ $scope.newLink.Link.title = title;
+ $scope.newLink.Link.description = description;
+ },
+ function(data, status){
+ $scope.flash.danger('サイト情報の取得に失敗しました')
+ }
+ );
+ }
+
+ $scope.cancel = function () {
+ $modalInstance.dismiss('cancel');
+ };
+
+
+ $scope.send = function (status) {
+ $scope.newLink.Link.status = status; // MyTodo 権限によって指定できないステータスがあるが、どうガードする?ここでは放置しておいてPHP側かな
+
+ Links_ajaxPostService.send(
+ $scope.newLink,
+ '/links/links/add_form/' + $scope.frameId,
+ '/links/links/add/' + $scope.frameId
+ )
+ .success(function (data) {
+ console.log(data);
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+
+ }
+
+ });
+
+// 管理画面 権限設定タブ
+NetCommonsApp.controller('Links.manage.permission',
+ function ($scope, $http, $sce, $timeout, dialogs, Links_RolePermissionRepository) {
+ $scope.rolePermissions =
+ {
+ add_link:{
+ chief_editor:{
+ name:"編集長",
+ permission: true
+ },
+ editor: {
+ name:"編集者",
+ permission: true
+ },
+ general_user:{
+ name:"一般",
+ permission: false
+ },
+ visitor:{
+ name:"参観者",
+ permission: false
+ }
+ }
+ };
+
+ $scope.send = function () {
+
+ Links_RolePermissionRepository.put(
+ $scope.frameId,
+ $scope.rolePermissions
+ )
+ .success(function (data) {
+ console.log(data);
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+
+ };
+
+
+ Links_RolePermissionRepository.get($scope.frameId, function(data){
+ $scope.rolePermissions = data;
+ });
+
+ }
+);
+
+// 管理画面リンク編集タブ
+NetCommonsApp.controller('Links.manage.links',
+ function ($scope, $http, $sce, $timeout, dialogs, Links_ajaxPostService) {
+ $scope.linkCategories = [];
+
+ $scope.init = function () {
+ // リンクリストを取得して$scope.linkCategoriesにセットする
+ $http.get('/links/links/all/' +
+ $scope.frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ $scope.linkCategories = data;
+ })
+ .error(function (data, status) {
+ //取得に失敗 MyTodoエラーメッセージ
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+
+ }
+ $scope.showEditLink = function (link) {
+ $scope.visibleAddLinkForm = true;
+ $scope.newLink = link;
+ $scope.loadCategories();
+
+// $scope.Form.link_url = link_url;
+// $scope.Form.title = title;
+// $scope.Form.description = description;
+ };
+
+
+ $scope.deleteButton = function (linkId) {
+ dlg = dialogs.confirm('Confirmation', 'リンクを削除してもよろしいですか?');
+ dlg.result.then(
+ function (btn) {
+ // Yes
+ $scope.sendDelete(linkId);
+ },
+ function (btn) {
+ } // NO
+ );
+ };
+
+ $scope.sendDelete = function (linkId) {
+ var sendData = {
+ Link: {
+ id: linkId
+ },
+ Frame: {
+ frame_id: $scope.frameId
+ }
+ };
+ Links_ajaxPostService.send(
+ sendData,
+ '/links/links/delete_form/' + $scope.frameId + '/' + linkId,
+ '/links/links/delete/' + $scope.frameId
+ )
+ .success(function (data) {
+ console.log(data);
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+
+ }
+
+
+// $scope.send = function () {
+// Links_ajaxPostService.send(
+// $scope.linkCategories,
+// '/links/links/update_weight_form/' + $scope.frameId + '/' + Math.random(),
+// '/links/links/update_weight/' + $scope.frameId + '/' + Math.random() + '.json'
+// )
+// .success(function (data) {
+// console.log(data);
+// $scope.flash.success(data.name);
+// $modalInstance.close();
+// })
+// .error(function (data, status) {
+// //keyの取得に失敗
+// console.log(data);
+// $scope.flash.danger(status + ' ' + data.name);
+// $scope.sending = false;
+// });
+//
+// }
+
+ var move = function (categoryIndex, origin, destination) {
+ console.log($scope.linkCategories[categoryIndex]);
+ var temp = $scope.linkCategories[categoryIndex].links[destination];
+ $scope.linkCategories[categoryIndex].links[destination] = $scope.linkCategories[categoryIndex].links[origin];
+ $scope.linkCategories[categoryIndex].links[origin] = temp;
+ // weight入れ換え
+ var tempWeight = $scope.linkCategories[categoryIndex].links[destination].LinkOrder.weight;
+ $scope.linkCategories[categoryIndex].links[destination].LinkOrder.weight = $scope.linkCategories[categoryIndex].links[origin].LinkOrder.weight;
+ $scope.linkCategories[categoryIndex].links[origin].LinkOrder.weight = tempWeight;
+ };
+
+
+ $scope.moveUp = function (categoryIndex, linkIndex) {
+ move(categoryIndex, linkIndex, linkIndex - 1);
+ };
+
+ $scope.moveDown = function (categoryIndex, linkIndex) {
+ move(categoryIndex, linkIndex, linkIndex + 1);
+ };
+
+
+// $scope.closeTest = function(){
+// modal.close(); //これは効く
+// }
+ }
+)
+
+NetCommonsApp.controller('Links.manage.links.edit',
+ function ($scope, $http, $sce, $timeout, dialogs, Links_ajaxPostService) {
+ // リンク編集フォームより
+ $scope.send = function (status) {
+ console.log($scope.newLink);
+ $scope.newLink.Link.status = status; // MyTodo 権限によって指定できないステータスがあるが、どうガードする?ここでは放置しておいてPHP側かな
+
+ // 余計なフィールドデータをPOSTするとセキュリティコンポーネントにBlackHole送りにされるので必用なフィールドだけ抜き出す。
+ var data = {
+ Link: {
+ id: $scope.newLink.Link.id,
+ url: $scope.newLink.Link.url,
+ link_category_id: $scope.newLink.Link.link_category_id,
+ title: $scope.newLink.Link.title,
+ description: $scope.newLink.Link.description,
+ status: $scope.newLink.Link.status
+ },
+ Frame: {
+ frame_id: $scope.frameId
+ }
+ }
+
+ Links_ajaxPostService.send(
+ data,
+ '/links/links/edit_form/' + $scope.frameId + '/' + $scope.newLink.Link.id,
+ '/links/links/edit/' + $scope.frameId + '/' + $scope.newLink.Link.id
+ )
+ .success(function (data) {
+ console.log(data);
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ console.log(data);
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+
+ }
+ });
+NetCommonsApp.controller('Links.manage.frame_setting',
+ function ($scope, $http, $sce, $timeout, dialogs, Links_ajaxPostService, Links_FrameSettingRepository) {
+ // DB上display_type 3だったらform ではdisplay_type2(リスト表示)+display_description true(説明表示あり)
+ $scope.FrameSetting = {
+ id: 0,
+// frame_key : '',
+ display_type: 0,
+ display_description: false,
+ open_new_tab: false,
+ display_click_number: 0,
+ category_separator_line: '',
+ list_style: ''
+ };
+
+ $scope.init = function () {
+ // 設定をロード
+ Links_FrameSettingRepository.get($scope.frameId, function(data){
+ $scope.FrameSetting = data;
+ // MyTodo これってModelのメソッドに切り出すべきか
+ if(data.display_type < 2){ // MyTodo MagicNumber
+ $scope.FrameSetting.display_description = false
+ }else{
+ $scope.FrameSetting.display_description = true
+ }
+ });
+ }
+
+ $scope.postDisplayStyle = function () {
+ // MyTodo display_typeのセット
+ putData = $scope.FrameSetting;
+ console.log(putData);
+ if($scope.FrameSetting.display_description){
+ putData.display_type = 2; //MyTodo fxi MagicNumber
+ }
+ Links_FrameSettingRepository.put($scope.frameId, putData)
+ .success(function(data){
+ $scope.flash.success(data.name);
+ $scope.modalInstance.close();
+ })
+ .error(function(data,status){
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ })
+ };
+
+// // リンク編集フォームより
+// $scope.send = function (status) {
+// console.log($scope.newLink);
+// $scope.newLink.Link.status = status; // MyTodo 権限によって指定できないステータスがあるが、どうガードする?ここでは放置しておいてPHP側かな
+//
+// // 余計なフィールドデータをPOSTするとセキュリティコンポーネントにBlackHole送りにされるので必用なフィールドだけ抜き出す。
+// var data = {
+// Link:{
+// id: $scope.newLink.Link.id,
+// url:$scope.newLink.Link.url,
+// link_category_id:$scope.newLink.Link.link_category_id,
+// title:$scope.newLink.Link.title,
+// description:$scope.newLink.Link.description,
+// status: $scope.newLink.Link.status
+// },
+// Frame: {
+// frame_id: $scope.frameId
+// }
+// }
+//
+// Links_ajaxPostService.send(
+// data,
+// '/links/links/edit_form/' + $scope.frameId + '/' + $scope.newLink.Link.id,
+// '/links/links/edit/' + $scope.frameId + '/' + $scope.newLink.Link.id
+// )
+// .success(function (data) {
+// console.log(data);
+// $scope.flash.success(data.name);
+// $modalInstance.close();
+// })
+// .error(function (data, status) {
+// //keyの取得に失敗
+// console.log(data);
+// $scope.flash.danger(status + ' ' + data.name);
+// $scope.sending = false;
+// });
+//
+// }
+ });
+
+NetCommonsApp.controller('Links.manage',
+ function ($scope, $http, $sce, $modalInstance, $timeout, dialogs, Links_ajaxPostService) {
+
+ $scope.modalInstance = $modalInstance;
+
+ /**
+ * edit _method
+ *
+ * @type {Object.
}
+ */
+ $scope.edit = {
+ _method: 'POST'
+ };
+
+ /**
+ * edit data
+ *
+ * @type {Object.}
+ */
+ $scope.edit.data = {
+ LinkCategory: {
+// name: $scope.link.LinkCategory.name,
+ name: ''
+// content: $scope.announcement.Announcement.content,
+// status: $scope.announcement.Announcement.status,
+// block_id: $scope.announcement.Announcement.block_id,
+// key: $scope.announcement.Announcement.key,
+// id: $scope.announcement.Announcement.id
+ },
+ Frame: {
+ frame_id: $scope.frameId
+ },
+ _Token: {
+ key: '',
+ fields: '',
+ unlocked: ''
+ }
+ };
+
+ $scope.editCategories = {
+ _method: 'POST'
+ };
+
+ $scope.editCategories.data = {
+ LinkCategories: [],
+// LinkCategory:[],
+// LinkCategoryOrder:[],
+ Frame: {
+ frame_id: $scope.frameId
+ },
+ _Token: {
+ key: '',
+ fields: '',
+ unlocked: ''
+ }
+ };
+
+
+ $scope.initialize = function (frameId, linkCategories) {
+ $scope.frameId = frameId;
+ angular.forEach(linkCategories, function (oneRecord) {
+ $scope.editCategories.data.LinkCategories.push(
+ {
+ LinkCategory: {
+ id: oneRecord.LinkCategory.id,
+ name: oneRecord.LinkCategory.name
+ },
+ LinkCategoryOrder: {
+ id: oneRecord.LinkCategoryOrder.id,
+ weight: oneRecord.LinkCategoryOrder.weight
+
+ }
+ }
+ )
+// $scope.editCategories.data.LinkCategories.push(oneRecord)
+// $scope.editCategories.data.LinkCategory.push(
+// {
+// id: oneRecord.LinkCategory.id,
+// name: oneRecord.LinkCategory.name
+// }
+// );
+// $scope.editCategories.data.LinkCategoryOrder.push(
+// {
+// id:oneRecord.LinkCategoryOrder.id,
+// weight:oneRecord.LinkCategoryOrder.weight
+// }
+// );
+ });
+// $scope.editCategories.data.LinkCategories = linkCategories;
+ console.log($scope.editCategories.data.LinkCategories);
+ };
+
+
+ $scope.cancel = function () {
+ $modalInstance.dismiss('cancel');
+ };
+
+
+ $scope.closeEditLink = function () {
+ $scope.visibleAddLinkForm = false;
+ $scope.Form.link_url = '';
+ $scope.Form.title = '';
+ $scope.Form.description = '';
+ };
+
+
+ $scope.deleteEditCategory = function (index) {
+
+ dlg = dialogs.confirm('Confirmation', 'カテゴリーを削除してもよろしいですか?');
+ dlg.result.then(
+ function (btn) {
+ var postData = {
+ LinkCategory: {
+ id: $scope.editCategories.data.LinkCategories[index].LinkCategory.id
+ },
+ Frame: {
+ frame_id: $scope.frameId
+ }
+ };
+ var formUrl = '/links/link_category/delete_form/' + $scope.frameId;
+ var postUrl = '/links/link_category/delete/' + $scope.frameId;
+ var callback = function () {
+ };
+ Links_ajaxPostService.send(postData, formUrl, postUrl)
+ .success(function (data) {
+ $scope.flash.success(data.name);
+ $modalInstance.close();
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+ //削除フォーム取得
+ // セキュリティキーセット
+ // ポスト
+ }, // Yes
+ function (btn) {
+ } // NO
+ );
+ };
+
+
+ /**
+ * dialog save
+ *
+ * @return {void}
+ */
+ $scope.addCategory = function () {
+ $scope.sending = true;
+
+ $http.get('/links/link_category/form/' +
+ $scope.frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ //フォームエレメント生成
+ var form = $('').html(data);
+
+ //セキュリティキーセット
+ $scope.edit.data._Token.key =
+ $(form).find('input[name="data[_Token][key]"]').val();
+ $scope.edit.data._Token.fields =
+ $(form).find('input[name="data[_Token][fields]"]').val();
+ $scope.edit.data._Token.unlocked =
+ $(form).find('input[name="data[_Token][unlocked]"]').val();
+ //ステータスセット
+// $scope.edit.data.Announcement.status = status;
+ //登録情報をPOST
+ $scope.sendCategoryPost($scope.edit);
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+ };
+
+ /**
+ * send post
+ *
+ * @param {Object.
} postParams
+ * @return {void}
+ */
+ $scope.sendCategoryPost = function (postParams) {
+ //$http.post($scope.PLUGIN_EDIT_URL + Math.random() + '.json',
+ $http.post('/links/link_category/add/' +
+ $scope.frameId + '/' + Math.random() + '.json',
+ //$.param(postParams))
+ //{data: postParams})
+ //postParams)
+ $.param(postParams),
+ {headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
+ .success(function (data) {
+ $scope.flash.success(data.name);
+ // MyTodo カテゴリ追加し終わったらカテゴリ一覧をリロードしたいよなぁ
+// $modalInstance.close(data.announcement);
+ })
+ .error(function (data, status) {
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+ };
+ /**
+ * dialog save
+ *
+ * @return {void}
+ */
+ $scope.updateCategories = function () {
+ $scope.sending = true;
+
+ $http.get('/links/link_category/categories_form/' +
+ $scope.frameId + '/' + Math.random() + '.json')
+ .success(function (data) {
+ //フォームエレメント生成
+ var form = $('').html(data);
+
+ //セキュリティキーセット
+ $scope.editCategories.data._Token.key =
+ $(form).find('input[name="data[_Token][key]"]').val();
+ $scope.editCategories.data._Token.fields =
+ $(form).find('input[name="data[_Token][fields]"]').val();
+ $scope.editCategories.data._Token.unlocked =
+ $(form).find('input[name="data[_Token][unlocked]"]').val();
+
+ //ステータスセット
+// $scope.edit.data.Announcement.status = status;
+ //登録情報をPOST
+ $scope.sendCategoriesPost($scope.editCategories);
+ })
+ .error(function (data, status) {
+ //keyの取得に失敗
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+ };
+
+ /**
+ * send post
+ *
+ * @param {Object.} postParams
+ * @return {void}
+ */
+ $scope.sendCategoriesPost = function (postParams) {
+ //$http.post($scope.PLUGIN_EDIT_URL + Math.random() + '.json',
+ postParams = angular.fromJson(angular.toJson(postParams)); // hashに$$hashKeyがつくのでこれで除去してる
+ console.log(postParams);
+ $http.post('/links/link_category/update_all/' +
+ $scope.frameId + '/' + Math.random() + '.json',
+ //$.param(postParams))
+ //{data: postParams})
+ //postParams)
+ $.param(postParams),
+ {headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
+ .success(function (data) {
+ $scope.flash.success(data.name);
+ $modalInstance.close(); //
+ })
+ .error(function (data, status) {
+ $scope.flash.danger(status + ' ' + data.name);
+ $scope.sending = false;
+ });
+ };
+
+ var move = function (origin, destination) {
+ var temp = $scope.editCategories.data.LinkCategories[destination];
+ $scope.editCategories.data.LinkCategories[destination] = $scope.editCategories.data.LinkCategories[origin];
+ $scope.editCategories.data.LinkCategories[origin] = temp;
+ // weight入れ換え
+ var tempWeight = $scope.editCategories.data.LinkCategories[destination].LinkCategoryOrder.weight;
+ $scope.editCategories.data.LinkCategories[destination].LinkCategoryOrder.weight = $scope.editCategories.data.LinkCategories[origin].LinkCategoryOrder.weight;
+ $scope.editCategories.data.LinkCategories[origin].LinkCategoryOrder.weight = tempWeight;
+
+ };
+
+ $scope.moveUp = function (index) {
+ move(index, index - 1);
+ };
+
+ $scope.moveDown = function (index) {
+ move(index, index + 1);
+ };
+
+ }
+
+);
+