<?php
/**
* @version		$Id: mod_latestnews.php 10381 2008-06-01 03:35:53Z pasamio $
* @package		Joomla
* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// Include the syndicate functions only once
require_once( dirname(__FILE__).'/helper.php' ); 
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
$helper = JPATH_SITE.DS.'media'.DS.'zengridframework'.DS.'helpers'.DS.'image.php';
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
if (!(JFile::exists($helper))){
	$helper = JPATH_SITE.DS.'media'.DS.'plg_jblibrary'.DS.'helpers'.DS.'image.php';
}
$framework = JPATH_SITE.DS.'plugins'.DS.'system'.DS.'zengridframework'.DS.'zengrid.php';
if (!(JFile::exists($framework))){
	$framework = false;
}
if (JFile::exists($helper)){ 
	require_once($helper); 
} else {

	echo '<div style="font-size:12px;font-family: helvetica neue, arial, sans serif;width:600px;margin:0 auto;background: #f9f9f9;border:1px solid #ddd ;margin-top:100px;padding:40px"><h3>Ooops. It looks like JbLibrary plugin is not installed!</h3> <br />Please install it and ensure that you have enabled the plugin by navigating to extensions > plugin manager. <br /><br />JB Library is a free Joomla extension that you can download directly from the <a href="http://www.joomlabamboo.com/joomla-extensions/jb-library-plugin-a-free-joomla-jquery-plugin">Joomla Bamboo website</a>.</div>';

}
$document =& JFactory::getDocument();
$modbase = JURI::base(true).'/modules/mod_microblog/';
$library = JURI::base(true).'/library/plg_jblibrary/';
$mbHeight = $params->get('mbHeight','');
$moduleID = $module->id;
$mbCSS = $params->get('loadCSS','head');
$layout	= $params->get( 'layout', 'intro' );
$type 		= intval( $params->get( 'type', 1 ) );
$count 		= intval( $params->get( 'count', 5 ) );
$displayMore	= $params->get( 'displayMore', '1' );
$show_front	= $params->get( 'show_front', 1 );
$showintro	= $params->get( 'showintro', 1 );
$showdate	= $params->get( 'showdate', 1 );
$titlelink	= $params->get( 'titlelink', '1' );
$titleClass	= $params->get( 'titleClass', 'h2' );
$titleLimit				= $params->get('titleLimit','0');
$titleSuffix			= $params->get('titleSuffix','');
$readonText	= $params->get( 'readonText', 'Click to read more.' );
$date = $params->get( 'dateFormat', 'j M, y');
$cbTheme = $params->get( 'cbTheme', 1);
$cbScripts = $params->get( 'loadJS', 'head');
if (file_exists($framework)){ 
$cbScripts = 0;
$mbCSS = "none";
}

$showCategory = $params->get('showCategory',0);
$catPrefix = $params->get('catPrefix',0);
$catlink = $params->get('catLink',0);
// Column Options
$colClearDiv = $params->get('colClearDiv','1');
// Filter Options
$trigger1 = $params->get('trigger1','');
$trigger2 = $params->get('trigger2','');
$trigger3 = $params->get('trigger3','');
$trigger4 = $params->get('trigger4','');
$trigger5 = $params->get('trigger5','');
$trigger6 = $params->get('trigger6','');
$trigger7 = $params->get('trigger7','');
$trigger8 = $params->get('trigger8','');
$trigger9 = $params->get('trigger9','');
// ColorBox - Content Gallery Options
$colorBox	= $params->get( 'colorBox', '0' );
$linkTarget = $params->get('linkTarget','article');
if($linkTarget == "lightbox") $colorBox=1;
$popupGallery = $params->get('popupGallery','1');
$overlayOpacity = $params->get('overlayOpacity','0.6');
$frameWidth = str_replace('px', '', $params->get('frameWidth','800'));
$frameHeight = str_replace('px', '', $params->get('frameHeight','400'));
$colorboxScrolling = $params->get('colorboxScrolling','false');
$justImage	= $params->get( 'justImage', '1' );
// Fade Effect
$fadeEffect = $params->get('fadeEffect','1');
$resizeImage = $params->get('resizeImage',1);
$option = $params->get( 'option', 'crop');
$image_width = str_replace('px', '', $params->get( 'image_width','170'));
$image_height = str_replace('px', '', $params->get( 'image_height','85'));
$bottomMargin = str_replace('px', '', $params->get('bottomMargin', '10'));
$rightMargin = str_replace('px', '', $params->get('rightMargin', '10'));
$addMargin = $params->get( 'addMargin','1');
$displayImages = $params->get( 'displayImages','article');
$imagesPerRow = $params->get( 'imagesPerRow','3');
$autoRightMargin = '0';
$imageNumber = 0;
$startDiv = 0;
$imgRightMargin = 0;
$floatImage = 'left';
$colWidth ="100%";
// Settings for the Column Widths in column display
	if ($imagesPerRow =="1") {
	$colWidth ="100%";
	$autoRightMargin ="0";
	}
	if ($imagesPerRow =="2") {
	$colWidth ="48%";
	$autoRightMargin = "3%";
	}
	if ($imagesPerRow =="3") {
	$colWidth ="30%";
	$autoRightMargin = "3%";
	}
	if ($imagesPerRow =="4") {
	$colWidth ="22%";
	$autoRightMargin = "3%";
	}
	if ($imagesPerRow =="5") {
	$colWidth ="17%";
	$autoRightMargin = "3%";
	}
	if ($imagesPerRow =="6") {
	$colWidth ="13%";
	$autoRightMargin = "4%";
	}
	if(!($addMargin)){
		$colWidth = $image_width.'px';
	}
$contentSource = $params->get('contentSource','article');
$k2 = JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_k2'.DS.'admin.k2.php';
if(($contentSource == "k2")&&(file_exists($k2)))
{
	$list = modMBK2ContentHelper::getList($params);
}
elseif($contentSource == "article")
{
	$list = modMicroBlogHelper::getList($params);
}
else
{
	echo 'K2 is not installed';
}


if($layout == 'filter'){
	require(JModuleHelper::getLayoutPath('mod_microblog','filter'));
}	
elseif($layout == 'columns'){
	require(JModuleHelper::getLayoutPath('mod_microblog','columns'));
}
elseif($layout == 'dateTitle'){
	require(JModuleHelper::getLayoutPath('mod_microblog','dateTitle'));
}
elseif($layout == 'flat'){
	require(JModuleHelper::getLayoutPath('mod_microblog','flat'));
}
elseif($layout == 'intro'){
	require(JModuleHelper::getLayoutPath('mod_microblog','intro'));
}
elseif($layout == 'newmedia'){
	require(JModuleHelper::getLayoutPath('mod_microblog','newmedia'));
}
elseif($layout == 'maxbiz'){
	require(JModuleHelper::getLayoutPath('mod_microblog','maxbiz'));
}
else{
	require(JModuleHelper::getLayoutPath('mod_microblog'));
}