@extends('layouts.blogdetaillayout', ['title' => $title.' - MySeaTime', 'desc' => $desc, 'detailurl' => Config::get('site.url')."/blog/detail/".$postslug, 'imageSrc' => $imageSrc, 'keywrds' => $keywrds])
@section('class_act_blogs')
	active
@endsection

@section('content')

<style>
.core { float: left !important; padding: 0 0 0 10px !important; }
.core .core-title A{ color: #31485f;
	    float: left;
	    font-family: "Proxima N W01 Smbd",verdana,sans-serif;
	    font-size: 1.3em;
	    line-height: 28px;
	    transition-duration: 0.5s;
	    width: 100%; }

</style>
<div class="N-blog-detail proxima text-center">
	<div class="g-bdetail-container">
		<?php
			$postId = Common::get_ID_by_slug($postslug);
			// function to see the post category by post id
			$cat_arr		= wp_get_post_categories($postId);
			$category	= "blog";
			$deturls = Config::get('site.url').'/blog/detail/'.$postslug;
			
			// Start the Loop to get post information.
			$the_query = new WP_Query( 'name='.$postslug );
			if ( $the_query->have_posts() ) { 
				while ( $the_query->have_posts() ) {
					$the_query->the_post();
					$detailPostid = get_the_ID();
					$infoStat = Common::get_heart_class_status($detailPostid);   // function to get counter and heart color class
					$class		= $infoStat['type'];
					if($class=='selected'){
						$chked = "like-blog";
					} else {
						$chked = "";
					}
					$counter = Common::get_post_like_counter($detailPostid);

					$post_thumbnail_id	= get_post_thumbnail_id( get_the_ID() );  
					$attachment_array		=	wp_get_attachment_image_src($post_thumbnail_id,'full'); // returns an array 
					$content_post = get_post($post_thumbnail_id);
					$imgrecord = $content_post->post_content;
					$url		= Config::get('site.imag_url')."".Timthumb::link($attachment_array[0], $attachment_array[1],$attachment_array[2]); 
					$content_post = get_post( get_the_ID());
					$content = $content_post->post_content;					
					$imgexist = preg_match('/(<img[^>]+>)/i', $content, $matches);
				?>
				<div class="g-blog_left">
					<div class="g-top-blog">
						<div class="gd-heading">	
							<h1><a href="{{ $deturls }}"><?php the_title(); ?></a></h1>
						</div>
						<div class="g-written-by">
							Written by <a href="javascript:void(0);"><?php echo ucwords(get_the_author()); ?></a> on <font><?php the_time('F j, Y'); ?></font>
						</div>
					</div>
					<div class="g-blog-disp">
						<?php
							if(!count($matches)){ ?>
								<div class="credits-container">
									<img src="<?php echo $url; ?>" alt="<?php the_title(); ?>" border="0" />									
								</div>
							<?php
							}
							the_content();
						?>
					</div>
					<div class="gb-share">
						<h3>Share this:</h3>
						<div class="addthis_inline_share_toolbox_fyl4"></div>
					</div>

					<div class="googlerelatedblog">
						<h2>Related Blogs</h2>
						<ins class="adsbygoogle"
						     style="display:block"
						     data-ad-format="autorelaxed"
						     data-ad-client="ca-pub-5121290036817258"
						     data-ad-slot="6759588128"></ins>
						<script>
						     (adsbygoogle = window.adsbygoogle || []).push({});
						</script>
					</div>

				</div>
			<?php
					$imgURL = get_cupp_meta(get_the_author_meta( 'ID' ), 'thumbnail');  
					$authorname = ucwords(get_the_author());
					if($imgURL) {						
						$url = $imgURL;
						$authorimg = '<img src="'.$url.' " alt="'.$authorname.'"> '; 
					} else {
						$authorimg = get_avatar( get_the_author_meta( 'ID' ), '220' );
					}					

					$authorimg = str_replace(Config::get('site.url'), Config::get('site.cdn_imag_url'), $authorimg);

					$authordetail = get_the_author_meta( 'description' );
				}
			}
		?>
		<div class="right-blog">
			<div class="socialNetwork">
				<div class="networkTitle">
					<h3>Follow us Today on<br> our social network</h3>
				</div>
				<div class="socialNetworkicon">
					<ul>
						<li class="fbnetwork"><a href="https://www.facebook.com/myseatime" target="_blank"></a></li>
						<li class="twitternetwork"><a href="https://www.twitter.com/myseatime" target="_blank"></a></li>
						<li class="innetwork"><a href="https://www.linkedin.com/company-beta/4228096" target="_blank"></a></li>
						<li class="pinnetwork"><a href="https://pinterest.com/myseatime" target="_blank"></a></li>
					</ul>
				</div>
			</div>
			<div class="about-auth">
				<div class="about-user-img">
					<span>
						<?php
							echo $authorimg;
						?>
					</span>
				</div>
				<div class="about-detail">
					<h3>About <?php echo $authorname; ?></h3>
					<p><?php echo $authordetail; ?></p>
				</div>
			</div>
			<!-- google ad-->					
			<ins class="adsbygoogle"
			     style="display:block"
			     data-ad-client="ca-pub-5121290036817258"
			     data-ad-slot="4777411327"
			     data-ad-format="auto"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>
			

			<div class="search-panel">
				<h2>Search Blog</h2>
				<gcse:search></gcse:search>
			</div>
		
			<!-- Blog detail right 2nd ad -->
			<ins class="adsbygoogle"
			     style="display:block"
			     data-ad-client="ca-pub-5121290036817258"
			     data-ad-slot="9814556526"
			     data-ad-format="auto"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>

			
			<div id="sticky-anchor" style="float: left; width: 100%;"></div>
			<div class="myseatime-newsletter" id="sticky" style="float: left; margin: 0 0 38px;">
				<div id="om-uijzqtdpmxepwjzx-holder"></div>
			</div>
		</div>

		

		<div class="comment-panel">
			<!-- start comment section --> 
			<div class="comment-section" id="comments">
				<?php
					$bid['postid'] = $postId;
					$cmnts = Common::getAjaxShowComents($bid);
					$cmntcont = Common::getCommentsCounter($postId);
				?>	
				<h3 class="cmntconter"><font>{{ $cmntcont }}</font> Comments</h3>
				

				<div class="user-comments-main-bg">
					<?php
						if(count($cmnts)){
							foreach($cmnts as $val){ 
								if($val->user_id){
									$userdetail = User::getUserDetailById($val->user_id);										
									$profileimg = $userdetail->profileImage;
									if($profileimg){
										$chkurl = "upload/profile/".$profileimg;			
									} else {
										$chkurl =  asset('assets/images/myseatime/user-dmi.png');
									}
									$usrname = ucfirst($userdetail->firstName)." ".ucfirst($userdetail->lastName);
								} else {
									$chkurl =  asset('assets/images/myseatime/user-dmi.png');
									$usrname = $val->comment_author;
								}
								$userimg = Config::get('site.imag_url')."".Timthumb::link($chkurl, '86', '88');
								$descripton = $val->comment_content;
								$now = date('Y-m-d H:i:s');
								$timedif = customFunctions::activityTimeDisplay($val->comment_date, $now, 'comments');		
								$reply = Common::getCommentReply($val->comment_ID);
								?> 
								<div class="c_content" id="cmntsction_{{ $val->comment_ID }}">
									<div class="b-user-img"><img src="{{ $userimg }}" title="{{ $usrname }}" alt="{{ $usrname }}"></div>
									<div class="user-comment">
										<div class="comments-list main-comment-list">
											<div class="uername">
												<font class='usernmesty'><?php echo $usrname; ?></font>
												<div class="date-blog">
													<span class="cal-icon"></span><font>{{ $timedif }}</font>
												</div>
											</div>
											<div class="comment-discription">
												<p>{{ $val->comment_content }}</p>
											</div>
											<div class="reply-cmnt">
												<a href="javascript:void(0);" class="reply">Reply</a>
											</div>
											<?php
												if(count($reply)){
													foreach($reply as $value){	
														if($value->user_id){
															$userdetail = User::getUserDetailById($value->user_id);
															$profileimg = $userdetail->profileImage;
															if($profileimg){
																$chkurl = "upload/profile/".$profileimg;			
															} else {
																$chkurl =  asset('assets/images/myseatime/user-dmi.png');
															}
															$usrname = ucfirst($userdetail->firstName)." ".ucfirst($userdetail->lastName);
														} else {
															$chkurl =  asset('assets/images/myseatime/user-dmi.png');
															$usrname = $value->comment_author;
														}
														$userimg = Config::get('site.imag_url')."".Timthumb::link($chkurl, '87', '86');
														$descripton = $value->comment_content;
														$timedif = customFunctions::activityTimeDisplay($value->comment_date, $now, 'comments');
													?>
													<div class="c_content sub-comment">
														<div class="b-user-img">
															<img src="{{ $userimg }}" title="{{ $usrname }}" alt="{{ $usrname }}">
														</div>
														<div class="user-comment">
															<div class="comments-list">
																<div class="uername">
																	<font class='usernmesty'><?php echo $usrname; ?></font>
																	<div class="date-blog">
																		<span class="cal-icon"></span><font>{{ $timedif }}</font>
																	</div>
																</div>
																<div class="comment-discription">
																	<p>{{ $descripton }}</p>
																</div>
																<div class="reply-cmnt">
																	<a class="reply" href="javascript:void(0);">Reply</a>
																</div>
															</div>
														</div>
													</div>
													<?php
													}
												}
											?>
										</div>
									</div>
									
									<?php if(Auth::check()){ ?>
										<div class="field-comments leave-comment-blog blog-in-comment">
											<div class="row">
												{{ Form::open(array('class'=>'form doreply')) }}
													<div class="fields-set">																
														<div class="col-md-12 textarea">
															<textarea name="content" class="cmnt_reply revcmnt" placeholder="Comment*"></textarea>
														</div>
													</div>
													<div class="col-md-12">
														<div class="m_save_result">
															<a href="javascript:void(0);" class="m_save_btn docmntrply">submit</a>
															<a href="javascript:void(0);" class="m_cancel_btn">Cancel</a>
															<input type="hidden" name="postid" class="getpostid" value="{{ $postId }}">	
															<input type="hidden" name="commentid" class="getcomentid" value="{{ $val->comment_ID }}"><input type="hidden" name="reply_name"  class="reply_nme" value="{{ Auth::user()->firstName }}">
															<input type="hidden" name="reply_email"  class="reply_emal" value="{{ Auth::user()->email}}">		
														</div>
													</div>			
													<div class="showloader"></div>
												{{ Form::close() }}
											</div>
										</div>		
									<?php } else { ?>
										<div class="field-comments leave-comment-blog blog-in-comment">
											<div class="row">
												{{ Form::open(array('class'=>'form doreply')) }}
													<div class="fields-set">
														<div class="col-md-6 col-sm-6">													
															<input type="text" name="reply_name" class="reply_nme revcmnt" placeholder="Name*">												
														</div>
														<div class="col-md-6 col-sm-6">													
															<input type="email" name="reply_email" class="reply_emal revcmnt" placeholder="Email*">												
														</div>
														<div class="col-md-12 textarea">
															<textarea name="content" class="cmnt_reply revcmnt" placeholder="Comment*"></textarea>
														</div>
													</div>
													<div class="col-md-12">
														<div class="m_save_result">
															<a href="javascript:void(0);" class="m_save_btn docmntrply">submit</a>
															<a href="javascript:void(0);" class="m_cancel_btn">Cancel</a>
															<input type="hidden" name="postid" class="getpostid" value="{{ $postId }}">	
															<input type="hidden" name="commentid" class="getcomentid" value="{{ $val->comment_ID }}">
														</div>
													</div>
													<div class="showloader"></div>
												{{ Form::close() }}
											</div>
										</div>
									<?php } ?>
								</div>
							<?php
							}
						} else {
							echo "<div class='blg-empty-msg'><strong>Be first to comment on this blog. </strong>We'd love to hear from you! Your comment(s) will appear instantly on the live site. Spam, promotional and derogatory comments will be removed.</div>";
						}
					?>
				</div>
			</div>

			<div class="leave-ur-comment">
				<h2>Leave Comment</h2>
				<div class="field-comments">
					<div class="row leave-comment-blog">
						<?php if(Auth::check()){ ?>
							{{ Form::open(array('class'=>'form doreply')) }}
								<div class="fields-set">											
									<div class="col-md-12 textarea">
										<textarea name="content" class="msgcontent revcmnt" placeholder="Comment*"></textarea>
									</div>
								</div>
								<div class="col-md-12">
									<div class="m_save_result">
										<a href="javascript:void(0);" class="m_save_btn" id="savepostcomment">post comment</a>
										<input type="hidden" name="postid" class="getpostid" value="{{ $postId }}">	
										<input type="hidden" name="name"  class="usr_nme" value="{{ Auth::user()->firstName }}">
										<input type="hidden" name="email"  class="usr_emal" value="{{ Auth::user()->email}}">
									</div>
								</div>
								<div class="showloader"></div>
							{{ Form::close() }}
						<?php } else { ?>
							{{ Form::open(array('class'=>'form doreply')) }}
								<div class="fields-set">
									<div class="col-md-6 col-sm-6">			
										<input type="text" name="name" class="usr_nme revcmnt" placeholder="Name*">
									</div>
									<div class="col-md-6 col-sm-6">													
										<input type="email" name="email" class="usr_emal revcmnt" placeholder="Email*">
									</div>
									<div class="col-md-12 textarea">
										<textarea name="content" class="msgcontent revcmnt" placeholder="Comment*"></textarea>
									</div>
								</div>
								<div class="col-md-12">
									<div class="m_save_result">
										<a href="javascript:void(0);" class="m_save_btn" id="savepostcomment">post comment</a>	
										<input type="hidden" name="postid" class="getpostid" value="{{ $postId }}">												
									</div>
								</div>
								<div class="showloader"></div>
							{{ Form::close() }}
						<?php } ?>
					</div>
				</div>
			</div>
		
		</div>


	</div>
	<div id="sticky-anchor-bottom" style="float: left; width: 100%;"></div>
	<div class="most-viewed">
		<div class="g-bdetail-container">
			<h2>Most Viewed Blogs</h2>
			<div class="blog-detail-row">
				<?php
					global $post;
					$user_id = Auth::id();
					//pagination
					//$currPage is get @PARAM 
					$paged = ($currPage) ? $currPage : 1;
					$args = array(
						'offset'			=> 0,
						'category_name'		=> 'blog',       // Getting blog Category respective post
						'orderby'			=> 'viewCounter',
						'order'				=> 'desc',
						'post_type'			=> 'post',
						'post_status'		=> 'publish', 
						'posts_per_page'   	=> 3,
						'paged'          	=> $paged,
						'page' 				=> $paged
						);
					$query = new WP_Query($args);
					while ( $query->have_posts() ) {
						$query->the_post(); 
						$deturls = Config::get('site.url').'/blog/detail/'.$post->post_name;
						$string = $post->post_content;	
						$attachment_array		= wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID())); 
						$wp_url = $attachment_array[0];
						$url = Config::get('site.cdn_imag_url')."".wp_make_link_relative($wp_url);
						$cmntconter = Common::getCommentsCounter($post->ID);
						?>
						<div class="col-md-4 list-blog-detail">
							<div class="b_listing">
								<div class="blog-img">
									<a href="{{ Config::get('site.url').'/blog/detail/'.$post->post_name }}" class="maritime-img" title="{{ $post->post_title }}">
										<img src="{{ $url }}" alt="{{ $post->post_title }}" title="{{ $post->post_title }}">
									</a>
								</div>
								<div class="blog-listing-content">
									<a href="{{ Config::get('site.url').'/blog/detail/'.$post->post_name }}" class="maritime-text">{{ $post->post_title }}</a>
								</div>
								<div class="date-section-blog">	
									<div class="date-blog">
										<span class="cal-icon"></span><font><?php echo date('j F, Y', strtotime($post->post_date));  ?></font>
									</div>
									<div class="comment-blog">
										<a href="javascript:void(0);"><span></span><font>{{ $cmntconter > 1 ? $cmntconter." comments" : $cmntconter." comment" }} </font></a>
									</div>
								</div>
							</div>
						</div>		
					<?php
					}
				?>				
			</div>
		</div>
	</div>
	<input type="hidden" name="postid" class="getpostid" value="{{ $postId }}">
	@include('partials.homefooterNew')
</div>

<div id="myseatime_loader" style="display: none;">
	<div class="double">
	 <span class="ouro ouro3">
		<span class="left"><span class="anim"></span></span>
		<span class="right"><span class="anim"></span></span>
	  </span>
	</div>
</div>
@stop

@section('addthisscript')
	
@stop