<?php
/**
 * @package		YJ Module Engine
 * @author		Youjoomla.com
 * @website     Youjoomla.com 
 * @copyright	Copyright (c) 2007 - 2011 Youjoomla.com.
 * @license   PHP files are GNU/GPL V2. CSS / JS / IMAGES are Copyrighted Commercial
 */
//Title: 			$yj_get_items['item_title']
//Author: 			$yj_get_items['item_author'] = username || $yj_get_items['item_author_rn'] = real name
//Image:			$yj_get_items['img_url'] = use isset to check before output
//Intro text:		$yj_get_items['item_intro']
//Create date:		$yj_get_items['item_date']
//Category:			$yj_get_items['cat_title']
//Item url:			$yj_get_items['item_url']
//Author url: 		$yj_get_items['author_url']
//Cat url:			$yj_get_items['cat_url']
//Foreach to be used =  foreach ($main_yj_arr as $yj_get_items){ echo each part here }

/*Image sizing: The images are inside div that is resizing when you enter the values in module parameters. this way there is no image disortion. For those who dont like that , you can add this
style="width:<?php echo $img_width ?>;height:<?php echo $img_height ?>;"
within image tag after alt="" (space it please) and have the images resized */

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

$categories = array_unique(array_map(function($val) {
    return $val['cat_title'];
}, $main_yj_arr));
$catsArray = strtolower(str_replace(" ","",implode(",", $categories)));
$catsArray 	= str_replace("&amp;","_",$catsArray);
?>
<!-- Powered by YJ News Pop find out more at www.youjoomla.com -->

