<?php
    $userPresenter = $postUserPresenter ?? $post->user->present();
    $postPresenter = $postPresenter ?? $post->present();
    $postUrl = $postPresenter->url();
    $canDeletePost = $postPresenter->canDelete();
    $themeAsset = $themeAsset ?? Theme::asset();

    $authId = \Auth::id();
    $isAuthed = (bool) $authId;
    $isPostOwner = ($isAuthed && (int) $authId === (int) $post->user->id);

    $community = $post->community;
    $isCommunityOwner = ($community && $isAuthed && (int) $community->user_id === (int) $authId);
    $userLink=$userPresenter->url();
	/*$profileUrl=$post->present()->                                         <li><a href="{{$post->present()->url()}}/whitepaper">{{trans('post.set-post-as-white-paper')}}</a> </li>
                                         
                                        <li><a class="transfer-my-post" data-id="{{$post->id}}" data-url="{{url('/')}}/c/{{$post->community_id}}/transferpost/{{$post->id}}">Transfer Post</a> </li>serCommunityMember($post->user_id,$post->community_id);
	if($post->user_id!=$post->community->user_id){
		if($profileUrl){
			$userLink=$profileUrl;	
		}
	}*/
	
	/*$resumeData=$post->user->present()->isResumeCreated($post->user->id);
	if($resumeData){
		$userLink = \URL::to('ip/')."/".$resumeData->slug;
	}*/
	
	$eventViewData='';
	if($post->content_type =="event"){
        \App\Performance\PerfMarks::start('post/header:community:event');
        $event=$postPresenter->getEvent();
        \App\Performance\PerfMarks::stop('post/header:community:event');
		$eventViewData=$event;
		if($event and $event->link_profile_name_to_url==0){
			$userLink="";
		}
	}
?>

