<?php
/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

 // no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Image\Image;
use Joomla\CMS\Uri\Uri;

$heightforicon = '';
if ( !$this->params->get( 'showImage',0 ) ) $heightforicon='height="20"';
?>
<?php if ($this->params->get('show_page_heading',0)) : ?>
	<div class="page-header">
		<h1><?php echo $this->escape($this->params->get('page_heading','')); ?></h1>
	</div>
<?php endif; ?>
<div class="table-responsive">
	<table class="category table table-striped table-bordered table-hover">
		<thead>
			<tr>
				<th id="icon_header_title">
					<?php echo Text::_('AUP_MEDALS'); ?>
				</th>
				<th id="medals_header_title">
					<?php echo Text::_('AUP_NAME'); ?>
				</th>
				<th id="description_header_title">
					<?php echo Text::_( 'AUP_DESCRIPTION' ); ?>
				</th>
				<th id="awarded_header_title">
					<?php echo Text::_( 'AUP_AWARDED' ); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
                        $i = 0;
			foreach ($this->levelrank as $row)
			{
				$icone = '';

				$startmedals = '';
				$endmedals  = '';
				if ( $row->nummedals ) {
					$link = 'index.php?option=com_userpoints&amp;view=medals&amp;task=detailsmedal&amp;cid='.$row->id;
					$startmedals = '<a href="'.Route::_($link).'" >';
					$endmedals  = '</a>';
				}

				if ( $this->params->get( 'showImage',0 ) ) {
					if ($row->image ) {
						$pathimage = JPATH_COMPONENT . '/assets/images/awards/large/'.$row->image;
						$image = new Image( $pathimage );
						$icone = $image->createThumbs( array( $this->params->get( 'heightImage', 32 ) .'x'.$this->params->get( 'heightImage', 32 ) ), Image::CROP_RESIZE, JPATH_COMPONENT .'/assets/images/awards/large/thumbs' );
						$icone = myImage::getLivePathImage($icone);
						$icone = '<img src="'.$icone.'" alt="" />';
					} else $icone ='';
				} else {
					if ($row->icon ) {
						$pathicon = Uri::root() . 'components/com_userpoints/assets/images/awards/icons/';
						$icone = '<img src="'.$pathicon . $row->icon.'" width="16" height="16" ';
					} else $icone ='';
				}

			?>
			<tr class="cat-list-row<?php echo $i % 2; ?>" >
				<td headers="categorylist_header_title" class="list-title">
					<?php echo $startmedals.$icone.$endmedals; ?>
				</td>
				<td headers="categorylist_header_title" class="list-title">
					<?php echo Text::_( $row->rank ); ?>
				</td>
				<td headers="categorylist_header_title" class="list-title">
					<?php echo Text::_( $row->description ); ?>
				</td>
				<td headers="categorylist_header_title" class="list-title">
					<?php
					if ( $row->nummedals ) {

						echo '<a href="'.Route::_( $link ).'"><span class="badge badge-info">'.$row->nummedals.'</span></a>';
					} else 	echo '<span class="badge">0</span>';
					?>
				</td>
			</tr>

		<?php
                            $i++;
			}
		?>
		</tbody>
	</table>
</div>
	<div class="pagination">
	<?php
	echo $this->pagination->getPagesCounter() . "<br />" ;
	echo $this->pagination->getPagesLinks();
	?>
	</div>
<?php
	/**
	*
	*  Provide copyright on frontend
	*  If you remove or hide this line below,
	*  please make a donation if you find UserPoints useful
	*  and want to support its continued development.
	*  Your donations help by hardware, hosting services and other expenses that come up as we develop,
	*  protect and promote UserPoints and other free components.
	*
	*/
	echo $this->getCopyrightNotice ();

