OSDN Git Service

NPC設定表示
authorCake <cake_67@users.sourceforge.jp>
Tue, 10 Aug 2010 08:15:57 +0000 (17:15 +0900)
committerCake <cake_67@users.sourceforge.jp>
Tue, 10 Aug 2010 08:15:57 +0000 (17:15 +0900)
13 files changed:
app/controllers/app_controller.php
app/controllers/characters_controller.php
app/locale/jpn/LC_MESSAGES/default.po
app/models/character.php
app/views/characters/add.ctp
app/views/characters/admin_index.ctp
app/views/characters/mycharacter.ctp
app/views/elements/character_index.ctp
app/views/elements/character_sidenav.ctp
app/views/elements/pc_mainnav.ctp
app/views/helpers/select.php
app/views/systems/view.ctp
app/webroot/css/character-sheet.css

index 5817d76..692392d 100644 (file)
@@ -216,7 +216,12 @@ class AppController extends Controller
        {
                $model_status = $this->get_status();
 
+               if (isset($this->isNpc) && empty($this->isNpc) && $key = array_search('npc', $model_status)) {
+                       unset($model_status[$key]);
+               }
+
                $this->set('status', $model_status);
+               $this->set('status2', array_merge($model_status, array('all')));
        }
        function get_status()
        {
index 2bfa87c..f250906 100644 (file)
@@ -22,6 +22,8 @@ class CharactersController extends AppController {
        var $view = 'View';
        var $theme = null;
 
+       var $isNpc = false;
+
        var $disableTokenActions = array();
        var $post_data = array();
 
@@ -54,7 +56,7 @@ class CharactersController extends AppController {
 
        function index($id = null) {
                if (!empty($id) && $id == $this->user_id) {
-                       $this->redirect(array('action'=>'mycharacter'));
+                       $this->redirect(array_merge(array('action'=>'mycharacter'), $this->params['named']));
                }
 
                $this->set('isOwner', false);
@@ -106,6 +108,23 @@ class CharactersController extends AppController {
        function add() {
                $systems = $this->_get_systems();
 
+               if (isset($this->params['named']['system_id'])) {
+                       $system = $this->Character->System->find('first', array(
+                               'conditions' => array(
+                                       'System.id' => $this->params['named']['system_id'],
+                               ),
+                               'recursive' => -1,
+                               'fields' => array(
+                                       'System.id',
+                                       'System.name',
+                                       'System.set_npc',
+                               )
+                       ));
+                       if (!empty($system['System']) && $system['System']['set_npc']) {
+                               $this->isNpc = true;
+                       }
+               }
+
                if (!empty($this->data)) {
                        $this->data['Character']['user_id'] = $this->user_id;
 
@@ -146,6 +165,9 @@ class CharactersController extends AppController {
                if (!$this->check_public_flag($character['System'])) {
                        $this->redirect(array('action'=>'change_system', $id));
                }
+               if ($character['System']['set_npc']) {
+                       $this->isNpc = true;
+               }
 
                if (empty($this->data)) {
                        $character['System']['Profile'] = $this->_set_profile_table2characters_has_profiles($character['System']['Profile']);
@@ -614,11 +636,17 @@ class CharactersController extends AppController {
                        }
                        $this_system = $this->_restore_html_system($this_system);
 
+                       if ($this_system['System']['set_npc']) {
+                               $this->isNpc = true;
+                       }
+
                        $title = $this_system['System']['name']. " ". $title;
 
                        $this->set('this_system', $this_system);
                } else {
                        $contain = array_merge(array('System'), (array)$contain);
+
+                       $this->isNpc = true;
                }
 
                $user = array();
@@ -658,7 +686,27 @@ class CharactersController extends AppController {
                if (isset($this->params['named']['system']) && intval($this->params['named']['system'])) {
                        $conditions['Character.system_id'] = $this->params['named']['system'];
                }
-                $characters =  $this->HtmlEscape->nl_unescape($this->_get_characters_page4user_id($id, $conditions, $limit, $fields, $contain, $order, $page));
+
+               // Status分岐
+               if (!isset($this->params['named']['status'])) {
+                       $status = 'active';
+               } else {
+                       $status = $this->params['named']['status'];
+               }
+               switch ($status) {
+                       case 'active':
+                       case 'inactive':
+                       case 'npc':
+                               $conditions['Character.status'] = $status;
+                               break;
+                       default:
+                               $status = 'all';
+                               unset($conditions['Character.status']);
+                               break;
+               }
+               $this->set('selected_status', $status);
+
+               $characters =  $this->HtmlEscape->nl_unescape($this->_get_characters_page4user_id($id, $conditions, $limit, $fields, $contain, $order, $page));
 
                $this->set('characters', $characters);
 
@@ -693,6 +741,9 @@ class CharactersController extends AppController {
                if (!$this->check_public_flag($character['System'])) {
                        $this->set('systemValid', 'unpublic');
                }
+               if ($character['System']['set_npc']) {
+                       $this->isNpc = true;
+               }
                $character = $this->_restore_html_system($character);
 
                $this->pageTitle .= " - ". $character['Character']['name'];
index d98730e..7811254 100644 (file)
@@ -1088,7 +1088,7 @@ msgstr "%sの"
 #: /views/characters/admin_index.ctp:13
 #: /views/characters/index.ctp:13
 msgid "All"
-msgstr "全"
+msgstr "全"
 
 #: /views/characters/admin_index.ctp:15
 #: /views/characters/index.ctp:15
@@ -1103,6 +1103,9 @@ msgstr "全"
 msgid "Characters"
 msgstr "キャラクター"
 
+msgid "Character List"
+msgstr "キャラクター一覧"
+
 #: /views/characters/change_system.ctp:14
 msgid "Previous System is unpubic or deleted. You can select New system."
 msgstr "以前のシステムは非公開になったか、あるいは削除されました。新しいシステムを選択できます。"
@@ -1174,7 +1177,7 @@ msgstr "更新履歴一覧"
 #: /views/elements/admin_character_sidenav.ctp:45
 #: /views/elements/character_sidenav.ctp:65
 msgid "List of All Characters"
-msgstr "キャラクター一覧"
+msgstr "キャラクター一覧"
 
 #: /views/elements/admin_system_sidenav.ctp:23
 msgid "List of All CharacterSheets"
index e8d1dbf..3669092 100644 (file)
@@ -16,6 +16,7 @@ class Character extends AppModel {
        var $status = array(
                'active',
                'inactive',
+               'npc',
        );
 
        var $fields = array(
@@ -81,6 +82,7 @@ class Character extends AppModel {
                                'System.id', 
                                'System.name', 
                                'System.public_flag',
+                               'System.set_npc',
                                'System.copyright',
                        ),
                ),
index f4a4886..fee894d 100644 (file)
@@ -4,7 +4,7 @@
                'controller' => 'characters',
                'action' => 'add',
        );
-       if (isset($this->params['named']['system_id'])) {
+       if (isset($this->params['named']['system_id']) && !empty($this->params['named']['system_id'])) {
                $url = array_merge($url, array('system_id:'.$this->params['named']['system_id']));
        } 
        echo $form->create('Character', array('url' => $url));
@@ -21,7 +21,7 @@
                        __(' * required', true)
                )
        ));
-       if (isset($this->params['named']['system_id'])) {
+       if (isset($this->params['named']['system_id']) && !empty($this->params['named']['system_id'])) {
                echo '<div class="input select">';
                echo '<label for="CharacterSystemId">'. __('System').'</label>';
                echo $form->input('system_id', array(
index adaae1a..3ed7718 100644 (file)
-<div class="characters index">
-<h2>
-<?php if (isset($this_system) && !$site_configs['System.singleSystem']['value']): ?>
-       <?php echo $html->link($this_system['System']['name'], array('controller' => 'systems', 'action' => 'view', $this_system['System']['id']), array(), false, false) ?>
-<?php endif; ?>
-<?php if (!empty($userSet)): ?>
- <?php
-       echo $html->link(
-               sprintf(__("%s's", true), $userSet['User']['name']), 
-               array('controller' => 'users', 'action' => 'view', $userSet['User']['id']), array(), false, false);
-?>
-<?php else: ?>
-       <?php __('All') ?>
-<?php endif; ?>
-<?php __('Characters');?></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>
-
-<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>
-<tr>
-       <th><?php echo $paginator->sort('id');?></th>
-       <th><?php echo $paginator->sort('name');?></th>
-       <th><?php __('Picture');?></th>
-<?php if (!isset($this->params['named']['system']) && !$site_configs['System.singleSystem']['value']): ?>
-       <th><?php echo $paginator->sort('system_id');?></th>
-<?php endif; ?>
-<?php if (empty($userSet)): ?>
-       <th><?php echo $paginator->sort(__('User Name', true), 'user_id');?></th>
-<?php endif; ?>
-       <th><?php echo $paginator->sort('modified');?></th>
-       <th><?php echo $paginator->sort('status');?></th>
-</tr>
-<?php
-       $i = 0;
-       foreach ($characters as $character):
-               $class = null;
-               if ($i++ % 2 == 0) {
-                       $class = ' class="altrow"';
-               }
-?>
-<tr<?php echo $class;?>>
-<td>
-       <?php echo $character['Character']['id']; ?>
-</td>
-<td>
-       <?php echo $html->link($text->truncate($character['Character']['name'], 32), array('action' => 'view', $character['Character']['id']), array(), false, false); ?>
-       <span class="publicFlag"><?php echo $select->get_i18n_unpublic_flag($character['Character']['public_flag'], $public_flags) ?></span>
-</td>
-<td class="center">
-<?php
-       $picture = $this->renderElement('character_picture_image', array(
-               'basename' => $character['Character']['main_picture'],
-               'options' => array(
-                       'previewVersion' => 's',
-                       'class' => '',
-                       'url' => array('controller' => 'characters', 'action' => 'view', $character['Character']['id']),
-                       'alternative' => '',
-                       'nodata' => '',
-               )
-       ));
-
-       echo $html->div('attachments', $picture);
-?>
-</td>
-<?php 
-       $character_list_url = array(
-               'controller' => 'characters', 
-               'action' => 'index'
-       );
-
-       if (!empty($userSet)) {
-               $character_list_url[] = $userSet['User']['id'];
-       }
-
- ?>
-<?php if (!isset($this_system) && !$site_configs['System.singleSystem']['value']): ?>
-<td>
-<?php 
-       echo $html->link($character['System']['name'], array_merge($character_list_url, array('system:'.$character['System']['id'])), array(), false, false);
-?>
-</td>
-<?php endif; ?>
-<?php if (empty($userSet)): ?>
-<td>
 <?php 
-       $character_list_url[] = $character['User']['id'];
-       if (isset($this_system)) {
-               $character_list_url[] = 'system:'.$this_system['System']['id'];
-       }
-       echo $html->link($text->truncate($character['User']['name'], 16), $character_list_url, array(), false, false); 
-?>
-</td>
-<?php endif; ?>
-<td>
-       <?php echo $time->niceShort($character['Character']['modified'], array('format' => 'Y/m/d H:i')); ?>
-</td>
-<td>
-       <?php echo $select->get_i18n_status($character['Character']['status'], $status); ?>
-</td>
-</tr>
-<?php endforeach; ?>
-</table>
-</div>
+echo $this->renderElement(
+       'character_index',
+       array(
+               'character' => $characters,
+               'isOwner' => false,
+               'isAdmin' => true,
+       )
+);
 
-<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>
index 5dabf5f..4edf95d 100644 (file)
@@ -2,7 +2,7 @@
 echo $this->renderElement(
        'character_index',
        array(
-               'character' => $character,
+               'character' => $characters,
                'isOwner' => $isOwner,
                'isAdmin' => false,
                'cache' => array(
index 065fd06..572e510 100644 (file)
@@ -1,6 +1,6 @@
 <div class="characters index">
-<h2>
-<?php if (isset($this_system)): ?>
+<h2><span>
+<?php if (isset($this_system) && !$site_configs['System.singleSystem']['value']): ?>
        <?php echo $html->link($this_system['System']['name'], array('controller' => 'systems', 'action' => 'view', $this_system['System']['id']), array(), false, false) ?>
 <?php endif; ?>
 <?php if (!empty($userSet)): ?>
@@ -9,10 +9,37 @@
                sprintf(__("%s's", true), $userSet['User']['name']), 
                array('controller' => 'users', 'action' => 'view', $userSet['User']['id']), array(), false, false);
 ?>
-<?php else: ?>
-       <?php __('All') ?>
 <?php endif; ?>
-<?php __('Characters');?></h2>
+<?php if ($selected_status != 'all' && $selected_status != 'active'): ?>
+<?php echo $select->get_i18n_status($selected_status, $status2);?>
+<?php endif; ?>
+<?php __('Character List');?>
+</span>
+<span class="selectStatus">[
+<?php 
+foreach ($status2 as $k => $v) {
+       if ($k != 0) {
+               echo " | ";
+       }
+       if ($v != $selected_status) {
+               $txt = $html->link(
+                       $select->get_i18n_status($v, $status2), 
+                       array_merge($this->params['named'], array('status' => $v)), 
+                       array(), 
+                       false, false
+               );
+       } else {
+               $txt = $select->get_i18n_status($v, $status2);
+       }
+
+       echo $html->tag('span', 
+               $txt,
+               array()
+       );
+}
+?>
+]</span>
+</h2>
 <p>
 <?php
 $paginator->options(array('url' => $this->passedArgs));
@@ -27,9 +54,11 @@ echo $paginator->counter(array(
  | <?php echo $paginator->numbers();?> | 
 <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
 </div>
-
 <table>
 <tr>
+<?php if ($isAdmin): ?>
+       <th><?php echo $paginator->sort('id');?></th>
+<?php endif; ?>
        <th><?php echo $paginator->sort('name');?></th>
        <th><?php __('Picture');?></th>
 <?php if (!isset($this_system) && !$site_configs['System.singleSystem']['value']): ?>
@@ -39,8 +68,9 @@ echo $paginator->counter(array(
        <th><?php echo $paginator->sort(__('User Name', true), 'user_id');?></th>
 <?php endif; ?>
        <th><?php echo $paginator->sort('modified');?></th>
+<?php if ($selected_status == 'all'): ?>
        <th><?php echo $paginator->sort('status');?></th>
-</th>
+<?php endif; ?>
 </tr>
 <?php
 $i = 0;
@@ -51,9 +81,14 @@ foreach ($characters as $character):
        }
 ?>
 <tr<?php echo $class;?>>
+<?php if ($isAdmin): ?>
+<td>
+       <?php echo $character['Character']['id']; ?>
+</td>
+<?php endif; ?>
 <td>
        <?php echo $html->link($text->truncate($character['Character']['name'], 32), array('action' => 'view', $character['Character']['id']), array(), false, false); ?>
-<?php if ($isOwner_userSet && $character['Character']['public_flag'] != 'public'): ?>
+<?php if ($isAdmin || ($isOwner_userSet && $character['Character']['public_flag'] != 'public')): ?>
 <span class="publicFlag"><?php echo $select->get_i18n_unpublic_flag($character['Character']['public_flag'], $public_flags) ?></span>
 <?php endif; ?>
 </td>
@@ -83,6 +118,10 @@ foreach ($characters as $character):
                $character_list_url[] = $userSet['User']['id'];
        }
 
+       if (!empty($selected_status)) {
+               $character_list_url['status'] = $selected_status;
+       }
+
  ?>
 <?php if (!isset($this_system) && !$site_configs['System.singleSystem']['value']): ?>
 <td>
@@ -105,9 +144,11 @@ foreach ($characters as $character):
 <td>
        <?php echo $time->niceShort($character['Character']['modified'], array('format' => 'Y/m/d H:i')); ?>
 </td>
+<?php if ($selected_status == 'all'): ?>
 <td>
        <?php echo $select->get_i18n_status($character['Character']['status'], $status); ?>
 </td>
+<?php endif; ?>
 </tr>
 <?php endforeach; ?>
 </table>
@@ -118,9 +159,3 @@ foreach ($characters as $character):
  | <?php echo $paginator->numbers();?> | 
 <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
 </div>
-
-<div class="actions">
-<ul>
-<li><?php echo $html->link(__('New Character', true), array('action' => 'add')); ?></li>
-</ul>
-</div>
index d6312ca..30cbed7 100644 (file)
@@ -17,6 +17,17 @@ if (isset($character['Character']['id'])) {
        $character_id = null;
 }
 
+$system_id = null;
+if (isset($character['System']['id'])) {
+       $system_id = $character['System']['id'];
+} elseif (isset($this->data['System']['id'])) {
+       $system_id = $this->data['System']['id'];
+} elseif (isset($this->data['System']['id'])) {
+       $system_id = $this->data['System']['id'];
+} elseif (isset($this->params["system_id"])) {
+       $system_id = $this->params["system_id"];
+}
+
 if (isset($character['Character']['name'])) {
        $character_name = $text->truncate($character['Character']['name'], 16);
 } elseif (isset($this->data['Character']['name'])) {
@@ -65,12 +76,12 @@ if (isset($character['Character']['name'])) {
 <li><?php echo $html->link(__('List of All Characters', true), array('controller' => 'characters', 'action' => 'index')); ?></li>
 
 <?php if ($user['User']['id']): ?>
-<li><?php echo $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add')); ?></li>
+<li><?php echo $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add', 'system_id:'.$system_id)); ?></li>
 <?php endif; ?>
 
 </ul>
 
-<?php if (isset($character['Character'])): ?>
+<?php if (isset($character['Character'])): ?> 
 <?php
        echo $this->renderElement(
                'character_skinchanger',
index 60b0652..3f98b28 100644 (file)
@@ -3,7 +3,7 @@
 
        <li><?php echo $html->link(__('Characters', true), array('controller' => 'characters', 'action' => 'index')); ?></li>
 
-<?php if (!$site_configs['System.singleSystem']['value']): ?>
+<?php if (isset($site_configs) && !$site_configs['System.singleSystem']['value']): ?>
        <li><?php echo $html->link(__('Systems', true), array('controller' => 'systems', 'action' => 'index')); ?></li>
 <?php endif; ?>
 
index 00b5468..3be13c2 100644 (file)
@@ -16,6 +16,7 @@ class SelectHelper extends Helper {
        var $default_status = array(
                'active',
                'inactive',
+               'npc',
        );
 
        /**
@@ -107,7 +108,12 @@ class SelectHelper extends Helper {
                }
 
                $status_list = $this->set_status($status_list);
-               return $status_list[$status];
+
+               if (isset($status_list[$status])) {
+                       return $status_list[$status];
+               } else {
+                       return null;
+               }
        }
        /**
         * statusの選択プルダウン出力
@@ -149,6 +155,8 @@ class SelectHelper extends Helper {
                                $i18n_status[$v] = __('NPC', true);
                        } elseif($v == 'inactive') {
                                $i18n_status[$v] = __('Inactive', true);
+                       } elseif($v == 'all') {
+                               $i18n_status[$v] = __('All', true);
                        } else {
                                $i18n_status[$v] = $v;
                        }
index 2ee8e13..7c5fc9b 100644 (file)
 <?php
        $total =  $html->tag('span', sprintf(__('Total Characters %d', true), $system['System']['character_num']), array('class' => 'total_chara_num'));
 
+       $add_link =  $html->tag('span', $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add', 'system_id:'.$system['System']['id'])), array('class' => 'addLink'));
+
        echo $this->renderElement('character_picture_table', array(
-               'header' => __('Characters', true). $total,
+               'header' => __('Characters', true). $total. $add_link,
                'characters' => $system['Character'],
                'previewVersion' => 'xs',
                'colNum' => 15,
index 6292c44..b6319f7 100644 (file)
@@ -187,6 +187,12 @@ div.view div.attachments {
        background-position: right top;
 }
 
+/* ステータス */
+.selectStatus {
+       font-size: 60%;
+       font-weight: normal;
+}
+
 /* プロフィール公開選択 */
 .profilePublic {
        display: inline;