<?php
/**
 * Adodis Blog package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2012 - 2013 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// Joomla predefined function for tooltip
JHtml::_('behavior.tooltip');

// Joomla predefined function for modal
JHTML::_('behavior.modal');

$path	 	= JURI::root();
$itemid  	= JRequest::getVar('Itemid', 0, '', 'int');
require_once JPATH_COMPONENT.'/helpers/videos.php';
$user 		=& JFactory::getUser();
$url1 		= JURI::base();
$parse 		= parse_url($url1);
$domain 	= $parse['host'];
$session 	= JFactory::getSession();

if ($user->get('guest')) {
 	if($this->allowed == 1){
 		if($this->params->get('show_add_blog_a', 1)){ ?>
		<div id="add">
			<a href="<?php echo JRoute::_('index.php?option=com_adodisblog&view=form&layout=edit'); ?> "><?php echo JText::_( 'COM_ADODISBLOG_ADD_BLOGS' ); ?></a>
		</div>
<?php
 		}
 	}
} else {
	 if($this->block_user){
	 	if($this->params->get('show_add_blog_r', 1)){
	 ?>
	 	<div id="add">
			<a href="<?php echo JRoute::_('index.php?option=com_adodisblog&view=form&layout=edit'); ?> "><?php echo JText::_( 'COM_ADODISBLOG_ADD_BLOGS' ); ?></a>
		</div>
	 <?php
		}
	}
}
$value 			= $this->items[0];
$value->content	= AdodisBlogVideosHelper::processVideos( $value->content );
?>
<div class="adodis-blog_bgitem_container" style="background-color:<?php echo $this->settings->bg_color;?>;" >
	<?php
	if($this->params->get('show_title_blog', 1)){
	?>
	<div>
		<a href="<?php echo JRoute::_(AdodisBlogHelperRoute::getBlogRoute($value->blogid));?>">
			<h2><?php echo $value->title;?></h2>
		</a>
	</div>
	<?php
	}
	?>
	<div style="float:left;">
		<?php
			if($this->params->get('show_blog_author', 1)) {
			echo JText::_('ADODIS_BLOG_POSTED_BY');
		?>
		<b>
			<?php
				if($value->name) {
					echo $value->name;
				} else{
					echo $value->post_by_name;
				}
			?>
		</b>
		<?php
			}
			if($this->params->get('show_blog_post_date', 1)) {
				echo JText::_('ADODIS_BLOG_ON');
		?> 		<b><?php echo date("l, F j, Y, g:i A", strtotime($value->created_date) ); ?></b>
		<?php }
			if($this->params->get('show_blog_cat_title', 1)) {
				echo JText::_('ADODIS_BLOG_IN');
		?> 		<b><?php echo $value->category_title; ?></b>
		<?php } ?>
	</div>
	<br style="clear:both;"/>
	<div>
		<?php
		echo $value->content;
		if($this->params->get('show_facebook_likes', 1)){
		?>
			<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $domain.JRoute::_(AdodisBlogHelperRoute::getBlogRoute($value->blogid));?>"
	        scrolling="no" frameborder="0"
	        style="border:none;height:24px"></iframe>
	    <?php } ?>
	</div>
	<?php
	if($this->params->get('show_like_dislike_b', 1)){
		$i = 1;
		$session->clear('blog_like_sess'.$value->blogid);
	?>
		<div id="comment_title_like_<?php echo $i; ?>" class="comment_title_like adodis-blog_likedis_b_con">
			<div id="displikes_b_<?php echo $i; ?>" style="display:none;float:left;"></div>
			<span class="likesdislikes adodis-blog_span_likedis_b" onclick="likeDislikesBlog('<?php echo $value->blogid; ?>','1','<?php echo $i; ?>','<?php echo $this->params->get('txt_like', JText::_('ADODIS_BLOG_LIKE_TEXT_BLOG'));?>','<?php echo $this->params->get('txt_dislike', JText::_('ADODIS_BLOG_DISLIKE_TEXT_BLOG'));?>')">
				<a title="<?php echo $this->params->get('txt_like');?>" href="javascript:void(0)">
					<?php
						echo $this->params->get('txt_like', JText::_('ADODIS_BLOG_LIKE_TEXT_BLOG'));
					?>
				</a>(<span id="total_likes_b_<?php echo $i; ?>"><?php echo $value->bg_isgood;?></span>)
			</span>
			<span class="adodis-blog_span_likedis_b" onclick="likeDislikesBlog('<?php echo $value->blogid; ?>','0','<?php echo $i; ?>','<?php echo $this->params->get('txt_like', JText::_('ADODIS_BLOG_LIKE_TEXT_BLOG'));?>','<?php echo $this->params->get('txt_dislike', JText::_('ADODIS_BLOG_DISLIKE_TEXT_BLOG'));?>')">
				<a title="<?php echo $this->params->get('txt_dislike');?>" href="javascript:void(0)">
					<?php
						echo $this->params->get('txt_dislike', JText::_('ADODIS_BLOG_DISLIKE_TEXT_BLOG'));
					?>
				</a>(<span id="total_dislikes_b_<?php echo $i; ?>"><?php echo $value->bg_isbad;?></span>)
			</span>
			<?php
				$countval 		= $value->bg_isgood - $value->bg_isbad;
				if($countval>0){
					$countval 	= '+'.$countval;
				}
			?>
			<span class="adodis-blog_span_likedis_count_b" id="total_like_b_<?php echo $i; ?>"><? echo $countval;?></span>
		</div>
	<?php
	}
	?>
	<div style="clear:both;"></div>
</div>
<input type="hidden" name="sitepath" id="sitepath" value="<?php echo JURI::ROOT(); ?>" />