OSDN Git Service

お知らせ機能実装
authorCake <cake_67@users.sourceforge.jp>
Sat, 25 Dec 2010 05:38:11 +0000 (14:38 +0900)
committerCake <cake_67@users.sourceforge.jp>
Sat, 25 Dec 2010 05:38:11 +0000 (14:38 +0900)
24 files changed:
app/config/sql/install/create_table.sql
app/controllers/app_controller.php
app/controllers/characters_controller.php
app/controllers/news_controller.php [new file with mode: 0644]
app/controllers/users_controller.php
app/locale/jpn/LC_MESSAGES/default.po
app/models/app_model.php
app/models/news.php [new file with mode: 0644]
app/tests/cases/controllers/news_controller.test.php [new file with mode: 0644]
app/tests/cases/models/news.test.php [new file with mode: 0644]
app/tests/fixtures/news_fixture.php [new file with mode: 0644]
app/views/characters/mycharacter.ctp
app/views/elements/character_index.ctp
app/views/elements/home_right.ctp
app/views/elements/information.ctp [new file with mode: 0644]
app/views/elements/sidenav_admin_news.ctp [new file with mode: 0644]
app/views/elements/sidenav_user.ctp [new file with mode: 0644]
app/views/layouts/admin_default.ctp
app/views/news/admin_add.ctp [new file with mode: 0644]
app/views/news/admin_edit.ctp [new file with mode: 0644]
app/views/news/admin_index.ctp [new file with mode: 0644]
app/views/news/index.ctp [new file with mode: 0644]
app/webroot/css/base.css
app/webroot/css/box.css

index 47aa55a..064f3ab 100644 (file)
@@ -23,10 +23,12 @@ DROP TABLE IF EXISTS `users`;
 DROP TABLE IF EXISTS `groups`;
 
 DROP TABLE IF EXISTS `send_mails`;
+DROP TABLE IF EXISTS `news`;
 DROP TABLE IF EXISTS `site_configs`;
 DROP TABLE IF EXISTS `cake_sessions`;
 
 
