Skip to content

Commit

Permalink
Merge pull request #3 from s-nakajima/master
Browse files Browse the repository at this point in the history
Rename BlocksController
  • Loading branch information
s-nakajima committed May 31, 2015
2 parents 6fefafb + b09af03 commit b04cd1e
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 81 deletions.
4 changes: 3 additions & 1 deletion Config/Migration/1418196036_bbses.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class Bbses extends CakeMigration {
'namespace' => 'netcommons/bbses',
'name' => '掲示板',
'type' => 1,
'default_action' => 'bbs_articles/index',
'default_setting_action' => 'bbs_blocks/index',
),
),
'plugins_roles' => array(
Expand Down Expand Up @@ -193,4 +195,4 @@ public function updateRecords($model, $records, $scope = null) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @author Kotaro Hokada <kotaro.hokada@gmail.com>
* @package NetCommons\Bbses\Controller
*/
class BlockRolePermissionsController extends BbsesAppController {
class BbsBlockRolePermissionsController extends BbsesAppController {

/**
* layout
Expand Down Expand Up @@ -73,9 +73,6 @@ class BlockRolePermissionsController extends BbsesAppController {
public function beforeFilter() {
parent::beforeFilter();

$results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
$this->set($results);

//タブの設定
$this->initTabs('block_index', 'role_permissions');
}
Expand Down Expand Up @@ -116,7 +113,7 @@ public function edit() {
$this->BbsSetting->saveBbsSetting($data);
if ($this->handleValidationError($this->BbsSetting->validationErrors)) {
if (! $this->request->is('ajax')) {
$this->redirect('/bbses/blocks/index/' . $this->viewVars['frameId']);
$this->redirect('/bbses/bbs_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @author Kotaro Hokada <kotaro.hokada@gmail.com>
* @package NetCommons\Bbses\Controller
*/
class BlocksController extends BbsesAppController {
class BbsBlocksController extends BbsesAppController {

/**
* layout
Expand Down Expand Up @@ -70,9 +70,6 @@ public function beforeFilter() {
parent::beforeFilter();
$this->Auth->deny('index');

$results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
$this->set($results);

//タブの設定
$this->initTabs('block_index', 'block_settings');
}
Expand All @@ -81,7 +78,6 @@ public function beforeFilter() {
* index
*
* @return void
* @throws Exception
*/
public function index() {
$this->Paginator->settings = array(
Expand All @@ -95,19 +91,9 @@ public function index() {
)
);

try {
$bbses = $this->Paginator->paginate('Bbs');
} catch (Exception $ex) {
if (isset($this->request['paging']) && $this->params['named']) {
$this->redirect('/bbses/blocks/index/' . $this->viewVars['frameId']);
return;
}
CakeLog::error($ex);
throw $ex;
}

$bbses = $this->Paginator->paginate('Bbs');
if (! $bbses) {
$this->view = 'Blocks/not_found';
$this->view = 'not_found';
return;
}

Expand All @@ -124,7 +110,7 @@ public function index() {
* @return void
*/
public function add() {
$this->view = 'Blocks/edit';
$this->view = 'edit';

$this->set('blockId', null);
$bbs = $this->Bbs->create(
Expand Down Expand Up @@ -158,7 +144,7 @@ public function add() {
$this->Bbs->saveBbs($data);
if ($this->handleValidationError($this->Bbs->validationErrors)) {
if (! $this->request->is('ajax')) {
$this->redirect('/bbses/blocks/index/' . $this->viewVars['frameId']);
$this->redirect('/bbses/bbs_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
Expand Down Expand Up @@ -192,7 +178,7 @@ public function edit() {
$this->Bbs->saveBbs($data);
if ($this->handleValidationError($this->Bbs->validationErrors)) {
if (! $this->request->is('ajax')) {
$this->redirect('/bbses/blocks/index/' . $this->viewVars['frameId']);
$this->redirect('/bbses/bbs_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
Expand All @@ -219,7 +205,7 @@ public function delete() {
if ($this->request->isDelete()) {
if ($this->Bbs->deleteBbs($this->data)) {
if (! $this->request->is('ajax')) {
$this->redirect('/bbses/blocks/index/' . $this->viewVars['frameId']);
$this->redirect('/bbses/bbs_blocks/index/' . $this->viewVars['frameId']);
}
return;
}
Expand Down
5 changes: 1 addition & 4 deletions Controller/BbsFrameSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BbsFrameSettingsController extends BbsesAppController {
*
* @var array
*/
public $layout = 'NetCommons.setting';
public $layout = 'Frames.setting';

/**
* use models
Expand Down Expand Up @@ -57,9 +57,6 @@ class BbsFrameSettingsController extends BbsesAppController {
public function beforeFilter() {
parent::beforeFilter();

$results = $this->camelizeKeyRecursive($this->NetCommonsFrame->data);
$this->set($results);

//タブの設定
$this->initTabs('frame_settings', '');
}
Expand Down
18 changes: 4 additions & 14 deletions Controller/BbsesAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class BbsesAppController extends AppController {
*/
public $components = array(
'NetCommons.NetCommonsFrame',
'Pages.PageLayout',
'Security'
);

Expand All @@ -48,17 +49,6 @@ class BbsesAppController extends AppController {
'NetCommons.Date',
);

/**
* beforeFilter
*
* @return void
*/
public function beforeFilter() {
parent::beforeFilter();
$results = $this->camelizeKeyRecursive(['current' => $this->current]);
$this->set($results);
}

/**
* initBbs
*
Expand Down Expand Up @@ -115,7 +105,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'block_index' => array(
'url' => array(
'plugin' => $this->params['plugin'],
'controller' => 'blocks',
'controller' => 'bbs_blocks',
'action' => 'index',
$this->viewVars['frameId'],
)
Expand All @@ -138,7 +128,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'block_settings' => array(
'url' => array(
'plugin' => $this->params['plugin'],
'controller' => 'blocks',
'controller' => 'bbs_blocks',
'action' => $this->params['action'],
$this->viewVars['frameId'],
$blockId
Expand All @@ -147,7 +137,7 @@ public function initTabs($mainActiveTab, $blockActiveTab) {
'role_permissions' => array(
'url' => array(
'plugin' => $this->params['plugin'],
'controller' => 'block_role_permissions',
'controller' => 'bbs_block_role_permissions',
'action' => 'edit',
$this->viewVars['frameId'],
$blockId
Expand Down
18 changes: 0 additions & 18 deletions Controller/BbsesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,4 @@
*/
class BbsesController extends BbsesAppController {

/**
* index
*
* @return void
*/
public function index() {
if (! $this->viewVars['blockId']) {
$this->autoRender = false;
return;
}
$html = $this->requestAction(
array('controller' => 'bbs_articles', 'action' => 'index', $this->viewVars['frameId']),
//array('controller' => 'bbs_posts', 'action' => 'index', $this->viewVars['frameId']),
array('return')
);

$this->set('html', $html);
}
}
3 changes: 1 addition & 2 deletions Model/BbsArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public function beforeValidate($options = array()) {
'notEmpty' => array(
'rule' => array('notEmpty'),
'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('bbses', 'Title')),
'required'
=> true
'required' => true
),
),
'content' => array(
Expand Down
2 changes: 1 addition & 1 deletion Test/Case/Controller/BbsesAppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BbsesAppTest extends YAControllerTestCase {
'plugin.containers.container',
'plugin.containers.containers_page',
'plugin.m17n.language',
'plugin.m17n.languages_page',
'plugin.pages.languages_page',
'plugin.pages.page',
'plugin.rooms.room',
'plugin.rooms.roles_rooms_user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<?php echo $this->element('Blocks.setting_tabs', $blockSettingTabs); ?>

<?php echo $this->element('Blocks.edit_form', array(
'controller' => 'BlockRolePermission',
'controller' => 'BbsBlockRolePermissions',
'action' => 'edit' . '/' . $frameId . '/' . $blockId,
'callback' => 'Bbses.BlockRolePermissions/edit_form',
'cancelUrl' => '/bbses/blocks/index/' . $frameId,
'callback' => 'Bbses.BbsBlockRolePermissions/edit_form',
'cancelUrl' => '/bbses/bbs_blocks/index/' . $frameId,
'options' => array('ng-controller' => 'Bbses'),
)); ?>
</div>
Expand Down
10 changes: 5 additions & 5 deletions View/Blocks/edit.ctp → View/BbsBlocks/edit.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
<?php echo $this->element('Blocks.setting_tabs', $blockSettingTabs); ?>

<?php echo $this->element('Blocks.edit_form', array(
'controller' => 'Blocks',
'controller' => 'BbsBlocks',
'action' => h($this->request->params['action']) . '/' . $frameId . '/' . $blockId,
'callback' => 'Bbses.Blocks/edit_form',
'cancelUrl' => '/bbses/blocks/index/' . $frameId
'callback' => 'Bbses.BbsBlocks/edit_form',
'cancelUrl' => '/bbses/bbs_blocks/index/' . $frameId
)); ?>

<?php if ($this->request->params['action'] === 'edit') : ?>
<?php echo $this->element('Blocks.delete_form', array(
'controller' => 'Blocks',
'controller' => 'BbsBlocks',
'action' => 'delete/' . $frameId . '/' . $blockId,
'callback' => 'Bbses.Blocks/delete_form'
'callback' => 'Bbses.BbsBlocks/delete_form'
)); ?>
<?php endif; ?>
</div>
Expand Down
6 changes: 3 additions & 3 deletions View/Blocks/index.ctp → View/BbsBlocks/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div class="tab-content">
<div class="text-right">
<a class="btn btn-success" href="<?php echo $this->Html->url('/bbses/blocks/add/' . $frameId);?>">
<a class="btn btn-success" href="<?php echo $this->Html->url('/bbses/bbs_blocks/add/' . $frameId);?>">
<span class="glyphicon glyphicon-plus"> </span>
</a>
</div>
Expand Down Expand Up @@ -62,7 +62,7 @@
)); ?>
</td>
<td>
<a href="<?php echo $this->Html->url('/bbses/blocks/edit/' . $frameId . '/' . (int)$bbs['block']['id']); ?>">
<a href="<?php echo $this->Html->url('/bbses/bbs_blocks/edit/' . $frameId . '/' . (int)$bbs['block']['id']); ?>">
<?php echo h($bbs['bbs']['name']); ?>
</a>
</td>
Expand All @@ -81,7 +81,7 @@
<div class="text-center">
<?php echo $this->element('NetCommons.paginator', array(
'url' => Hash::merge(
array('controller' => 'blocks', 'action' => 'index', $frameId),
array('controller' => 'bbs_blocks', 'action' => 'index', $frameId),
$this->Paginator->params['named']
)
)); ?>
Expand Down
2 changes: 1 addition & 1 deletion View/Blocks/not_found.ctp → View/BbsBlocks/not_found.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div class="tab-content">
<div class="text-right">
<a class="btn btn-success" href="<?php echo $this->Html->url('/bbses/blocks/add/' . $frameId);?>">
<a class="btn btn-success" href="<?php echo $this->Html->url('/bbses/bbs_blocks/add/' . $frameId);?>">
<span class="glyphicon glyphicon-plus"> </span>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion View/BbsFrameSettings/edit.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)); ?>

<?php echo $this->element('Blocks.edit_form', array(
'controller' => 'Blocks',
'controller' => 'BbsBlocks',
'action' => 'edit' . '/' . $frameId,
'callback' => 'Bbses.BbsFrameSettings/edit_form',
'cancelUrl' => $this->Html->url(isset($current['page']) ? '/' . $current['page']['permalink'] : null)
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
"satooshi/php-coveralls": "dev-master",
"netcommons/auth": "dev-master",
"netcommons/auth-general": "dev-master",
"netcommons/boxes": "dev-master",
"netcommons/blocks": "dev-master",
"netcommons/boxes": "dev-master",
"netcommons/comments": "dev-master",
"netcommons/containers": "dev-master",
"netcommons/frames": "dev-master",
"netcommons/install": "dev-master",
"netcommons/likes": "dev-master",
"netcommons/m17n": "dev-master",
"netcommons/net-commons": "dev-master",
"netcommons/pages": "dev-master",
"netcommons/plugin-manager": "dev-master",
"netcommons/roles": "dev-master",
"netcommons/rooms": "dev-master",
"netcommons/pages": "dev-master",
"netcommons/users": "dev-master"
},
"license": "NetCommons License",
Expand Down

0 comments on commit b04cd1e

Please sign in to comment.