OSDN Git Service

System一覧にキャラクター表示
authorCake <cake_67@users.sourceforge.jp>
Thu, 25 Mar 2010 10:07:50 +0000 (19:07 +0900)
committerCake <cake_67@users.sourceforge.jp>
Thu, 25 Mar 2010 10:07:50 +0000 (19:07 +0900)
app/controllers/systems_controller.php
app/models/system.php
app/views/elements/character_picture_table.ctp
app/views/systems/admin_index.ctp
app/views/systems/index.ctp
app/webroot/css/box.css
app/webroot/css/character-sheet.css
app/webroot/css/ie.css

index a286a40..b3fbbd0 100644 (file)
@@ -21,8 +21,9 @@ class SystemsController extends AppController {
                'recursive' => 1,
                'contain' => array(
                        'Attachment',
+                       'Character',
                ),
-               'limit' => 20,
+               'limit' => 10,
                'order' => array(
                        'System.sort_order' => 'asc'
                ),
@@ -55,6 +56,7 @@ class SystemsController extends AppController {
 
        function index() {
                $this->paginate['conditions']['public_flag'] = 'public';
+               $this->System->hasMany['Character']['limit'] = 8;
                $this->_index();
        }
 
@@ -63,6 +65,7 @@ class SystemsController extends AppController {
        }
 
        function admin_index() {
+               unset($this->System->hasMany['Character']['conditions']['Character.public_flag']);
                $this->_index();
        }
 
@@ -145,6 +148,20 @@ class SystemsController extends AppController {
                $systems = $this->paginate();
 
                if (!empty($systems)) {
+                       // 全キャラクター数取得
+                       foreach ($systems as $k => $v) {
+                               if (empty($v['Character'])) {
+                                       $systems[$k]['System']['character_num'] = 0;
+                                       continue;
+                               }
+
+                               $systems[$k]['System']['character_num'] = $this->System->Character->find('count', array(
+                                       'conditions' => array_merge($this->System->hasMany['Character']['conditions'],
+                                               array('Character.system_id' => $v['System']['id'])),
+                                       'recursive' => -1,
+                               ));
+                       }
+
                        $systems = $this->HtmlEscape->nl_unescape($systems);
                }
 
index 15256b9..d18a2f5 100644 (file)
@@ -73,7 +73,7 @@ class System extends AppModel {
                        ),
                        'fields' => '',
                        'order' => 'Character.modified DESC',
-                       'limit' => '20',
+                       'limit' => '5',
                ),
                'Profile' => array(
                        'className' => 'Profile',
index 4076fc1..323e044 100644 (file)
@@ -8,6 +8,9 @@
 <?php
 $i = 0;
 foreach ($characters as $character):
+       if (!isset($character['Character'])) {
+               $character['Character'] = $character;
+       }
        if ($i % $colNum == 0) {
                echo '<tr>';
        }
@@ -32,9 +35,11 @@ foreach ($characters as $character):
        ));
  ?>
 </div>
+<?php if (isset($isCharacter) && $isCharacter === true): ?>
 <?php
-//     echo $html->div('characterName', $html->link($character['Character']['name'], array('controller' => 'characters', 'action' => 'view', $character['Character']['id'])));
+       echo $html->div('characterName', $html->link($character['Character']['name'], array('controller' => 'characters', 'action' => 'view', $character['Character']['id'])));
 ?>
+<?php endif; ?>
 <?php if ($isUser && isset($character['User'])): ?>
 <?php
        echo $html->div('userName', $html->link($character['User']['name'], array('controller' => 'users', 'action' => 'view', $character['User']['id'])));
@@ -45,9 +50,11 @@ foreach ($characters as $character):
        echo $html->div('systemName', $html->link($character['System']['name'], array('controller' => 'systems', 'action' => 'view', $character['System']['id'])));
 ?>
 <?php endif; ?>
+<?php if (!isset($isModified) || $isModified === true): ?>
 <?php
        echo $html->div('lastModified', $time->niceShort($character['Character']['modified'], array('format' => 'Y/m/d H:i')));
 ?>
+<?php endif; ?>
 </td>
 
 <?php
@@ -69,11 +76,6 @@ foreach ($characters as $character):
 </tr>
 </table>
 <?php else: ?>
-<?php if (isset($nodata)): ?>
-<?php echo $nodata; ?>
-<?php else: ?>
-<?php echo $html->div('noData', __('No data', true)); ?>
-<?php endif; ?>
 <?php endif; ?>
 </div>
 
index 2211f7a..ba5f16d 100644 (file)
@@ -2,6 +2,8 @@
 <h2><?php __('Systems');?></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)
 ));