<div class="post-header clearfix">
            <div class="header-object">
                <a data-url="{{$userPresenter->popoverUrl()}}" href="{{$userLink}}">
                    @php(\App\Performance\PerfMarks::start('post/header:community:avatar'))
                    <img class="lazy" data-original="{{$userPresenter->getAvatar(100)}}" alt="profile image"/>
					@php(\App\Performance\PerfMarks::stop('post/header:community:avatar'))
				</a>
            </div>
            <div class="header-body">
                <h3 class="title">

                   @if($userLink=="#") Contributed by {{$post->user->fullname}} <span>{{($post->shared) ? 'shared a post' : null}}</span> @else <a data-ajaxify="true" href="{{$userLink}}">{{$post->user->fullname}}</a> <span>{{($post->shared) ? 'shared a post' : null}}</span> @endif
                  	
                    @if($userLink!="#")
                        @php(\App\Performance\PerfMarks::start('post/header:community:verified'))
                        {!! Theme::section('user.verified', [
                            'user' => $post->user,
                            'accessCommunityId' => $accessCommunityId,
                            'accessCategoryId' => $accessCategoryId,
                            'themeAsset' => $themeAsset,
                            'userPresenter' => $userPresenter,
                            'communityId' => $accessCommunityId,
                        ]) !!} 
						@php(\App\Performance\PerfMarks::stop('post/header:community:verified'))
					@endif
                    	
                       <?php /* @if(Request::segment(1) != 'community' and $post->community)
                            <i class="icon ion-ios7-arrow-thin-right"></i> <a data-ajaxify="true" style="color:#0fb492" href="{{$post->community->present()->url()}}">{{$post->community->title}}</a>
                        @endif */?>

                </h3>
                               
                <span class="scheduled-title" id="post-scheduled-details{{$post->id}}"> 
                    @php(\App\Performance\PerfMarks::start('post/header:community:scheduled'))
                	{!! Theme::section('post.scheduled', ['post' => $post]) !!} 
                    @php(\App\Performance\PerfMarks::stop('post/header:community:scheduled'))
				</span>

                @php(\App\Performance\PerfMarks::start('post/header:community:extend'))
                {!! Theme::extend('post-header', ['post' => $post]) !!}
                @php(\App\Performance\PerfMarks::stop('post/header:community:extend'))

                <div class="post-action-dropdown dropdown">
                    <a  data-hover="dropdown" data-toggle="dropdown" class="dropdown-toggle" href=""><i class="icon ion-ios7-arrow-down"></i></a>
					@php(\App\Performance\PerfMarks::start('post/header:community:dropdown'))

                         <ul class="dropdown-menu pull-right">

                                                            @if ($isAuthed)
                             
                                                                 @if (! $isPostOwner)
                                 <li><a data-id="{{$post->id}}" href="" class="hide-post">{{trans('post.dont-want-see')}}</a> </li>
                                 @endif
    
                                                                @if (! $isPostOwner)
                                    <li><a data-location="post" data-userid="{{$post->user->id}}" class="block-user" href="">{{trans('user.block-user')}}</a> </li>
                                @endif
    
                                <li><a href="{{URL::route('report', ['type' => 'post'])}}?url={{$postUrl}}">{{trans('post.report-post')}}</a> </li>
                                <!-- <li class="viewpost"><a href="{{route('post-page', ['id' => $post->id])}}">{{trans('post.view-post')}}</a> </li>-->
                                
                               <?php /*?> @if($post->community_id==getVisitingCommunityId())<?php */?>
                               
                               @if(($accessCommunityId!="" and $post->community_id==$accessCommunityId) || $accessCommunityId=="")
                                    @if ($canDeletePost)
                                        <li><a href="" data-id="{{$post->id}}" class="edit-post-trigger">{{trans('post.edit')}}</a> </li>
                                        <li><a data-id="{{$post->id}}" class="delete-post" data-message="{{trans('post.delete-post-confirm')}}" href="">{{trans('post.remove-post')}}</a> </li>
                                        @if($post->content_type == 'image')
                                            <li><a data-id="{{$post->id}}" class="add-image-to-post">{{trans('post.add-more-images')}}</a> </li>
                                        @endif
                                    
                                        @if(!empty($post->video_path))
                                            <li style=""><a data-id="{{$post->id}}" class="add-video-thumbnail-to-post">Add/Edit a video thumbnail</a> </li>
                                        @endif
                                        
                                         <li><a href="{{$postUrl}}/whitepaper">{{trans('post.set-post-as-white-paper')}}</a> </li>
                                         
                                        <li><a class="transfer-my-post" data-id="{{$post->id}}" data-url="{{url('/')}}/c/{{$post->community_id}}/transferpost/{{$post->id}}">Transfer Post</a> </li>
                                        
                                    @endif
                                @endif
                             @endif  
                             
                             @if($isAuthed)
                                <?php
                            \App\Performance\PerfMarks::start('post/header:community:dropdown:ownCommunity');
                            $ownCommunityId = Auth::user()->present()->ownCommunityId();
                            \App\Performance\PerfMarks::stop('post/header:community:dropdown:ownCommunity');
								?>
                        @if($ownCommunityId and $isPostOwner and $post->community_id!=$ownCommunityId and $accessCommunityId==$ownCommunityId)
                              	    <li>
                                        <a class="show-on-own-blog-page" data-id="{{$post->id}}" data-value="{{$post->show_on_blog_page}}">
                                        @if($post->show_on_blog_page==1)
                                        	Hide from Blog
                                        @else
                                        	Show On Blog
                                        @endif
                                        </a>
                                    </li>
                                @endif
                             @endif  
							
                            <li class="copy-post-url-menu">
                                <a href="" class="post-url-copy" data-id="{{$post->id}}">
                                        {{trans('post.copy-this-post')}}
                                </a>
                            </li>
                            
                            @if($canDeletePost)
                            	<li class="manage-seo-contents">
                                    <a href="" class="add-seo-contents" data-id="{{$post->id}}">
                                          Manage SEO Contents
                                    </a>
                                </li>
                                
                                <li class="view-post-analytic-link">
                                  	<a href="" class="view-post-analytic" data-id="{{$post->id}}">
                                		Post Analytic	
                                    </a>    
                                </li>
                                
                                @if ($isPostOwner)
                                 	@if($post->community and $eventViewData)
                                    	<?php
										
										?>
                                    	<li><a href="{{$post->community->present()->url('eventsemailinvite')}}/{{$eventViewData->id}}/{{$eventViewData->community_id}}">Email Invitation to this Event</a> </li>
                                    @endif    
                                @endif
								
                            @endif
							
                            @if($isCommunityOwner and $post->community->race_community==1)
								<li>
                                    <a href="{{$postUrl}}/setlocation">
										Set Preferred Location
									</a>
								</li>
							@endif
							
                            @if($isCommunityOwner)
								<li>
                                    <a href="{{$postUrl}}/seteventnews/{{$post->community->id}}">
										Set Events for News
									</a>
								</li>
							@endif
                            
                            @php(\App\Performance\PerfMarks::start('post/header:community:dropdown:extend_links'))
                            {!! Theme::extend('post-header-links', ['post' => $post]) !!}
                            @php(\App\Performance\PerfMarks::stop('post/header:community:dropdown:extend_links'))

                            @php(\App\Performance\PerfMarks::start('post/header:community:dropdown:social_share'))
                            {!! Theme::section('post.social-share', ['post' => $post]) !!}
                            @php(\App\Performance\PerfMarks::stop('post/header:community:dropdown:social_share'))
                        </ul>
                </div>
                
                <span style="display:none" id="postUrlToCopy{{$post->id}}">{{$postUrl}}</span>
                <div class="postUrlcopyMessage" id="postUrlcopyMessage{{$post->id}}">{{trans('post.copied')}}</div>
				@php(\App\Performance\PerfMarks::stop('post/header:community:dropdown'))

            </div>
    </div>