<div id="yjNewsPopContainer<?php echo $Thismodule_id?>" class="yjNewsPopContainer" data-catsarray="<?php echo $catsArray ?>" data-items="4">
<?php if($show_filter == 1) { ?>
	<ul id="yjnewspopFilter<?php echo $Thismodule_id?>" class="yjnewspopFilter option-set" data-filter-group="themes" data-setsize="">
		<li class="selectAll">
			<a href="#" data-filter-value="" class="selected">
				Show All
			</a>
		</li>
		<?php foreach ($categories as $cat): 

			$filterLink 	= '.'.strtolower(str_replace(" ","",$cat)); 
			$filterLink 	= str_replace("&amp;","_",$filterLink);
			$addData 		=' data-iscat="'.$filterLink.'"';
			$classHide 		= 'hide';
		
		
		?>
		<li<?php echo $addData?> class="<?php echo $classHide ?>">
			<a href="#" data-filter-value="<?php echo $filterLink ?>" class="showtips">
				<?php echo $cat ?>
			</a>
		</li>
		<?php endforeach; ?>
	</ul>
	<?php } ?>
	<div id="yjnewspopLayout<?php echo $Thismodule_id?>" class="yjnewspopLayout">
		<?php 
			$numberof = count($main_yj_arr);
			foreach ($main_yj_arr as $key=> $yj_get_items):
			require(JPATH_ROOT.DIRECTORY_SEPARATOR.'modules/'.$yj_mod_name.'/yjme/params/extend.php');
			$catTitle = strtolower(str_replace(" ","",$yj_get_items['cat_title']));
			$catTitle 	= str_replace("&amp;","_",$catTitle);
		
		?>
		<div class="yjnewspopItem <?php echo $catTitle ?>" data-mykey="<?php echo $key ?>">
			<div class="yjnewspop" data-catname="<?php echo $catTitle?>" data-relacatname="<?php echo $yj_get_items['cat_title']?>">
				<?php if ($global_layout == "image" || $global_layout == "hook"){ ?>
				<?php if((!empty($itemImage) && ($yj_get_items['item_hook'] == "imageonly" || $yj_get_items['item_hook'] == "both")) || ($global_layout == "image")){  ?>
				<div class="yjnewspopC">
					<a class="yjnewspopLink" href="<?php echo $yj_get_items['item_url'] ?>">
						<img src="<?php echo $itemImage ?>" alt="<?php echo $yj_get_items['item_title'] ?>" />
					</a>
					<div class="yjnewspopIntro">
						<div class="yjnewspopInfo">
							<h2 class="yjnewspopTitle">
								<?php if($disable_directlink == 1 ) { ?>
								<a href="<?php echo $yj_get_items['item_url'] ?>">
									<?php echo $yj_get_items['item_title']; ?>
								</a>
								<?php }else{ ?>
									<?php echo $yj_get_items['item_title']; ?>
								<?php }?>
							</h2>
							<div class="yjnewspopIcons infoItem">
								<a class="group<?php echo $Thismodule_id.$cboxClass; ?>" href="<?php echo $media_link ?>" data-nptitle="<?php echo $yj_get_items['item_title']; ?>">
									<span class="<?php echo $iconClass?>"></span>
								</a>
								<a class="popnewsLoad<?php echo $Thismodule_id; ?> popnewsLoadFull" href="javascript:;" data-getlink="<?php echo $yj_get_items['item_url'] ?>?tmpl=component"  data-nptitle="<?php echo $yj_get_items['item_title']; ?>">
									<span class="ico_link"></span>
								</a>
							</div>
							<div class="yjnewspopCat infoItem" data-category="<?php echo $yj_get_items['cat_title'] ?>">
								<?php if($disable_directlink == 1 ) { ?>
								<a href="<?php echo $yj_get_items['cat_url'] ?>">
									<?php echo $yj_get_items['cat_title'] ?>
								</a>
								<?php }else{ ?>
									<?php echo $yj_get_items['cat_title'] ?>
								<?php }?>
							</div>
						</div>
					</div>
					<div class="clear-news"></div>
				</div>
				<div class="clear-news"></div>
				<?php } // end image only?>
				<?php } // end image only?>
				<?php if ($global_layout == "text" || $global_layout == "hook"){ ?>
				<?php if(($yj_get_items['item_hook'] == "textonly" || $yj_get_items['item_hook'] == "both") || ($global_layout == "text")){ ?>
				<div class="yjnewspopIntroBlock">
					<?php if ($show_title == 1):  ?>
					<?php if($disable_directlink == 1 ) { ?>
					<div class="introTitle">
						<a href="<?php echo $yj_get_items['item_url'] ?>">
							<?php echo $yj_get_items['item_title'] ?>
						</a>
					</div>
					<?php }else{ ?>
					<div class="introTitle">
						<?php echo $yj_get_items['item_title'] ?>
					</div>					
					<?php }?>
					
					<?php endif; ?>
					
					<?php if(empty($itemImage) || $yj_get_items['item_hook'] == "textonly" || $global_layout == "text"){ ?>
					<div class="clear-news"></div>
					<a class="popnewsLoad<?php echo $Thismodule_id; ?> popnewsLoadFull popnewsloadFullSingle" href="javascript:;" data-getlink="<?php echo $yj_get_items['item_url'] ?>?tmpl=component"  data-nptitle="<?php echo $yj_get_items['item_title']; ?>">
						<span class="ico_link"></span>
					</a>
					<?php if(isset($yj_get_items['item_media'])){ ?>
						<a class="group<?php echo $Thismodule_id.$cboxClass; ?>" href="<?php echo $media_link ?>" data-nptitle="<?php echo $yj_get_items['item_title']; ?>">
							<span class="<?php echo $iconClass?>"></span>
						</a>
					<?php } ?>
					<?php } ?>
					
					<div class="introText">
						<?php echo $yj_get_items['item_intro'] ?>
					</div>
					<?php if($show_author == 1) : ?>
					<div class="introAuthor">
						<?php
						if($author_name == 1) :
							$author = 'by '.$yj_get_items['item_author'];
						else:
							$author = 'by '.$yj_get_items['item_author_rn'];
						endif;	
						?>
						<?php if($item_source == 1) : ?>
						<?php echo $author ?>
						<?php else: ?>
						<a href="<?php echo $yj_get_items['author_url'] ?>">
							<?php echo $author ?>
						</a>
						<?php endif; ?>
					</div>
					<?php endif; ?>
					<div class="clear-news"></div>
				</div>
				<?php } // end text only  ?>
				<?php } // end global layout  ?>
				<div class="clear-news"></div>
			</div>
			<div class="clear-news"></div>
		</div>
		<?php endforeach; ?>
		<div class="clear-news"></div>
	</div>
	<?php 	if($load_action == 'click'){ ?>
	<div class="clear-news"></div>
	<div id="load_more<?php echo $Thismodule_id; ?>" class="load_more">
	
		<a id="getmore<?php echo $Thismodule_id; ?>" class="getmore">
			<?php
			echo JText::_('MOD_YJ_NEWS_POP_GET_MORE');
		?>
		</a>
		
	</div>
	<?php } ?>
	<div class="clear-news"></div>
</div>