+/*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `cake_sessions` (
   `id` varchar(255) NOT NULL default '',
   `data` text,
@@ -34,7 +36,6 @@ CREATE TABLE `cake_sessions` (
   PRIMARY KEY  (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
-/*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `site_configs` (
   `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
   `key_name` VARCHAR(64) NOT NULL,
@@ -44,6 +45,19 @@ CREATE TABLE `site_configs` (
   UNIQUE INDEX `site_settings_key`(`key_name`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+CREATE TABLE `news` (
+  `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+  `title` varchar(512) NOT NULL,
+  `value` TEXT NOT NULL,
+  `public_flag` ENUM('public','private') NOT NULL DEFAULT 'public',
+  `date` DATE NOT NULL,
+  `end_date` DATE NOT NULL DEFAULT '0000-00-00',
+  `modified` DATETIME NOT NULL,
+  PRIMARY KEY(`id`),
+  INDEX `news_date`(`date`),
+  INDEX `news_public_date_end`(`public_flag`, `date`, `end_date`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 CREATE TABLE `send_mails` (
   `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
   `user_id` INTEGER UNSIGNED NULL,
@@ -51,6 +65,8 @@ CREATE TABLE `send_mails` (
   `from_user_id` INTEGER UNSIGNED NULL,
   `subject` TEXT NOT NULL,
   `body` TEXT NOT NULL,
+  `useragent` varchar(512) NOT NULL,
+  `host` varchar(64) NOT NULL,
   `created` DATETIME NOT NULL,
   `modified` DATETIME NOT NULL,
   PRIMARY KEY(`id`),
index 05e7d96..e37c081 100644 (file)
@@ -611,6 +611,19 @@ class AppController extends Controller
 
                return $data;
        }
+       function _restore_html_news($data, $nl2br = false) {
+               $data['title'] = $this->{$this->modelClass}->restore_html($data['title'], false, false, false);
+
+               if (isset($data['value']) && !empty($data['value'])) {
+                       $data['value'] = $this->{$this->modelClass}->restore_html($data['value'], false, false, false);
+                       if ($nl2br) {
+                               $data['value'] = str_replace('<br />', "\n", $data['value']);
+                       }
+               }
+
+               return $data;
+       }
+
        // アドレス復号化
        function decrypt_mail($data)
        {
@@ -789,6 +802,30 @@ class AppController extends Controller
                return true;
        }
 
+       // 最新のお知らせ
+       function get_news($limit = 5) {
+               $this->News = CorePlus::set_model('News');
+
+               $news = $this->News->find('all', array(
+                       'conditions' => array(
+                               'News.public_flag' => 'public',
+                               'News.end_date > ' => date('Y-m-d 00:00:00', time()),
+                       ),
+                       'fields' => '',
+                       'recursive' => -1,
+                       'order' => array(
+                               'News.date' => 'desc'
+                       ),
+                       'limit' => $limit,
+               ));
+
+               foreach($news as $k => $v) {
+                       $news[$k]['News'] = $this->_restore_html_news($v['News']);
+               }
+
+               return $news;
+       }
+
 }
 
 /*
index 9eafaaa..6a734d8 100644 (file)
@@ -87,6 +87,13 @@ class CharactersController extends AppController {
        }
 
        function mycharacter(){
+               // お知らせ
+               $news = array();
+               if (empty($this->site_configs['Site.myHome']['value'])) {
+                       $news = $this->get_news();
+               }
+               $this->set('news', $news);
+
                $this->set('isOwner', true);
 
                $this->_index($this->user_id);
diff --git a/app/controllers/news_controller.php b/app/controllers/news_controller.php
new file mode 100644 (file)
index 0000000..2796abd
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+class NewsController extends AppController {
+
+       var $name = 'News';
+       var $helpers = array(
+               'Group',
+               'Select',
+               'Time',
+       );
+
+       // listView用のpagenate設定
+       var $paginate = array(
+               'conditions' => array(
+                       'News.public_flag' => 'public',
+               ),
+               'fields' => array(
+                       'News.id',
+                       'News.title',
+                       'News.value',
+                       'News.date',
+                       'News.end_date',
+                       'News.modified',
+               ),
+               'recursive' => -1,
+               'limit' => 20,
+               'order' => array(
+                       'News.date' => 'desc'
+               ),
+       );
+
+
+       function beforeFilter() {
+
+               parent::beforeFilter();
+
+               // Cache
+               $this->cacheAction = array(
+                       'view' => Configure::read('Cache.expireLong'),
+                       'index' => Configure::read('Cache.expireLong'),
+               );
+
+               // 認証なしアクセス可
+               $this->AuthPlus->allow('index');
+               $this->AuthPlus->allow('view');
+
+               // 設定
+               $this->set_public_flag4view();
+       }
+
+       /* アクション */
+       function index() {
+               $this->_index(false);
+       }
+
+       function admin_index() {
+               $this->_index(true);
+       }
+
+       function admin_add() {
+               if (!empty($this->data)) {
+                       $this->News->create();
+                       if ($this->News->save($this->data, array('fieldList' => $this->SendMail->fields['add'], 'validate' => false))) {
+                               $this->Session->setFlash(__('The news has been saved', true));
+                               $this->redirect(array('action' => 'index'));
+                       } else {
+                               $this->Session->setFlash(__('The news could not be saved. Please, try again.', true));
+                       }
+               }
+
+               $this->set('title_for_layout', " - ". __('Add News', true));
+       }
+
+       function admin_edit($id = null) {
+               if (!$id && empty($this->data)) {
+                       $this->Session->setFlash(__('Invalid news', true));
+                       $this->redirect(array('action' => 'index'));
+               }
+               if (!empty($this->data)) {
+                       if ($this->News->save($this->data)) {
+                               $this->Session->setFlash(__('The news has been saved', true));
+                               $this->redirect(array('action' => 'index'));
+                       } else {
+                               $this->Session->setFlash(__('The news could not be saved. Please, try again.', true));
+                               $this->data['News']['id'] = $id;
+                       }
+               }
+               if (empty($this->data)) {
+                       $news = $this->News->find('first', array(
+                               'conditions' => array(
+                                       'News.id' => $id
+                               ),
+                               'fields' => '',
+                               'recursive' => -1,
+                               'order' => array(
+                                       'News.date' => 'desc'
+                               ),
+                       ));
+                       if (empty($news)) {
+                               $this->Session->setFlash(__('Invalid news', true));
+                               $this->redirect(array('action' => 'index'));
+                       }
+
+                       $news['News'] = $this->_restore_html_news($news['News'], true);
+
+                       $this->data = $news;
+               }
+
+               $this->set('title_for_layout', " - ". __('Edit News', true));
+       }
+
+       function admin_delete($id = null) {
+               if (!$id) {
+                       $this->Session->setFlash(__('Invalid Id.', true));
+                       $this->redirect(array('action'=>'index'));
+               }
+               if ($this->News->delete($id)) {
+                       $this->Session->setFlash(__('News deleted', true));
+                       $this->redirect(array('action'=>'index'));
+               }
+               $this->Session->setFlash(__('News was not deleted', true));
+               $this->redirect(array('action' => 'index'));
+       }
+
+       function _index($isAdmin = false)
+       {
+               $this->set('isAdmin', $isAdmin);
+
+               if ($isAdmin) {
+                       unset($this->paginate['conditions']['News.public_flag']);
+
+                       $this->paginate['fields'] = '';
+               }
+
+               $news = $this->paginate();
+               foreach ($news as $k => $v) {
+                       $news[$k]['News'] = $this->_restore_html_news($v['News']);
+
+               }
+
+               $this->set('news', $news);
+
+               $this->set('title_for_layout', " - ". __('News List', true));
+       }
+
+}
index 7d0d72b..4b455ec 100644 (file)
@@ -88,14 +88,9 @@ class UsersController extends AppController {
                }
 
 
