<?php

/**

* WDC Like Dislike

* @author WDC <contact@web-designs-company.com>

* @link http://www.web-designs-company.com/

* @copyright (C) 2011 - 2012 JExtension

* @license GNU/GPL, see LICENSE.php for full license.

**/





// Check to ensure this file is included in Joomla!

defined('_JEXEC') or die('Restricted access');



?>

<script>

function ShowPicture(id,Source) {

if (Source=="1"){

if (document.layers) document.layers[''+id+''].visibility = "show"

else if (document.all) document.all[''+id+''].style.visibility = "visible"

else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"

}

else

if (Source=="0"){

if (document.layers) document.layers[''+id+''].visibility = "hide"

else if (document.all) document.all[''+id+''].style.visibility = "hidden"

else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"

}

}

</script>

<style>

#pop{

	visibility:hidden;

	background:#cbcbcb;

    border: 1px solid #CCCCCC;

    color: #000000;

    font-family: arial;

    font-size: 10px;

    padding: 5px;

    position: absolute

}

#pop1{

	visibility:hidden;

	background:#cbcbcb;

    border: 1px solid #CCCCCC;

    color: #000000;

    font-family: arial;

    font-size: 10px;

    padding: 5px;

    position: absolute

}

.icon-48-wdc {

background: url(<?php echo JURI::base(); ?>components/com_wdclikedislike/images/icon2.jpg) no-repeat left top;

}

</style>

<form action="index.php" method="post" name="adminForm">

<table>

<tr>

	<td align="left" width="100%">

		<?php echo JText::_( 'Filter' ); ?>:

		<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />

		<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>

		<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Filter Reset' ); ?></button>

	</td>

	<td nowrap="nowrap">

		<?php

		echo $this->lists['state'];

		?>

	</td>

</tr>

</table>



<table class="adminlist">

<thead>

	<tr>

		<th width="1%">

			<?php echo JText::_( 'JEXTN_ID' ); ?>

		</th>

		<th width="2%">

			<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />

		</th>

		<th>

			<?php echo JHTML::_('grid.sort',  JText::_( 'JEXT_CONT_TITLE' ), 's.title', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>

		</th>

		<th width="10%">

			<?php echo JHTML::_('grid.sort',  JText::_( 'JEXT_LIKE' ), 's.like', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>

		</th>

		<th width="10%">

			<?php echo JHTML::_('grid.sort',  JText::_( 'JEXT_DISLIKE' ), 's.dilike', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>



		</th>

		<th width="20%">

			<?php echo JHTML::_('grid.sort',  JText::_( 'JEXT_MOSTLIKE' ), 's.mlike', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>

			<a href="#" onMouseOver="ShowPicture('pop1',1)" onMouseOut="ShowPicture('pop1',0)">&nbsp;<img src="<?php echo JURI::base(); ?>components/com_wdclikedislike/images/information.png"></a>

			<div id="pop1"> <?php echo JTEXT::_("POP_MSG_LIKE"); ?></div>

		</th>

		<th width="20%">

			<?php echo JHTML::_('grid.sort',  JText::_( 'JEXT_MOSTDISLIKE' ), 's.mdlike', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>

			<a href="#" onMouseOver="ShowPicture('pop',1)" onMouseOut="ShowPicture('pop',0)">&nbsp;<img src="<?php echo JURI::base(); ?>components/com_wdclikedislike/images/information.png"></a>

			<div id="pop"> <?php echo JTEXT::_("POP_MSG_DISLIKE"); ?></div>

		</th>



		<th width="10%">

			<?php echo JHTML::_('grid.sort',   JText::_( 'JEXT_PUBLISHED' ), 's.state', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>

		</th>



		<th width="1%" nowrap="nowrap">

			<?php echo JHTML::_('grid.sort',   'ID', 's.id', @$lists['order_Dir'], @$lists['order'] ); ?>

		</th>

	</tr>

</thead>

<tfoot>

	<tr>

		<td colspan="10">

			<?php echo $this->pageNav->getListFooter(); ?>

		</td>

	</tr>

</tfoot>

<?php //print_r($this->items);

$db=&JFactory::getDBO();

$k = 0;

for ($i=0, $n=count( $this->items ); $i < $n; $i++)



{

	$row = &$this->items[$i];





	$checked 	= JHTML::_('grid.id',   $i, $row->id );

	$link 		= JRoute::_( 'index.php?option=com_content&sectionid=-1&task=edit&cid[]='. $row->id );







	$row->published = $row->state;

	$published		= JHTML::_('grid.published', $row, $i );



	?>

	<tr class="<?php echo "row$k"; ?>">

		<td>

			<?php echo $row->id; ?>

		</td>

		<td>

			<?php echo $checked; ?>

		</td>

		<td align="center">

			<a href="<?php echo $link; ?>"><?php echo $row->title; ?></a>

		</td>

		<td align="center">

			<?php

				 	    $l="SELECT COUNT(*) FROM `#__cvote` WHERE `article_id`='$row->id' AND `like`=1";

				 	  	$db->setQuery($l);

				       	echo $like=$db->loadResult();



			?>

		</td>

		<td align="center">

			<?php

			 		  $d="select count(*) from #__cvote where article_id='$row->id' AND dlike='1'";

				 	  $db->setQuery($d);

				      echo  $dlike=$db->loadResult();





				   ?>

		</td>

		<td align="center">



			<?php

		 	$img=JURI::root().'administrator/components/com_wdclikedislike/images/likes.PNG';

		 				$l="SELECT COUNT(*) FROM `#__cvote` WHERE `article_id`='$row->id' AND `like`=1";

				 	  	$db->setQuery($l);

				       	$like=$db->loadResult();

			if($like>=5){

				echo "<img src='$img' />";

			}else{

				echo "-";

			}



		  ?>

		</td>

			<td align="center">

			<?php

		 	$img=JURI::root().'administrator/components/com_wdclikedislike/images/dlikes.PNG';

					  $d="select count(*) from #__cvote where article_id='$row->id' AND dlike='1'";

				 	  $db->setQuery($d);

				      $dlike=$db->loadResult();

			if($dlike>=5){

				echo "<img src='$img' />";

			}else{

				echo "-";

			}

			   ?>

		</td>



	    <td align="center">

			<?php echo $published	; ?>

		</td>



		<td align="center">

			<?php echo $row->id; ?>

		</td>

	</tr>

	<?php

	$k = 1 - $k;

}

?>

</table>

<input type="hidden" name="option" value="com_wdclikedislike" />

<input type="hidden" name="task" value="" />

<input type="hidden" name="boxchecked" value="0" />

<input type="hidden" name="c" value="wdclikedislike" />

<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />

<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />

<?php echo JHTML::_( 'form.token' ); ?>

</form>

<p class="copyright" align="center">

	WDC Like Dislike 1.1.0 - developed by <a href="http://www.web-designs-company.com/" target="_blank">Website Design Company</a>

</p>