<?php
/**
 *    @version [ Wainuiomata ]
 *    @package hwdVideoShare
 *    @copyright (C) 2007 - 2009 Highwood Design
 *    @license Creative Commons Attribution-Non-Commercial-No Derivative Works 3.0 Unported Licence
 *    @license http://creativecommons.org/licenses/by-nc-nd/3.0/
 */
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

global $print_ulink, $print_glink, $smartyvs, $hwdvsTemplateOverride, $j15, $j16, $option, $Itemid;
$c = hwd_vs_Config::get_instance();
$my = & JFactory::getUser();
$app = & JFactory::getApplication();
$doc = & JFactory::getDocument();

if (!file_exists(JPATH_SITE.DS.'components'.DS.'com_community'))
{
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">You are trying to use the JomSocial template in hwdVideoShare but you don't have JomSocial installed. Please use another template.</div>";
}

jimport( 'joomla.html.parameter' );
$plugin =& JPluginHelper::getPlugin('hwdvs-template', 'jomsocial');
$pluginParams = new JParameter( $plugin->params );
$hwdvsTemplateOverride['js_template'] = $pluginParams->def( 'js_template', 'default' );
$hwdvsTemplateOverride['thumbWidth1'] = $pluginParams->def( 'thumbWidth1', '120' );
$hwdvsTemplateOverride['thumbWidth2'] = $pluginParams->def( 'thumbWidth2', '80' );
$hwdvsTemplateOverride['thumbWidth3'] = $pluginParams->def( 'thumbWidth3', '80' );
$hwdvsTemplateOverride['thumbWidth4'] = $pluginParams->def( 'thumbWidth4', '80' );
$hwdvsTemplateOverride['thumbWidth5'] = $pluginParams->def( 'thumbWidth5', '120' );
$hwdvsTemplateOverride['thumbWidth6'] = $pluginParams->def( 'thumbWidth6', '120' );
$hwdvsTemplateOverride['thumbWidth7'] = $pluginParams->def( 'thumbWidth7', '80' );
$hwdvsTemplateOverride['thumbWidth8'] = $pluginParams->def( 'thumbWidth8', '80' );
$hwdvsTemplateOverride['thumbWidth9'] = $pluginParams->def( 'thumbWidth9', '80' );
$hwdvsTemplateOverride['beingWatchNow'] = $pluginParams->def( 'beingWatchNow', '3' );
$hwdvsTemplateOverride['vpr'] = $pluginParams->def( 'vpr', '3' );
$hwdvsTemplateOverride['cpr'] = $pluginParams->def( 'cpr', '4' );
$hwdvsTemplateOverride['gpr'] = $pluginParams->def( 'gpr', '2' );
$hwdvsTemplateOverride['hideSubcats'] = $pluginParams->def( 'hideSubcats', '0' );
$hwdvsTemplateOverride['homeButton'] = intval($pluginParams->def( 'homeButton', '0' ));
$hwdvsTemplateOverride['jsItemid'] = intval($pluginParams->def( 'jsItemid', $Itemid ));
$hwdvsTemplateOverride['playerAlign'] = $pluginParams->def( 'playerAlign', 'L' );
$hwdvsTemplateOverride['loadCarousel'] = 0;
$hwdvsTemplateOverride['wrapText'] = $pluginParams->def( 'wrapText', '0' );

$hwdvsTemplateOverride['show_thumbnail'] 	= $pluginParams->def( 'show_thumbnail', '1' );
$hwdvsTemplateOverride['show_title'] 		= $pluginParams->def( 'show_title', '1' );
$hwdvsTemplateOverride['show_views'] 		= $pluginParams->def( 'show_views', '1' );
$hwdvsTemplateOverride['show_category'] 	= $pluginParams->def( 'show_category', '1' );
$hwdvsTemplateOverride['show_rating'] 		= $pluginParams->def( 'show_rating', '1' );
$hwdvsTemplateOverride['show_uploader'] 	= $pluginParams->def( 'show_uploader', '1' );
$hwdvsTemplateOverride['show_description'] 	= $pluginParams->def( 'show_description', '0' );
$hwdvsTemplateOverride['show_duration'] 	= $pluginParams->def( 'show_duration', '0' );
$hwdvsTemplateOverride['show_upload_date'] 	= $pluginParams->def( 'show_upload_date', '0' );
$hwdvsTemplateOverride['show_avatar'] 		= $pluginParams->def( 'show_avatar', '1' );
$hwdvsTemplateOverride['show_comments'] 	= $pluginParams->def( 'show_comments', '0' );
$hwdvsTemplateOverride['show_tags'] 		= $pluginParams->def( 'show_tags', '0' );
$hwdvsTemplateOverride['show_timesince'] 	= $pluginParams->def( 'show_timesince', '0' );