-               // ユーザ情報表示
-               if ($this->AuthPlus->user()) {
-                       $name = $this->user['User']['name'];
-                       self::_index();
-               } else {
-                       $name = __('Guest', true);
-               }
-               $this->set('title_for_layout', " - ". sprintf(__("%s's Home", true), $name));
+                       // お知らせ
+                       $this->set('news', $this->get_news());
+                       }
 
                // 全体の情報
                self::_view($this->user_id);
@@ -473,7 +468,7 @@ class UsersController extends AppController {
                }
                $this->set('users', $users);
 
-               $this->set('title_for_layout', " - ". __('List Users', true));
+               $this->set('title_for_layout', " - ". __('Users List', true));
        }
 
        function _search($isAdmin = false) {
index 32edcc2..460dba2 100644 (file)
@@ -2519,3 +2519,43 @@ msgstr "送信者アドレス"
 
 msgid "Receive"
 msgstr "受信者"
+
+msgid "Invalid news"
+msgstr "指定のお知らせはありません。"
+
+msgid "The news has been saved"
+msgstr "お知らせを保存しました。"
+
+msgid "The news could not be saved. Please, try again."
+msgstr "お知らせを保存できませんでした。"
+
+msgid "News deleted"
+msgstr "お知らせを削除しました。"
+
+msgid "News was not deleted"
+msgstr "お知らせを削除できませんでした。"
+
+msgid "Add News"
+msgstr "お知らせ作成"
+
+msgid "Edit News"
+msgstr "お知らせ編集"
+
+msgid "News"
+msgstr "お知らせ"
+
+msgid "News List"
+msgstr "お知らせ一覧"
+
+msgid "Released"
+msgstr "公開日"
+
+msgid "End Date as the Home News"
+msgstr "ホーム掲載終了日"
+
+msgid "You cannot set the Past date."
+msgstr "過去の日付を設定することはできません。"
+
+msgid "Invalid date."
+msgstr "正しい日付を入力してください。"
+
index 68ef684..acd738c 100644 (file)
@@ -66,6 +66,7 @@ class AppModel extends Model {
                        'boolean' => __('Incorrect value.', true),
                        'compare2fields' => __('Input same as avobe.', true),
                        'comparison' => __('Please input number %2$s %3$d.', true),
+                       'date' => __('Invalid date.', true),
                        'isAddress' => __('Invalid mail address.', true),
                        'isPcMail' => __('Invalid PC-mail address.', true),
                        'isUnique' => __('It was already registed.', true),
@@ -79,6 +80,7 @@ class AppModel extends Model {
                        'maxLength' => __('Less than %2$d characters', true),
                        'notEmpty'      => __('Please be sure to input.', true),
                        'numeric' => __('Please input only number.', true),
+                       'onlyFuture' => __('You cannot set the Past date.', true),
                        'orderNumeric' => __('Order must be only number.', true),
                        'profileType' => __('Invalid Type.', true),
                        'publicFlag' => __('Incorrect value.', true),
diff --git a/app/models/news.php b/app/models/news.php
new file mode 100644 (file)
index 0000000..c9741fa
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+class News extends AppModel {
+       var $name = 'News';
+
+       var $fields = array(
+               'add' => array('title', 'value', 'public_flag', 'date', 'end_date'),
+               'edit' => array('title', 'value', 'public_flag', 'date', 'end_date'),
+               'escape' => array(
+                       'title' => array(
+                               'html' => false,
+                               'tags' => false,
+                               'images' => false,
+                               'sctipts' => false,
+                       ),
+                       'value' => array(
+                               'html' => false,
+                               'tags' => false,
+                               'images' => false,
+                               'sctipts' => false,
+                       ),
+               ),
+       );
+
+       var $validate = array(
+               'title' => array(
+                       'notEmpty' => array(
+                               'rule' => array('notEmpty'),
+                       ),
+               ),
+               'value' => array(
+                       'notEmpty' => array(
+                               'rule' => array('notEmpty'),
+                       ),
+               ),
+               'date' => array(
+                       'date' => array(
+                               'rule' => array('date'),
+                       ),
+                       'onlyFuture' => array(
+                               'rule' => array('onlyFuture'),
+                               'on' => 'create',
+                       ),
+               ),
+               'end_date' => array(
+                       'date' => array(
+                               'rule' => array('date'),
+                       ),
+               ),
+       );
+
+       function afterSave($created) {
+               $this->deleteCache4News();
+
+               return parent::afterSave($created);
+       }
+       function afterDelete() {
+               $this->deleteCache4News();
+
+               return parent::afterDelete();
+       }
+
+       /* キャッシュ削除 */
+       function deleteCache4News($news_id = null)
+       {
+               clearCache('_news.php', 'views', '');
+               clearCache('_news_index');
+               if ($news_id) {
+                       clearCache('_news_view_'.$news_id);
+               }
+
+               // Home
+               @unlink(CACHE.'views'.DS.'element_news_cache_information');
+       }
+
+       /* validate */
+       function onlyFuture($data, $oneday = true)
+       {
+               if (empty($data) || (!isset($data['date']) && !isset($data['datetime']))) {
+                       return false;
+               }
+
+               if (isset($data['date'])) {
+                       $date = $data['date'];
+               } else {
+                       $date = $data['datetime'];
+               }
+
+               // 00:00:00時を基準に判定
+               $today = date('Y-m-d 00:00:00');
+               $today_timestanp = strtotime($today);
+               $data_time = strtotime($date);
+
+               if ($data_time >= $today_timestanp) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+}
diff --git a/app/tests/cases/controllers/news_controller.test.php b/app/tests/cases/controllers/news_controller.test.php
new file mode 100644 (file)
index 0000000..b0e6552
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/* News Test cases generated on: 2010-12-23 20:12:13 : 1293102553*/
+App::import('Controller', 'News');
+
+class TestNewsController extends NewsController {
+       var $autoRender = false;
+
+       function redirect($url, $status = null, $exit = true) {
+               $this->redirectUrl = $url;
+       }
+}
+
+class NewsControllerTestCase extends CakeTestCase {
+       var $fixtures = array('app.news');
+
+       function startTest() {
+               $this->News =& new TestNewsController();
+               $this->News->constructClasses();
+       }
+
+       function endTest() {
+               unset($this->News);
+               ClassRegistry::flush();
+       }
+
+       function testIndex() {
+
+       }
+
+       function testView() {
+
+       }
+
+       function testAdd() {
+
+       }
+
+       function testEdit() {
+
+       }
+
+       function testDelete() {
+
+       }
+
+       function testAdminIndex() {
+
+       }
+
+       function testAdminView() {
+
+       }
+
+       function testAdminAdd() {
+
+       }
+
+       function testAdminEdit() {
+
+       }
+
+       function testAdminDelete() {
+
+       }
+
+}
+?>
\ No newline at end of file
diff --git a/app/tests/cases/models/news.test.php b/app/tests/cases/models/news.test.php
new file mode 100644 (file)
index 0000000..ffd5a79
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/* News Test cases generated on: 2010-12-23 20:12:45 : 1293102525*/
+App::import('Model', 'News');
+
+class NewsTestCase extends CakeTestCase {
+       var $fixtures = array('app.news');
+
+       function startTest() {
+               $this->News =& ClassRegistry::init('News');
+       }
+
+       function endTest() {
+               unset($this->News);
+               ClassRegistry::flush();
+       }
+
+}
+?>
\ No newline at end of file
diff --git a/app/tests/fixtures/news_fixture.php b/app/tests/fixtures/news_fixture.php
new file mode 100644 (file)
index 0000000..6682277
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/* News Fixture generated on: 2010-12-23 20:12:45 : 1293102525 */
+class NewsFixture extends CakeTestFixture {
+       var $name = 'News';
+
+       var $fields = array(
+               'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
+               'title' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 512, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+               'value' => array('type' => 'text', 'null' => false, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+               'date' => array('type' => 'datetime', 'null' => false, 'default' => NULL, 'key' => 'index'),
+               'end_date' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
+               'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
+               'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'news_date' => array('column' => 'date', 'unique' => 0), 'news_public_date_end' => array('column' => array('public_flag', 'date', 'end_date'), 'unique' => 0)),
+               'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+       );
+
+       var $records = array(
+               array(
+                       'id' => 1,
+                       'title' => 'Lorem ipsum dolor sit amet',
+                       'value' => '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.',
+                       'date' => '2010-12-23 20:08:45',
+                       'end_date' => '2010-12-23 20:08:45',
+                       'modified' => '2010-12-23 20:08:45'
+               ),
+       );
+}
+?>
\ No newline at end of file
index bc009b6..37aa1ba 100644 (file)
@@ -3,7 +3,7 @@ echo $this->element(
        'character_index',
        array(
                'character' => $characters,
-               'isOwner' => $isOwner,
+               'isOwner' => true,
                'isAdmin' => false,
                'cache' => array(
                        'time' => time() + Configure::read('Cache.expireShort'),
index a0f0a09..18194fd 100644 (file)
@@ -1,5 +1,11 @@
-<?php 
+<?php
+if (empty($site_configs['Site.myHome']['value']) && !empty($isOwner)) {
+       echo $this->element('information', array(
+               'cache' => time() + Configure::read('Cache.expireLong'),
+       ));
+}
 ?>
+
 <div class="characters listview">
 <div class="box full">
 <div class="boxHeader"><h2><span>
index 3a7de51..0ffe8a7 100644 (file)
@@ -6,6 +6,15 @@ echo $this->element('insert_html', array(
 ));
 ?>
 
+<?php
+if (isset($news)) {
+       echo $this->element('information', array(
+               'news' => $news,
+               'cache' => time() + Configure::read('Cache.expireLong'),
+       ));
+}
+?>
+
 <?php 
        $add_url = $html->link(__('New Character', true), array('controller' => 'characters', 'action' => 'add'));
  ?>
diff --git a/app/views/elements/information.ctp b/app/views/elements/information.ctp
new file mode 100644 (file)
index 0000000..d34b6f7
--- /dev/null
@@ -0,0 +1,31 @@
+<?php if (isset($news) && !empty($news)): ?>
+<div class="news">
+<div class="SimpleBox" id="Infomation_homeNews">
+<ul class="information">
+<?php
+foreach ($news as $v) {
+       echo $html->tag('li', sprintf(
+               '%s %s',
+               $v['News']['date'],
+               $html->link($v['News']['title'], array(
+                       'controller' => 'news',
+                       'action' => 'view',
+                       $v['News']['id'],
+               ), array(
+                       'escape' => false,
+               ))
+       ));
+}
+?>
+</ul>
+<div style="text-align: right; margin-right:10px;">
+<?php
+echo  $html->link(__(' ...More', true), array(
+       'controller' => 'news',
+       'action' => 'index',
+));
+?>
+</div>
+</div>
+</div>
+<?php endif ?>
diff --git a/app/views/elements/sidenav_admin_news.ctp b/app/views/elements/sidenav_admin_news.ctp
new file mode 100644 (file)
index 0000000..427ab15
--- /dev/null
@@ -0,0 +1,6 @@
+<ul>
+
+<li><?php echo $html->link(__('News List', true), array('controller' => 'news', 'action' => 'index'));?></li>
+
+<li><?php echo $html->link(__('Add News', true), array('controller' => 'news', 'action' => 'add')); ?></li>
+</ul>
diff --git a/app/views/elements/sidenav_user.ctp b/app/views/elements/sidenav_user.ctp
new file mode 100644 (file)
index 0000000..5107d59
--- /dev/null
@@ -0,0 +1,3 @@
+<ul>
+       <li><?php echo $html->link(__('Users List', true), array('controller' => 'users', 'action' => 'listview')); ?> </li>
+</ul>
index 7371380..0a3f916 100644 (file)
@@ -102,6 +102,10 @@ echo $this->element('sidenav_admin_user', array(
 </li>
 
 <li>
+<?php echo $html->link(__('News', true), array('controller' => 'news', 'action' => 'index')); ?>
+</li>
+
+<li>
 <?php echo $html->link(__('Site Settings', true), array('controller' => 'site_configs', 'action' => 'edit')); ?>
 </li>
 
@@ -158,6 +162,9 @@ switch ($this->params["controller"]) {
                                break;
                }
                break;
+       case 'news':
+               echo $this->element('sidenav_admin_news', array());
+               break;
        default:
                echo null;
                break;
diff --git a/app/views/news/admin_add.ctp b/app/views/news/admin_add.ctp
new file mode 100644 (file)
index 0000000..efa3837
--- /dev/null
@@ -0,0 +1,53 @@
+<div class="news form">
+<?php echo $this->Form->create('News');?>
+<fieldset>
+<legend><?php __('Add News'); ?></legend>
+<?php
+       echo $form->input('title', array(
+               'maxLength' => 512,
+               'class' => 'longInput',
+       ));
+       echo $form->input('value', array(
+               'label' => __('Detail', true),
+               'class' => 'InformationInput',
+       ));
+       echo $select->create_publicflag_select($public_flags, 'public_flag', array(
+               'label' => __('Public Flag', true),
+               'default' => 'private',
+       ));
+       echo $form->input('date', array(
+               'label' => __('Released', true),
+               'default' => time(),
+               'dateFormat' => 'YMD',
+               'timeFormat' => 24,
+               'minYear' => date('Y'),
+               'maxYear' => date('Y')+1,
+               'separator' => '/',
+               'monthNames' => false,
+       ));
+       echo $form->input('end_date', array(
+               'label' => __('End Date as the Home News', true),
+               'default' => time() + 60*60*24*365,
+               'dateFormat' => 'YMD',
+               'minYear' => date('Y')-1,
+               'maxYear' => date('Y')+10,
+               'separator' => '/',
+               'monthNames' => false,
+       ));
+?>
+</fieldset>
+<?php echo $token->create(); ?>
+<?php echo $this->Form->end(__('Submit', true));?>
+</div>
+
+
+<div class="backButton">
+<?php
+echo $form->create('', array('url' => array(
+       'action' => 'index'),
+       'type' => 'GET',
+       'id' => 'CancelButton'
+));
+echo $form->end(array('label' => __('Cancel', true)));
+?>
+</div>
diff --git a/app/views/news/admin_edit.ctp b/app/views/news/admin_edit.ctp
new file mode 100644 (file)
index 0000000..7496521
--- /dev/null
@@ -0,0 +1,49 @@
+<div class="news form">
+<?php echo $this->Form->create('News');?>
+<fieldset>
+<legend><?php __('Edit News'); ?></legend>
+<?php
+       echo $form->input('title', array(
+               'maxLength' => 512,
+               'class' => 'longInput',
+       ));
+       echo $form->input('value', array(
+               'label' => __('Detail', true),
+               'class' => 'InformationInput',
+       ));
+       echo $select->create_publicflag_select($public_flags, 'public_flag', array(
+               'label' => __('Public Flag', true),
+               'default' => 'private',
+       ));
+       echo $form->input('date', array(
+               'label' => __('Released', true),
+               'dateFormat' => 'YMD',
+               'minYear' => date('Y'),
+               'maxYear' => date('Y')+1,
+               'separator' => '/',
+               'monthNames' => false,
+       ));
+       echo $form->input('end_date', array(
+               'label' => __('End Date as the Home News', true),
+               'dateFormat' => 'YMD',
+               'minYear' => date('Y')-1,
+               'maxYear' => date('Y')+10,
+               'separator' => '/',
+               'monthNames' => false,
+       ));
+?>
+</fieldset>
+<?php echo $token->create(); ?>
+<?php echo $this->Form->end(__('Submit', true));?>
+</div>
+
+<div class="backButton">
+<?php
+echo $form->create('', array('url' => array(
+       'action' => 'view', $this->data['News']['id']),
+       'type' => 'GET',
+       'id' => 'CancelButton'
+));
+echo $form->end(array('label' => __('Cancel', true)));
+?>
+</div>
diff --git a/app/views/news/admin_index.ctp b/app/views/news/admin_index.ctp
new file mode 100644 (file)
index 0000000..45313ff
--- /dev/null
@@ -0,0 +1,68 @@
+<div class="news listview">
+
+<div class="box full">
+<div class="boxHeader"><h2><span><?php __('News');?></h2></span></div>
+<div class="boxBody">
+
+<p>
+<?php
+echo $this->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 $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
+ |     <?php echo $this->Paginator->numbers();?>
+ |
+       <?php echo $this->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(__('Released' ,true), 'date');?></th>
+       <th><?php echo $paginatorEx->sortAllow('title');?></th>
+       <th><?php echo $paginatorEx->sortAllow('public_flag');?></th>
+       <th><?php echo $paginatorEx->sortAllow(__('End Date as the Home News' ,true), 'end_date');?></th>
+       <th><?php echo $paginatorEx->sortAllow('modified');?></th>
+</tr>
+<?php
+$i = 0;
+foreach ($news as $news):
+       $class = null;
+       if ($i++ % 2 == 0) {
+               $class = ' class="altrow"';
+       }
+?>
+<tr<?php echo $class;?>>
+       <td rowspan="2"><?php echo $news['News']['id']; ?></td>
+       <td><?php echo $news['News']['date']; ?></td>
+       <td><?php echo $news['News']['title']; ?></td>
+       <td><?php echo $select->get_i18n_public_flag($news['News']['public_flag'], $public_flags); ?></td>
+       <td><?php echo $news['News']['end_date']; ?></td>
+       <td><?php echo $news['News']['modified']; ?></td>
+</tr>
+<tr>
+       <td colspan="5">
+               <div><?php echo nl2br($news['News']['value']); ?></div>
+               <div class="actions">
+                       <?php echo $this->Html->link(__('Edit', true), array('action' => 'edit', $news['News']['id'])); ?>
+                       <?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $news['News']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $news['News']['id'])); ?>
+               </div>
+       </td>
+</tr>
+<?php endforeach; ?>
+</table>
+
+<div class="paging">
+       <?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
+ |     <?php echo $this->Paginator->numbers();?>
+ |
+       <?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
+</div>
+
+</div?
\ No newline at end of file
diff --git a/app/views/news/index.ctp b/app/views/news/index.ctp
new file mode 100644 (file)
index 0000000..502eb05
--- /dev/null
@@ -0,0 +1,63 @@
+<div class="news listview">
+
+<div class="box full">
+<div class="boxHeader"><h2><span><?php __('News');?></h2></span></div>
+<div class="boxBody">
+
+<p>
+<?php
+echo $this->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 $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
+ |     <?php echo $this->Paginator->numbers();?>
+ |
+       <?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
+<?php
+$i = 0;
+foreach ($news as $news):
+       $class = null;
+       if ($i++ % 2 == 0) {
+               $class = ' class="altrow"';
+       }
+?>
+
+<div class="SimpleBox" id="Infomation_index">
+<div class="innerBox">
+<div class="box full">
+
+<div class="boxHeader"><h3>
+       <?php echo $news['News']['date']; ?> <?php echo $news['News']['title']; ?>
+       <span><?php __('End Date as the Home News') ?> : <?php echo $news['News']['end_date']; ?></span>
+</h3></div>
+
+<div class="boxBody">
+       <div class="infoBody">
+               <?php echo nl2br($news['News']['value']); ?>
+       </div>
+
+       <div class="infoModified">
+               (<?php __('Modified') ?>:<?php echo $time->niceshort($news['News']['modified']); ?>)
+       </div>
+
+</div>
+</div>
+</div>
+</div>
+
+<?php endforeach; ?>
+
+<div class="paging">
+<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
+ | <?php echo $this->Paginator->numbers();?> |
+<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
+</div>
+
+</div>
+</div>
\ No newline at end of file
index b5027bd..c95e52e 100644 (file)
@@ -700,11 +700,21 @@ ul.noticeList li {
        font-size: 16px;
 }
 
-/* ユーザ情報 */
-div.UserAgent,
-div.Host {
+/* お知らせ */
+ul.information li {
+       display: list-item;
+       margin-left: 10px;
+}
+ul.information li span {
+       margin-right: 10px;
+}
+.infoBody {
+       font-size: 130%;
+       padding: 15px 10px;
+}
+.infoModified {
        font-size: 80%;
-       text-align: right;
        color: #999;
+       text-align: left;
 }
-
+}
\ No newline at end of file
index 960d17c..206dfd5 100644 (file)
@@ -454,7 +454,8 @@ div.characterProfileArchives .boxBody {
 /* SimpleBox */
 .SimpleBox {
        padding: 10px;
-       margin-top: 15px;
+       margin-top: 3px;
+       margin-right: 25px;
        background:#e6e49f;
        background: -webkit-gradient(linear, left top, left bottom, from(#f1f1d4), to(#e6e49f));
        background-image: -moz-linear-gradient(top, #f1f1d4, #e6e49f);
@@ -475,6 +476,11 @@ div.characterProfileArchives .boxBody {
        border-radius:8px;
        text-decoration:none;
 }
+div.news .SimpleBox {
+       margin-top: 0px;
+       margin-bottom: 10px;
+}
+
 .SimpleBox ul li {
        list-style: disc inside none;
 }