<?php
/*------------------------------------------------------------------------
# 6News module by Team of Six, balbooa.com
# ------------------------------------------------------------------------
# author Balbooa
http://www.balbooa.com/# Copyright@2013 balbooa.com. All Rights Reserved.
# @license -
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites:
http://www.balbooa.com/-------------------------------------------------------------------------*/
defined('_JEXEC') or die;
$comments = JPATH_SITE . '/components/com_jcomments/jcomments.php';
if (file_exists($comments)) {
require_once($comments);
$jcomments = true;
}
?>
<div class="newsflash<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<?php
if($jcomments)
{
$options = array();
$options['object_id'] = $item->id;
$options['object_group'] = 'com_content';
$count = JCommentsModel::getCommentsCount($options);
}
?>
<?php require JModuleHelper::getLayoutPath('mod_articles_news', '_item'); ?>
<?php endforeach; ?>
</div><style scoped>
#six_news<?php echo $module->id ?>.horizontal .article_content{
background-color: rgba(<?php echo $rgbaColor ?>,<?php echo $background_opasity ?>);
}
</style>
<?php
$counter = $count;
switch($modulName){
case 1:
$k2Show = true;
$joomlaShow = false;
break;
case 2:
$joomlaShow = true;
$k2Show = true;
break;
default:
$joomlaShow = true;
$k2Show = false;
break;
}
echo '<div id="six_news'.$module->id.'" class="six_news '.$layout.' balbooa'.$moduleclass_sfx.'">';
if($joomlaShow){
foreach ($listJoomla as $item) :
if($counter > 0){
$newsLink = $item->link;
$newsPublishData = $item->publish_up;
$newsAuthor = $item->author;
$newsHits = $item->hits;
$newsCategory = $item->category_title;
if ($show_image) {
$string = getImage($item->introtext);
preg_match_all('/<img[^>]+src="?\'?([^"\']+)"?\'?[^>]*>/i',$string,$array);
if (isset($array[1][0])) {
$imageSrc = $array[1][0];
$imageName = explode("/", $imageSrc);
$imageName = end($imageName);
} else {
$imageSrc = false;
$imageName = explode("/", $imageSrc);
$imageName = end($imageName);
}
$dirPut = "images/6news".$module->id;
$dirPut2 = "images/6news".$module->id."/joomla/";
if (!file_exists($dirPut)) mkdir($dirPut);
if (!file_exists($dirPut2)) mkdir($dirPut2);
if (isset($array[1][0])) {
$dirSave = $dirPut."/joomla/".$imageName;
} else {
$dirSave = false;
}
createNewImage($imageSrc, $dirSave, $width, $height, true,100);
}
$newsLinkCat = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catslug));
$newsTitle = substr("$item->title",0, $limit_number_title);
$newsDiscription = getDescription($item->introtext,$limit_number_desk);
echo '<div class="six_news_article amount_'.$count.'">';
if($show_image){
if (isset($array[1][0])) {
$newsImage = "<div class='images'><a href='".$item->link."'><img src='".JURI::base().$dirSave."'></a></div>";
echo $newsImage;
}
}
echo '<div class="article_content">';
echo '<div class="article_container_content">';
if($show_title){
echo "<h3><a href='".$newsLink."'>".$newsTitle."</a></h3>";
}
if($show_author){
echo "<span class='autor'><i class='fa fa-user'></i>".$newsAuthor."</span>";
}
if($show_category){
echo "<span class='category'><a href=".$newsLinkCat."><i class='fa fa-folder'></i>".$newsCategory."</a></span>";
}
if($show_hits){
echo "<span class='hits'><i class='fa fa-eye'></i>".$newsHits."</span>";
}
if($show_publish_date){
echo "<span class='6newsdata'><i class='fa fa-clock-o'></i>".$newsPublishData."</span>";
}
if($show_description){
echo "<p>".$newsDiscription."</p>";
}
if($show_link){
echo "<a href='".$newsLink."'>Подробнее <i class='fa fa-long-arrow-right'></i></a>";
}
echo'</div>';
echo'</div>';
echo'</div>';
$counter--;
}
endforeach;
}
if($k2Show){
foreach ($listK2 as $item) :
if($counter > 0 && !empty($category_id)){
$newsLink = $item->link;
$newsPublishData = $item->publish_up;
$newsAuthor = $item->author;
$newsHits = $item->hits;
$newsCategory = $item->categoryname;
$newsLinkCat = $item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid.':'.$item->categoryname)));
$newsTitle = substr("$item->title",0,$limit_number_title);
$newsDiscription = getDescription($item->introtext,$limit_number_desk);
if(isset($item->imageXLarge)){
$imageSrcK2 = $item->imageXLarge;
$imageSrcK2 = explode("/", $imageSrcK2);
$imageNameK2 = end($imageSrcK2);
$imageSrcK2 = $item->imageXLarge;
}
$dirPutK2 = "images/6news".$module->id;
$dirPutK22 = "images/6news".$module->id."/k2/";
if (!file_exists($dirPutK2)) mkdir($dirPutK2);
if (!file_exists($dirPutK22)) mkdir($dirPutK22);
$rrr = explode("/", $_SERVER['REQUEST_URI']);
if(!empty($rrr[2])){
$imgK2Src = explode("/".$rrr[1]."/".$rrr[2]."/", $imageSrcK2);
}else{
$imgK2Src = explode("/".$rrr[1]."/", $imageSrcK2);
}
if(isset($item->imageXLarge)){
$imageNameK2Start = "media/k2/items/cache/".$imageNameK2;
$dirSaveK2 = $dirPutK2."/k2/".$imageNameK2;
} else {
$imageNameK2Start = false;
$dirSaveK2 = false;
}
createNewImage($imageNameK2Start, $dirSaveK2, $width, $height, true, 100);
$newsImage = "<div class='images'><a href='".$item->link."'><img alt='' src='".JURI::base().$dirSaveK2."'></a></div>";
echo '<div class="six_news_article amount_'.$count.'">';
if($show_image){
if(isset($imageSrcK2)){
echo $newsImage;
}
}
echo '<div class="article_content">';
echo '<div class="article_container_content">';
if($show_title){
echo "<h3><a href='".$newsLink."'>".$newsTitle."</a></h3>";
}
if($show_author){
echo "<span class='autor'><i class='fa fa-user'></i>".$newsAuthor."</span>";
}
if($show_category){
echo "<span class='category'><a href=".$newsLinkCat."><i class='fa fa-folder'></i>".$newsCategory."</a></span>";
}
if($show_hits){
echo "<span class='hits'><i class='fa fa-eye'></i>".$newsHits."</span>";
}
if($show_publish_date){
echo "<span class='6newsdata'><i class='fa fa-clock-o'></i>".$newsPublishData."</span>";
}
if($show_description){
echo "<p>".$newsDiscription."</p>";
}
if($show_link){
echo "<a href='".$newsLink."'>Подробнее <i class='fa fa-long-arrow-right'></i></a>";
}
if($jcomments){
if($count > 0){
echo JText::plural('LINK_READ_COMMENTS', $count);
}
else{
echo JText::_('LINK_ADD_COMMENT');
}
} echo'</div>';
echo'</div>';
echo'</div>';
$counter--;
}
endforeach;
}
echo'</div>';
?>
<script>
jQuery(document).ready(function() {
function six_news(){
var containerNew = jQuery('#six_news<?php echo $module->id ?>:not(".default").six_news_article');
var marginLeftContainer = containerNew.css('margin-left');
var marginRightContainer = containerNew.css('margin-right');
var marginLeftInt = parseInt(marginLeftContainer);
var marginRightInt = parseInt(marginRightContainer);
var marginInt = marginLeftInt+marginRightInt;
var widthContainer = jQuery("#six_news<?php echo $module->id ?>").width();
var lengthBox = jQuery('#six_news<?php echo $module->id ?> .six_news_article').length;
if (lengthBox === <?php echo $itemCount ?>) {
var widthImgBlock = (widthContainer-(marginInt*<?php echo $itemCount ?>))/<?php echo $itemCount ?>;
} else {
var widthImgBlock = (widthContainer-(marginInt*lengthBox))/lengthBox;
}
jQuery("#six_news<?php echo $module->id ?>.horizontal .six_news_article, #six_news<?php echo $module->id ?>.vertical .six_news_article").width(widthImgBlock-0.1);
}
six_news();
jQuery(window).resize(function() {
six_news();
});
});
</script>