$smartyvs->assign("hwdvsTemplateOverride", $hwdvsTemplateOverride);

$template_folder = $app->getUserState( "com_hwdvideoshare.template_folder", '' );
$template_element = $app->getUserState( "com_hwdvideoshare.template_element", '' );
if (!empty($template_folder) && !empty($template_element))
{
	$c->hwdvids_template_path = $template_folder;
	$c->hwdvids_template_file = $template_element;
}
if (empty($c->hwdvids_template_file)) { $c->hwdvids_template_file = "default"; }
if ($j16)
{
	$templateDirectoryUrl = JURI::root( true ).'/plugins/hwdvs-template/'.$c->hwdvids_template_file.'/'.$c->hwdvids_template_file.'/';
}
else
{
	$templateDirectoryUrl = JURI::root( true ).'/plugins/hwdvs-template/'.$c->hwdvids_template_file.'/';
}
if($doc->getType() != 'raw')
{
	$doc->addCustomTag('<link rel="stylesheet" href="'.$templateDirectoryUrl.'template.css" type="text/css" />');
	$doc->addCustomTag('<link rel="stylesheet" href="'.$templateDirectoryUrl.'css/rating.css" type="text/css" />');
}

if ($option !== "com_community")
{
	$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.JURI::root( true ).'/media/system/js/mootools.js"></script>
                                  <script type="text/javascript" src="'.JURI::root( true ).'/media/system/js/modal.js"></script>
                                  <script type="text/javascript" src="'.JURI::root( true ).'/includes/js/joomla.javascript.js"></script>
                                  <script type="text/javascript" src="'.JURI::root( true ).'/components/com_community/assets/jquery-1.3.2.pack.js"></script>
                                  <script type="text/javascript" src="'.JURI::root( true ).'/components/com_community/assets/window-1.0.js"></script>
                                  <script type="text/javascript" src="'.JURI::root( true ).'/components/com_community/assets/script-1.2.js"></script>
                                  <script type="text/javascript" src="'.JURI::root( true ).'/components/com_community/assets/jquery.qtip-1.0.0-rc3.min.js"></script>
                                  <script type="text/javascript" src="'.JURI::root( true ).'/plugins/system/pc_includes/ajax_1.2.js"></script>');

	if ($hwdvsTemplateOverride['js_template'] == "default" || $hwdvsTemplateOverride['js_template'] == "blueface" || $hwdvsTemplateOverride['js_template'] == "bubble" || $hwdvsTemplateOverride['js_template'] == "blackout")
	{
		$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/components/com_community/templates/'.$hwdvsTemplateOverride['js_template'].'/css/style.css" type="text/css" />
                                      <!--[if IE 7.0]>
                                      <link rel="stylesheet" href="'.JURI::root( true ).'/components/com_community/templates/'.$hwdvsTemplateOverride['js_template'].'/css/styleIE7.css" type="text/css" />
                                      <![endif]-->
                                      <!--[if lte IE 6]>
                                      <link rel="stylesheet" href="'.JURI::root( true ).'/components/com_community/templates/'.$hwdvsTemplateOverride['js_template'].'/css/styleIE6.css" type="text/css" />
                                      <![endif]-->');

		$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/plugins/hwdvs-template/jomsocial/css/style.css" type="text/css" />
                                      <!--[if IE 7.0]>
                                      <link rel="stylesheet" href="'.JURI::root( true ).'/plugins/hwdvs-template/jomsocial/css/styleIE7.css" type="text/css" />
                                      <![endif]-->');
	}
	else if ($hwdvsTemplateOverride['js_template'] == "rt_affinity_j15")
	{
		if (file_exists(JPATH_SITE.DS.'templates'.DS.'rt_affinity_j15'.DS.'html'.DS.'com_community'.DS.'css'.DS.'style.css'))
		{
			$mainframe->addCustomHeadTag('<link rel="stylesheet" href="'.JURI::root( true ).'/templates/rt_affinity_j15/html/com_community/css/style.css" type="text/css" />');
		}
	}
}


$template_folder = $mainframe->getUserState( "com_hwdvideoshare.template_folder", '' );
$template_element = $mainframe->getUserState( "com_hwdvideoshare.template_element", '' );

if (!empty($template_folder) && !empty($template_element)) {

	$c->hwdvids_template_path = $template_folder;
	$c->hwdvids_template_file = $template_element;

}

