echo render('_parts/member_contents_box', array('member' => $thread->member, 'model' => 'thread', 'id' => $id, 'size' => 'M', 'public_flag' => $thread->public_flag, 'public_flag_option_type' => 'public', 'date' => array('datetime' => $thread->sort_datetime))); $dropdown_btn_group_attr = array('id' => 'btn_dropdown_' . $id, 'class' => array('dropdown', 'boxBtn')); $dropdown_btn_attr = array('class' => 'js-dropdown_content_menu', 'data-uri' => sprintf('thread/api/menu/%d.html', $id), 'data-member_id' => $thread->member_id, 'data-menu' => '#menu_' . $thread->id, 'data-loaded' => 0); $menus = array(array('icon_term' => 'site.show_detail', 'href' => 'thread/' . $id)); echo btn_dropdown('noterm.dropdown', $menus, false, 'xs', null, true, $dropdown_btn_group_attr, $dropdown_btn_attr, false); ?> </div><!-- list_subtitle --> </div><!-- header --> <div class="body"> <?php echo convert_body($thread->body, array('truncate_line' => conf('view_params_default.list.truncate_lines.body'), 'read_more_uri' => 'thread/' . $id)); ?> </div> <?php list($images, $count) = \Thread\Model_ThreadImage::get4thread_id($id, 3, true); if ($images) { echo render('_parts/thumbnails', array('is_display_name' => true, 'images' => array('list' => $images, 'file_cate' => 't', 'size' => 'M', 'column_count' => 3, 'parent_page_uri' => 'thread/' . $id, 'count_all' => $count))); } ?> <?php // thread_comment list($comments, $comment_next_id, $all_comment_count) = \Thread\Model_ThreadComment::get_list(array('thread_id' => $id), conf('view_params_default.list.comment.limit'), true, false, 0, 0, null, false, true); ?> <div class="comment_info"> <?php // comment_count_and_link $link_comment_attr = array('id' => 'link_show_comment_form_' . $id, 'class' => 'js-display_parts link_show_comment_' . $id, 'data-target_id' => 'commentPostBox_' . $id, 'data-hide_selector' => '.link_show_comment_' . $id, 'data-focus_selector' => '#textarea_comment_' . $id); echo render('_parts/comment/count_and_link_display', array('id' => $id, 'count' => $all_comment_count, 'link_attr' => $link_comment_attr));
public static function get_timeline_images($type, $foreign_id, $timeline_id = null, $access_from = null, $is_detail = false) { // defaults $images = array(); $images['file_cate'] = 'ai'; $images['size'] = 'N_M'; $images['column_count'] = 3; switch ($type) { case \Config::get('timeline.types.album_image_profile'): $images['list'] = array(); if ($list = \Album\Model_AlbumImage::check_authority($foreign_id)) { $images['list'][] = $list; $images['column_count'] = 2; } break; case \Config::get('timeline.types.profile_image'): $images['list'] = array(); if ($list = \Model_File::find($foreign_id)) { $images['list'][] = $list; $images['file_cate'] = 'm'; $images['size'] = 'LL'; $images['column_count'] = 2; } break; case \Config::get('timeline.types.note'): list($images['list'], $images['count_all']) = \Note\Model_NoteAlbumImage::get_album_image4note_id($foreign_id, $is_detail ? 0 : \Config::get('timeline.articles.thumbnail.limit.default'), array('id' => 'asc'), true); $images['parent_page_uri'] = 'note/' . $foreign_id; break; case \Config::get('timeline.types.thread'): list($images['list'], $images['count_all']) = \Thread\Model_ThreadImage::get4thread_id($foreign_id, 3, true); $images['file_cate'] = 't'; $images['size'] = 'M'; $images['column_count'] = 3; $images['parent_page_uri'] = 'thread/' . $foreign_id; break; case \Config::get('timeline.types.album'): case \Config::get('timeline.types.album_image'): $images['list'] = array(); $images['count'] = 0; if ($album_image_ids = Model_TimelineChildData::get_foreign_ids4timeline_id($timeline_id)) { list($images['list'], $images['count']) = \Album\Model_AlbumImage::get_list_and_count(array('where' => \Site_Model::get_where_public_flag4access_from($access_from, array(array('id', 'in', $album_image_ids))), $is_detail ? 0 : 'limit' => \Config::get('timeline.articles.thumbnail.limit.default'), 'order_by' => array('created_at' => 'asc'))); } $images['count_all'] = \Album\Model_AlbumImage::get_list_count(array('where' => \Site_Model::get_where_public_flag4access_from($access_from, array(array('album_id', $foreign_id))))); $images['parent_page_uri'] = 'album/' . $foreign_id; break; case \Config::get('timeline.types.album_image_timeline'): list($images['list'], $images['count']) = \Album\Model_AlbumImage::get_list_and_count(array('where' => \Site_Model::get_where_public_flag4access_from($access_from, array(array('id', 'in', Model_TimelineChildData::get_foreign_ids4timeline_id($timeline_id)))), $is_detail ? 0 : 'limit' => \Config::get('timeline.articles.thumbnail.limit.album_image_timeline'), 'order_by' => array('created_at' => 'asc'))); $images['count_all'] = $images['count']; $images['parent_page_uri'] = 'timeline/' . $timeline_id; break; default: break; } return $images; }
/** * Thread edit * * @access public * @params integer * @return Response */ public function action_edit($id = null) { $thread = Model_Thread::check_authority($id, $this->u->id); $val = self::get_validation_object($thread, true); $thread_images = \Thread\Model_ThreadImage::get4thread_id($thread->id); $images = \Site_Upload::get_file_objects($thread_images, $thread->id); $image_tmps = array(); if (\Input::method() == 'POST') { \Util_security::check_csrf(); $moved_images = array(); $news_image_ids = array(); $error_message = ''; try { $image_tmps = \Site_FileTmp::get_file_tmps_and_check_filesize($this->u->id, $this->u->filesize_total); if (!$val->run()) { throw new \FuelException($val->show_errors()); } $post = $val->validated(); \DB::start_transaction(); $thread->save_with_relations($this->u->id, $post); list($moved_images, $thread_image_ids) = \Site_FileTmp::save_images($image_tmps, $thread->id, 'thread_id', 'thread_image'); \Site_Upload::update_image_objs4file_objects($thread_images, $images); \DB::commit_transaction(); // thumbnail 作成 & tmp_file thumbnail 削除 \Site_FileTmp::make_and_remove_thumbnails($moved_images); $message = sprintf('%sを%sしました。', term('thread'), term('form.edit')); \Session::set_flash('message', $message); \Response::redirect('thread/detail/' . $thread->id); } catch (\Database_Exception $e) { $error_message = \Site_Controller::get_error_message($e, true); } catch (\FuelException $e) { $error_message = $e->getMessage(); } if ($error_message) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } if ($moved_images) { \Site_FileTmp::move_files_to_tmp_dir($moved_images); } $image_tmps = \Site_FileTmp::get_file_objects($image_tmps, $this->u->id); \Session::set_flash('error', $error_message); } } $images = array_merge($images, $image_tmps); $this->set_title_and_breadcrumbs(sprintf('%sを%s', term('thread'), term('form.do_edit')), array('/thread/' . $id => $thread->title), null, 'thread'); $this->template->post_header = \View::forge('_parts/form_header'); $this->template->post_footer = \View::forge('_parts/form_footer'); $this->template->content = \View::forge('_parts/form', array('val' => $val, 'thread' => $thread, 'is_edit' => true, 'images' => $images)); }