@@ -12,25 +14,21 @@ echo $paginator->counter(array(
        <th><?php echo $paginator->sort('id');?></th>
        <th><?php echo $paginator->sort(__('Name', true), 'name');?></th>
        <th><?php echo $paginator->sort(__('Order', true), 'sort_order');?></th>
-       <th><?php echo $paginator->sort(__('Use NPC', true), 'set_npc');?></th>
        <th><?php echo $paginator->sort(__('Public', true), 'public_flag');?></th>
 </tr>
 <?php
 $i = 0;
 foreach ($systems as $system):
        $class = null;
-       if ($i++ % 2 == 0) {
-               $class = ' class="altrow"';
-       }
 ?>
-<tr<?php echo $class;?>>
+<tr>
 <td>
        <?php echo $system['System']['id']; ?>
 </td>
 <td>
 <?php
        $file = $upfile->file(
-               'filter/xxs', 
+               'filter/xs', 
                CorePlus::get_value($system, 'Attachment.0'),
                array(
                        'model_name' => 'System', 
@@ -38,7 +36,7 @@ foreach ($systems as $system):
                        'nodata' => 'image',
                )
        );
-       echo $upfile->embed(
+       $system_img = $upfile->embed(
                $file,
                array(
                        'alt' => CorePlus::get_value($system, 'Attachment.0.alternative'),
@@ -48,20 +46,33 @@ foreach ($systems as $system):
                        ),
                )
        );
+
+       $system_name =  $html->link($system['System']['name'], array('action' => 'view', $system['System']['id']));
+
+       $total =  $html->tag('span', sprintf(__('Total Characters %d', true), $system['System']['character_num']), array('class' => 'total_chara_num'));
+
+       echo $this->renderElement('character_picture_table', array(
+               'header' => $system_img. $system_name. $total,
+               'characters' => $system['Character'],
+               'previewVersion' => 's',
+               'colNum' => 5,
+               'id' => null,
+               'isUser' => false,
+               'isCharacter' => true,
+               'isSystem' => false,
+               'isModified' => false,
+               'more_url' => array(
+                       'controller' => 'systems', 
+                       'action' => 'view',
+                       $system['System']['id'],
+               ),
+       ));
 ?>
-       <?php echo $html->link($system['System']['name'], array('action' => 'view', $system['System']['id'])); ?>
 </td>
 <td>
        <?php echo $system['System']['sort_order']; ?>
 </td>
 <td>
-<?php if ($system['System']['set_npc']): ?>
-       <?php echo __('Use'); ?>
-<?php else: ?>
-       <?php echo __('No Use'); ?>
-<?php endif; ?>
-</td>
-<td>
        <?php echo $select->get_i18n_public_flag($system['System']['public_flag'], $public_flags) ?>
 </td>
 </tr>
@@ -71,6 +82,6 @@ foreach ($systems as $system):
 
 <div class="paging">
 <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
- |     <?php echo $paginator->numbers();?>
+ |     <?php echo $paginator->numbers();?> | 
 <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
 </div>
index 129adbd..cf3498c 100644 (file)
@@ -2,26 +2,19 @@
 <h2><?php __('Systems');?></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>
-<tr>
-<tr>
-       <th><?php echo __('Name', true);?></th>
-       <th><?php echo __('Characters', true);?></th>
-</tr>
+
 <?php
        $i = 0;
        foreach ($systems as $system):
                $class = null;
-               if ($i++ % 2 == 0) {
-                       $class = ' class="altrow"';
-               }
 ?>
-<tr<?php echo $class;?>>
-<td>
+<div class="systemList">
 <?php
        $file = $upfile->file(
                'filter/xs', 
@@ -32,7 +25,7 @@ echo $paginator->counter(array(
                        'nodata' => 'image',
                )
        );
-       echo $upfile->embed(
+       $system_img = $upfile->embed(
                $file,
                array(
                        'alt' => CorePlus::get_value($system, 'Attachment.0.alternative'),
@@ -42,16 +35,34 @@ echo $paginator->counter(array(
                        ),
                )
        );
+
+       $system_name =  $html->link($system['System']['name'], array('action' => 'view', $system['System']['id']));
+
+       $total =  $html->tag('span', sprintf(__('Total Characters %d', true), $system['System']['character_num']), array('class' => 'total_chara_num'));
+
+       echo $this->renderElement('character_picture_table', array(
+               'header' => $system_img. $system_name. $total,
+               'characters' => $system['Character'],
+               'previewVersion' => 's',
+               'colNum' => 8,
+               'id' => null,
+               'isUser' => false,
+               'isCharacter' => true,
+               'isSystem' => false,
+               'isModified' => false,
+               'more_url' => array(
+                       'controller' => 'systems', 
+                       'action' => 'view',
+                       $system['System']['id'],
+               ),
+       ));
 ?>
-       <?php echo $html->link($system['System']['name'], array('action' => 'view', $system['System']['id'])); ?>
-</td>
-</tr>
+</div>
 <?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->numbers();?> | 
 <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
 </div>
index 73905e9..791f8a5 100644 (file)
 }
 
 /* 各サイズごとの設定 */
+.CharacterTable_s_5
+{
+       width: 400px;
+       overflow: hidden;
+}
+.CharacterTable_s_8
+{
+       width: 640px;
+       overflow: hidden;
+}
+.CharacterTable_s_5 td,
+.CharacterTable_s_8 td
+{
+       width: 64px;
+       overflow: hidden;
+}
+.CharacterTable_s_5 div.picture,
+.CharacterTable_s_8 div.picture
+{
+       width: 64px;
+       height: 64px;
+       overflow: hidden;
+       padding: 3px;
+}
+.CharacterTable_s_5 div.picture a.characterThmbnail,
+.CharacterTable_s_8 div.picture a.characterThmbnail
+{
+       width: 64px;
+       height: 64px;
+       overflow: hidden;
+}
+.CharacterTable_s_5 div.picture a.characterThmbnail span.image_caption,
+.CharacterTable_s_8 div.picture a.characterThmbnail span.image_caption
+{
+       display: none;
+}
+.CharacterTable_s_5 div.characterName,
+.CharacterTable_s_8 div.characterName
+{
+       height: 0.7em;
+       font-size: 70%;
+       width: 64px;
+}
+.CharacterTable_s_5 .boxFooter .editLink,
+.CharacterTable_s_8 .boxFooter .editLink
+{
+       padding: 2px 32px;
+}
+
+
 .CharacterTable_m_5
 {
        width: 725px;
index d83234b..d45a6e4 100644 (file)
@@ -122,3 +122,18 @@ div.image div.action li {
        margin: 10px;
        font-size: 120%;
 }
+
+/* System一覧 */
+.systemList {
+       padding-top: 10px;
+}
+
+/* キャラクター数表示 */
+.total_chara_num {
+       padding-left: 7px;
+}
+
+.boxHeader .total_chara_num {
+       font-size: 80%;
+       font-weight: normal;
+}
index 4921060..846013b 100644 (file)
@@ -39,3 +39,23 @@ a.shadow {
        width: 177px;
        left: 4px;
 }
+
+.CharacterTable_s_5
+{
+       width: 435px;
+}
+.CharacterTable_s_8
+{
+       width: 696px;
+}
+.CharacterTable_s_5 td,
+.CharacterTable_s_8 td
+{
+       width: 70px;
+}
+.CharacterTable_s_5 div.picture,
+.CharacterTable_s_8 div.picture
+{
+       width: 70px;
+       height: 70px;
+}