if ($fe && file_exists(JPATH_PLUGINS.DS.'hwdvs-template'.DS.'jomsocial'.DS.'templates'.DS.$hwdvsTemplateOverride['js_template'].DS.'index.tpl'))
{
	$smartyvs->template_dir = JPATH_PLUGINS.DS.$c->hwdvids_template_path.DS.$c->hwdvids_template_file.DS.'templates'.DS.$hwdvsTemplateOverride['js_template'];
}

if ($hwdvsTemplateOverride['homeButton'] !== 2) {
	$smartyvs->assign("print_HomeButton", 1);
	if ($hwdvsTemplateOverride['homeButton'] == 0) {
		$jsItemid = $hwdvsTemplateOverride['jsItemid'];
		$smartyvs->assign("HomeButtonLink", JRoute::_("index.php?option=com_community&view=frontpage&Itemid=$jsItemid") );
	} else {
		$smartyvs->assign("HomeButtonLink", JRoute::_('index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=frontpage') );
	}

}

$smartyvs->assign("bwn_no", $hwdvsTemplateOverride['beingWatchNow']);
$smartyvs->assign("vpr", $hwdvsTemplateOverride['vpr']);
$smartyvs->assign("gpr", $hwdvsTemplateOverride['gpr']);
$smartyvs->assign("cpr", $hwdvsTemplateOverride['cpr']);

$smartyvs->assign("js_v", JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=frontpage"));
$smartyvs->assign("js_c", JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=categories"));
$smartyvs->assign("js_g", JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=groups"));
$smartyvs->assign("js_u", JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=upload"));

if ($c->diable_nav_user1 == 0) { $smartyvs->assign("js_yv", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=yourvideos")."\">"._HWDVIDS_NAV_YOURVIDS."</a>"); }
if ($c->diable_nav_user2 == 0) { $smartyvs->assign("js_yf", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=yourfavourites")."\">"._HWDVIDS_NAV_YOURFAVS."</a>"); }
if ($c->diable_nav_groups == 0 && $c->diable_nav_user3 == 0) { $smartyvs->assign("js_yg", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=yourgroups")."\">"._HWDVIDS_NAV_YOURGROUPS."</a>"); }
if ($c->diable_nav_groups == 0 && $c->diable_nav_user4 == 0) { $smartyvs->assign("js_ym", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=yourmemberships")."\">"._HWDVIDS_NAV_YOURMEMBERSHIPS."</a>"); }
if ($c->diable_nav_groups == 0 && $c->diable_nav_user5 == 0) { $smartyvs->assign("js_cg", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=creategroup")."\">"._HWDVIDS_NAV_CREATEGROUP."</a>"); }

if ($c->disable_nav_playlist == 0) { $smartyvs->assign("js_cp", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=createPlaylist")."\">"._HWDVIDS_NAV_CREATEPL."</a>"); }
if ($c->disable_nav_playlist == 0) { $smartyvs->assign("js_yp", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=viewChannel&user_id=".$my->id."&sort=playlists")."\">"._HWDVIDS_NAV_YOURPL."</a>"); }
if ($c->disable_nav_channel == 0) { $smartyvs->assign("js_yc", "<a href=\"".JRoute::_("index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=viewChannel&user_id=".$my->id)."\">"._HWDVIDS_NAV_YOURCHANNEL."</a>"); }

if ($hwdvsTemplateOverride['hideSubcats'] == "1") {
	$smartyvs->assign("hideSubcats", 1);
} else {
	$smartyvs->assign("hideSubcats", 0);
}

if ($hwdvsTemplateOverride['playerAlign'] == "C") {
	$smartyvs->assign("playerAlign", "C");
} else  {
	$smartyvs->assign("playerAlign", "L");
}

$vsvboxwidth = intval(100/$hwdvsTemplateOverride['vpr'])-2;
$vsgboxwidth = intval(100/$hwdvsTemplateOverride['gpr'])-2;
$vscboxwidth = intval(100/$hwdvsTemplateOverride['cpr'])-2;

$css = "#community-wrap .videoBox {
			width: ".$vsvboxwidth ."%;
			float:left;
		}

		#community-wrap .groupBox {
			width: ".$vsgboxwidth ."%;
			float:left;
		}

		#community-wrap .categoryBox {
			width: ".$vscboxwidth ."%;
			float:left;
		}

		#community-wrap .box
		{
			background: transparent url('".JURI::root( true )."/images/blank.png') no-repeat top center!important;
		}";

require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'draw.php');
hwdvsDrawFile::processDynamicCSS($css, true);

return;

function templateSetCategoryTab($tab='videos')
{
}

?>