<?php TPL::output('global/header.tpl.htm'); ?>

  <div class="tny-basic main tny-clear allbg">
    <div class="tny-left lsidebar">
    	
        <!--My Favorites START-->
        <div class="b_restrain">
        	<h4  class="trends-H3 qAll rel content-H3 ">My favorite</h4>
        	
        	<?php if (sizeof($this->favorite_tags) > 0) { ?>
            <div class="sC_collectFloating rel">
            	<span class="sC_all abs">Tags</em></span>
                <p class="sC_list">
                <?php foreach ($this->favorite_tags AS $key => $val) { ?>
                    <span><a href="favorite/tag-<?php echo urlencode($val['title']); ?>" class="glotopic"><?php echo $val['title']; ?></a></span>
                <?php } ?>
                </p>
            </div>
            <?php } ?>
            
            
			<?php if (sizeof ($this->list) > 0) { ?>
			<div id="sC_list">
			<?php foreach ($this->list AS $key => $val) { ?>
			<!--Content Module START-->
			<div class="smodule">
			 <!--User avatar--> 
			  <?php if ($val['anonymous'] == 0) { ?><a class="suser tny-alpHover" href="people/<?php echo $val['user_info']['url_token']; ?>"><img src="<?php echo get_avatar_url($val['user_info']['uid'], 'mid'); ?>" alt="<?php echo $val['user_info']['user_name']; ?>"  class="umsg" data-message="&uid=<?php echo $val['user_info']['uid']; ?>&card=user" /></a><?php } else { ?><a href="javascript:;" class="suser alpHover"><img src="<?php echo GET_STATIC_URL; ?>/common/avatar-mid-img.jpg" alt="Anonymous" title="Anonymous" /></a><?php } ?>
			    
			  <h4><a class="blank_link" href="question/<?php echo $val['question_id']; ?>#reply<?php echo $val['answer_count']; ?>"><?php echo $val['question_content']; ?></a></h4>
			 	
			 	<!-- Reply START-->
				<?php if ($val['associate_action'] == ACTION_LOG::ANSWER_QUESTION OR $val['associate_action'] == ACTION_LOG::ADD_AGREE) { ?>
			    <div class="s-txt rel">
			    	<p class="sendorsepeople tny-gray tny-cl_02 tny-hide"> 
			            <span class="g_txt">Agree from:</span> 
			            <?php if ($val['answer_info']['agree_users']) { ?>
							<?php $count = 0;
							foreach ($val['answer_info']['agree_users'] as $uid => $user) { ?>
								<a href="people/<?php echo $user['url_token']; ?>" data-id="<?php echo $uid;?>" class="a umsg" data-message="&uid=<?php echo $uid;?>&card=user" name="agee_people"><?php echo $user['user_name']; ?></a><?php if (count($val['answer_info']['agree_users'])!= ++$count) { ?><em>, </em><?php } ?>
							<?php } ?>
						<?php } ?>
			           <!-- <a class="v_more " href="javascript:;">More »</a>-->
			        </p>
				    
				   
				      	<div id="detail_<?php echo $val['history_id']; ?>" class="tny-cl_01">
				      		
				      		<p class="s_autograph tny-txtHide"><a href="people/<?php echo $val['answer_info']['url_token']; ?>"><?php echo $val['answer_info']['user_name']; ?></a><?php if ($val['answer_info']['signature']) { ?> - <?php echo $val['answer_info']['signature']; ?><?php } ?></p>
				      		
				      		<div class="tags_Mark tny-cl_01 lineHeight">
				      		<?php echo nl2br(utf8_substr($val['answer_info']['answer_content'], 0, 130, 'UTF-8', '...')); ?>
				      		<?php if (utf8_strlen($val['answer_info']['answer_content']) > 130) { ?>
				        	<a href="javascript:;" class="showMore" onclick="content_switcher($('#detail_<?php echo $val['history_id']; ?>'), $('#detail_more_<?php echo $val['history_id']; ?>'));">Display all »</a>
				        	<?php } ?>
				        	</div>
							<?php if ($val['answer_info']['attachs']) { ?>
								<div class="q_con_imgs tny-alpHover" style="padding-top:6px;">
								  <?php foreach($val['answer_info']['attachs'] AS $t_key => $t_val) { ?>
								  <?php if ($t_val['is_image']): ?>
								  <a href="javascript:;" onclick="content_switcher($('#detail_<?php echo $val['history_id']; ?>'), $('#detail_more_<?php echo $val['history_id']; ?>')); return false;"><img src="<?php echo $t_val[thumb]; ?>" alt="" /></a>
								  <?php else: ?>
								  <p class="questionacc"><a href="<?php echo download_url($t_val['file_name'], $t_val['attachment']); ?>" class="tny-txtHide"><em class="q_ico"></em><?php echo $t_val['file_name']; ?></a></p>
								  <?php endif; ?>
								  <?php } ?>
								</div>
							<?php } ?>
							<!-- Display attachment thumbnail END-->
							
				        </div>
				   
				    <div class="tny-cl_01 " style="display:none" id="detail_more_<?php echo $val['history_id']; ?>">
				    	<?php if ($val['answer_info']['uid'] != $val['user_info']['uid']) { ?>
				    	<p class="s_autograph tny-txtHide"><a href="people/<?php echo $val['answer_info']['url_token']; ?>"><?php echo $val['answer_info']['user_name']; ?></a><?php if ($val['answer_info']['signature']) { ?> - <?php echo $val['answer_info']['signature']; ?><?php } ?></p>
				    	<?php } ?>
				    	<div class="tags_Mark tny-cl_01 lineHeight">
					    <?php echo nl2br($val['answer_info']['answer_content']); ?>
					    
						<!-- Attachments to enlarge(Reply to question) -->
						<?php if ($val['answer_info']['attachs']) { ?>
							<div class="picTrueD">
								<div class="aScue listPicTrueBig">
								<?php foreach($val['answer_info']['attachs'] AS $t_key => $t_val) { ?>
								<?php if ($t_val['is_image']): ?>
								<a href="<?php echo $t_val['attachment']; ?>" target="lightbox" data-fancybox-group="thumb" rel="lightbox"><img src="<?php echo $t_val['attachment']; ?>" alt="" /></a>
								<?php else: ?>
								<p><a href="<?php echo download_url($t_val['file_name'], $t_val['attachment']); ?>" class="file_ico"><?php echo $t_val['file_name']; ?></a></p>
								<?php endif; ?>
								<?php } ?>
								</div>
							</div>
						<?php } ?>
						<!-- Attachments to enlarge(Reply to question) END-->
			            </div>
					</div>
					    		
			        <!--Here is the new START-->
                    <div class="sC_dgar">
                       <a href="javascript:;" onclick="ajax_request(GET_BASE_URL + '/favorite/ajax/remove_favorite_item/', 'answer_id=' + <?php echo $val['answer_info']['answer_id']; ?>);" class="tny-cl_02 tny-right btn-gray">Unfavorite</a>&nbsp;&nbsp;&nbsp;&nbsp;<span id="PublicTopic<?php echo $val['answer_info']['answer_id']; ?>" class="q_topicMuster">
                            <?php if ($this->favorite_items_tags[$val['answer_info']['answer_id']]) { ?>
                            <?php foreach ($this->favorite_items_tags[$val['answer_info']['answer_id']] AS $f_key => $f_val) { ?>
                            <span class="glotopic" data-text="<?php echo $f_val['title']; ?>"><?php echo $f_val['title']; ?></span>
                            <?php } ?>
                            <?php } ?>
                        </span>
                        <span id="editor_topicBtns" onclick="$.topic.editor_topic({flg:this,make:false,answer_id:<?php echo $val['answer_info']['answer_id']; ?>});" title="Topic Edit" class="q_editor tny-small">Topic Edit</span>	
                                                                              <!--It should pass a parameter question_id:2259 This question id-->
            		</div>
                    <!--Add END-->
			        
					<a class="sendorse abs" href="javascript:;" onClick="$.I.click_eve({flg:this,appNum:<?php echo $val['answer_info']['agree_count']; ?>,uid:GET_USER_ID,username:GET_USER_NAME,ready:<?php echo $val['answer_info']['agree_status']; ?>,answer_id:<?php echo $val['answer_info']['answer_id']; ?>});"><?php echo $val['answer_info']['agree_count']; ?></a>
			        <!--flg:Itself, appNum:Agree number, uid: id corresponding with Username ,username: Username, ready: whether praise or opposed the issue{1: Agree as before,-1: has opposed, and 0: No operation is not over} -->
			    </div>
				<?php } ?>
				<!-- Reply-END--> 	
			</div>
			<!--Content Module END--> 
			<?php } ?>
			</div>
			<?php } else { ?>
			<p align="center" style="padding: 15px 0">No Content</p>
			<?php } ?>
        <!--My Favorites END-->
        </div>
        
        <?php echo $this->pagination; ?>
	</div>

    <div class="rsidebar tny-index">

		<!--Notice START-->
		<?php TPL::output('block/sidebar_announce.tpl.htm'); ?>	
		<!--Notice START-->

		<?php TPL::output('block/sidebar_menu.tpl.htm'); ?>	
		
		<div class="rightMain">
        <!--Invite friends to site-->
        <p class="unityjoin">Invite friends to site<?php if ($this->user_info['invitation_available']) { ?><em class="mtooltips"><?php echo $this->user_info['invitation_available']; ?></em><?php } ?> <a href="invitation/" class="btn-blue" title="Send invitation »">Send invitation</a> </p>
        
        <!-- People may be interested in the topic or sidebar -->
		<?php TPL::output('block/sidebar_recommend_users_topics.tpl.htm'); ?>
      </div>
    </div>
  </div>

<?php TPL::output('global/footer.tpl.htm'); ?>