<? global $vis_language; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6">
      <h3 class="m-b-xs text-black"><? echo $operation['view_title'];?></h3>
      <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
         <li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
         <li><a class="link" href="#/selfhelp/view_selfhelp/<? echo $vis_language['TXTSELFHELP']; ?>"><? echo $vis_language['TXTSELFHELP']; ?></a></li>
         <li> <a href="#/selfhelp/view_articles/<? echo $vis_language['TXTARTICLES']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTARTICLES']; ?>',{'vis_module':'selfhelp','vis_operation':'view_articles'});" class="link"><? echo $operation['view_title']; ?></a></li>
         <li class="active"> <? echo (strlen($article['article_title'])>25)?substr($article['article_title'],0,25).".....":$article['article_title']; ?></li>
      </ul>
   </div>
</section>
<section class="padder">
   <section class="panel panel-default">
	   <div class="wrapper-sm">
	   <div class="btn-group pull-right">
	   <button class="btn bg-empty btn-sm dropdown-toggle action_btn pull-right" data-toggle="dropdown">
	   <i class="vh vh-action"></i> <span class="caret"></span>
	   </button>
	   <ul class="dropdown-menu">
	   <li><a href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTARTICLES']; ?>',{'vis_module':'selfhelp','vis_operation':'edit_article','vis_article_id':'<? echo $article['article_id']; ?>','vis_action':'<? echo $operation['vis_action']; ?>'});"><? echo $vis_language['TXTEDIT']; ?></a>
	   <li><a href="javascript:void(0);" data-modal-arguments="vis_module=selfhelp&vis_operation=confirm_delete&vis_static_area=vis_article_delete_confirm&vis_area=1&vis_article_id=<? echo $article['article_id']; ?>" title="<? echo $vis_language['TXTDELETE']; ?>"  data-toggle="ajaxModal"><? echo $vis_language['TXTDELETE']; ?></a>  </li>
	   </ul>
	   </div>
	   <div class="btn-group">
	   <div class="form-group">
	   <h4><? echo $article['article_title']; ?></h4>
	   </div>
	   </div>
	   </div>
		<div class="line line-dashed b-b line-lg pull-in"></div>
	    <div class="wrapper">
			 <div class="btn-group pull-right">
	   <div>
    <span class="m-l-xs pull-right" >
      <span title="Like"><i class="vh vh-thumbs-up fsize-18" ></i> (<? echo $article['art_likes']; ?>)&nbsp;&nbsp;</span>
      <span title="Unlike"><i class="vh vh-thumbs-up fsize-18 vh-rotate-180" ></i> (<? echo abs($article['art_likes'] - $article['like_count']); ?>)</span>
       </span>
			      
        </div>
	   </div>
			<div class="btn-group m-b">
   <? if($authorDetails==null || $authorDetails=='default.jpg'){?>
   <div class="l-avatar m-r">
   <? if($article['author']!='' || $article['author_name']!=''){
				$authorname=(trim($article['author_name'])!='')?$article['author_name']:$article['author'];
$namearr=explode(' ',$authorname);
$fullname='';
if($article['first_name']!=''){ 
$lastname=preg_split('//u', $article['last_name'], -1, PREG_SPLIT_NO_EMPTY); 
$firstname=preg_split('//u', $article['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$fullname=ucfirst($firstname[0]).ucfirst($lastname[0]);
}else{
	$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
	$fullname=ucfirst($firstname[0]);
}
				?>
    <div class="md"><?=$fullname;?></div>
    <? }else{ ?>
    <img class="md img-circle" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>
				
		    </div>
      <? }else{?>
			<div class="l-avatar m-r">
				<img src="<? echo VIS_PATH_PROFILE.$authorDetails; ?>" class="md img-circle" >
		    </div>
      <? }?>
      
			<!--<a href="#" class="thumb-md m-r">
				<img src="<? //echo VIS_PATH_PROFILE.(($authorDetails==null)?'default.jpg':$authorDetails); ?>"  class="img-circle"/>
            </a>-->
            
              <span class="m-r-md"><? echo $vis_language['TXTPOSTEDBY']; ?>: <a class="text-md link" href="#/home/profile_view/<? echo $vis_language['TXTPROFILE'];?><?= ($article['author_id'] != VIS_STAFF_ID) ? '/'.$article['author_id'] : '';?>"><? echo $authorname;// $article['author']; ?></a></span>
              <span class="m-r-md"><? echo $vis_language['TXTPOSTON']; ?>: <span class="text-muted"><? echo format_datetime($article['entry_date']); ?></span></span>
	   </div>
	    <div class="line line-dashed b-b line-lg pull-in"></div>
       <div class="m">
	   <? echo $vis_language['TXTKEYWORDS'].' :  ';?>
	     <? if($article['article_keywords']){
			 $article['article_keywords'] = trim($article['article_keywords']);
				$keywords = explode(',', $article['article_keywords']);
					for($j=0;$j<count($keywords);$j++){  ?>
			 <div class="btn-group wrapper-xxs" >
			 	<span class="btn btn-xs alert-success"><?php echo $keywords[$j];?></span>
			 </div>
		 <? }}?>
         <div class="wrapper m-b-sm vis_max_img_size" >
         <? echo $article['content']; ?>
            <!-- /.clear -->
             <? if($attachment!=-1): ?>
            <div class="clear">
               <form name="vis_selfhelp_article_form" id="vis_selfhelp_article_form" class="form-horizontal" method="post">
                  <br/>
                  <div class="line line-dashed b-b line-lg pull-in"></div>
                  <br/>
                  <label class="control-label"><i class="vh vh-link"></i> <? echo $vis_language['TXTATTACHMENTS']; ?>:</label>
                  <?	 for($i=0;$i<count($attachment);$i++) {
                     if($attachment[$i]['attachment_id']!='')
                     								echo '<div class="btn-group wrapper-xxs"><label class="btn btn-xs alert-success no-border bg-success-ltest"><a href="?vis_module=export&vis_operation=get_attachment&vis_attachment='.$attachment[$i]['attachment_id'].'">'.addslashes($attachment[$i]['file_name']).' ('.format_size($attachment[$i]['file_size']).')</a></label></div>';
                     							}?>

               </form>
            </div>
            <? endif;?>
            <form name="vis_selfhelp_comment_form" id="vis_selfhelp_comment_form" class="form-horizontal" method="post">
               <input type="hidden" name="vis_action" value="<? echo $operation['vis_action']; ?>" />
               <input type="hidden" name="vis_article_id" value="<? echo $article['article_id']; ?>" />
               <input type="hidden" name="vis_domain_id" value="<? echo $article['domain_id']; ?>" />
               <div class="clear">
                  <br/>
                  <div class="line line-dashed b-b line-lg pull-in"></div>
                  <br/>
                  <section class="chat-list">
                     <article class="chat-item chat-item-c left m-r-xxs">
                     <? if(defined('VIS_STAFF_IMAGE') && VIS_STAFF_IMAGE!='' && VIS_STAFF_IMAGE!='default.jpg'){?>
                     <div class="l-avatar pull-left m-t-lg">
																					<img src="<? echo VIS_PATH_PROFILE; echo VIS_STAFF_IMAGE; ?>" class="sm">
		    															</div>
                     <? }else{
																						
$firstname=preg_split('//u', $staff[0]['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$lastname=preg_split('//u', $staff[0]['last_name'], -1, PREG_SPLIT_NO_EMPTY);
																						?>
                     <div class="l-avatar pull-left m-t-lg">
																					<div class="sm"><? echo ucfirst($firstname[0]).ucfirst($lastname[0]);?></div>
		   																</div>
                     <? }?>
			
                        <!--<a href="#" class="pull-left m-t-lg thumb-sm avatar"><img src="<? //echo VIS_PATH_PROFILE; echo (defined('VIS_STAFF_IMAGE') && VIS_STAFF_IMAGE!='')?VIS_STAFF_IMAGE:'default.jpg'; ?>" /></a>-->
                        
                        <span class="font-bold m-l"><? echo $staff[0]['first_name']." ".$staff[0]['last_name'];  ?></span>
                        <section class="chat-body m-t-xs">
                           <div class="panel bg-light dk text-sm m-b-none">
                              <div class="panel-body">
                                 <span class="arrow left"></span>
                                 <div class="input-group">
                                    <input type="text" class="input-sm form-control input-s-sm" name="vis_selfhelp_comment" placeholder="Type comment here..." onkeydown="if (event.keyCode == 13) return false;">
                                    <div class="input-group-btn">
                                       <button type="button" class="btn btn-sm btn-default" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'selfhelp', 'vis_operation':'set_comment', 'vis_form':'vis_selfhelp_comment_form'})"><? echo $vis_language['TXTADD']; ?></button>
                                    </div>
                                 </div>
                              </div>
                           </div>
                        </section>
                     </article>
                     <?  if($comment!=-1) for($i=0;$i<count($comment);$i++) { ?>
                     <article class="chat-item left">
						 <? if($article['author_id']==VIS_STAFF_ID || $comment[$i]['poster_id']==VIS_STAFF_ID){?>
						<button type="button" title="Delete" class="close pull-right" data-toggle="ajaxModal" data-modal-arguments="vis_module=selfhelp&vis_operation=get_delete_comment&vis_comment_id=<? echo $comment[$i]['comment_id']; ?>&vis_article_id=<?= $comment[$i]['article_id'];?>&vis_static_area=vis_selfhelp_comment_form"><i class="vh vh-cross text-sm"></i></button><? } else {?>
						<a class="close pull-right" id="vis_delete" href="javascript:void(0);" onclick ="delete_comment()" title="<? echo $vis_language['TXTDELETE']; ?>"><i class="vh vh-cross text-sm"></i></a><? } ?>
      <? if($comment[$i]['poster_image']=='' || $comment[$i]['poster_image']=='default.jpg'){
							$authorname=(trim($comment[$i]['postername'])!='')?$comment[$i]['postername']:$comment[$i]['poster_name'];
$namearr=explode(' ',$authorname);
$fullname='';
if($comment[$i]['first_name']!=''){ 
$lastname=preg_split('//u', $comment[$i]['last_name'], -1, PREG_SPLIT_NO_EMPTY); 
$firstname=preg_split('//u', $comment[$i]['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$fullname=ucfirst($firstname[0]).ucfirst($lastname[0]);
}else{
	$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
	$fullname=ucfirst($firstname[0]);
}
							?>
<div class="l-avatar pull-left m-t-lg">
<div class="sm"><? echo $fullname;?></div>
</div>
<? }else{ ?>
<div class="l-avatar pull-left m-t-lg">
<img src="<? echo VIS_PATH_PROFILE.$comment[$i]['poster_image']; ?>" class="sm">
</div>
<? }?>
                       <!-- <a href="#" class="pull-left m-t-lg thumb-sm avatar"><img src="<? //echo VIS_PATH_PROFILE.($comment[$i]['poster_image']==''?'default.jpg':$comment[$i]['poster_image']); ?>" /></a>-->
                        <span class="font-bold m-l"><? echo 	$authorname=(trim($comment[$i]['postername'])!='')?$comment[$i]['postername']:$comment[$i]['poster_name']; ?></span>
                        <small class="text-muted m-l-sm"><? echo format_datetime($comment[$i]['entry_date']); ?></small>
                        <section class="chat-body m-t-xs">
                           <div class="panel bg-light dk text-sm m-b-none">
                              <div class="panel-body">
                                 <span class="arrow left"></span>
                                 <p class="m-b-none"><? echo $comment[$i]['content']; ?></p>
                              </div>
                           </div>
                        </section>
                     </article>
                     <?   } ?>
                  </section>
               </div>
            </form>
         </div>
         <!-- /.wrapper-sm -->
      </div>
   </section>
</section>
<script>
 function delete_comment()
 {
	 $("#vis_global_msg_div").show();
	 document.getElementById("vis_global_msg_div").innerHTML = '<? echo $vis_language['MSGACCSSDND'];?>';
	 setTimeout( function(){ $("#vis_global_msg_div").hide().html(''); }, 10000);
 }
</script>
