ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 5061


Ignore:
Timestamp:
Jan 28, 2008, 1:27:20 AM (12 years ago)
Author:
ebihara
Message:

#1843:バリデーションのサンプルとしてDiaryモデルの追加

Location:
OpenPNE/branches/prj/framework/cakephp/app
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/prj/framework/cakephp/app/app_controller.php

    r5057 r5061  
    2525            $this->Auth->fields = array('username' => 'pc_address', 'password' => 'password');
    2626            $this->Auth->authenticate = new OpenPNE_Auth();
     27            $auth = $this->Auth->user();
     28            if ($auth) {
     29                $this->you = $this->Member->findById($auth['Secure']['member_id']);
     30            }
    2731        }
    2832
     
    3337    {
    3438        parent::beforeRender();
    35         $auth = $this->Auth->user();
    36         if ($auth) {
    37             $this->you = $this->Member->findById($auth['Secure']['member_id']);
    38         }
    3939        $this->set('u', $this->you);
    4040        $this->set('SNS_NAME', 'OpenPNE 実装サンプル by CakePHP');
  • OpenPNE/branches/prj/framework/cakephp/app/config/sql/convert_openpne2cakepne.sql

    r5039 r5061  
    2828) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    2929
     30DROP TABLE IF EXISTS `diaries`;
     31CREATE TABLE `diaries` (
     32  `id` int(11) NOT NULL auto_increment,
     33  `subject` text NOT NULL,
     34  `body` text NOT NULL,
     35  `member_id` int(11) NOT NULL,
     36  `created` datetime NOT NULL,
     37  `modified` datetime NOT NULL,
     38  PRIMARY KEY  (`id`)
     39) ENGINE=MyISAM DEFAULT CHARSET=utf8;
     40
    3041INSERT INTO `members` (`id`, `nickname`, `birth_year`, `birth_month`, `birth_day`,
    3142`image_filename`, `access_date`, `created`, `modified`)
     
    4152     FROM `c_member_secure`
    4253     ORDER BY `c_member_id`);
     54
     55INSERT INTO `diaries` (`id`, `member_id`, `subject`, `body`, `created`, `modified`)
     56  (SELECT `c_diary_id`, `c_member_id`, `subject`, `body`, `r_datetime`, `u_datetime`
     57     FROM `c_diary`
     58     ORDER BY `c_diary_id`);
  • OpenPNE/branches/prj/framework/cakephp/app/controllers/members_controller.php

    r5057 r5061  
    33{
    44    var $name = 'Members';
    5     var $uses = array('Member', 'Secure');
     5    var $uses = array('Member', 'Secure', 'Diary');
    66
    77    function beforeFilter()
     
    2727    }
    2828
    29     function home()
     29    function home($id = null)
    3030    {
     31        if (is_null($id) || $this->you['Member']['id'] == $id) {
     32            $target_member = $this->you;
     33            $id = $target_member['Member']['id'];
     34        } else {
     35            $target_member = $this->Member->findById($id);
     36            if (empty($target_member)) {
     37                return false;
     38            }
     39        }
     40
     41        $this->pageTitle = $target_member['Member']['nickname'] . 'さんのホーム';
     42
     43        // メンバーの最新日記5件
     44        $member_diary = $this->Diary->findAllByMemberId($id, array('id', 'subject', 'created'), 'Diary.created DESC', 5);
     45
     46        $this->set('target_member', $target_member);
     47        $this->set('member_diary', $member_diary);
    3148    }
    3249}
  • OpenPNE/branches/prj/framework/cakephp/app/views/layouts/default.tpl

    r5057 r5061  
    55<meta http-equiv="Content-Style-Type" content="text/css">
    66<title>({$SNS_NAME}) | ({$title_for_layout})</title>
    7 <link rel="stylesheet" href="./css/default.css" type="text/css">
     7<link rel="stylesheet" href="({$html->url('/css/default.css')})" type="text/css">
    88<style type="text/css">
    99<!--
     
    363363
    364364<tr>
    365 <td class="container main_content" align="center">
     365<td class="container main_content">
    366366<table class="container" border="0" cellspacing="0" cellpadding="0"><tr>
    367367<td class="full_content">
  • OpenPNE/branches/prj/framework/cakephp/app/views/members/home.tpl

    r5046 r5061  
    1 ログイン成功。ようこそ({$u.Member.nickname})さん! ここがあなたのマイホームになります。
     1<h2>({$target_member.Member.nickname})さん()</h2>
     2
     3<h3>■フレンドリスト</h3>
     4
     5<hr>
     6
     7<h3>■最新情報</h3>
     8<h4>マイフレンド最新日記</h4>
     9
     10<hr>
     11<h3>■最新日記・レビュー</h3>
     12<h4>最新日記</h4>
     13<ul>
     14({foreach from=$member_diary item=value})
     15    <li>({$value.Diary.created|date_format:"%Y/%m/%d"})&nbsp;…&nbsp;<a href="({$html->url('/diaries/view/')})({$value.Diary.id})">({$value.Diary.subject})</a></li>
     16({/foreach})
     17</ul>
     18<a href="({$html->url('/diaries/add/')})">→日記を書く</a>
Note: See TracChangeset for help on using the changeset viewer.