Example #1
0
 function getDefaultView()
 {
     $context =& $this->getContext();
     $user = $context->getUser();
     $request = $context->getRequest();
     $acs_user_info_row = $user->getAttribute('acs_user_info_row');
     // 表示対象となるユーザコミュニティIDを取得
     $user_community_id = $request->ACSgetParameter('id');
     // ユーザ情報
     $target_user_info_row = ACSUser::get_user_info_row_by_user_community_id($user_community_id);
     $year = $request->ACSgetParameter('year');
     // 年
     $month = $request->ACSgetParameter('month');
     // 月
     $day = $request->ACSgetParameter('day');
     // 日
     if (checkdate($month, $day, $year)) {
         // 年月日指定
         $diary_row_array = ACSDiary::get_diary_row_array_by_year_month_day($user_community_id, $year, $month, $day);
     } elseif (checkdate($month, 1, $year)) {
         // 年月指定
         $diary_row_array = ACSDiary::get_diary_row_array_by_year_month($user_community_id, $year, $month);
         unset($day);
     } else {
         // 全てのダイアリー
         $diary_row_array = ACSDiary::get_diary_row_array($user_community_id);
         unset($year);
         unset($month);
         unset($day);
     }
     // 公開範囲を最終登録と同じもので表示しておく
     if ($diary_row_array) {
         $last_open_level_code = $diary_row_array[0]['open_level_code'];
     }
     // 信頼済みコミュニティ情報
     foreach ($diary_row_array as $index => $diary_row) {
         if ($diary_row['open_level_name'] == ACSMsg::get_mst('open_level_master', 'D05')) {
             $diary_row_array[$index]['trusted_community_row_array'] = ACSDiary::get_diary_trusted_community_row_array($diary_row['diary_id']);
         }
     }
     // 公開範囲
     $open_level_master_row_array = ACSAccessControl::get_open_level_master_row_array(ACSMsg::get_mst('community_type_master', 'D10'), ACSMsg::get_mst('contents_type_master', 'D21'));
     // マイフレンズグループ
     $friends_group_row_array = ACSUser::get_friends_group_row_array($user_community_id);
     // set
     $request->setAttribute('target_user_info_row', $target_user_info_row);
     $request->setAttribute('diary_row_array', $diary_row_array);
     $request->setAttribute('open_level_master_row_array', $open_level_master_row_array);
     $request->setAttribute('friends_group_row_array', $friends_group_row_array);
     $request->setAttribute('last_open_level_code', $last_open_level_code);
     return View::INPUT;
 }
 /**
  * バックアップコンテンツの作成
  * 
  * @param string $encoding エンコーディング
  */
 function make_contents($encoding = '')
 {
     $diary_row_array = ACSDiary::get_diary_row_array($this->user_community_id);
     // 日記が存在しない場合は何もせず終了
     if (count($diary_row_array) == 0) {
         return;
     }
     // ダイアリフォルダとイメージフォルダの作成
     ACSLib::make_dir($this->diary_dir);
     ACSLib::make_dir($this->img_dir);
     $contents = '';
     $diary_array = array();
     $months_array = array();
     foreach ($diary_row_array as $diary_row) {
         if ($diary_row['delete_flag'] == 'f') {
             // html実態ファイルを作成
             $html_file = $this->create_diary_html($diary_row, $encoding);
             $post_tm = ACSLib::convert_pg_date_to_timestamp($diary_row['post_date']);
             $ym = date("Ym", $post_tm);
             // 年月用フォーマットの生成
             if (!array_key_exists($ym, $months_array)) {
                 $ym_str = ACSMsg::get_mdmsg(__FILE__, 'YEAR_MONTH');
                 $ym_str = str_replace('{YEAR}', date("Y", $post_tm), $ym_str);
                 $ym_str = str_replace('{MONTH}', date("m", $post_tm), $ym_str);
                 $months_array[$ym] = mb_ereg_replace('@MONTHLY_TITLE@', htmlspecialchars($ym_str), _ACSDIARYBACKUP_INDEX_MONTHLY_FORMAT);
             }
             $ymd = ACSLib::convert_pg_date_to_str($diary_row['post_date']);
             // 日記インデックスの生成
             $diary_contents = _ACSDIARYBACKUP_INDEX_DAIRY_FORMAT;
             $diary_contents = mb_ereg_replace('@YMD@', htmlspecialchars($ymd), $diary_contents);
             $diary_contents = mb_ereg_replace('@DIARY_URL@', htmlspecialchars($this->index_to_diary_url . '/' . $html_file), $diary_contents);
             $diary_contents = mb_ereg_replace('@DIARY_SUBJECT@', htmlspecialchars($diary_row['subject']), $diary_contents);
             $diary_array[$ym] .= $diary_contents;
         }
     }
     // index.htmlの生成
     $contents = "";
     foreach ($diary_array as $ym => $diary_contents) {
         $contents .= mb_ereg_replace('@DIARY_CONTENTS@', $diary_contents, $months_array[$ym]);
     }
     $contents = mb_ereg_replace('@CONTENTS@', $contents, _ACSDIARYBACKUP_INDEX_FORMAT);
     // 漢字コードの変換
     if ($encoding != '') {
         $contents = mb_convert_encoding($contents, $encoding);
     }
     // indexファイルの出力
     $fp = fopen($this->contents_dir . '/index.html', "w");
     fputs($fp, $contents);
     fclose($fp);
 }