CREATE TABLE `character_sheets` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`system_id` INTEGER UNSIGNED NULL,
+ `user_id` INTEGER UNSIGNED NOT NULL,
`key_name` VARCHAR(40) NOT NULL,
`name` VARCHAR(64) NOT NULL,
`public_flag` ENUM('public', 'private') NOT NULL DEFAULT 'public',
`sort_order` INTEGER UNSIGNED NOT NULL,
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
PRIMARY KEY(`id`),
- INDEX `character_sheets_system`(`system_id`, `public_flag`, `sort_order`),
+ INDEX `character_sheets_system`(`system_id`, `public_flag`),
+ INDEX `character_sheets_user`(`user_id`, `public_flag`),
UNIQUE INDEX `character_sheets_key_name`(`key_name`),
CONSTRAINT `fk_systems-character_sheets`
- FOREIGN KEY (`system_id`) REFERENCES `systems` (`id`) ON DELETE CASCADE
+ FOREIGN KEY (`system_id`) REFERENCES `systems` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_users-character_sheets`
+ FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) TYPE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `profiles` (
`public_flag` ENUM('public', 'private') NOT NULL DEFAULT 'public',
`link_value` TEXT NOT NULL,
PRIMARY KEY(`id`),
- INDEX `characters_has_profiles_character`(`character_id`),
- INDEX `characters_has_profiles_character_public`(`character_id`, `public_flag`),
+ INDEX `characters_has_profiles_character` (`character_id`),
+ INDEX `characters_has_profiles_character_public` (`character_id`, `public_flag`),
CONSTRAINT `fk_profiles-characters_has_profiles`
FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_profile_selects-characters_has_profiles`
$contain = array(
'Attachment',
+ 'CharacterSheet' => array(
+ 'System',
+ ),
);
+
+ if ($id == $this->user_id || $isAdmin === true) {
+ unset($this->User->hasMany['CharacterSheet']['conditions']['CharacterSheet.public_flag']);
+ } else {
+ $this->User->hasMany['CharacterSheet']['conditions']['CharacterSheet.public_flag'] = 'public';
+ }
+
if ($isAdmin === true || $isDelete === true) {
$contain = array_merge($contain, array(
'Character',
if (empty($contain)) {
$recursive = -1;
} else {
- $recursive = Set::countDim($contain);
+ $recursive = Set::countDim($contain, true);
}
$user = $this->User->find('first', array(
return $user;
}
+ /* 指定Systemを取得 */
+ function _getThisSystem($id, $isAdmin = false)
+ {
+ static $this_system;
+ static $prev_id;
+ static $prev_isAdmin;
+
+ if (!empty($this_system)
+ && (!empty($prev_id) && $id == $prev_id)
+ && ($isAdmin == $prev_isAdmin)) {
+ return $this_system;
+ }
+
+ $prev_id = $id;
+ $prev_isAdmin = $isAdmin;
+ $system_conditions['System.id'] = $id;
+ if ($isAdmin === false) {
+ $system_conditions['System.public_flag'] = 'public';
+ }
+
+ $this_system = $this->{$this->modelClass}->System->find('first', array(
+ 'conditions' => $system_conditions,
+ 'recursive' => -1,
+ ));
+
+ if (!isset($this_system['System'])) {
+ $this->Session->setFlash(__('Invalid System.', true));
+ $this->redirect(array('action' => 'index'));
+ }
+
+ return $this_system;
+ }
+
/* デモモードチェック */
function _check_demo()
{
return $data;
}
+ function _checkCharaSheeOwner($characterSheet)
+ {
+ if (!isset($characterSheet['CharacterSheet']) || empty($characterSheet['CharacterSheet']) || !isset($characterSheet['CharacterSheet']['user_id']) || empty($characterSheet['CharacterSheet']['user_id'])) {
+ return false;
+ }
+
+ if ($characterSheet['CharacterSheet']['user_id'] == $this->user_id) {
+ return true;
+ }
+
+ return false;
+ }
+
}
/*
'recursive' => 1,
'contain' => array(
'System',
+ 'User',
),
'limit' => 20,
'order' => array(
parent::beforeFilter();
+ // Cache
+ $this->cacheAction = array(
+ );
+
// 認証なしアクセス可
}
/* アクションメソッド */
+ function index($system_id = null) {
+ // Check
+ $this->_checkCharaSheeAuth($system_id);
+
+ $this->_index($system_id, false);
+ }
+
function admin_index($system_id = null) {
+
+ $this->_index($system_id, true);
+ }
+
+ function _index($system_id = null, $isAdmin = false) {
+ // user_id指定
+ if (!$isAdmin) {
+ // character_sheets絞込み
+ $this->paginate['conditions']['CharacterSheet.user_id'] = $this->user_id;
+ }
+
// $system_id指定
if (!empty($system_id)) {
// System情報取得
- $this_system = $this->CharacterSheet->System->find('first', array(
- 'conditions' => array(
- 'System.id' => $system_id,
- ),
- 'recursive' => -1,
- ));
-
- if (!isset($this_system['System'])) {
- $this->Session->setFlash(__('Invalid System.', true));
- $this->redirect(array('controller' => 'character_sheets', 'action' => 'index'));
- }
+ $this_system = $this->__getThisSystem($system_id, $isAdmin);
$this->set('this_system', $this_system);
// character_sheets絞込み
$this->set('title_for_layout', " - ". __('List of All CharacterSheets', true));
}
+ function view($id = null) {
+ // Check
+ $this->_checkCharaSheeAuth();
+
+ $this->_view($id , false);
+ }
+
function admin_view($id = null) {
+
+ $this->_view($id , true);
+ }
+
+ function _view($id = null, $isAdmin = true) {
if (!$id) {
$this->Session->setFlash(__('Invalid CharacterSheet.', true));
$this->redirect(array('action'=>'index'));
}
+ $contain = array(
+ 'System' => array(
+ 'Character',
+ ),
+ );
+ if ($isAdmin) {
+ $contain[] = 'User';
+ }
+
$characterSheet = $this->CharacterSheet->find('first', array(
'conditions' => array('CharacterSheet.id' => $id),
'fields' => '',
'recursive' => 2,
- 'contain' => array(
- 'System' => array(
- 'Character',
- ),
- )
+ 'contain' => $contain,
));
+ $characterSheet = $this->__restore_html_system($characterSheet);
+
if (empty($characterSheet)) {
$this->Session->setFlash(__('Invalid CharacterSheet.', true));
$this->redirect(array('action'=>'index'));
}
+ // 一般ユーザの場合、自身のキャラシのみ
+ if (empty($isAdmin)) {
+ $this->__checkCharaSheeOwner($characterSheet);
+ }
+
$this->set('characterSheets', $characterSheet);
// キャラシビュー表示
$this->set('title_for_layout', " - ". __('CharacterSheets', true));
}
+ function add($system_id = null) {
+ // Check
+ $this->_checkCharaSheeAuth($system_id);
+
+ $this->_add($system_id, false);
+ }
+
+
function admin_add($system_id = null) {
+
+ $this->_add($system_id, true);
+ }
+
+ function _add($system_id = null, $isAdmin = false) {
$systems = $this->_get_systems(null);
$this->set(compact('systems'));
+ // System情報取得
$this_system = array();
if (!empty($system_id)) {
if (!empty($this->data)) {
$this->data['CharacterSheet']['system_id'] = $system_id;
}
- $this_system = $this->CharacterSheet->System->read(null, $system_id);
+ $this_system = $this->__getThisSystem($system_id, $isAdmin);
}
$this->set('this_system', $this_system);
if (!empty($this->data)) {
+ $this->data['CharacterSheet']['user_id'] = $this->user_id;
+
// Dir作れなかった場合のロールバック用
$dataSource = $this->CharacterSheet->getDataSource();
$dataSource->begin($this);
$this->set('title_for_layout', " - ". __('Add CharacterSheet', true));
}
+ function edit($id = null) {
+ // Check
+ $this->_checkCharaSheeAuth();
+
+ $this->_edit($id, false);
+ }
+
function admin_edit($id = null) {
- if (!$id && empty($this->data)) {
+
+ $this->_edit($id, true);
+ }
+
+ function _edit($id = null, $isAdmin = false) {
+ if (!$id) {
$this->Session->setFlash(__('Invalid CharacterSheet', true));
$this->redirect(array('action'=>'index'));
}
+
+ $characterSheet = $this->CharacterSheet->find('first', array(
+ 'conditions' => array('CharacterSheet.id' => $id),
+ 'recursive' => -1,
+ ));
+ if (empty($characterSheet)) {
+ $this->Session->setFlash(__('Invalid CharacterSheet.', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ // 一般ユーザの場合、自身のキャラシのみ
+ if (empty($isAdmin)) {
+ $this->__checkCharaSheeOwner($characterSheet);
+ }
+
if (!empty($this->data)) {
if ($this->CharacterSheet->save($this->data, array('fieldList' => $this->CharacterSheet->fields['edit']))) {
$this->Session->setFlash(__('The CharacterSheet has been saved', true));
$this->redirect(array('action'=>'view', $id));
}
+ function delete($id = null) {
+ // Check
+ $this->_checkCharaSheeAuth();
+
+ $this->_delete($id, true);
+ }
+
function admin_delete($id = null) {
+
+ $this->_delete($id, true);
+ }
+
+ function _delete($id = null, $isAdmin = false) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for CharacterSheet', true));
$this->redirect(array('action'=>'index'));
}
- $characterSheet = $this->CharacterSheet->read(null, $id);
+ $characterSheet = $this->CharacterSheet->find('first', array(
+ 'conditions' => array('CharacterSheet.id' => $id),
+ 'recursive' => -1,
+ ));
if (empty($characterSheet)) {
$this->Session->setFlash(__('Invalid CharacterSheet.', true));
$this->redirect(array('action'=>'index'));
}
+ // 一般ユーザの場合、自身のキャラシのみ
+ if (empty($isAdmin)) {
+ $this->__checkCharaSheeOwner($characterSheet);
+ }
if ($this->CharacterSheet->delete($id)) {
$dir = $this->getSkinDir($characterSheet['CharacterSheet']['key_name']);
$this->set('title_for_layout', " - ". __('Delete CharacterSheet', true));
}
+ function upload($id = null) {
+ // Check
+ $this->_checkCharaSheeAuth();
+
+ $this->_upload($id, false);
+ }
+
function admin_upload($id = null) {
+
+ $this->_upload($id, true);
+ }
+
+ function _upload($id = null, $isAdmin = false) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for CharacterSheet', true));
$this->redirect(array('action'=>'index'));
}
- $characterSheet = $this->CharacterSheet->read(null, $id);
+ $characterSheet = $this->CharacterSheet->find('first', array(
+ 'conditions' => array('CharacterSheet.id' => $id),
+ 'recursive' => -1,
+ ));
if (empty($characterSheet)) {
$this->Session->setFlash(__('Invalid CharacterSheet.', true));
$this->redirect(array('action'=>'index'));
}
+ // 一般ユーザの場合、自身のキャラシのみ
+ if (empty($isAdmin)) {
+ $this->__checkCharaSheeOwner($characterSheet);
+ }
$skin_dir = $this->getSkinDir($characterSheet['CharacterSheet']['key_name']);
$tmpfile = $skin_dir. 'view.tmp';
return $replacement;
}
+
+ function _checkCharaSheeAuth($system_id = null)
+ {
+ if (empty($this->site_configs['System.allowUserSheet']['value'])) {
+ $this->Session->setFlash(__('Unavailable Now.', true));
+ $this->redirect(array('action'=>'index', $system_id));
+ }
+
+ // デモモードチェック
+ $this->_check_demo();
+ }
+
+ function __checkCharaSheeOwner($characterSheet)
+ {
+ if (!$this->_checkCharaSheeOwner($characterSheet)) {
+ $this->Session->setFlash(__('No Permission', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ }
+
+ function __getThisSystem($id, $isAdmin = false)
+ {
+ $this_system = $this->_getThisSystem($id, $isAdmin);
+
+ return $this->__restore_html_system($this_system);
+ }
+
+ function __restore_html_system($data)
+ {
+ if (!isset($data['System']) || empty($data['System'])) {
+ return $data;
+ }
+
+ return $this->_restore_html_system($data);
+ }
+
}
function _view($id, $conditions = array(), $isAdmin = false) {
$this->helpers[] = 'CharacterSheet';
- // キャラクターシート設定
- $mode = null;
- if (isset($this->params['named']['mode']) && !empty($this->params['named']['mode'])) {
- $this->view = 'Theme';
- $this->theme = $this->params['named']['mode'];
-
- }
-
// キャラデータ取得
$orig_character = $this->_get_character($id, $conditions, $isAdmin);
$character = $this->Character->set_profiles2view($orig_character);
$this->set('title_for_layout', " - ". $character['Character']['name']);
+ // キャラクターシート設定
+ if (isset($this->params['named']['mode']) && !empty($this->params['named']['mode'])) {
+ $mode = $this->params['named']['mode'];
+
+ // スキン公開チェック
+ $public_flg = false;
+ $skin = array();
+ if (!$isAdmin) {
+ // 公開済み
+ foreach ($character['System']['CharacterSheet'] as $v) {
+ if ($v['key_name'] == $mode) {
+ $public_flg = true;
+ $skin = $v;
+ break;
+ }
+ }
+
+ // 自身のキャラシのみ
+ if (!$public_flg) {
+ $this->CharacterSheet = CorePlus::set_model('CharacterSheet');
+ $characterSheet = $this->CharacterSheet->find('first', array(
+ 'conditions' => array('CharacterSheet.key_name' => $mode),
+ 'recursive' => -1,
+ ));
+
+ if ($this->_checkCharaSheeOwner($characterSheet)) {
+ $skin = $characterSheet['CharacterSheet'];
+ $public_flg = true;
+ }
+ }
+ } else {
+ $public_flg = true;
+ }
+ if ($public_flg) {
+ $this->view = 'Theme';
+ $this->theme = $mode;
+
+ $this->set('skin', $skin);
+ }
+ }
+
return $character;
}
return $result;
}
- function _getThisSystem($id, $isAdmin = false)
- {
- static $this_system;
-
- if (!empty($this_system)) {
- return $this_system;
- }
-
- $system_conditions['System.id'] = $id;
- if ($isAdmin === false) {
- $system_conditions['System.public_flag'] = 'public';
- }
-
- $this_system = $this->Character->System->find('first', array(
- 'conditions' => $system_conditions,
- 'recursive' => -1,
- ));
-
- if (!isset($this_system['System'])) {
- $this->Session->setFlash(__('Invalid System.', true));
- $this->redirect(array('controller' => 'systems', 'action' => 'index'));
- }
-
- return $this_system;
- }
-
}
} else {
$contain = array(
'Character',
+ 'CharacterSheet',
'Attachment',
);
$recursive = 1;
msgid "Add CharacterSheet"
msgstr "キャラクターシート追加"
+msgid "Your CharacterSheet"
+msgstr "あなたのキャラクターシート"
+
#: /views/character_sheets/admin_add.ctp:19;24
#: /views/character_sheets/admin_index.ctp:24
#: /views/characters/add.ctp:26;35
msgid "Site Description"
msgstr "サイト紹介"
+msgid "Allow User Character-sheet"
+msgstr "一般ユーザによるキャラクターシート表示スキン追加"
+
#: /views/site_configs/admin_edit.ctp:
msgid "Single System"
msgstr "単一システム"
msgid "OFF"
msgstr "×"
+msgid "true"
+msgstr "◎"
+
#: /views/systems/admin_view.ctp:260
msgid "Edit Items"
msgstr "項目編集"
var $name = 'CharacterSheet';
var $fields = array(
- 'add' => array('system_id', 'key_name', 'name', 'public_flag', 'sort_order'),
+ 'add' => array('system_id', 'user_id', 'key_name', 'name', 'public_flag', 'sort_order'),
'edit' => array('name', 'public_flag', 'sort_order'),
'escape' => array(
),
'System.public_flag'
),
'order' => ''
+ ),
+ 'User' => array(
+ 'className' => 'User',
+ 'foreignKey' => 'user_id',
+ 'conditions' => '',
+ 'fields' => array(
+ 'User.id',
+ 'User.group_id',
+ 'User.name'
+ ),
)
);
$this->System = CorePlus::set_model('System');
}
$this->System->cacheDelete();
+
+ // 自セッション関連
+ $this->deleteCacheMyData();
}
}
'value' => 0
),
+ 'System.allowUserSheet' => array(
+ 'id' => null,
+ 'value' => 0
+ ),
+
'Design.customCss' => array(
'id' => null,
'value' => null
),
'limit' => '5',
'offset' => '',
+ ),
+ 'CharacterSheet' => array(
+ 'className' => 'CharacterSheet',
+ 'foreignKey' => 'user_id',
+ 'dependent' => false,
+ 'conditions' => array(
+ 'CharacterSheet.public_flag' => 'public',
+ ),
+ 'fields' => array(
+ 'CharacterSheet.id',
+ 'CharacterSheet.system_id',
+ 'CharacterSheet.key_name',
+ 'CharacterSheet.name',
+ 'CharacterSheet.public_flag',
+ 'CharacterSheet.modified',
+ ),
+ 'order' => array(
+ 'CharacterSheet.modified' => 'DESC',
+ ),
+ 'limit' => '5',
+ 'offset' => '',
)
);
--- /dev/null
+<?php
+echo $this->element(
+ 'character_sheet_add',
+ array(
+ 'this_system' => $this_system,
+ 'isAdmin' => false,
+ )
+);
+
-<div class="characterSheets form">
<?php
- $url = array(
- 'controller' => 'character_sheets',
- 'action' => 'add',
- );
- if (isset($this_system['System']['id'])) {
- $url[] = $this_system['System']['id'];
- }
- echo $form->create('CharacterSheet', array('url' => $url));
-
-?>
-<fieldset>
-<legend><?php __('Add CharacterSheet');?></legend>
-
-<?php
- if (isset($this_system['System']['id'])) {
- echo '<div class="input select">';
- echo '<label for="CharacterSheetSystemId">'. __('System').'</label>';
- echo $systems[$this_system['System']['id']];
- echo '</div>';
- } else {
- echo $form->input('system_id', array(
- 'label' => __('System', true),
- 'after' => $html->tag(
- 'div',
- __('No Editable', true),
- array('class' => 'required')
- )
- ));
- }
-
- echo $form->input('name', array(
- 'type' => 'text',
- 'label' => __('Name', true).
- $html->tag(
- 'span',
- __(' required', true),
- array('class' => 'required')
- ),
- 'after' => $html->tag(
- 'div',
- sprintf(__('Less than %d characters', true), 64),
- array('class' => 'attention')
- )
- ));
-
-
- echo $form->input('key_name', array(
- 'type' => 'text',
- 'label' => __('Key Name', true).
- $html->tag(
- 'span',
- __(' required', true),
- array('class' => 'required')
- ),
- 'style' => 'ime-mode:inactive;',
- 'after' =>
- $html->tag(
- 'div',
- __('No Editable', true),
- array('class' => 'required')
- ).
- $html->tag(
- 'div',
- __('Only Number, Small letter and Underline.', true),
- array('class' => 'attention')
- ).
- $html->tag(
- 'div',
- sprintf(__('Less than %d characters', true), 40),
- array('class' => 'attention')
- )
- ));
- echo $select->create_publicflag_select($public_flags, 'public_flag', array(
- 'label' => __('Public Flag', true),
- 'default' => 'private',
- ));
-
- echo $form->input('sort_order', array(
- 'label' => __('Order', true),
- 'style' => 'ime-mode:inactive;',
- ));
-
- echo $token->create();
-?>
-</fieldset>
-<?php echo $form->end(array('label' => __('Submit', true)));?>
-</div>
-
-<div class="backButton">
-<?php
-$url['action'] = 'index';
-echo $form->create('', array(
- 'url' => $url,
- 'type' => 'GET',
-));
-echo $form->end(array('label' => __('Cancel', true)));
-?>
-</div>
-
+echo $this->element(
+ 'character_sheet_add',
+ array(
+ 'this_system' => $this_system,
+ 'isAdmin' => true,
+ )
+);
-<div class="characterSheets index">
-<h2>
-<?php if (isset($this_system['System'])): ?>
- <?php echo $html->link($this_system['System']['name'], array('controller' => 'systems', 'action' => 'view', $this_system['System']['id']), array('escape' => false), false) ?>
-<?php endif; ?>
- <?php __('CharacterSheets');?>
-</h2>
-
-<p>
-<?php
-$paginator->options(array('url' => $this->passedArgs));
-
-echo $paginator->counter(array(
-'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
-));
-?></p>
-<table cellpadding="0" cellspacing="0">
-<tr>
- <th><?php echo $paginatorEx->sortAllow('id');?></th>
- <th><?php echo $paginatorEx->sortAllow(__('Name', true), 'name');?></th>
- <th><?php echo $paginatorEx->sortAllow(__('Key Name', true), 'key_name');?></th>
- <th><?php echo $paginatorEx->sortAllow(__('Public', true), 'public_flag');?></th>
-<?php if (!isset($this_system)): ?>
- <th><?php echo $paginatorEx->sortAllow(__('System', true), 'system_id');?></th>
-<?php endif; ?>
- <th><?php echo $paginatorEx->sortAllow(__('Order', true), 'sort_order');?></th>
-</tr>
-
-<?php
-$i = 0;
-foreach ($characterSheets as $characterSheet):
- $class = null;
- if ($i++ % 2 == 0) {
- $class = ' class="altrow"';
- }
-?>
-<tr<?php echo $class;?>>
-<td>
- <?php echo $characterSheet['CharacterSheet']['id']; ?>
-</td>
-<td>
<?php
- echo $html->link(
- $characterSheet['CharacterSheet']['name'],
- array(
- 'controller' => 'character_sheets',
- 'action' => 'view',
- $characterSheet['CharacterSheet']['id']
- ), array('escape' => false), false
- );
-?>
-</td>
-<td>
- <?php echo $characterSheet['CharacterSheet']['key_name']; ?>
-</td>
-<td>
-<?php
- echo $select->get_i18n_public_flag($characterSheet['CharacterSheet']['public_flag'], $public_flags);
-?>
-</td>
-<?php if (!isset($this_system)): ?>
-<td>
-<?php
- echo $html->link(
- $characterSheet['System']['name'],
- array(
- 'controller' => 'character_sheets',
- 'action' => 'index',
- $characterSheet['System']['id']
- ), array('escape' => false), false
- );
-?>
-</td>
-<?php endif; ?>
-<td>
- <?php echo $characterSheet['CharacterSheet']['sort_order']; ?>
-</td>
-</tr>
-<?php endforeach; ?>
-</table>
-</div>
-<div class="paging">
-<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
- | <?php echo $paginator->numbers();?> |
-<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
-</div>
+echo $this->element(
+ 'character_sheet_index',
+ array(
+ 'characterSheets' => $characterSheets,
+ 'isAdmin' => true,
+ )
+);
-<div class="action">
-<?php
- if (isset($this_system['System']['id'])) {
- $system_id = $this_system['System']['id'];
- } else {
- $system_id = null;
- }
- $url = array(
- 'controller' => 'character_sheets',
- 'action' => 'add',
- $system_id
- );
- echo $form->create('CharacterSheet', array('url' => $url, 'type' => 'get'));
-?>
-<?php echo $form->end(__('New CharacterSheet', true));?>
-</div>
-<div class="characterSheets view">
<?php
- $url = array(
- 'controller' => 'character_sheets',
- 'action' => 'upload',
- $characterSheets['CharacterSheet']['id'],
- ''
- );
- echo $form->create('CharacterSheet', array(
- 'type' => 'file',
- 'url' => $url
- ));
-?>
+echo $this->element(
+ 'character_sheet_view',
+ array(
+ 'characterSheets' => $characterSheets,
+ 'isAdmin' => true,
+ )
+);
-<?php
- $character_sheet_name = $characterSheets['CharacterSheet']['name'];
-
- $system_name = $html->tag('span',
- $html->link($characterSheets['System']['name'], array('controller' => 'systems', 'action' => 'view', $characterSheets['System']['id']), array('escape' => false), false),
- array(
- 'class' => 'text',
- )
- );
-
- $public = $html->tag('span',
- $select->get_i18n_public_flag($characterSheets['CharacterSheet']['public_flag'], $public_flags),
- array(
- 'class' => 'text publicFlag',
- )
- );
-
- $header = $character_sheet_name. $system_name. $public;
-
- if (!empty($view_link)) {
- $header .= $html->tag('span',
- $html->link(
- __('Check View', true),
- $view_link,
- array(
- 'target' => 'sampleView',
- )
- ),
- array(
- 'class' => 'text',
- )
- );
- }
-
- // メイン表示
- // Upfile
- $body = "<fieldset>\n".
- $html->div('upsheet',
- $form->input('file', array(
- 'label' => __('Upload CharacterSheet', true),
- 'type' => 'file',
- 'error' => array(
- )))
- ).
- $token->create().
- $form->end(array('label' => __('Submit', true)));
-
- $body .= "</fieldset>\n";
-
- $footer = null;
-
- echo $this->element('box', array(
- 'header' => $header,
- 'body' => $body,
- 'footer' => $footer,
- ));
-
-?>
-
-</div>
-
-<div class="characterSheets form">
-<?php
- $url = array(
- 'controller' => 'character_sheets',
- 'action' => 'edit',
- $characterSheets['CharacterSheet']['id'],
- ''
- );
- echo $form->create('CharacterSheet', array(
- 'url' => $url
- ));
-?>
-
-<?php
-
- $header = __('Edit CharacterSheet', true);
- $header .= $html->tag('span',
- $html->link(__('Delete CharacterSheet', true), array(
- 'action' => 'delete', $characterSheets['CharacterSheet']['id']), null,
- sprintf(__('Are you sure you want to delete # %s?', true), $characterSheets['CharacterSheet']['name'])
- ),
- array(
- 'class' => 'text',
- )
- );
-
- $body = "<fieldset>\n".
- $form->input('name', array(
- 'type' => 'text',
- 'label' => __('Name', true).
- $html->tag(
- 'span',
- __(' required', true),
- array('class' => 'required')
- ),
- 'default' => $characterSheets['CharacterSheet']['name'],
- 'after' => $html->tag(
- 'div',
- sprintf(__('Less than %d characters', true), 64),
- array('class' => 'attention')
- )
- )).
- $select->create_publicflag_select($public_flags, 'public_flag', array(
- 'label' => __('Public Flag', true),
- 'default' => $characterSheets['CharacterSheet']['public_flag'],
- )).
- $form->input('sort_order', array(
- 'label' => __('Order', true),
- 'style' => 'ime-mode:inactive;',
- 'default' => $characterSheets['CharacterSheet']['sort_order'],
- )).
- $token->create().
- $form->end(array('label' => __('Submit', true)));
-
- $body .= "</fieldset>\n";
-
- $footer = null;
-
- echo $this->element('box', array(
- 'header' => $header,
- 'body' => $body,
- 'footer' => $footer,
- ));
-
-
-?>
-</div>
\ No newline at end of file
--- /dev/null
+<?php
+echo $this->element(
+ 'character_sheet_index',
+ array(
+ 'characterSheets' => $characterSheets,
+ 'isAdmin' => false,
+ )
+);
+
--- /dev/null
+<?php
+echo $this->element(
+ 'character_sheet_view',
+ array(
+ 'characterSheets' => $characterSheets,
+ 'isAdmin' => false,
+ )
+);
+
--- /dev/null
+<div class="characterSheets form">
+<?php
+ $url = array(
+ 'controller' => 'character_sheets',
+ 'action' => 'add',
+ );
+ if (isset($this_system['System']['id'])) {
+ $url[] = $this_system['System']['id'];
+ }
+ echo $form->create('CharacterSheet', array('url' => $url));
+
+?>
+<fieldset>
+<legend><?php __('Add CharacterSheet');?></legend>
+
+<?php
+ if (isset($this_system['System']['id'])) {
+ echo '<div class="input select">';
+ echo '<label for="CharacterSheetSystemId">'. __('System').'</label>';
+ echo $systems[$this_system['System']['id']];
+ echo '</div>';
+ } else {
+ echo $form->input('system_id', array(
+ 'label' => __('System', true),
+ 'after' => $html->tag(
+ 'div',
+ __('No Editable', true),
+ array('class' => 'required')
+ )
+ ));
+ }
+
+ echo $form->input('name', array(
+ 'type' => 'text',
+ 'label' => __('Name', true).
+ $html->tag(
+ 'span',
+ __(' required', true),
+ array('class' => 'required')
+ ),
+ 'after' => $html->tag(
+ 'div',
+ sprintf(__('Less than %d characters', true), 64),
+ array('class' => 'attention')
+ )
+ ));
+
+
+ echo $form->input('key_name', array(
+ 'type' => 'text',
+ 'label' => __('Key Name', true).
+ $html->tag(
+ 'span',
+ __(' required', true),
+ array('class' => 'required')
+ ),
+ 'style' => 'ime-mode:inactive;',
+ 'after' =>
+ $html->tag(
+ 'div',
+ __('No Editable', true),
+ array('class' => 'required')
+ ).
+ $html->tag(
+ 'div',
+ __('Only Number, Small letter and Underline.', true),
+ array('class' => 'attention')
+ ).
+ $html->tag(
+ 'div',
+ sprintf(__('Less than %d characters', true), 40),
+ array('class' => 'attention')
+ )
+ ));
+ echo $select->create_publicflag_select($public_flags, 'public_flag', array(
+ 'label' => __('Public Flag', true),
+ 'default' => 'private',
+ ));
+
+ echo $form->input('sort_order', array(
+ 'label' => __('Order', true),
+ 'style' => 'ime-mode:inactive;',
+ ));
+
+ echo $token->create();
+?>
+</fieldset>
+<?php echo $form->end(array('label' => __('Submit', true)));?>
+</div>
+
+<div class="backButton">
+<?php
+$url['action'] = 'index';
+echo $form->create('', array(
+ 'url' => $url,
+ 'type' => 'GET',
+));
+echo $form->end(array('label' => __('Cancel', true)));
+?>
+</div>
+
+
--- /dev/null
+<div class="characterSheets index">
+
+<div class="characters listview">
+<div class="box full">
+<div class="boxHeader"><h2><span>
+<?php if (isset($this_system['System'])): ?>
+ <?php echo $html->link($this_system['System']['name'], array('controller' => 'systems', 'action' => 'view', $this_system['System']['id']), array('escape' => false), false) ?>
+<?php endif; ?>
+
+<?php if (empty($isAdmin)): ?>
+<?php
+ printf(__("%s's", true),
+ $user['User']['name']
+ );
+?>
+<?php endif; ?>
+<?php __('CharacterSheets');?>
+</h2>
+</h2></div>
+<div class="boxBody">
+<p>
+<?php
+$paginator->options(array('url' => $this->passedArgs));
+$pagenator_options = array();
+
+$paginator->options(array('url' => $this->passedArgs));
+
+echo $paginator->counter(array(
+'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
+));
+?></p>
+
+<div class="paging">
+<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?> |
+<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
+<table cellpadding="0" cellspacing="0">
+<tr>
+ <th><?php echo $paginatorEx->sortAllow('id');?></th>
+ <th><?php echo $paginatorEx->sortAllow(__('Name', true), 'name');?></th>
+ <th><?php echo $paginatorEx->sortAllow(__('Key Name', true), 'key_name');?></th>
+ <th><?php echo $paginatorEx->sortAllow(__('Public', true), 'public_flag');?></th>
+<?php if (!isset($this_system)): ?>
+ <th><?php echo $paginatorEx->sortAllow(__('System', true), 'system_id');?></th>
+<?php endif; ?>
+<?php if (!empty($isAdmin)): ?>
+ <th><?php echo $paginatorEx->sortAllow(__('User Name', true), 'user_id');?></th>
+ <th><?php __('User');?></th>
+<?php endif; ?>
+ <th><?php __('Order');?></th>
+ <th><?php echo $paginatorEx->sortAllow(__('Modified', true), 'modified');?></th>
+</tr>
+
+<?php
+$i = 0;
+foreach ($characterSheets as $characterSheet):
+ $class = null;
+ if ($i++ % 2 == 0) {
+ $class = ' class="altrow"';
+ }
+?>
+<tr<?php echo $class;?>>
+<td>
+ <?php echo $characterSheet['CharacterSheet']['id']; ?>
+</td>
+<td>
+<?php
+ echo $html->link(
+ $characterSheet['CharacterSheet']['name'],
+ array(
+ 'controller' => 'character_sheets',
+ 'action' => 'view',
+ $characterSheet['CharacterSheet']['id']
+ ), array('escape' => false), false
+ );
+?>
+</td>
+<td>
+ <?php echo $characterSheet['CharacterSheet']['key_name']; ?>
+</td>
+<td>
+<?php
+ echo $select->get_i18n_public_flag($characterSheet['CharacterSheet']['public_flag'], $public_flags);
+?>
+</td>
+<?php if (!isset($this_system)): ?>
+<td>
+<?php
+ echo $html->link(
+ $characterSheet['System']['name'],
+ array(
+ 'controller' => 'character_sheets',
+ 'action' => 'index',
+ $characterSheet['System']['id']
+ ), array('escape' => false), false
+ );
+?>
+</td>
+<?php endif; ?>
+<?php if (!empty($isAdmin)): ?>
+<td>
+<?php
+ echo $html->link(
+ $characterSheet['User']['name'],
+ array(
+ 'controller' => 'users',
+ 'action' => 'view',
+ $characterSheet['User']['id']
+ ), array('escape' => false), false
+ );
+?>
+</td>
+<td>
+<?php
+if (!in_array($characterSheet['User']['group_id'], array(1,2,3))) {
+ __('true');
+}
+?>
+</td>
+<?php endif; ?>
+<td>
+ <?php echo $characterSheet['CharacterSheet']['sort_order']; ?>
+</td>
+<td>
+ <?php echo $time->niceShort($characterSheet['CharacterSheet']['modified'], array('format' => 'Y/m/d H:i')); ?>
+</td>
+</tr>
+<?php endforeach; ?>
+</table>
+
+<div class="paging">
+<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $paginator->numbers();?> |
+<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
+<div class="action">
+<?php
+ if (isset($this_system['System']['id'])) {
+ $system_id = $this_system['System']['id'];
+ } else {
+ $system_id = null;
+ }
+ $url = array(
+ 'controller' => 'character_sheets',
+ 'action' => 'add',
+ $system_id
+ );
+ echo $form->create('CharacterSheet', array('url' => $url, 'type' => 'get'));
+?>
+<?php echo $form->end(__('New CharacterSheet', true));?>
+</div>
+
+
+</div>
+</div>
+
+</div>
\ No newline at end of file
--- /dev/null
+<div class="characterSheets view">
+<?php
+ $url = array(
+ 'controller' => 'character_sheets',
+ 'action' => 'upload',
+ $characterSheets['CharacterSheet']['id'],
+ ''
+ );
+ echo $form->create('CharacterSheet', array(
+ 'type' => 'file',
+ 'url' => $url
+ ));
+?>
+
+<?php
+ $character_sheet_name = $characterSheets['CharacterSheet']['name'];
+
+ if (!empty($isAdmin)) {
+ $character_sheet_name .= $html->tag('span',
+ ' By '. $html->link($characterSheets['User']['name'], array('controller' => 'users', 'action' => 'view', $characterSheets['User']['id']), array('escape' => false), false),
+ array(
+ 'class' => 'text',
+ )
+ );
+ }
+
+ $system_name = $html->tag('span',
+ $html->link($characterSheets['System']['name'], array('controller' => 'systems', 'action' => 'view', $characterSheets['System']['id']), array('escape' => false), false),
+ array(
+ 'class' => 'text',
+ )
+ );
+
+ $public = $html->tag('span',
+ $select->get_i18n_public_flag($characterSheets['CharacterSheet']['public_flag'], $public_flags),
+ array(
+ 'class' => 'text publicFlag',
+ )
+ );
+
+ $header = $character_sheet_name. $system_name. $public;
+
+ if (!empty($view_link)) {
+ $header .= $html->tag('span',
+ $html->link(
+ __('Check View', true),
+ $view_link,
+ array(
+ 'target' => 'sampleView',
+ )
+ ),
+ array(
+ 'class' => 'text',
+ )
+ );
+ }
+
+ // メイン表示
+ // Upfile
+ $body = "<fieldset>\n".
+ $html->div('upsheet',
+ $form->input('file', array(
+ 'label' => __('Upload CharacterSheet', true),
+ 'type' => 'file',
+ 'error' => array(
+ )))
+ ).
+ $token->create().
+ $form->end(array('label' => __('Submit', true)));
+
+ $body .= "</fieldset>\n";
+
+ $footer = null;
+
+ echo $this->element('box', array(
+ 'header' => $header,
+ 'body' => $body,
+ 'footer' => $footer,
+ ));
+
+?>
+
+</div>
+
+<div class="characterSheets form">
+<?php
+ $url = array(
+ 'controller' => 'character_sheets',
+ 'action' => 'edit',
+ $characterSheets['CharacterSheet']['id'],
+ ''
+ );
+ echo $form->create('CharacterSheet', array(
+ 'url' => $url
+ ));
+?>
+
+<?php
+
+ $header = __('Edit CharacterSheet', true);
+ $header .= $html->tag('span',
+ $html->link(__('Delete CharacterSheet', true), array(
+ 'action' => 'delete', $characterSheets['CharacterSheet']['id']), null,
+ sprintf(__('Are you sure you want to delete # %s?', true), $characterSheets['CharacterSheet']['name'])
+ ),
+ array(
+ 'class' => 'text',
+ )
+ );
+
+ $body = "<fieldset>\n".
+ $form->input('name', array(
+ 'type' => 'text',
+ 'label' => __('Name', true).
+ $html->tag(
+ 'span',
+ __(' required', true),
+ array('class' => 'required')
+ ),
+ 'default' => $characterSheets['CharacterSheet']['name'],
+ 'after' => $html->tag(
+ 'div',
+ sprintf(__('Less than %d characters', true), 64),
+ array('class' => 'attention')
+ )
+ )).
+ $select->create_publicflag_select($public_flags, 'public_flag', array(
+ 'label' => __('Public Flag', true),
+ 'default' => $characterSheets['CharacterSheet']['public_flag'],
+ )).
+ $form->input('sort_order', array(
+ 'label' => __('Order', true),
+ 'style' => 'ime-mode:inactive;',
+ 'default' => $characterSheets['CharacterSheet']['sort_order'],
+ )).
+ $token->create().
+ $form->end(array('label' => __('Submit', true)));
+
+ $body .= "</fieldset>\n";
+
+ $footer = null;
+
+ echo $this->element('box', array(
+ 'header' => $header,
+ 'body' => $body,
+ 'footer' => $footer,
+ ));
+
+
+?>
+</div>
\ No newline at end of file
</li>
<?php endforeach; ?>
+<?php if ($site_configs['System.allowUserSheet']['value']): ?>
+<li class="SkinAddLink">
+<?php
+echo $html->link("[".__('Add', true)."]", array(
+ 'controller' => 'character_sheets',
+ 'action' => 'add',
+ $character['Character']['system_id'],
+ ), array('escape' => false), false
+);
+ ?>
+</li>
+<?php endif; ?>
+
</ul>
<?php endif; ?>
\ No newline at end of file
);
?>
</div>
+</div>
<?php
if (!empty($target_user['User']['url'])) {
)
);
}
-?>
+echo $html->div('userNotice',
+ $target_user['User']['notes']
+);
+
+if (isset($target_user['CharacterSheet']) && !empty($target_user['CharacterSheet'])) {
+ $header = __('CharacterSheets', true);
+
+ $body = '<ul class="boxList">';
+ foreach($target_user['CharacterSheet'] as $v) {
+ $body .= $html->tag('li',
+ $v['name']. '('. $v['System']['name']. ')',
+ array(
+ )
+ );
+ }
+ $body .= '</ul>';
+
+ $footer = null;
+ if (isset($isOwner) && $isOwner === true) {
+ $footer = $html->link(__(' ...More', true), array('controller' => 'character_sheets', 'action' => 'index'));
+ }
+
+ echo $this->element('box', array(
+ 'id' => 'userCharaShee',
+ 'header' => $header,
+ 'body' => $body,
+ 'footer' => $footer,
+ ));
+}
-<?php
- echo $html->div('userNotice',
- $target_user['User']['notes']
- );
?>
</div>
-</div>
<?php endif; ?>
} else {
$character_name = null;
}
+
+if (isset($character['System']['id'])) {
+ $system_id = $character['System']['id'];
+} else {
+ $system_id = null;
+}
+
+if (isset($this->params['named']['mode'])) {
+ $mode = $this->params['named']['mode'];
+} else {
+ $mode = null;
+}
+
?>
<ul>
'character_skinchanger',
array(
'character' => $character,
+/* 'cache' => array(
+ 'time' => time() + Configure::read('Cache.expire'),
+ 'key' => $character_id. '_'. $mode,
+ ),*/
)
);
?>
$system_id = $this->params["system_id"];
}
+if (isset($this->params['named']['mode'])) {
+ $mode = $this->params['named']['mode'];
+} else {
+ $mode = null;
+}
+
if (isset($character['Character']['name'])) {
$character_name = $text->truncate($character['Character']['name'], 16);
} elseif (isset($this->data['Character']['name'])) {
'character_skinchanger',
array(
'character' => $character,
+/* 'cache' => array(
+ 'time' => time() + Configure::read('Cache.expire'),
+ 'key' => $character_id. '_'. $mode,
+ ),*/
)
);
?>
+<?php
+if (isset($character['Character']['id'])) {
+ $character = $character['Character']['id'];
+} else {
+ $character = null;
+}
+
+if (isset($this->params['named']['mode'])) {
+ $mode = $this->params['named']['mode'];
+} else {
+ $mode = null;
+}
+ ?>
+
<?php if (!isset($chracter['Character']) || (isset($character['System']['CharacterSheet']) && !empty($character['System']['CharacterSheet']))) ?>
<ul>
array(
'character' => $character,
'params' => $this->params,
+/* 'cache' => array(
+ 'time' => time() + Configure::read('Cache.expire'),
+ 'key' => $character_id. '_'. $mode,
+ ),*/
)
);
?>
+<?php
+if (isset($system['System']['name'])) {
+ $system_name = $system['System']['name'];
+ $system_id = $system['System']['id'];
+} elseif(isset($this->data['System']['name'])) {
+ $system_name = $this->data['System']['name'];
+ $system_id = $this->data['System']['id'];
+} elseif(isset($this_system['System']['name'])) {
+ $system_name = $this_system['System']['name'];
+ $system_id = $this_system['System']['id'];
+} elseif(isset($characterSheets['System']['name'])) {
+ $system_name = $characterSheets['System']['name'];
+ $system_id = $characterSheets['System']['id'];
+} else {
+ $system_name = null;
+ $system_id = null;
+}
+
+ ?>
<ul>
<?php if (isset($system['System']['name'])): ?>
<li>
<?php
echo $html->link(
- sprintf(__("%s's Home", true), $system['System']['name']),
- array('controller' => 'systems', 'action' => 'view', $system['System']['id']), array('escape' => false), false
+ sprintf(__("%s's Home", true), $system_name),
+ array('controller' => 'systems', 'action' => 'view', $system_id), array('escape' => false), false
);
?>
</li>
<?php endif; ?>
+<?php if ($user['User']['id'] && isset($system_id)): ?>
+<li><?php echo $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add', 'system_id:'.$system_id)); ?></li>
+<?php endif; ?>
+
<li><?php echo $html->link(__('List of All Systems', true), array('controller' => 'systems', 'action' => 'index')); ?></li>
-<?php if ($user['User']['id'] && isset($system['System']['id'])): ?>
-<li><?php echo $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add', 'system_id:'.$system['System']['id'])); ?></li>
+<?php if ($site_configs['System.allowUserSheet']['value']): ?>
+<li><?php echo $html->link(__('New CharacterSheet', true), array('controller' => 'character_sheets', 'action' => 'add', $system_id)); ?></li>
+
+<li><?php echo $html->link(__('List of All CharacterSheets', true), array('controller' => 'character_sheets', 'action' => 'index', $system_id));?></li>
<?php endif; ?>
</ul>
}
break;
case 'systems':
+ case 'character_sheets':
if (!$site_configs['System.singleSystem']['value']) {
echo $this->element('sidenav_system', array());
}
<table>
<tr>
+<th><?php echo __('Allow User Character-sheet') ?></th>
+<td id="System_allowUserSheet">
+<div class="input radio inline">
+<input name="data[SiteConfig][System.allowUserSheet][value]" type="radio" value="1"<?php if (!empty($this->data['SiteConfig']['System.allowUserSheet']['value'])): ?> checked="checked"<?php endif; ?>><?php __('Allow') ?>
+<input name="data[SiteConfig][System.allowUserSheet][value]" type="radio" value="0"<?php if (empty($this->data['SiteConfig']['System.allowUserSheet']['value'])): ?> checked="checked"<?php endif; ?>><?php __('No Allow') ?>
+</div>
+<input name="data[SiteConfig][System.allowUserSheet][id]" type="hidden" value="<?php echo $this->data['SiteConfig']['System.allowUserSheet']['id'];?>">
+</td>
+</tr>
+
+<tr>
<th><?php echo __('Single System') ?></th>
<td id="System_singleSystem">
<?php echo $html->div('caption', __('Use the only one System. Make the system before setting.', true)); ?>
?>
</div>
+<div class="character_sheets">
+<?php
+ $header = __('CharacterSheets', true).
+ $html->tag(
+ 'span',
+ $html->link(
+ __('Your CharacterSheet', true),
+ array(
+ 'controller' => 'character_sheets',
+ 'action' => 'index',
+ $system['System']['id'],
+ )
+ ),
+ array(
+ 'class' => 'link',
+ )
+ ).
+ $html->tag(
+ 'span',
+ $html->link(
+ __('New CharacterSheet', true),
+ array(
+ 'controller' => 'character_sheets',
+ 'action' => 'add',
+ $system['System']['id'],
+ )
+ ),
+ array(
+ 'class' => 'link',
+ )
+ );
+
+
+ $body = '';
+ if (isset($system['CharacterSheet'])) {
+ foreach($system['CharacterSheet'] as $characterSheet) {
+ $sheet = $html->link(
+ $characterSheet['name'],
+ array(
+ 'controller' => 'character_sheets',
+'action' => 'view',
+$characterSheet['id'],
+ ), array('escape' => false), false
+ );
+ $body .= $html->tag(
+ 'span',
+ $sheet,
+ array(
+ 'class' => 'characterSheet',
+ )
+ );
+ }
+ }
+
+ $footer = null;
+
+ echo $this->element('box', array(
+ 'header' =>$header,
+ 'body' => $body,
+ 'footer' => $footer,
+ ));
+ ?>
+</div>
+
+
</div>
?>
</div>
+
+<div class="character_sheets">
+<?php
+ $body = '<ul class="boxList">';
+ foreach($target_user['CharacterSheet'] as $v) {
+ $content = $html->link($v['name'], array(
+ 'controller' => 'character_sheets',
+ 'action' => 'view',
+ $v['id']
+ ), array('escape' => false), false);
+ $content .= '('.
+ $html->link($v['System']['name'], array(
+ 'controller' => 'character_sheets',
+ 'action' => 'index',
+ $v['System']['id']
+ ), array('escape' => false), false)
+ . ')';
+ $body .= $html->tag('li', $content,
+ array(
+ )
+ );
+ }
+ $body .= '</ul>';
+
+ echo $this->element('box', array(
+ 'id' => 'userCharaShee',
+ 'header' => __('CharacterSheets', true),
+ 'body' => $body,
+ 'footer' => null,
+ ));
+?>
+</div>
+
</div>
\ No newline at end of file